mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-21 00:39:58 +00:00
Fixed ntoa/aton/ntop/pton definitions after making IPv4 optional
This commit is contained in:
parent
bc99f75b53
commit
69c337b31d
@ -251,7 +251,7 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
|
||||
|
||||
#if LWIP_IPV4
|
||||
/** Convert IPv6 address to generic IP address.
|
||||
* Since source types do not contain the type field, a target storage need to be supplied.
|
||||
* Since source types do not contain the type field, a target storage needs to be supplied.
|
||||
*/
|
||||
ip_addr_t*
|
||||
ip6_2_ip(const ip6_addr_t *ip6addr, ip_addr_t* storage)
|
||||
@ -266,6 +266,10 @@ ip6_2_ip(const ip6_addr_t *ip6addr, ip_addr_t* storage)
|
||||
|
||||
/** 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
|
||||
*/
|
||||
int
|
||||
ipaddr_aton(const char *cp, ip_addr_t *addr)
|
||||
|
@ -139,9 +139,9 @@ extern const struct in6_addr in6addr_any;
|
||||
|
||||
/* directly map this to the lwip internal functions */
|
||||
#define inet_addr(cp) ipaddr_addr(cp)
|
||||
#define inet_aton(cp, addr) ipaddr_aton(cp, (ip4_addr_t*)addr)
|
||||
#define inet_ntoa(addr) ipaddr_ntoa((const ip4_addr_t*)&(addr))
|
||||
#define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
|
||||
#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr)
|
||||
#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr))
|
||||
#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
|
||||
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
|
@ -464,19 +464,24 @@ int lwip_fcntl(int s, int cmd, int val);
|
||||
#define fcntl(a,b,c) lwip_fcntl(a,b,c)
|
||||
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
|
||||
|
||||
#if LWIP_IPV6
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
#define inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((src),(dst),(size)) \
|
||||
: (((af) == AF_INET) ? ipaddr_ntoa_r((src),(dst),(size)) : NULL))
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \
|
||||
: (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL))
|
||||
#define inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET6) ? inet6_aton((src),(dst)) \
|
||||
: (((af) == AF_INET) ? inet_aton((src),(dst)) : 0))
|
||||
#else /* LWIP_IPV6 */
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
|
||||
: (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
|
||||
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
#define inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET) ? ipaddr_ntoa_r((src),(dst),(size)) : NULL)
|
||||
(((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL)
|
||||
#define inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET) ? inet_aton((src),(dst)) : 0)
|
||||
#endif /* LWIP_IPV6 */
|
||||
(((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
|
||||
#else /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
#define inet_ntop(af,src,dst,size) \
|
||||
(((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) : NULL)
|
||||
#define inet_pton(af,src,dst) \
|
||||
(((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0)
|
||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||
|
||||
#endif /* LWIP_COMPAT_SOCKETS */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user