mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-06 18:41:30 +00:00
ipaddr_aton(): favour ':' over '.' to decide for IPv6 first (since IPv6 mapped IPv4 addresses might contain both ':' and '.')
This commit is contained in:
parent
0621e8d1b1
commit
f950bf4362
@ -293,18 +293,18 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
|
|||||||
if (cp != NULL) {
|
if (cp != NULL) {
|
||||||
const char* c;
|
const char* c;
|
||||||
for (c = cp; *c != 0; c++) {
|
for (c = cp; *c != 0; c++) {
|
||||||
if (*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 == ':') {
|
|
||||||
/* contains a colon: IPv6 address */
|
/* contains a colon: IPv6 address */
|
||||||
if (addr) {
|
if (addr) {
|
||||||
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V6);
|
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V6);
|
||||||
}
|
}
|
||||||
return ip6addr_aton(cp, ip_2_ip6(addr));
|
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 */
|
/* nothing found, call ip4addr_aton as fallback */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user