upnpsoap.c: comment and improve GetExternalIPAddress()
GetExternalIPAddress returns empty string when the External IP address can not be retrieved.
This commit is contained in:
parent
20ee72f9c8
commit
3a87be33e7
|
@ -1,5 +1,9 @@
|
|||
$Id: Changelog.txt,v 1.473 2020/12/20 18:06:36 nanard Exp $
|
||||
|
||||
2020/03/31:
|
||||
GetExternalIPAddress returns empty string when the External IP address can
|
||||
not be retrieved.
|
||||
|
||||
VERSION 2.2.1 : released on 2020/12/20
|
||||
(only minor build corrections)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||
* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2020 Thomas Bernard
|
||||
* (c) 2006-2021 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -345,15 +345,15 @@ GetExternalIPAddress(struct upnphttp * h, const char * action, const char * ns)
|
|||
{
|
||||
syslog(LOG_ERR, "Failed to get ip address for interface %s",
|
||||
ext_if_name);
|
||||
strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);
|
||||
ext_ip_addr[0] = '\0';
|
||||
} else if (addr_is_reserved(&addr)) {
|
||||
syslog(LOG_NOTICE, "private/reserved address %s is not suitable for external IP", ext_ip_addr);
|
||||
strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);
|
||||
ext_ip_addr[0] = '\0';
|
||||
}
|
||||
}
|
||||
#else
|
||||
struct lan_addr_s * lan_addr;
|
||||
strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);
|
||||
ext_ip_addr[0] = '\0';
|
||||
for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next)
|
||||
{
|
||||
if( (h->clientaddr.s_addr & lan_addr->mask.s_addr)
|
||||
|
@ -364,6 +364,15 @@ GetExternalIPAddress(struct upnphttp * h, const char * action, const char * ns)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
/* WANIPConnection:2 Service 2.3.13 :
|
||||
* When the external IP address could not be retrieved by the gateway
|
||||
* (for example, because the interface is down or because there was a
|
||||
* failure in the last connection setup attempt),
|
||||
* then the ExternalIPAddress MUST be equal to the empty string.
|
||||
*
|
||||
* There is no precise requirement on how theses cases must be handled
|
||||
* in IGDv1 specifications, but ExternalIPAddress default value is empty
|
||||
* string. */
|
||||
if (strcmp(ext_ip_addr, "0.0.0.0") == 0)
|
||||
ext_ip_addr[0] = '\0';
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
|
|
Loading…
Reference in New Issue