40#ifndef LWIP_HDR_INET_H
41#define LWIP_HDR_INET_H
45#if LWIP_SOCKET_EXTERNAL_HEADERS
46#include LWIP_SOCKET_EXTERNAL_HEADER_INET_H
59#if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED)
72#define s6_addr un.u8_addr
76#define INADDR_NONE IPADDR_NONE
78#define INADDR_LOOPBACK IPADDR_LOOPBACK
80#define INADDR_ANY IPADDR_ANY
82#define INADDR_BROADCAST IPADDR_BROADCAST
86#define IN6ADDR_ANY_INIT {{{0,0,0,0}}}
89#define IN6ADDR_LOOPBACK_INIT {{{0,0,0,PP_HTONL(1)}}}
97#define IN_CLASSA(a) IP_CLASSA(a)
98#define IN_CLASSA_NET IP_CLASSA_NET
99#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT
100#define IN_CLASSA_HOST IP_CLASSA_HOST
101#define IN_CLASSA_MAX IP_CLASSA_MAX
103#define IN_CLASSB(b) IP_CLASSB(b)
104#define IN_CLASSB_NET IP_CLASSB_NET
105#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT
106#define IN_CLASSB_HOST IP_CLASSB_HOST
107#define IN_CLASSB_MAX IP_CLASSB_MAX
109#define IN_CLASSC(c) IP_CLASSC(c)
110#define IN_CLASSC_NET IP_CLASSC_NET
111#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT
112#define IN_CLASSC_HOST IP_CLASSC_HOST
113#define IN_CLASSC_MAX IP_CLASSC_MAX
115#define IN_CLASSD(d) IP_CLASSD(d)
116#define IN_CLASSD_NET IP_CLASSD_NET
117#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT
118#define IN_CLASSD_HOST IP_CLASSD_HOST
119#define IN_CLASSD_MAX IP_CLASSD_MAX
121#define IN_MULTICAST(a) IP_MULTICAST(a)
123#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a)
124#define IN_BADCLASS(a) IP_BADCLASS(a)
126#define IN_LOOPBACKNET IP_LOOPBACKNET
128#define IN6_IS_ADDR_UNSPECIFIED(a) ip6_addr_isany((ip6_addr_t*)(a))
129#define IN6_IS_ADDR_LOOPBACK(a) ip6_addr_isloopback((ip6_addr_t*)(a))
130#define IN6_IS_ADDR_MULTICAST(a) ip6_addr_ismulticast((ip6_addr_t*)(a))
131#define IN6_IS_ADDR_LINKLOCAL(a) ip6_addr_islinklocal((ip6_addr_t*)(a))
132#define IN6_IS_ADDR_SITELOCAL(a) ip6_addr_issitelocal((ip6_addr_t*)(a))
133#define IN6_IS_ADDR_V4MAPPED(a) ip6_addr_isipv4mappedipv6((ip6_addr_t*)(a))
134#define IN6_IS_ADDR_V4COMPAT(a) ip6_addr_isipv4compat((ip6_addr_t*)(a))
135#define IN6_IS_ADDR_MC_NODELOCAL(a) ip6_addr_ismulticast_iflocal((ip6_addr_t*)(a))
136#define IN6_IS_ADDR_MC_LINKLOCAL(a) ip6_addr_ismulticast_linklocal((ip6_addr_t*)(a))
137#define IN6_IS_ADDR_MC_SITELOCAL(a) ip6_addr_ismulticast_sitelocal((ip6_addr_t*)(a))
138#define IN6_IS_ADDR_MC_ORGLOCAL(a) ip6_addr_ismulticast_orglocal((ip6_addr_t*)(a))
139#define IN6_IS_ADDR_MC_GLOBAL(a) ip6_addr_ismulticast_global((ip6_addr_t*)(a))
141#ifndef INET_ADDRSTRLEN
142#define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX
145#ifndef INET6_ADDRSTRLEN
146#define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX
152#define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
153#define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
156#define inet_addr(cp) ipaddr_addr(cp)
157#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr)
158#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr))
159#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
164#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \
165 (target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \
166 (target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \
167 (target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];}
168#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \
169 (target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \
170 (target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \
171 (target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3]; \
172 ip6_addr_clear_zone(target_ip6addr);}
175#define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr)
176#define inet6_ntoa(addr) ip6addr_ntoa((const ip6_addr_t*)&(addr))
177#define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((const ip6_addr_t*)&(addr), buf, buflen)
const struct in6_addr in6addr_any