Multicast problems should be gone, although the fix is Linux only and we'll
need to figure out something better when working on new ports.
This commit is contained in:
parent
28323d9ddb
commit
0e5aa966cc
1 changed files with 8 additions and 4 deletions
|
@ -23,6 +23,8 @@ set_inaddr(struct in6_addr *ia, ip_addr a)
|
|||
|
||||
#else
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
static inline void
|
||||
set_inaddr(struct in_addr *ia, ip_addr a)
|
||||
{
|
||||
|
@ -78,14 +80,18 @@ static inline char *sysio_mcast_join(sock *s)
|
|||
{
|
||||
struct ip_mreqn mreq;
|
||||
char *err;
|
||||
struct ifreq ifr;
|
||||
|
||||
if (err = sysio_mcast_setup(s))
|
||||
return err;
|
||||
strcpy(ifr.ifr_name, s->iface->name);
|
||||
if (setsockopt(s->fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0)
|
||||
return "SO_BINDTODEVICE";
|
||||
mreq.imr_ifindex = s->iface->index;
|
||||
set_inaddr(&mreq.imr_address, s->iface->addr->ip);
|
||||
set_inaddr(&mreq.imr_multiaddr, s->daddr);
|
||||
/* This defines where should we send _outgoing_ multicasts */
|
||||
if (setsockopt(s->fd, SOL_IP, IP_MULTICAST_IF, &mreq, sizeof(mreq)) < 0)
|
||||
if (ipa_nonzero(s->daddr) && setsockopt(s->fd, SOL_IP, IP_MULTICAST_IF, &mreq, sizeof(mreq)) < 0)
|
||||
return "IP_MULTICAST_IF";
|
||||
/* And this one sets interface for _receiving_ multicasts from */
|
||||
if (ipa_nonzero(s->saddr) && setsockopt(s->fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
|
||||
|
@ -101,8 +107,6 @@ static inline char *sysio_mcast_join(sock *s)
|
|||
* we can use SO_BINDTODEVICE to circumvent this problem.
|
||||
*/
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
static inline char *sysio_mcast_join(sock *s)
|
||||
{
|
||||
struct in_addr mreq;
|
||||
|
@ -125,7 +129,7 @@ static inline char *sysio_mcast_join(sock *s)
|
|||
#endif
|
||||
set_inaddr(&mreq_add.imr_multiaddr, s->daddr);
|
||||
/* This defines where should we send _outgoing_ multicasts */
|
||||
if (setsockopt(s->fd, SOL_IP, IP_MULTICAST_IF, &mreq, sizeof(mreq)) < 0)
|
||||
if (ipa_nonzero(s->daddr) && setsockopt(s->fd, SOL_IP, IP_MULTICAST_IF, &mreq, sizeof(mreq)) < 0)
|
||||
return "IP_MULTICAST_IF";
|
||||
/* And this one sets interface for _receiving_ multicasts from */
|
||||
if (ipa_nonzero(s->saddr) && setsockopt(s->fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq_add, sizeof(mreq_add)) < 0)
|
||||
|
|
Loading…
Reference in a new issue