From ca779d47dc189eff4c8197bc25fc4654ac704c79 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 23 Feb 2018 13:22:50 +0100 Subject: [PATCH] minissdpd: Fix compilation with IPv6 disabled see #285 --- minissdpd/ifacewatch.c | 15 +++++++++++++++ minissdpd/openssdpsocket.c | 8 +++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/minissdpd/ifacewatch.c b/minissdpd/ifacewatch.c index 37596ca..2a479b8 100644 --- a/minissdpd/ifacewatch.c +++ b/minissdpd/ifacewatch.c @@ -27,6 +27,7 @@ #include #include +#include "config.h" #include "openssdpsocket.h" #include "upnputils.h" #include "minissdpdtypes.h" @@ -170,13 +171,20 @@ ProcessInterfaceWatch(int s, int s_ssdp, int s_ssdp6) is_del ? "RTM_DELADDR" : "RTM_NEWADDR", address, ifa->ifa_prefixlen, ifname); 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)) || (0 == strcmp(ifname, lan_addr->ifname)) || (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) AddDropMulticastMembership(s_ssdp, lan_addr, 0, is_del); +#ifdef ENABLE_IPV6 else if(ifa->ifa_family == AF_INET6) AddDropMulticastMembership(s_ssdp6, lan_addr, 1, is_del); +#endif break; } } @@ -303,13 +311,20 @@ ProcessInterfaceWatch(int s, int s_ssdp, int s_ssdp6) is_del ? "RTM_DELADDR" : "RTM_NEWADDR", address, prefixlen, ifname); 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)) || (0 == strcmp(ifname, lan_addr->ifname)) || (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) AddDropMulticastMembership(s_ssdp, lan_addr, 0, is_del); +#ifdef ENABLE_IPV6 else if(family == AF_INET6) AddDropMulticastMembership(s_ssdp6, lan_addr, 1, is_del); +#endif break; } } diff --git a/minissdpd/openssdpsocket.c b/minissdpd/openssdpsocket.c index 890eca6..702856d 100644 --- a/minissdpd/openssdpsocket.c +++ b/minissdpd/openssdpsocket.c @@ -180,13 +180,13 @@ OpenAndConfSSDPReceiveSocket(int ipv6, unsigned char ttl) sockname.sin_family = AF_INET; sockname.sin_port = htons(SSDP_PORT); #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) { syslog(LOG_ERR, "no IPv4 address for interface %s", - listen_addr[0]); + lan_addrs.lh_first->ifname); close(s); return -1; } @@ -231,5 +231,3 @@ OpenAndConfSSDPReceiveSocket(int ipv6, unsigned char ttl) return s; } - -