22#include <sys/select.h>
43#define LWIP_IPV6_MLD 0
45#ifndef LWIP_CHECKSUM_CTRL_PER_NETIF
46#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
48#ifndef LWIP_NETIF_REMOVE_CALLBACK
49#define LWIP_NETIF_REMOVE_CALLBACK 0
51#ifndef LWIP_IPV6_AUTOCONFIG
52#define LWIP_IPV6_AUTOCONFIG 0
54#ifndef LWIP_MULTICAST_TX_OPTIONS
55#define LWIP_MULTICAST_TX_OPTIONS 0
72#ifndef ENABLE_LOOPBACK
73#define ENABLE_LOOPBACK 0
75#ifndef DNS_LOCAL_HOSTLIST
76#define DNS_LOCAL_HOSTLIST 0
81#define MEMP_NUM_UDP_PCB 4
82#define MEMP_NUM_TCP_PCB 5
83#define MEMP_NUM_NETCONN (MEMP_NUM_TCP_PCB + MEMP_NUM_UDP_PCB)
84#define LWIP_NETIF_STATUS_CALLBACK 0
85#define LWIP_NETIF_LINK_CALLBACK 0
87#define LWIP_NETIF_HOSTNAME 0
90#define LWIP_NETIF_HWADDRHINT 0
91#define LWIP_LOOPBACK_MAX_PBUFS 0
92#define LWIP_NUM_NETIF_CLIENT_DATA 0
93#define LWIP_SOCKET_OFFSET 0
94#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
95#define DNS_MAX_SERVERS 2
129typedef signed char err_t;
133#define PBUF_TRANSPORT_HLEN 20
135#define PBUF_IP_HLEN 40
137#define PBUF_IP_HLEN 20
244typedef struct ip4_addr_packed ip4_addr_p_t;
247#define IPADDR_NONE ((u32)0xffffffffUL)
249#define IPADDR_LOOPBACK ((u32)0x7f000001UL)
251#define IPADDR_ANY ((u32)0x00000000UL)
253#define IPADDR_BROADCAST ((u32)0xffffffffUL)
259#define IP_CLASSA(a) ((((u32)(a)) & 0x80000000UL) == 0)
260#define IP_CLASSA_NET 0xff000000
261#define IP_CLASSA_NSHIFT 24
262#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET)
263#define IP_CLASSA_MAX 128
265#define IP_CLASSB(a) ((((u32)(a)) & 0xc0000000UL) == 0x80000000UL)
266#define IP_CLASSB_NET 0xffff0000
267#define IP_CLASSB_NSHIFT 16
268#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET)
269#define IP_CLASSB_MAX 65536
271#define IP_CLASSC(a) ((((u32)(a)) & 0xe0000000UL) == 0xc0000000UL)
272#define IP_CLASSC_NET 0xffffff00
273#define IP_CLASSC_NSHIFT 8
274#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET)
276#define IP_CLASSD(a) (((u32)(a)&0xf0000000UL) == 0xe0000000UL)
277#define IP_CLASSD_NET 0xf0000000
278#define IP_CLASSD_NSHIFT 28
279#define IP_CLASSD_HOST 0x0fffffff
280#define IP_MULTICAST(a) IP_CLASSD(a)
282#define IP_EXPERIMENTAL(a) (((u32)(a)&0xf0000000UL) == 0xf0000000UL)
283#define IP_BADCLASS(a) (((u32)(a)&0xf0000000UL) == 0xf0000000UL)
285#define IP_LOOPBACKNET 127
290#define IP4_ADDR(ipaddr, a, b, c, d) \
291 (ipaddr)->addr = ((u32)((d)&0xff) << 24) | \
292 ((u32)((c)&0xff) << 16) | \
293 ((u32)((b)&0xff) << 8) | \
300#define IPADDR2_COPY(dest, src) memcpy(dest, src, sizeof(ip4_addr_t))
304#define ip4_addr_copy(dest, src) ((dest).addr = (src).addr)
306#define ip4_addr_set(dest, src) ((dest)->addr = \
307 ((src) == NULL ? 0 : \
310#define ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0)
312#define ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY)
314#define ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK))
316#define ip4_addr_isloopback(ipaddr) (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32)IP_LOOPBACKNET) << 24))
319#define ip4_addr_set_hton(dest, src) ((dest)->addr = \
320 ((src) == NULL ? 0 : \
321 lwip_htonl((src)->addr)))
323#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32))
325#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr)
328#define ip4_addr_get_network(target, host, netmask) \
330 ((target)->addr = ((host)->addr) & ((netmask)->addr)); \
341#define ip4_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
345#define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
347#define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY)
348#define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1)))
350#define ip4_addr_isbroadcast(addr1, netif) ip4_addr_isbroadcast_u32((addr1)->addr, netif)
352#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr)
354#define ip4_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL))
356#define ip4_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
358#define ip4_addr_debug_print_parts(debug, a, b, c, d) \
359 LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d))
360#define ip4_addr_debug_print(debug, ipaddr) \
361 ip4_addr_debug_print_parts(debug, \
362 (u16)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \
363 (u16)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \
364 (u16)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \
365 (u16)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0))
366#define ip4_addr_debug_print_val(debug, ipaddr) \
367 ip4_addr_debug_print_parts(debug, \
368 ip4_addr1_16(&(ipaddr)), \
369 ip4_addr2_16(&(ipaddr)), \
370 ip4_addr3_16(&(ipaddr)), \
371 ip4_addr4_16(&(ipaddr)))
374#define ip4_addr1(ipaddr) (((const u8 *)(&(ipaddr)->addr))[0])
375#define ip4_addr2(ipaddr) (((const u8 *)(&(ipaddr)->addr))[1])
376#define ip4_addr3(ipaddr) (((const u8 *)(&(ipaddr)->addr))[2])
377#define ip4_addr4(ipaddr) (((const u8 *)(&(ipaddr)->addr))[3])
380#define ip4_addr1_16(ipaddr) ((u16)ip4_addr1(ipaddr))
381#define ip4_addr2_16(ipaddr) ((u16)ip4_addr2(ipaddr))
382#define ip4_addr3_16(ipaddr) ((u16)ip4_addr3(ipaddr))
383#define ip4_addr4_16(ipaddr) ((u16)ip4_addr4(ipaddr))
385#define IP4ADDR_STRLEN_MAX 16
397typedef struct ip6_addr_packed ip6_addr_p_t;
401#define IP6_ADDR_PART(ip6addr, index, a, b, c, d) \
402 (ip6addr)->addr[index] = ((u32)((d)&0xff) << 24) | \
403 ((u32)((c)&0xff) << 16) | \
404 ((u32)((b)&0xff) << 8) | \
409#define IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3) \
411 (ip6addr)->addr[0] = idx0; \
412 (ip6addr)->addr[1] = idx1; \
413 (ip6addr)->addr[2] = idx2; \
414 (ip6addr)->addr[3] = idx3; \
418#define IP6_ADDR_BLOCK1(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff))
420#define IP6_ADDR_BLOCK2(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[0])) & 0xffff))
422#define IP6_ADDR_BLOCK3(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff))
424#define IP6_ADDR_BLOCK4(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[1])) & 0xffff))
426#define IP6_ADDR_BLOCK5(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff))
428#define IP6_ADDR_BLOCK6(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[2])) & 0xffff))
430#define IP6_ADDR_BLOCK7(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff))
432#define IP6_ADDR_BLOCK8(ip6addr) ((u16)((lwip_htonl((ip6addr)->addr[3])) & 0xffff))
435#define ip6_addr_copy(dest, src) \
437 (dest).addr[0] = (src).addr[0]; \
438 (dest).addr[1] = (src).addr[1]; \
439 (dest).addr[2] = (src).addr[2]; \
440 (dest).addr[3] = (src).addr[3]; \
443#define ip6_addr_set(dest, src) \
445 (dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \
446 (dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \
447 (dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \
448 (dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3]; \
452#define ip6_addr_set_zero(ip6addr) \
454 (ip6addr)->addr[0] = 0; \
455 (ip6addr)->addr[1] = 0; \
456 (ip6addr)->addr[2] = 0; \
457 (ip6addr)->addr[3] = 0; \
461#define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr)
463#define ip6_addr_set_loopback(ip6addr) \
465 (ip6addr)->addr[0] = 0; \
466 (ip6addr)->addr[1] = 0; \
467 (ip6addr)->addr[2] = 0; \
468 (ip6addr)->addr[3] = PP_HTONL(0x00000001UL); \
472#define ip6_addr_set_hton(dest, src) \
474 (dest)->addr[0] = (src) == NULL ? 0 : lwip_htonl((src)->addr[0]); \
475 (dest)->addr[1] = (src) == NULL ? 0 : lwip_htonl((src)->addr[1]); \
476 (dest)->addr[2] = (src) == NULL ? 0 : lwip_htonl((src)->addr[2]); \
477 (dest)->addr[3] = (src) == NULL ? 0 : lwip_htonl((src)->addr[3]); \
488#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
489 ((addr1)->addr[1] == (addr2)->addr[1]))
491#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
492 ((addr1)->addr[1] == (addr2)->addr[1]) && \
493 ((addr1)->addr[2] == (addr2)->addr[2]) && \
494 ((addr1)->addr[3] == (addr2)->addr[3]))
496#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[2]) & 0x0000ffffUL)
498#define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \
499 ((ip6addr).addr[1] == 0) && \
500 ((ip6addr).addr[2] == 0) && \
501 ((ip6addr).addr[3] == 0))
502#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || ip6_addr_isany_val(*(ip6addr)))
504#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \
505 ((ip6addr)->addr[1] == 0UL) && \
506 ((ip6addr)->addr[2] == 0UL) && \
507 ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
509#define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL))
511#define ip6_addr_islinklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfe800000UL))
513#define ip6_addr_issitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfec00000UL))
515#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL))
517#define ip6_addr_isipv6mappedipv4(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL)))
519#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL))
520#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL))
521#define ip6_addr_multicast_prefix_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00200000UL))
522#define ip6_addr_multicast_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL))
523#define ip6_addr_multicast_scope(ip6addr) ((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xf)
524#define IP6_MULTICAST_SCOPE_RESERVED 0x0
525#define IP6_MULTICAST_SCOPE_RESERVED0 0x0
526#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1
527#define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2
528#define IP6_MULTICAST_SCOPE_RESERVED3 0x3
529#define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4
530#define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5
531#define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8
532#define IP6_MULTICAST_SCOPE_GLOBAL 0xe
533#define IP6_MULTICAST_SCOPE_RESERVEDF 0xf
534#define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff010000UL))
535#define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff020000UL))
536#define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff040000UL))
537#define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff050000UL))
538#define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff080000UL))
539#define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff0e0000UL))
542#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \
543 ((ip6addr)->addr[1] == 0UL) && \
544 ((ip6addr)->addr[2] == 0UL) && \
545 ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
547#define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
548 ((ip6addr)->addr[1] == 0UL) && \
549 ((ip6addr)->addr[2] == 0UL) && \
550 ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL)))
551#define ip6_addr_set_allnodes_linklocal(ip6addr) \
553 (ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
554 (ip6addr)->addr[1] = 0; \
555 (ip6addr)->addr[2] = 0; \
556 (ip6addr)->addr[3] = PP_HTONL(0x00000001UL); \
559#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
560 ((ip6addr)->addr[1] == 0UL) && \
561 ((ip6addr)->addr[2] == 0UL) && \
562 ((ip6addr)->addr[3] == PP_HTONL(0x00000002UL)))
563#define ip6_addr_set_allrouters_linklocal(ip6addr) \
565 (ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
566 (ip6addr)->addr[1] = 0; \
567 (ip6addr)->addr[2] = 0; \
568 (ip6addr)->addr[3] = PP_HTONL(0x00000002UL); \
571#define ip6_addr_issolicitednode(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
572 ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
573 (((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)))
575#define ip6_addr_set_solicitednode(ip6addr, if_id) \
577 (ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \
578 (ip6addr)->addr[1] = 0; \
579 (ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \
580 (ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id)); \
583#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \
584 ((ip6addr)->addr[1] == 0) && \
585 ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \
586 ((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3])))
589#define IP6_ADDR_INVALID 0x00
590#define IP6_ADDR_TENTATIVE 0x08
591#define IP6_ADDR_TENTATIVE_1 0x09
592#define IP6_ADDR_TENTATIVE_2 0x0a
593#define IP6_ADDR_TENTATIVE_3 0x0b
594#define IP6_ADDR_TENTATIVE_4 0x0c
595#define IP6_ADDR_TENTATIVE_5 0x0d
596#define IP6_ADDR_TENTATIVE_6 0x0e
597#define IP6_ADDR_TENTATIVE_7 0x0f
598#define IP6_ADDR_VALID 0x10
599#define IP6_ADDR_PREFERRED 0x30
600#define IP6_ADDR_DEPRECATED 0x10
602#define IP6_ADDR_TENTATIVE_COUNT_MASK 0x07
604#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID)
605#define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE)
606#define ip6_addr_isvalid(addr_state) (addr_state & IP6_ADDR_VALID)
607#define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED)
608#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
610#define ip6_addr_debug_print_parts(debug, a, b, c, d, e, f, g, h) \
611 LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
612 a, b, c, d, e, f, g, h))
613#define ip6_addr_debug_print(debug, ipaddr) \
614 ip6_addr_debug_print_parts(debug, \
615 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0), \
616 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0), \
617 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0), \
618 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0), \
619 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0), \
620 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0), \
621 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0), \
622 (u16)((ipaddr) != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0))
623#define ip6_addr_debug_print_val(debug, ipaddr) \
624 ip6_addr_debug_print_parts(debug, \
625 IP6_ADDR_BLOCK1(&(ipaddr)), \
626 IP6_ADDR_BLOCK2(&(ipaddr)), \
627 IP6_ADDR_BLOCK3(&(ipaddr)), \
628 IP6_ADDR_BLOCK4(&(ipaddr)), \
629 IP6_ADDR_BLOCK5(&(ipaddr)), \
630 IP6_ADDR_BLOCK6(&(ipaddr)), \
631 IP6_ADDR_BLOCK7(&(ipaddr)), \
632 IP6_ADDR_BLOCK8(&(ipaddr)))
634#define IP6ADDR_STRLEN_MAX 46
651#if LWIP_IPV4 && LWIP_IPV6
657typedef struct _ip_addr
671#define IPADDR4_INIT(u32val) \
673 {{{u32val, 0ul, 0ul, 0ul}}}, IPADDR_TYPE_V4 \
676#define IPADDR6_INIT(a, b, c, d) \
678 {{{a, b, c, d}}}, IPADDR_TYPE_V6 \
682#define IP_IS_ANY_TYPE_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_ANY)
684#define IPADDR_ANY_TYPE_INIT \
686 {{{0ul, 0ul, 0ul, 0ul}}}, IPADDR_TYPE_ANY \
690#define IP_IS_V4_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V4)
692#define IP_IS_V6_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V6)
694#define IP_IS_V4(ipaddr) (((ipaddr) == NULL) || IP_IS_V4_VAL(*(ipaddr)))
696#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr)))
698#define IP_SET_TYPE_VAL(ipaddr, iptype) \
700 (ipaddr).type = (iptype); \
702#define IP_SET_TYPE(ipaddr, iptype) \
704 if ((ipaddr) != NULL) { \
705 IP_SET_TYPE_VAL(*(ipaddr), iptype); \
708#define IP_GET_TYPE(ipaddr) ((ipaddr)->type)
710#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) (IP_GET_TYPE(&pcb->local_ip) == IP_GET_TYPE(ipaddr))
711#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (IP_IS_ANY_TYPE_VAL(pcb->local_ip) || IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr))
716#define ip_2_ip6(ipaddr) (&((ipaddr)->uaddr.ip6))
720#define ip_2_ip4(ipaddr) (&((ipaddr)->uaddr.ip4))
723#define IP_ADDR4(ipaddr, a, b, c, d) \
725 IP4_ADDR(ip_2_ip4(ipaddr), a, b, c, d); \
726 IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V4); \
729#define IP_ADDR6(ipaddr, i0, i1, i2, i3) \
731 IP6_ADDR(ip_2_ip6(ipaddr), i0, i1, i2, i3); \
732 IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V6); \
736#define ip_addr_copy(dest, src) \
738 IP_SET_TYPE_VAL(dest, IP_GET_TYPE(&src)); \
739 if (IP_IS_V6_VAL(src)) { \
740 ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); \
742 ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); \
746#define ip_addr_copy_from_ip6(dest, src) \
748 ip6_addr_copy(*ip_2_ip6(&(dest)), src); \
749 IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); \
752#define ip_addr_copy_from_ip4(dest, src) \
754 ip4_addr_copy(*ip_2_ip4(&(dest)), src); \
755 IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4); \
758#define ip_addr_set_ip4_u32(ipaddr, val) \
761 ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
762 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); \
766#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && IP_IS_V4(ipaddr)) ? \
767 ip4_addr_get_u32(ip_2_ip4(ipaddr)) : \
770#define ip_addr_set(dest, src) \
772 IP_SET_TYPE(dest, IP_GET_TYPE(src)); \
773 if (IP_IS_V6(src)) { \
774 ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); \
776 ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); \
780#define ip_addr_set_ipaddr(dest, src) ip_addr_set(dest, src)
782#define ip_addr_set_zero(ipaddr) \
784 ip6_addr_set_zero(ip_2_ip6(ipaddr)); \
785 IP_SET_TYPE(ipaddr, 0); \
788#define ip_addr_set_zero_ip4(ipaddr) \
790 ip6_addr_set_zero(ip_2_ip6(ipaddr)); \
791 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); \
794#define ip_addr_set_zero_ip6(ipaddr) \
796 ip6_addr_set_zero(ip_2_ip6(ipaddr)); \
797 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); \
800#define ip_addr_set_any(is_ipv6, ipaddr) \
803 ip6_addr_set_any(ip_2_ip6(ipaddr)); \
804 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); \
806 ip4_addr_set_any(ip_2_ip4(ipaddr)); \
807 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); \
811#define ip_addr_set_loopback(is_ipv6, ipaddr) \
814 ip6_addr_set_loopback(ip_2_ip6(ipaddr)); \
815 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); \
817 ip4_addr_set_loopback(ip_2_ip4(ipaddr)); \
818 IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); \
822#define ip_addr_set_hton(dest, src) \
824 if (IP_IS_V6(src)) { \
825 ip6_addr_set_hton(ip_2_ip6(ipaddr), (src)); \
826 IP_SET_TYPE(dest, IPADDR_TYPE_V6); \
828 ip4_addr_set_hton(ip_2_ip4(ipaddr), (src)); \
829 IP_SET_TYPE(dest, IPADDR_TYPE_V4); \
833#define ip_addr_get_network(target, host, netmask) \
835 if (IP_IS_V6(host)) { \
836 ip4_addr_set_zero(ip_2_ip4(target)); \
837 IP_SET_TYPE(target, IPADDR_TYPE_V6); \
839 ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); \
840 IP_SET_TYPE(target, IPADDR_TYPE_V4); \
844#define ip_addr_netcmp(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \
846 ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
848#define ip_addr_cmp(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2))))
850#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \
851 ip6_addr_isany(ip_2_ip6(ipaddr)) : \
852 ip4_addr_isany(ip_2_ip4(ipaddr)))
854#define ip_addr_isany_val(ipaddr) ((IP_IS_V6_VAL(ipaddr)) ? \
855 ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \
856 ip4_addr_isany_val(*ip_2_ip4(&(ipaddr))))
858#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \
860 ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
862#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \
863 ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
864 ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
866#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \
867 ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
868 ip4_addr_isloopback(ip_2_ip4(ipaddr)))
870#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \
871 ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
872 ip4_addr_islinklocal(ip_2_ip4(ipaddr)))
873#define ip_addr_debug_print(debug, ipaddr) \
875 if (IP_IS_V6(ipaddr)) { \
876 ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); \
878 ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); \
881#define ip_addr_debug_print_val(debug, ipaddr) \
883 if (IP_IS_V6_VAL(ipaddr)) { \
884 ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); \
886 ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); \
890#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \
891 ((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
893#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \
894 ((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen)))
895int ipaddr_aton(
const char *cp,
ip_addr_t *addr);
898#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX
902#define IP_ADDR_PCB_VERSION_MATCH(addr, pcb) 1
903#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) 1
908#define IPADDR4_INIT(u32val) \
912#define IP_IS_V4_VAL(ipaddr) 1
913#define IP_IS_V6_VAL(ipaddr) 0
914#define IP_IS_V4(ipaddr) 1
915#define IP_IS_V6(ipaddr) 0
916#define IP_IS_ANY_TYPE_VAL(ipaddr) 0
917#define IP_SET_TYPE_VAL(ipaddr, iptype)
918#define IP_SET_TYPE(ipaddr, iptype)
919#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V4
920#define ip_2_ip4(ipaddr) (ipaddr)
921#define IP_ADDR4(ipaddr, a, b, c, d) IP4_ADDR(ipaddr, a, b, c, d)
923#define ip_addr_copy(dest, src) ip4_addr_copy(dest, src)
924#define ip_addr_copy_from_ip4(dest, src) ip4_addr_copy(dest, src)
925#define ip_addr_set_ip4_u32(ipaddr, val) ip4_addr_set_u32(ip_2_ip4(ipaddr), val)
926#define ip_addr_get_ip4_u32(ipaddr) ip4_addr_get_u32(ip_2_ip4(ipaddr))
927#define ip_addr_set(dest, src) ip4_addr_set(dest, src)
928#define ip_addr_set_ipaddr(dest, src) ip4_addr_set(dest, src)
929#define ip_addr_set_zero(ipaddr) ip4_addr_set_zero(ipaddr)
930#define ip_addr_set_zero_ip4(ipaddr) ip4_addr_set_zero(ipaddr)
931#define ip_addr_set_any(is_ipv6, ipaddr) ip4_addr_set_any(ipaddr)
932#define ip_addr_set_loopback(is_ipv6, ipaddr) ip4_addr_set_loopback(ipaddr)
933#define ip_addr_set_hton(dest, src) ip4_addr_set_hton(dest, src)
934#define ip_addr_get_network(target, host, mask) ip4_addr_get_network(target, host, mask)
935#define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_netcmp(addr1, addr2, mask)
936#define ip_addr_cmp(addr1, addr2) ip4_addr_cmp(addr1, addr2)
937#define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr)
938#define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr)
939#define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr)
940#define ip_addr_islinklocal(ipaddr) ip4_addr_islinklocal(ipaddr)
941#define ip_addr_isbroadcast(addr, netif) ip4_addr_isbroadcast(addr, netif)
942#define ip_addr_ismulticast(ipaddr) ip4_addr_ismulticast(ipaddr)
943#define ip_addr_debug_print(debug, ipaddr) ip4_addr_debug_print(debug, ipaddr)
944#define ip_addr_debug_print_val(debug, ipaddr) ip4_addr_debug_print_val(debug, ipaddr)
945#define ipaddr_ntoa(ipaddr) ip4addr_ntoa(ipaddr)
946#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip4addr_ntoa_r(ipaddr, buf, buflen)
947#define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr)
949#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX
954#define IPADDR6_INIT(a, b, c, d) \
960#define IP_IS_V4_VAL(ipaddr) 0
961#define IP_IS_V6_VAL(ipaddr) 1
962#define IP_IS_V4(ipaddr) 0
963#define IP_IS_V6(ipaddr) 1
964#define IP_IS_ANY_TYPE_VAL(ipaddr) 0
965#define IP_SET_TYPE_VAL(ipaddr, iptype)
966#define IP_SET_TYPE(ipaddr, iptype)
967#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V6
968#define ip_2_ip6(ipaddr) (ipaddr)
969#define IP_ADDR6(ipaddr, i0, i1, i2, i3) IP6_ADDR(ipaddr, i0, i1, i2, i3)
971#define ip_addr_copy(dest, src) ip6_addr_copy(dest, src)
972#define ip_addr_copy_from_ip6(dest, src) ip6_addr_copy(dest, src)
973#define ip_addr_set(dest, src) ip6_addr_set(dest, src)
974#define ip_addr_set_ipaddr(dest, src) ip6_addr_set(dest, src)
975#define ip_addr_set_zero(ipaddr) ip6_addr_set_zero(ipaddr)
976#define ip_addr_set_zero_ip6(ipaddr) ip6_addr_set_zero(ipaddr)
977#define ip_addr_set_any(is_ipv6, ipaddr) ip6_addr_set_any(ipaddr)
978#define ip_addr_set_loopback(is_ipv6, ipaddr) ip6_addr_set_loopback(ipaddr)
979#define ip_addr_set_hton(dest, src) ip6_addr_set_hton(dest, src)
980#define ip_addr_get_network(target, host, mask) ip6_addr_set_zero(target)
981#define ip_addr_netcmp(addr1, addr2, mask) 0
982#define ip_addr_cmp(addr1, addr2) ip6_addr_cmp(addr1, addr2)
983#define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr)
984#define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr)
985#define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr)
986#define ip_addr_islinklocal(ipaddr) ip6_addr_islinklocal(ipaddr)
987#define ip_addr_isbroadcast(addr, netif) 0
988#define ip_addr_ismulticast(ipaddr) ip6_addr_ismulticast(ipaddr)
989#define ip_addr_debug_print(debug, ipaddr) ip6_addr_debug_print(debug, ipaddr)
990#define ip_addr_debug_print_val(debug, ipaddr) ip6_addr_debug_print_val(debug, ipaddr)
991#define ipaddr_ntoa(ipaddr) ip6addr_ntoa(ipaddr)
992#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip6addr_ntoa_r(ipaddr, buf, buflen)
993#define ipaddr_aton(cp, addr) ip6addr_aton(cp, addr)
995#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX
1003extern const ip_addr_t ip_addr_broadcast;
1009#define IP_ADDR_ANY IP4_ADDR_ANY
1015#define IP4_ADDR_ANY (&ip_addr_any)
1021#define IP4_ADDR_ANY4 (ip_2_ip4(&ip_addr_any))
1024#define IP_ADDR_BROADCAST (&ip_addr_broadcast)
1026#define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast))
1039#define IP6_ADDR_ANY (&ip6_addr_any)
1045#define IP6_ADDR_ANY6 (ip_2_ip6(&ip6_addr_any))
1049#define IP_ADDR_ANY IP6_ADDR_ANY
1054#if LWIP_IPV4 && LWIP_IPV6
1056#define IP_ANY_TYPE (&ip_addr_any_type)
1058#define IP_ANY_TYPE IP_ADDR_ANY
1070#ifndef NETIF_MAX_HWADDR_LEN
1071#define NETIF_MAX_HWADDR_LEN 6U
1086#define NETIF_FLAG_UP 0x01U
1089#define NETIF_FLAG_BROADCAST 0x02U
1095#define NETIF_FLAG_LINK_UP 0x04U
1099#define NETIF_FLAG_ETHARP 0x08U
1103#define NETIF_FLAG_ETHERNET 0x10U
1106#define NETIF_FLAG_IGMP 0x20U
1109#define NETIF_FLAG_MLD6 0x40U
1115enum lwip_internal_netif_client_data_index {
1117 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
1120 LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
1123 LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
1126 LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
1128 LWIP_NETIF_CLIENT_DATA_INDEX_MAX
1131#if LWIP_CHECKSUM_CTRL_PER_NETIF
1132#define NETIF_CHECKSUM_GEN_IP 0x0001
1133#define NETIF_CHECKSUM_GEN_UDP 0x0002
1134#define NETIF_CHECKSUM_GEN_TCP 0x0004
1135#define NETIF_CHECKSUM_GEN_ICMP 0x0008
1136#define NETIF_CHECKSUM_GEN_ICMP6 0x0010
1137#define NETIF_CHECKSUM_CHECK_IP 0x0100
1138#define NETIF_CHECKSUM_CHECK_UDP 0x0200
1139#define NETIF_CHECKSUM_CHECK_TCP 0x0400
1140#define NETIF_CHECKSUM_CHECK_ICMP 0x0800
1141#define NETIF_CHECKSUM_CHECK_ICMP6 0x1000
1142#define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF
1143#define NETIF_CHECKSUM_DISABLE_ALL 0x0000
1193typedef err_t (*netif_output_ip6_fn)(
struct netif *
netif,
struct pbuf *p,
1206#if LWIP_IPV4 && LWIP_IGMP
1208typedef err_t (*netif_igmp_mac_filter_fn)(
struct netif *
netif,
1211#if LWIP_IPV6 && LWIP_IPV6_MLD
1213typedef err_t (*netif_mld_mac_filter_fn)(
struct netif *
netif,
1217#if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || (LWIP_NUM_NETIF_CLIENT_DATA > 0)
1218u8 netif_alloc_client_data_id(
void);
1222#define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data)
1226#define netif_get_client_data(netif, id) (netif)->client_data[(id)]
1248 u8 ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES];
1269 netif_output_ip6_fn output_ip6;
1271#if LWIP_NETIF_STATUS_CALLBACK
1276#if LWIP_NETIF_LINK_CALLBACK
1281#if LWIP_NETIF_REMOVE_CALLBACK
1288#ifdef netif_get_client_data
1289 void *client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA];
1291#if LWIP_IPV6_AUTOCONFIG
1293 u8 ip6_autoconfig_enabled;
1295#if LWIP_IPV6_SEND_ROUTER_SOLICIT
1299#if LWIP_NETIF_HOSTNAME
1301 const char *hostname;
1303#if LWIP_CHECKSUM_CTRL_PER_NETIF
1326 struct stats_mib2_netif_ctrs mib2_counters;
1328#if LWIP_IPV4 && LWIP_IGMP
1331 netif_igmp_mac_filter_fn igmp_mac_filter;
1333#if LWIP_IPV6 && LWIP_IPV6_MLD
1336 netif_mld_mac_filter_fn mld_mac_filter;
1338#if LWIP_NETIF_HWADDRHINT
1343 struct pbuf *loop_first;
1344 struct pbuf *loop_last;
1345#if LWIP_LOOPBACK_MAX_PBUFS
1346 u16 loop_cnt_current;
1351#if LWIP_CHECKSUM_CTRL_PER_NETIF
1352#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) \
1354 (netif)->chksum_flags = chksumflags; \
1356#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0))
1358#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)
1359#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
1369#define netif_ip4_addr(netif) ((const ip4_addr_t *)ip_2_ip4(&((netif)->ip_addr)))
1371#define netif_ip4_netmask(netif) ((const ip4_addr_t *)ip_2_ip4(&((netif)->netmask)))
1373#define netif_ip4_gw(netif) ((const ip4_addr_t *)ip_2_ip4(&((netif)->gw)))
1375#define netif_ip_addr4(netif) ((const ip_addr_t *)&((netif)->ip_addr))
1377#define netif_ip_netmask4(netif) ((const ip_addr_t *)&((netif)->netmask))
1379#define netif_ip_gw4(netif) ((const ip_addr_t *)&((netif)->gw))
1385#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8)1 : (u8)0)
1388#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8)1 : (u8)0)
1390#if LWIP_NETIF_HOSTNAME
1392#define netif_set_hostname(netif, name) \
1394 if ((netif) != NULL) { \
1395 (netif)->hostname = name; \
1399#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
1404#define netif_set_igmp_mac_filter(netif, function) \
1406 if ((netif) != NULL) { \
1407 (netif)->igmp_mac_filter = function; \
1410#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL)
1413#if LWIP_IPV6 && LWIP_IPV6_MLD
1415#define netif_set_mld_mac_filter(netif, function) \
1417 if ((netif) != NULL) { \
1418 (netif)->mld_mac_filter = function; \
1421#define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL)
1422#define netif_mld_mac_filter(netif, addr, action) \
1424 if ((netif) && (netif)->mld_mac_filter) { \
1425 (netif)->mld_mac_filter((netif), (addr), (action)); \
1432#define netif_ip_addr6(netif, i) ((const ip_addr_t *)(&((netif)->ip6_addr[i])))
1434#define netif_ip6_addr(netif, i) ((const ip6_addr_t *)ip_2_ip6(&((netif)->ip6_addr[i])))
1436void netif_ip6_addr_set_parts(
struct netif *
netif, s8_t addr_idx, u32 i0, u32 i1, u32 i2, u32 i3);
1437#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i])
1438#define netif_set_ip6_autoconfig_enabled(netif, action) \
1441 (netif)->ip6_autoconfig_enabled = (action); \
1446#if LWIP_NETIF_HWADDRHINT
1447#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint))
1449#define NETIF_SET_HWADDRHINT(netif, hint)
1456 DHCP_STATE_REQUESTING = 1,
1457 DHCP_STATE_INIT = 2,
1458 DHCP_STATE_REBOOTING = 3,
1459 DHCP_STATE_REBINDING = 4,
1460 DHCP_STATE_RENEWING = 5,
1461 DHCP_STATE_SELECTING = 6,
1462 DHCP_STATE_INFORMING = 7,
1463 DHCP_STATE_CHECKING = 8,
1464 DHCP_STATE_PERMANENT = 9,
1465 DHCP_STATE_BOUND = 10,
1466 DHCP_STATE_RELEASING = 11,
1467 DHCP_STATE_BACKING_OFF = 12
1484#define s6_addr un.u8_addr
1488#define INADDR_NONE IPADDR_NONE
1490#define INADDR_LOOPBACK IPADDR_LOOPBACK
1492#define INADDR_ANY IPADDR_ANY
1494#define INADDR_BROADCAST IPADDR_BROADCAST
1498#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
1499typedef u8 sa_family_t;
1503#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
1504typedef u16 in_port_t;
1512 sa_family_t sin_family;
1515#define SIN_ZERO_LEN 8
1516 char sin_zero[SIN_ZERO_LEN];
1524 sa_family_t sin6_family;
1525 in_port_t sin6_port;
1535 sa_family_t sa_family;
1542 sa_family_t ss_family;
1551#define SOCKLEN_T_DEFINED 1
1552typedef int socklen_t;
1555#define SOCK_STREAM 1
1562#define SO_REUSEADDR 0x0004
1563#define SO_KEEPALIVE 0x0008
1564#define SO_BROADCAST 0x0020
1570#define SO_DEBUG 0x0001
1571#define SO_ACCEPTCONN 0x0002
1572#define SO_DONTROUTE 0x0010
1573#define SO_USELOOPBACK 0x0040
1574#define SO_LINGER 0x0080
1575#define SO_DONTLINGER ((int)(~SO_LINGER))
1576#define SO_OOBINLINE 0x0100
1577#define SO_REUSEPORT 0x0200
1578#define SO_SNDBUF 0x1001
1579#define SO_RCVBUF 0x1002
1580#define SO_SNDLOWAT 0x1003
1581#define SO_RCVLOWAT 0x1004
1582#define SO_SNDTIMEO 0x1005
1583#define SO_RCVTIMEO 0x1006
1584#define SO_ERROR 0x1007
1585#define SO_TYPE 0x1008
1586#define SO_CONTIMEO 0x1009
1587#define SO_NO_CHECK 0x100a
1592#define SOL_SOCKET 0xfff
1599#define AF_INET6 AF_UNSPEC
1601#define PF_INET AF_INET
1602#define PF_INET6 AF_INET6
1603#define PF_UNSPEC AF_UNSPEC
1606#define IPPROTO_ICMP 1
1607#define IPPROTO_TCP 6
1608#define IPPROTO_UDP 17
1610#define IPPROTO_IPV6 41
1611#define IPPROTO_ICMPV6 58
1613#define IPPROTO_UDPLITE 136
1614#define IPPROTO_RAW 255
1617#define MSG_PEEK 0x01
1618#define MSG_WAITALL 0x02
1620#define MSG_DONTWAIT 0x08
1621#define MSG_MORE 0x10
1633#define TCP_NODELAY 0x01
1634#define TCP_KEEPALIVE 0x02
1635#define TCP_KEEPIDLE 0x03
1636#define TCP_KEEPINTVL 0x04
1637#define TCP_KEEPCNT 0x05
1644#define IPV6_CHECKSUM 7
1645#define IPV6_V6ONLY 27
1648#if LWIP_UDP && LWIP_UDPLITE
1652#define UDPLITE_SEND_CSCOV 0x01
1653#define UDPLITE_RECV_CSCOV 0x02
1657#if LWIP_MULTICAST_TX_OPTIONS
1661#define IP_MULTICAST_TTL 5
1662#define IP_MULTICAST_IF 6
1663#define IP_MULTICAST_LOOP 7
1670#define IP_ADD_MEMBERSHIP 3
1671#define IP_DROP_MEMBERSHIP 4
1673typedef struct ip_mreq
1696#define IPTOS_TOS_MASK 0x1E
1697#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
1698#define IPTOS_LOWDELAY 0x10
1699#define IPTOS_THROUGHPUT 0x08
1700#define IPTOS_RELIABILITY 0x04
1701#define IPTOS_LOWCOST 0x02
1702#define IPTOS_MINCOST IPTOS_LOWCOST
1713#define IPTOS_PREC_MASK 0xe0
1714#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
1715#define IPTOS_PREC_NETCONTROL 0xe0
1716#define IPTOS_PREC_INTERNETCONTROL 0xc0
1717#define IPTOS_PREC_CRITIC_ECP 0xa0
1718#define IPTOS_PREC_FLASHOVERRIDE 0x80
1719#define IPTOS_PREC_FLASH 0x60
1720#define IPTOS_PREC_IMMEDIATE 0x40
1721#define IPTOS_PREC_PRIORITY 0x20
1722#define IPTOS_PREC_ROUTINE 0x00
1735#if !defined(FIONREAD) || !defined(FIONBIO)
1736#define IOCPARM_MASK 0x7fU
1737#define IOC_VOID 0x20000000UL
1738#define IOC_OUT 0x40000000UL
1739#define IOC_IN 0x80000000UL
1740#define IOC_INOUT (IOC_IN | IOC_OUT)
1743#define _IO(x, y) (IOC_VOID | ((x) << 8) | (y))
1745#define _IOR(x, y, t) (IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
1747#define _IOW(x, y, t) (IOC_IN | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
1751#define FIONREAD _IOR('f', 127, unsigned long)
1754#define FIONBIO _IOW('f', 126, unsigned long)
1759#define SIOCSHIWAT _IOW('s', 0, unsigned long)
1760#define SIOCGHIWAT _IOR('s', 1, unsigned long)
1761#define SIOCSLOWAT _IOW('s', 2, unsigned long)
1762#define SIOCGLOWAT _IOR('s', 3, unsigned long)
1763#define SIOCATMARK _IOR('s', 7, unsigned long)
1793#define FD_SETSIZE MEMP_NUM_NETCONN
1794#define FDSETSAFESET(n, code) \
1796 if (((n)-LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n)-LWIP_SOCKET_OFFSET) >= 0)) { \
1800#define FDSETSAFEGET(n, code) (((n)-LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n)-LWIP_SOCKET_OFFSET) >= 0) ? \
1803#define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET) / 8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
1804#define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET) / 8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
1805#define FD_ISSET(n, p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET) / 8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
1806#define FD_ZERO(p) memset((void *)(p), 0, sizeof(*(p)))
1810 unsigned char fd_bits[(FD_SETSIZE + 7) / 8];
1813#elif LWIP_SOCKET_OFFSET
1814#error LWIP_SOCKET_OFFSET does not work with external FD_SET!
1815#elif FD_SETSIZE < MEMP_NUM_NETCONN
1816#error "external FD_SETSIZE too small for number of sockets"
1821#define DNS_TMR_INTERVAL 1000
1824#define LWIP_DNS_ADDRTYPE_IPV4 0
1825#define LWIP_DNS_ADDRTYPE_IPV6 1
1826#define LWIP_DNS_ADDRTYPE_IPV4_IPV6 2
1827#define LWIP_DNS_ADDRTYPE_IPV6_IPV4 3
1828#if LWIP_IPV4 && LWIP_IPV6
1829#ifndef LWIP_DNS_ADDRTYPE_DEFAULT
1830#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4_IPV6
1832#elif defined(LWIP_IPV4)
1833#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4
1835#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV6
1838#if DNS_LOCAL_HOSTLIST
1840struct local_hostlist_entry
1846 struct local_hostlist_entry *next;
1848#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
1849#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
1850#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH
1852#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
1868#ifndef LWIP_DNS_API_DECLARE_H_ERRNO
1869#define LWIP_DNS_API_DECLARE_H_ERRNO 1
1872#ifndef LWIP_DNS_API_DEFINE_ERRORS
1873#define LWIP_DNS_API_DEFINE_ERRORS 1
1876#ifndef LWIP_DNS_API_DEFINE_FLAGS
1877#define LWIP_DNS_API_DEFINE_FLAGS 1
1880#ifndef LWIP_DNS_API_DECLARE_STRUCTS
1881#define LWIP_DNS_API_DECLARE_STRUCTS 1
1884#if LWIP_DNS_API_DEFINE_ERRORS
1886#define EAI_NONAME 200
1887#define EAI_SERVICE 201
1889#define EAI_MEMORY 203
1890#define EAI_FAMILY 204
1892#define HOST_NOT_FOUND 210
1894#define NO_RECOVERY 212
1895#define TRY_AGAIN 213
1898#if LWIP_DNS_API_DEFINE_FLAGS
1900#define AI_PASSIVE 0x01
1901#define AI_CANONNAME 0x02
1902#define AI_NUMERICHOST 0x04
1903#define AI_NUMERICSERV 0x08
1904#define AI_V4MAPPED 0x10
1906#define AI_ADDRCONFIG 0x40
1909#if LWIP_DNS_API_DECLARE_STRUCTS
1919#define h_addr h_addr_list[0]
1928 socklen_t ai_addrlen;
1935#define NETDB_ELEM_SIZE (sizeof(struct addrinfo) + sizeof(struct sockaddr_storage) + DNS_MAX_NAME_LENGTH + 1)
1938#define htons(x) lwip_htons(x)
1939#define ntohs(x) lwip_ntohs(x)
1940#define htonl(x) lwip_htonl(x)
1941#define ntohl(x) lwip_ntohl(x)
1943#define lwip_htons(x) PP_HTONS(x)
1944#define lwip_ntohs(x) PP_NTOHS(x)
1945#define lwip_htonl(x) PP_HTONL(x)
1946#define lwip_ntohl(x) PP_NTOHL(x)
1951#define PP_HTONS(x) ((((x)&0xff) << 8) | (((x)&0xff00) >> 8))
1952#define PP_NTOHS(x) PP_HTONS(x)
1953#define PP_HTONL(x) ((((x)&0xff) << 24) | \
1954 (((x)&0xff00) << 8) | \
1955 (((x)&0xff0000UL) >> 8) | \
1956 (((x)&0xff000000UL) >> 24))
1957#define PP_NTOHL(x) PP_HTONL(x)
struct netif * netif_list
err_t(* netif_init_fn)(struct netif *netif)
struct netif * netif_default
void(* netif_status_callback_fn)(struct netif *netif)
err_t(* netif_output_fn)(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
void(* dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
err_t(* netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)
#define NETIF_MAX_HWADDR_LEN
u8 hwaddr[NETIF_MAX_HWADDR_LEN]
netif_linkoutput_fn linkoutput