From 81fa1bcd57e6f00b3b1d0aa6d240abb3e35a30a7 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 13 Mar 2014 10:00:42 +0100 Subject: [PATCH] miniupnpd/getifaddr.c: getifaddr_in6() only return IPv4 address when IPV6 disabled see if it can help for issue #62 pcp/CheckAddress() is likely to need more changes. --- miniupnpd/getifaddr.c | 6 +++++- miniupnpd/pcpserver.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/miniupnpd/getifaddr.c b/miniupnpd/getifaddr.c index 2b71909..3bdc281 100644 --- a/miniupnpd/getifaddr.c +++ b/miniupnpd/getifaddr.c @@ -119,6 +119,8 @@ getifaddr(const char * ifname, char * buf, int len, } #ifdef ENABLE_PCP +/* XXX I don't know if this function should return + * IPv4 or IPv6 if both are enabled... */ int getifaddr_in6(const char * ifname, struct in6_addr * addr){ struct ifaddrs * ifap; struct ifaddrs * ife; @@ -157,6 +159,7 @@ int getifaddr_in6(const char * ifname, struct in6_addr * addr){ found = 1; break; +#ifdef ENABLE_IPV6 case AF_INET6: if(!IN6_IS_ADDR_LOOPBACK(addr) && !IN6_IS_ADDR_LINKLOCAL(addr)) { @@ -164,12 +167,13 @@ int getifaddr_in6(const char * ifname, struct in6_addr * addr){ found = 1; } break; +#endif /* ENABLE_IPV6 */ } } freeifaddrs(ifap); return (found ? 0 : -1); } -#endif +#endif /* ENABLE_PCP */ #ifdef ENABLE_IPV6 int diff --git a/miniupnpd/pcpserver.c b/miniupnpd/pcpserver.c index 98a6feb..ed6416e 100644 --- a/miniupnpd/pcpserver.c +++ b/miniupnpd/pcpserver.c @@ -536,6 +536,7 @@ static int parsePCPOptions(void* pcp_buf, int* remainingSize, static int CheckExternalAddress(pcp_info_t* pcp_msg_info) { + /* can contain a IPv4-mapped IPv6 address */ static struct in6_addr external_addr; if(use_ext_ip_addr) { @@ -554,6 +555,7 @@ static int CheckExternalAddress(pcp_info_t* pcp_msg_info) pcp_msg_info->result_code = PCP_ERR_NETWORK_FAILURE; return -1; } + /* how do we know which address we need ? IPv6 or IPv4 ? */ if(getifaddr_in6(ext_if_name, &external_addr) < 0) { pcp_msg_info->result_code = PCP_ERR_NETWORK_FAILURE; return -1;