ipaddr_aton: Avoid duplicate code to handle IPv4 address string conversion

Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2015-11-27 18:02:08 +08:00 committed by Dirk Ziegelmeier
parent 6e863ecb50
commit fb6d0f9006

View File

@ -311,13 +311,10 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
return ip6addr_aton(cp, ip_2_ip6(addr)); return ip6addr_aton(cp, ip_2_ip6(addr));
} else if (*c == '.') { } else if (*c == '.') {
/* contains a dot: IPv4 address */ /* contains a dot: IPv4 address */
if (addr) { break;
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4);
}
return ip4addr_aton(cp, ip_2_ip4(addr));
} }
} }
/* nothing found, call ip4addr_aton as fallback */ /* call ip4addr_aton as fallback or if IPv4 was found */
if (addr) { if (addr) {
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4); IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4);
} }