ssdp: add multicast membership as the individual interfaces come up
Previously, this was only done during startup, so interfaces that came up later wouldn't have been added.
This commit is contained in:
23
minissdp.c
23
minissdp.c
@ -59,6 +59,7 @@
|
||||
static int
|
||||
AddMulticastMembership(int s, struct lan_addr_s *iface)
|
||||
{
|
||||
int ret;
|
||||
#ifdef HAVE_STRUCT_IP_MREQN
|
||||
struct ip_mreqn imr; /* Ip multicast membership */
|
||||
/* setting up imr structure */
|
||||
@ -70,9 +71,11 @@ AddMulticastMembership(int s, struct lan_addr_s *iface)
|
||||
imr.imr_multiaddr.s_addr = inet_addr(SSDP_MCAST_ADDR);
|
||||
imr.imr_interface.s_addr = iface->addr.s_addr;
|
||||
#endif
|
||||
if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&imr, sizeof(imr)) < 0)
|
||||
ret = setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&imr, sizeof(imr));
|
||||
if (ret < 0 && errno != EADDRINUSE)
|
||||
{
|
||||
DPRINTF(E_ERROR, L_SSDP, "setsockopt(udp, IP_ADD_MEMBERSHIP): %s\n", strerror(errno));
|
||||
DPRINTF(E_ERROR, L_SSDP, "setsockopt(udp, IP_ADD_MEMBERSHIP): %s\n",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -111,16 +114,6 @@ OpenAndConfSSDPReceiveSocket(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_lan_addr; i++)
|
||||
{
|
||||
if (AddMulticastMembership(s, &lan_addr[i]) < 0)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SSDP,
|
||||
"Failed to add multicast membership for address %s\n",
|
||||
lan_addr[i].str );
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -179,6 +172,12 @@ OpenAndConfSSDPNotifySocket(struct lan_addr_s *iface)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (AddMulticastMembership(sssdp, iface) < 0)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SSDP, "Failed to add multicast membership for address %s\n",
|
||||
iface->str);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user