parent
b8c957a3a8
commit
ca779d47dc
|
@ -27,6 +27,7 @@
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "openssdpsocket.h"
|
#include "openssdpsocket.h"
|
||||||
#include "upnputils.h"
|
#include "upnputils.h"
|
||||||
#include "minissdpdtypes.h"
|
#include "minissdpdtypes.h"
|
||||||
|
@ -170,13 +171,20 @@ ProcessInterfaceWatch(int s, int s_ssdp, int s_ssdp6)
|
||||||
is_del ? "RTM_DELADDR" : "RTM_NEWADDR",
|
is_del ? "RTM_DELADDR" : "RTM_NEWADDR",
|
||||||
address, ifa->ifa_prefixlen, ifname);
|
address, ifa->ifa_prefixlen, ifname);
|
||||||
for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next) {
|
for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next) {
|
||||||
|
#ifdef ENABLE_IPV6
|
||||||
if((0 == strcmp(address, lan_addr->str)) ||
|
if((0 == strcmp(address, lan_addr->str)) ||
|
||||||
(0 == strcmp(ifname, lan_addr->ifname)) ||
|
(0 == strcmp(ifname, lan_addr->ifname)) ||
|
||||||
(ifa->ifa_index == lan_addr->index)) {
|
(ifa->ifa_index == lan_addr->index)) {
|
||||||
|
#else
|
||||||
|
if((0 == strcmp(address, lan_addr->str)) ||
|
||||||
|
(0 == strcmp(ifname, lan_addr->ifname))) {
|
||||||
|
#endif
|
||||||
if(ifa->ifa_family == AF_INET)
|
if(ifa->ifa_family == AF_INET)
|
||||||
AddDropMulticastMembership(s_ssdp, lan_addr, 0, is_del);
|
AddDropMulticastMembership(s_ssdp, lan_addr, 0, is_del);
|
||||||
|
#ifdef ENABLE_IPV6
|
||||||
else if(ifa->ifa_family == AF_INET6)
|
else if(ifa->ifa_family == AF_INET6)
|
||||||
AddDropMulticastMembership(s_ssdp6, lan_addr, 1, is_del);
|
AddDropMulticastMembership(s_ssdp6, lan_addr, 1, is_del);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,13 +311,20 @@ ProcessInterfaceWatch(int s, int s_ssdp, int s_ssdp6)
|
||||||
is_del ? "RTM_DELADDR" : "RTM_NEWADDR",
|
is_del ? "RTM_DELADDR" : "RTM_NEWADDR",
|
||||||
address, prefixlen, ifname);
|
address, prefixlen, ifname);
|
||||||
for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next) {
|
for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next) {
|
||||||
|
#ifdef ENABLE_IPV6
|
||||||
if((0 == strcmp(address, lan_addr->str)) ||
|
if((0 == strcmp(address, lan_addr->str)) ||
|
||||||
(0 == strcmp(ifname, lan_addr->ifname)) ||
|
(0 == strcmp(ifname, lan_addr->ifname)) ||
|
||||||
(ifam->ifam_index == lan_addr->index)) {
|
(ifam->ifam_index == lan_addr->index)) {
|
||||||
|
#else
|
||||||
|
if((0 == strcmp(address, lan_addr->str)) ||
|
||||||
|
(0 == strcmp(ifname, lan_addr->ifname))) {
|
||||||
|
#endif
|
||||||
if(family == AF_INET)
|
if(family == AF_INET)
|
||||||
AddDropMulticastMembership(s_ssdp, lan_addr, 0, is_del);
|
AddDropMulticastMembership(s_ssdp, lan_addr, 0, is_del);
|
||||||
|
#ifdef ENABLE_IPV6
|
||||||
else if(family == AF_INET6)
|
else if(family == AF_INET6)
|
||||||
AddDropMulticastMembership(s_ssdp6, lan_addr, 1, is_del);
|
AddDropMulticastMembership(s_ssdp6, lan_addr, 1, is_del);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,13 +180,13 @@ OpenAndConfSSDPReceiveSocket(int ipv6, unsigned char ttl)
|
||||||
sockname.sin_family = AF_INET;
|
sockname.sin_family = AF_INET;
|
||||||
sockname.sin_port = htons(SSDP_PORT);
|
sockname.sin_port = htons(SSDP_PORT);
|
||||||
#ifdef SSDP_LISTEN_ON_SPECIFIC_ADDR
|
#ifdef SSDP_LISTEN_ON_SPECIFIC_ADDR
|
||||||
if(n_listen_addr == 1)
|
if(lan_addrs.lh_first != NULL && lan_addrs.lh_first->list.le_next == NULL)
|
||||||
{
|
{
|
||||||
sockname.sin_addr.s_addr = GetIfAddrIPv4(listen_addr[0]);
|
sockname.sin_addr.s_addr = lan_addrs.lh_first->addr.s_addr;
|
||||||
if(sockname.sin_addr.s_addr == INADDR_NONE)
|
if(sockname.sin_addr.s_addr == INADDR_NONE)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR, "no IPv4 address for interface %s",
|
syslog(LOG_ERR, "no IPv4 address for interface %s",
|
||||||
listen_addr[0]);
|
lan_addrs.lh_first->ifname);
|
||||||
close(s);
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -231,5 +231,3 @@ OpenAndConfSSDPReceiveSocket(int ipv6, unsigned char ttl)
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue