56 #ifndef LWIP_HDR_IP4_ADDR_H 57 #define LWIP_HDR_IP4_ADDR_H 76 typedef struct ip4_addr ip4_addr_t;
82 #ifdef PACK_STRUCT_USE_INCLUDES 83 # include "arch/bpstruct.h" 90 #ifdef PACK_STRUCT_USE_INCLUDES 91 # include "arch/epstruct.h" 98 #define IPADDR_NONE ((u32_t)0xffffffffUL) 100 #define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) 102 #define IPADDR_ANY ((u32_t)0x00000000UL) 104 #define IPADDR_BROADCAST ((u32_t)0xffffffffUL) 110 #define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) 111 #define IP_CLASSA_NET 0xff000000 112 #define IP_CLASSA_NSHIFT 24 113 #define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) 114 #define IP_CLASSA_MAX 128 116 #define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) 117 #define IP_CLASSB_NET 0xffff0000 118 #define IP_CLASSB_NSHIFT 16 119 #define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET) 120 #define IP_CLASSB_MAX 65536 122 #define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) 123 #define IP_CLASSC_NET 0xffffff00 124 #define IP_CLASSC_NSHIFT 8 125 #define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET) 127 #define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) 128 #define IP_CLASSD_NET 0xf0000000 129 #define IP_CLASSD_NSHIFT 28 130 #define IP_CLASSD_HOST 0x0fffffff 131 #define IP_MULTICAST(a) IP_CLASSD(a) 133 #define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) 134 #define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) 136 #define IP_LOOPBACKNET 127 139 #define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) 145 #define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip4_addr_t)) 149 #define ip4_addr_copy(dest, src) ((dest).addr = (src).addr) 151 #define ip4_addr_set(dest, src) ((dest)->addr = \ 152 ((src) == NULL ? 0 : \ 155 #define ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) 157 #define ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) 159 #define ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) 161 #define ip4_addr_isloopback(ipaddr) (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32_t)IP_LOOPBACKNET) << 24)) 164 #define ip4_addr_set_hton(dest, src) ((dest)->addr = \ 166 lwip_htonl((src)->addr))) 168 #define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) 170 #define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) 173 #define ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0) 183 #define ip4_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ 187 #define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) 189 #define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY) 190 #define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1))) 192 #define ip4_addr_isbroadcast(addr1, netif) ip4_addr_isbroadcast_u32((addr1)->addr, netif) 193 u8_t ip4_addr_isbroadcast_u32(u32_t addr,
const struct netif *
netif);
195 #define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr) 196 u8_t ip4_addr_netmask_valid(u32_t netmask);
198 #define ip4_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL)) 200 #define ip4_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) 202 #define ip4_addr_debug_print_parts(debug, a, b, c, d) \ 203 LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d)) 204 #define ip4_addr_debug_print(debug, ipaddr) \ 205 ip4_addr_debug_print_parts(debug, \ 206 (u16_t)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \ 207 (u16_t)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \ 208 (u16_t)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \ 209 (u16_t)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0)) 210 #define ip4_addr_debug_print_val(debug, ipaddr) \ 211 ip4_addr_debug_print_parts(debug, \ 212 ip4_addr1_16(&(ipaddr)), \ 213 ip4_addr2_16(&(ipaddr)), \ 214 ip4_addr3_16(&(ipaddr)), \ 215 ip4_addr4_16(&(ipaddr))) 218 #define ip4_addr1(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[0]) 219 #define ip4_addr2(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[1]) 220 #define ip4_addr3(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[2]) 221 #define ip4_addr4(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[3]) 224 #define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) 225 #define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) 226 #define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) 227 #define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) 229 #define IP4ADDR_STRLEN_MAX 16 232 #define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) 234 u32_t ipaddr_addr(
const char *cp);
235 int ip4addr_aton(
const char *cp, ip4_addr_t *addr);
237 char *ip4addr_ntoa(
const ip4_addr_t *addr);
238 char *ip4addr_ntoa_r(
const ip4_addr_t *addr,
char *buf,
int buflen);
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_FIELD(x)