32#ifndef __LWIP_IP_ADDR_H__
33#define __LWIP_IP_ADDR_H__
50#ifdef PACK_STRUCT_USE_INCLUDES
58#ifdef PACK_STRUCT_USE_INCLUDES
71#ifdef PACK_STRUCT_USE_INCLUDES
79#ifdef PACK_STRUCT_USE_INCLUDES
92#define IP_ADDR_ANY ((ip_addr_t *)&ip_addr_any)
93#define IP_ADDR_BROADCAST ((ip_addr_t *)&ip_addr_broadcast)
96#define IPADDR_NONE ((u32_t)0xffffffffUL)
98#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL)
100#define IPADDR_ANY ((u32_t)0x00000000UL)
102#define IPADDR_BROADCAST ((u32_t)0xffffffffUL)
108#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0)
109#define IP_CLASSA_NET 0xff000000
110#define IP_CLASSA_NSHIFT 24
111#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET)
112#define IP_CLASSA_MAX 128
114#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL)
115#define IP_CLASSB_NET 0xffff0000
116#define IP_CLASSB_NSHIFT 16
117#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET)
118#define IP_CLASSB_MAX 65536
120#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL)
121#define IP_CLASSC_NET 0xffffff00
122#define IP_CLASSC_NSHIFT 8
123#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET)
125#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL)
126#define IP_CLASSD_NET 0xf0000000
127#define IP_CLASSD_NSHIFT 28
128#define IP_CLASSD_HOST 0x0fffffff
129#define IP_MULTICAST(a) IP_CLASSD(a)
131#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
132#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
134#define IP_LOOPBACKNET 127
137#if BYTE_ORDER == BIG_ENDIAN
139#define IP4_ADDR(ipaddr, a,b,c,d) \
140 (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \
141 ((u32_t)((b) & 0xff) << 16) | \
142 ((u32_t)((c) & 0xff) << 8) | \
147#define IP4_ADDR(ipaddr, a,b,c,d) \
148 (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \
149 ((u32_t)((c) & 0xff) << 16) | \
150 ((u32_t)((b) & 0xff) << 8) | \
158#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t))
162#define ip_addr_copy(dest, src) ((dest).addr = (src).addr)
164#define ip_addr_set(dest, src) ((dest)->addr = \
165 ((src) == NULL ? 0 : \
168#define ip_addr_set_zero(ipaddr) ((ipaddr)->addr = 0)
170#define ip_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY)
172#define ip_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK))
175#define ip_addr_set_hton(dest, src) ((dest)->addr = \
179#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32))
181#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr)
184#define ip_addr_get_network(target, host, netmask) ((target)->addr = ((host)->addr) & ((netmask)->addr))
194#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
198#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
200#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY)
202#define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif))
205#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr)
208#define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL))
210#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
212#define ip_addr_debug_print(debug, ipaddr) \
213 LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
214 ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \
215 ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
216 ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
217 ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0))
220#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
221#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
222#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
223#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
226#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
227#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
228#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
229#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
232#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr)
#define PACK_STRUCT_BEGIN
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum const GLvoid * addr
char * ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen)
u32_t ipaddr_addr(const char *cp)
PACK_STRUCT_BEGIN struct ip_addr_packed PACK_STRUCT_STRUCT
int ipaddr_aton(const char *cp, ip_addr_t *addr)
const ip_addr_t ip_addr_any
u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif)
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
char * ipaddr_ntoa(const ip_addr_t *addr)
u8_t ip4_addr_netmask_valid(u32_t netmask)
const ip_addr_t ip_addr_broadcast
PACK_STRUCT_FIELD(u16_t addrw[2])
PACK_STRUCT_FIELD(u32_t addr)