summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-10-15 02:26:26 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-10-15 02:26:26 +0200
commit5111d4c9e012569cd513e2c971150a0137d1ea9d (patch)
tree29e2920e8b3d4934f02dcb65355bcaa58f70a7c5
parente2c66910fde5f0dd693f515f75e6c7d2441191bc (diff)
downloadmulticat-5111d4c9e012569cd513e2c971150a0137d1ea9d.tar
multicat-5111d4c9e012569cd513e2c971150a0137d1ea9d.zip
IPv6: As binding to a multicast address isn't possible, bind to :: when a multicast address is given
-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) )
{