MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ipaddr_aton

Function ipaddr_aton

components/net/lwip/lwip-2.1.2/src/core/ip.c:122–146  ·  view source on GitHub ↗

* @ingroup ipaddr * Convert IP address string (both versions) to numeric. * The version is auto-detected from the string. * * @param cp IP address string to convert * @param addr conversion result is stored here * @return 1 on success, 0 on error */

Source from the content-addressed store, hash-verified

120 * @return 1 on success, 0 on error
121 */
122int
123ipaddr_aton(const char *cp, ip_addr_t *addr)
124{
125 if (cp != NULL) {
126 const char *c;
127 for (c = cp; *c != 0; c++) {
128 if (*c == ':') {
129 /* contains a colon: IPv6 address */
130 if (addr) {
131 IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V6);
132 }
133 return ip6addr_aton(cp, ip_2_ip6(addr));
134 } else if (*c == '.') {
135 /* contains a dot: IPv4 address */
136 break;
137 }
138 }
139 /* call ip4addr_aton as fallback or if IPv4 was found */
140 if (addr) {
141 IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4);
142 }
143 return ip4addr_aton(cp, ip_2_ip4(addr));
144 }
145 return 0;
146}
147
148/**
149 * @ingroup lwip_nosys

Callers 8

START_TESTFunction · 0.50
httpc_get_internal_dnsFunction · 0.50
smtp_send_mail_allocedFunction · 0.50
lwip_getaddrinfoFunction · 0.50
set_dnsFunction · 0.50
dhcp_server_recvFunction · 0.50
dhcpd_thread_entryFunction · 0.50

Calls 2

ip6addr_atonFunction · 0.50
ip4addr_atonFunction · 0.50

Tested by 1

START_TESTFunction · 0.40