minissdp: Re-add SSDP filtering

Add back SSDP filtering.  Relying on the kernel to filter out multicast
traffic from non-member interfaces simply doesn't work the way many
people think it does, so we need to re-introduce manual filtering.  But
this time we will use in_pktinfo's ifindex for comparison rather than a
netmask comparison, so SSDP packets from other subnets should still work.
This commit is contained in:
Justin Maggard 2018-01-16 17:12:20 -08:00
parent 8fe7293c7a
commit 9bb6cf5051

View File

@ -671,6 +671,11 @@ ProcessSSDPRequest(struct event *ev)
pi = (struct in_pktinfo *)CMSG_DATA(cmsg); pi = (struct in_pktinfo *)CMSG_DATA(cmsg);
addr = pi->ipi_spec_dst; addr = pi->ipi_spec_dst;
inet_ntop(AF_INET, &addr, host, sizeof(host)); inet_ntop(AF_INET, &addr, host, sizeof(host));
for (i = 0; i < n_lan_addr; i++)
{
if (pi->ipi_ifindex == lan_addr[i].ifindex)
break;
}
} }
#else #else
const char *host; const char *host;
@ -685,14 +690,14 @@ ProcessSSDPRequest(struct event *ev)
break; break;
} }
} }
host = lan_addr[iface].str;
#endif
if (n_lan_addr == i) if (n_lan_addr == i)
{ {
DPRINTF(E_DEBUG, L_SSDP, "Ignoring SSDP M-SEARCH on other interface [%s]\n", DPRINTF(E_DEBUG, L_SSDP, "Ignoring SSDP M-SEARCH on other interface [%s]\n",
inet_ntoa(sendername.sin_addr)); inet_ntoa(sendername.sin_addr));
return; return;
} }
host = lan_addr[iface].str;
#endif
DPRINTF(E_DEBUG, L_SSDP, "SSDP M-SEARCH from %s:%d ST: %.*s, MX: %.*s, MAN: %.*s\n", DPRINTF(E_DEBUG, L_SSDP, "SSDP M-SEARCH from %s:%d ST: %.*s, MX: %.*s, MAN: %.*s\n",
inet_ntoa(sendername.sin_addr), inet_ntoa(sendername.sin_addr),
ntohs(sendername.sin_port), ntohs(sendername.sin_port),