summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/util.c b/util.c
index c513a6c..1951f21 100644
--- a/util.c
+++ b/util.c
@@ -488,19 +488,20 @@ int OpenSocket6( const char *_psz_arg, int i_ttl, unsigned int *pi_weight )
i = 0x80000;
setsockopt( i_fd, SOL_SOCKET, SO_RCVBUF, (void *) &i, sizeof( i ) );
- if ( bind( i_fd, (struct sockaddr *)&bind_addr, sizeof(bind_addr) ) < 0 )
- {
- msg_Err( NULL, "couldn't bind" );
- PrintSocket6( "socket definition:", &bind_addr, &connect_addr );
- exit(EXIT_FAILURE);
- }
-
- /* Join the multicast group if the socket is a multicast address */
if ( IN6_IS_ADDR_MULTICAST( &bind_addr.sin6_addr ) )
{
struct ipv6_mreq imr;
+ struct sockaddr_in6 bind_addr_any = bind_addr;
+ bind_addr_any.sin6_addr = in6addr_any;
+
+ if ( bind( i_fd, (struct sockaddr *)&bind_addr_any, sizeof(bind_addr_any) ) < 0 )
+ {
+ msg_Err( NULL, "couldn't bind" );
+ PrintSocket6( "socket definition:", &bind_addr, &connect_addr );
+ exit(EXIT_FAILURE);
+ }
- imr.ipv6mr_multiaddr = bind_addr.sin6_addr;
+ imr.ipv6mr_multiaddr = bind_addr.sin6_addr;
imr.ipv6mr_interface = i_bind_ifindex;
/* Join Multicast group without source filter */
@@ -512,6 +513,15 @@ int OpenSocket6( const char *_psz_arg, int i_ttl, unsigned int *pi_weight )
exit(EXIT_FAILURE);
}
}
+ else
+ {
+ if ( bind( i_fd, (struct sockaddr *)&bind_addr, sizeof(bind_addr) ) < 0 )
+ {
+ msg_Err( NULL, "couldn't bind" );
+ PrintSocket6( "socket definition:", &bind_addr, &connect_addr );
+ exit(EXIT_FAILURE);
+ }
+ }
if ( !IN6_IS_ADDR_UNSPECIFIED(&connect_addr.sin6_addr) )
{