patch #8021 Add INET[6]_ADDRSTRLEN Preprocessor Definitions If Not Previously Defined

This commit is contained in:
Simon Goldschmidt 2014-01-18 22:02:32 +01:00
parent 29824f9baa
commit db472c73c1
3 changed files with 15 additions and 4 deletions

View File

@ -94,6 +94,15 @@ struct in_addr {
#define IN_LOOPBACKNET IP_LOOPBACKNET
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX
#endif
#if LWIP_IPV6
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX
#endif
#endif
#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */

View File

@ -228,6 +228,9 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
#define IP4ADDR_STRLEN_MAX 16
#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX
/** For backwards compatibility */
#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr)

View File

@ -85,8 +85,6 @@ extern const ip6_addr_t ip6_addr_any;
#define IP6_ADDR_ANY ((ip6_addr_t *)&ip6_addr_any)
#if BYTE_ORDER == BIG_ENDIAN
/** Set an IPv6 partial address given by byte-parts. */
#define IP6_ADDR(ip6addr, index, a,b,c,d) \
@ -146,7 +144,6 @@ Little-endian version, stored in network order (no htonl). */
(dest)->addr[3] = (src) == NULL ? 0 : htonl((src)->addr[3]);}while(0)
/**
* Determine if two IPv6 address are on the same network.
*
@ -264,7 +261,7 @@ Little-endian version, stored in network order (no htonl). */
#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
#define ip6_addr_debug_print(debug, ipaddr) \
LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
ipaddr != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0, \
@ -274,6 +271,8 @@ Little-endian version, stored in network order (no htonl). */
ipaddr != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \
ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0))
#define IP6ADDR_STRLEN_MAX 46
int ip6addr_aton(const char *cp, ip6_addr_t *addr);
/** returns ptr to static buffer; not reentrant! */
char *ip6addr_ntoa(const ip6_addr_t *addr);