ipaddr_aton(): favour ':' over '.' to decide for IPv6 first (since IPv6 mapped IPv4 addresses might contain both ':' and '.')

This commit is contained in:
goldsimon 2015-09-30 14:06:44 +02:00
parent 0621e8d1b1
commit f950bf4362

View File

@ -293,18 +293,18 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
if (cp != NULL) {
const char* c;
for (c = cp; *c != 0; c++) {
if (*c == '.') {
/* contains a dot: IPv4 address */
if (addr) {
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4);
}
return ip4addr_aton(cp, ip_2_ip4(addr));
} else if (*c == ':') {
if (*c == ':') {
/* contains a colon: IPv6 address */
if (addr) {
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V6);
}
return ip6addr_aton(cp, ip_2_ip6(addr));
} else if (*c == '.') {
/* contains a dot: IPv4 address */
if (addr) {
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4);
}
return ip4addr_aton(cp, ip_2_ip4(addr));
}
}
/* nothing found, call ip4addr_aton as fallback */