summaryrefslogtreecommitdiffstats
path: root/sysdep/unix
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-04-12 16:57:46 +0200
committerMartin Mares <mj@ucw.cz>1999-04-12 16:57:46 +0200
commit5a99ade413b97a780758f5c8f927604ad6c8e57b (patch)
tree55c85d0b8a24755fd3409ba610b77871a88fd2a4 /sysdep/unix
parentbad631e04806287e99e2464c0fdc884f9efa1e71 (diff)
downloadbird-5a99ade413b97a780758f5c8f927604ad6c8e57b.tar
bird-5a99ade413b97a780758f5c8f927604ad6c8e57b.zip
Fixed a couple of bugs in handling of multicast sockets.
See comments in lib/socket.h for a detailed guide on how to use them.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 9a38844..69f8a5c 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -408,21 +408,18 @@ sk_open(sock *s)
case SK_IP_MC:
{
#ifdef HAVE_IP_MREQN
+ /* FIXME: Define HAVE_IP_MREQN somewhere :) */
struct ip_mreqn mreq;
#define mreq_add mreq
+ ASSERT(s->iface);
mreq.imr_ifindex = s->iface->index;
- if (has_src)
- set_inaddr(&mreq.imr_address, s->saddr);
- else
- set_inaddr(&mreq.imr_address, s->iface->ifa->ip);
+ set_inaddr(&mreq.imr_address, s->iface->ip);
#else
struct in_addr mreq;
struct ip_mreq mreq_add;
- if (has_src)
- set_inaddr(&mreq, s->saddr);
- else
- set_inaddr(&mreq, s->iface->ip);
- memcpy(&mreq_add.imr_interface, &mreq, sizeof(struct in_addr));
+ ASSERT(s->iface);
+ set_inaddr(&mreq, s->iface->ip);
+ mreq_add.imr_interface = mreq;
#endif
set_inaddr(&mreq_add.imr_multiaddr, s->daddr);
if (has_dest)
@@ -439,9 +436,11 @@ sk_open(sock *s)
#endif
setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &zero, sizeof(zero)) < 0)
ERR("IP_MULTICAST_LOOP");
+ /* This defines where should we send _outgoing_ multicasts */
if (setsockopt(fd, SOL_IP, IP_MULTICAST_IF, &mreq, sizeof(mreq)) < 0)
ERR("IP_MULTICAST_IF");
}
+ /* And this one sets interface for _receiving_ multicasts from */
if (has_src && setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq_add, sizeof(mreq_add)) < 0)
ERR("IP_ADD_MEMBERSHIP");
break;