miniupnpd.c: don't die when IPv6 is enabled and interface has no IPv4 address

This commit is contained in:
Thomas Bernard 2015-02-20 18:31:55 +01:00
parent 46533e6f6c
commit eb72ab5330
1 changed files with 9 additions and 1 deletions

View File

@ -715,8 +715,16 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str)
memcpy(lan_addr->ifname, str, n);
lan_addr->ifname[n] = '\0';
if(getifaddr(lan_addr->ifname, lan_addr->str, sizeof(lan_addr->str),
&lan_addr->addr, &lan_addr->mask) < 0)
&lan_addr->addr, &lan_addr->mask) < 0) {
#ifdef ENABLE_IPV6
fprintf(stderr, "interface \"%s\" has no IPv4 address\n", str);
lan_addr->str[0] = '\0';
lan_addr->addr.s_addr = htonl(0x00000000u);
lan_addr->mask.s_addr = htonl(0xffffffffu);
#else /* ENABLE_IPV6 */
goto parselan_error;
#endif /* ENABLE_IPV6 */
}
/*printf("%s => %s\n", lan_addr->ifname, lan_addr->str);*/
}
else