64 typedef union uip_ip6addr_t {
104 #if UIP_CONF_LL_802154
107 #define UIP_802154_SHORTADDR_LEN 2
108 #define UIP_802154_LONGADDR_LEN 8
109 #define UIP_LLADDR_LEN UIP_802154_LONGADDR_LEN
111 #if UIP_CONF_LL_80211
114 #define UIP_LLADDR_LEN 6
118 #define UIP_LLADDR_LEN 6
159 #define uip_sethostaddr(addr) uip_ipaddr_copy(&uip_hostaddr, (addr))
179 #define uip_gethostaddr(addr) uip_ipaddr_copy((addr), &uip_hostaddr)
191 #define uip_setdraddr(addr) uip_ipaddr_copy(&uip_draddr, (addr))
203 #define uip_setnetmask(addr) uip_ipaddr_copy(&uip_netmask, (addr))
214 #define uip_getdraddr(addr) uip_ipaddr_copy((addr), &uip_draddr)
224 #define uip_getnetmask(addr) uip_ipaddr_copy((addr), &uip_netmask)
310 #define uip_input() uip_process(UIP_DATA)
356 #define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \
357 uip_process(UIP_TIMER); } while (0)
363 #define uip_conn_active(conn) (uip_conns[conn].tcpstateflags != UIP_CLOSED)
378 #define uip_periodic_conn(conn) do { uip_conn = conn; \
379 uip_process(UIP_TIMER); } while (0)
392 #define uip_poll_conn(conn) do { uip_conn = conn; \
393 uip_process(UIP_POLL_REQUEST); } while (0)
429 #define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \
430 uip_process(UIP_UDP_TIMER); } while(0)
446 #define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \
447 uip_process(UIP_UDP_TIMER); } while(0)
486 #define uip_buf (uip_aligned_buf.u8)
576 #define uip_outstanding(conn) ((conn)->len)
615 #define uip_datalen() uip_len
626 #define uip_urgdatalen() uip_urglen
635 #define uip_close() (uip_flags = UIP_CLOSE)
646 #define uip_abort() (uip_flags = UIP_ABORT)
656 #define uip_stop() (uip_conn->tcpstateflags |= UIP_STOPPED)
664 #define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED)
675 #define uip_restart() do { uip_flags |= UIP_NEWDATA; \
676 uip_conn->tcpstateflags &= ~UIP_STOPPED; \
691 #define uip_udpconnection() (uip_conn == NULL)
702 #define uip_newdata() (uip_flags & UIP_NEWDATA)
713 #define uip_acked() (uip_flags & UIP_ACKDATA)
725 #define uip_connected() (uip_flags & UIP_CONNECTED)
735 #define uip_closed() (uip_flags & UIP_CLOSE)
745 #define uip_aborted() (uip_flags & UIP_ABORT)
755 #define uip_timedout() (uip_flags & UIP_TIMEDOUT)
767 #define uip_rexmit() (uip_flags & UIP_REXMIT)
781 #define uip_poll() (uip_flags & UIP_POLL)
789 #define uip_initialmss() (uip_conn->initialmss)
802 #define uip_mss() (uip_conn->mss)
840 #define uip_udp_remove(conn) (conn)->lport = 0
852 #define uip_udp_bind(conn, port) (conn)->lport = port
865 #define uip_udp_send(len) uip_send((char *)uip_appdata, len)
891 #define uip_ipaddr_to_quad(a) (a)->u8[0],(a)->u8[1],(a)->u8[2],(a)->u8[3]
919 #define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
920 (addr)->u8[0] = addr0; \
921 (addr)->u8[1] = addr1; \
922 (addr)->u8[2] = addr2; \
923 (addr)->u8[3] = addr3; \
933 #define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \
934 (addr)->u16[0] = UIP_HTONS(addr0); \
935 (addr)->u16[1] = UIP_HTONS(addr1); \
936 (addr)->u16[2] = UIP_HTONS(addr2); \
937 (addr)->u16[3] = UIP_HTONS(addr3); \
938 (addr)->u16[4] = UIP_HTONS(addr4); \
939 (addr)->u16[5] = UIP_HTONS(addr5); \
940 (addr)->u16[6] = UIP_HTONS(addr6); \
941 (addr)->u16[7] = UIP_HTONS(addr7); \
951 #define uip_ip6addr_u8(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7,addr8,addr9,addr10,addr11,addr12,addr13,addr14,addr15) do { \
952 (addr)->u8[0] = addr0; \
953 (addr)->u8[1] = addr1; \
954 (addr)->u8[2] = addr2; \
955 (addr)->u8[3] = addr3; \
956 (addr)->u8[4] = addr4; \
957 (addr)->u8[5] = addr5; \
958 (addr)->u8[6] = addr6; \
959 (addr)->u8[7] = addr7; \
960 (addr)->u8[8] = addr8; \
961 (addr)->u8[9] = addr9; \
962 (addr)->u8[10] = addr10; \
963 (addr)->u8[11] = addr11; \
964 (addr)->u8[12] = addr12; \
965 (addr)->u8[13] = addr13; \
966 (addr)->u8[14] = addr14; \
967 (addr)->u8[15] = addr15; \
989 #ifndef uip_ipaddr_copy
990 #define uip_ipaddr_copy(dest, src) (*(dest) = *(src))
1014 #define uip_ipaddr_cmp(addr1, addr2) ((addr1)->u16[0] == (addr2)->u16[0] && \
1015 (addr1)->u16[1] == (addr2)->u16[1])
1017 #define uip_ipaddr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0)
1045 #define uip_ipaddr_maskcmp(addr1, addr2, mask) \
1046 (((((u16_t *)addr1)[0] & ((u16_t *)mask)[0]) == \
1047 (((u16_t *)addr2)[0] & ((u16_t *)mask)[0])) && \
1048 ((((u16_t *)addr1)[1] & ((u16_t *)mask)[1]) == \
1049 (((u16_t *)addr2)[1] & ((u16_t *)mask)[1])))
1051 #define uip_ipaddr_prefixcmp(addr1, addr2, length) (memcmp(addr1, addr2, length>>3) == 0)
1097 #define uip_ipaddr_mask(dest, src, mask) do { \
1098 ((u16_t *)dest)[0] = ((u16_t *)src)[0] & ((u16_t *)mask)[0]; \
1099 ((u16_t *)dest)[1] = ((u16_t *)src)[1] & ((u16_t *)mask)[1]; \
1120 #define uip_ipaddr1(addr) ((addr)->u8[0])
1140 #define uip_ipaddr2(addr) ((addr)->u8[1])
1160 #define uip_ipaddr3(addr) ((addr)->u8[2])
1180 #define uip_ipaddr4(addr) ((addr)->u8[3])
1192 # if UIP_BYTE_ORDER == UIP_BIG_ENDIAN
1193 # define UIP_HTONS(n) (n)
1194 # define UIP_HTONL(n) (n)
1196 # define UIP_HTONS(n) (u16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8))
1197 # define UIP_HTONL(n) (((u32_t)UIP_HTONS(n) << 16) | UIP_HTONS((u32_t)(n) >> 16))
1200 #error "UIP_HTONS already defined!"
1214 #define uip_ntohs uip_htons
1218 CCIF u32_t uip_htonl(u32_t val);
1221 #define uip_ntohl uip_htonl
1241 extern void *uip_urgdata;
1277 extern u16_t uip_urglen, uip_surglen;
1332 CCIF
extern struct uip_conn uip_conns[
UIP_CONNS];
1365 struct uip_fallback_interface {
1367 void (*output)(void);
1371 struct uip_icmp6_conn {
1372 uip_icmp6_appstate_t appstate;
1374 extern struct uip_icmp6_conn uip_icmp6_conns;
1382 #if UIP_STATISTICS == 1
1384 #define UIP_STAT(s) s
1437 uip_stats_t syndrop;
1476 CCIF
extern u8_t uip_flags;
1485 #define UIP_ACKDATA 1
1489 #define UIP_NEWDATA 2
1491 #define UIP_REXMIT 4
1496 #define UIP_CLOSE 16
1501 #define UIP_ABORT 32
1506 #define UIP_CONNECTED 64
1511 #define UIP_TIMEDOUT 128
1543 #define UIP_POLL_REQUEST 3
1545 #define UIP_UDP_SEND_CONN 4
1549 #define UIP_UDP_TIMER 5
1553 #define UIP_CLOSED 0
1554 #define UIP_SYN_RCVD 1
1555 #define UIP_SYN_SENT 2
1556 #define UIP_ESTABLISHED 3
1557 #define UIP_FIN_WAIT_1 4
1558 #define UIP_FIN_WAIT_2 5
1559 #define UIP_CLOSING 6
1560 #define UIP_TIME_WAIT 7
1561 #define UIP_LAST_ACK 8
1562 #define UIP_TS_MASK 15
1564 #define UIP_STOPPED 16
1567 struct uip_tcpip_hdr {
1575 uip_ip6addr_t srcipaddr, destipaddr;
1603 struct uip_icmpip_hdr {
1611 uip_ip6addr_t srcipaddr, destipaddr;
1636 struct uip_udpip_hdr {
1644 uip_ip6addr_t srcipaddr, destipaddr;
1679 uip_ip6addr_t srcipaddr, destipaddr;
1716 typedef struct uip_ext_hdr {
1722 typedef struct uip_hbho_hdr {
1728 typedef struct uip_desto_hdr {
1743 typedef struct uip_routing_hdr {
1751 typedef struct uip_frag_hdr {
1754 u16_t offsetresmore;
1762 typedef struct uip_ext_hdr_opt {
1768 typedef struct uip_ext_hdr_opt_padn {
1771 } uip_ext_hdr_opt_padn;
1774 struct uip_tcp_hdr {
1788 struct uip_icmp_hdr {
1798 struct uip_udp_hdr {
1820 #define UIP_APPDATA_SIZE (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
1821 #define UIP_APPDATA_PTR (void *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN]
1823 #define UIP_PROTO_ICMP 1
1824 #define UIP_PROTO_TCP 6
1825 #define UIP_PROTO_UDP 17
1826 #define UIP_PROTO_ICMP6 58
1832 #define UIP_PROTO_HBHO 0
1833 #define UIP_PROTO_DESTO 60
1834 #define UIP_PROTO_ROUTING 43
1835 #define UIP_PROTO_FRAG 44
1836 #define UIP_PROTO_NONE 59
1841 #define UIP_EXT_HDR_OPT_PAD1 0
1842 #define UIP_EXT_HDR_OPT_PADN 1
1854 #define UIP_EXT_HDR_BITMAP_HBHO 0x01
1855 #define UIP_EXT_HDR_BITMAP_DESTO1 0x02
1856 #define UIP_EXT_HDR_BITMAP_ROUTING 0x04
1857 #define UIP_EXT_HDR_BITMAP_FRAG 0x08
1858 #define UIP_EXT_HDR_BITMAP_AH 0x10
1859 #define UIP_EXT_HDR_BITMAP_ESP 0x20
1860 #define UIP_EXT_HDR_BITMAP_DESTO2 0x40
1869 #define UIP_IPH_LEN 40
1870 #define UIP_FRAGH_LEN 8
1872 #define UIP_IPH_LEN 20
1875 #define UIP_UDPH_LEN 8
1876 #define UIP_TCPH_LEN 20
1878 #define UIP_ICMPH_LEN 4
1880 #define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN)
1883 #define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN)
1886 #define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
1887 #define UIP_IPICMPH_LEN (UIP_IPH_LEN + UIP_ICMPH_LEN)
1889 #define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN)
1898 #define uip_l2_l3_hdr_len (UIP_LLH_LEN + UIP_IPH_LEN + uip_ext_len)
1899 #define uip_l2_l3_icmp_hdr_len (UIP_LLH_LEN + UIP_IPH_LEN + uip_ext_len + UIP_ICMPH_LEN)
1900 #define uip_l3_hdr_len (UIP_IPH_LEN + uip_ext_len)
1901 #define uip_l3_icmp_hdr_len (UIP_IPH_LEN + uip_ext_len + UIP_ICMPH_LEN)
1906 CCIF
extern const uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
1908 CCIF
extern uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
1913 #if UIP_FIXEDETHADDR
1922 #ifdef UIP_CONF_IPV6
1924 #define UIP_LLPREF_LEN 10
1930 #define uip_is_addr_loopback(a) \
1931 ((((a)->u16[0]) == 0) && \
1932 (((a)->u16[1]) == 0) && \
1933 (((a)->u16[2]) == 0) && \
1934 (((a)->u16[3]) == 0) && \
1935 (((a)->u16[4]) == 0) && \
1936 (((a)->u16[5]) == 0) && \
1937 (((a)->u16[6]) == 0) && \
1938 (((a)->u8[14]) == 0) && \
1939 (((a)->u8[15]) == 0x01))
1944 #define uip_is_addr_unspecified(a) \
1945 ((((a)->u16[0]) == 0) && \
1946 (((a)->u16[1]) == 0) && \
1947 (((a)->u16[2]) == 0) && \
1948 (((a)->u16[3]) == 0) && \
1949 (((a)->u16[4]) == 0) && \
1950 (((a)->u16[5]) == 0) && \
1951 (((a)->u16[6]) == 0) && \
1952 (((a)->u16[7]) == 0))
1955 #define uip_is_addr_linklocal_allnodes_mcast(a) \
1956 ((((a)->u8[0]) == 0xff) && \
1957 (((a)->u8[1]) == 0x02) && \
1958 (((a)->u16[1]) == 0) && \
1959 (((a)->u16[2]) == 0) && \
1960 (((a)->u16[3]) == 0) && \
1961 (((a)->u16[4]) == 0) && \
1962 (((a)->u16[5]) == 0) && \
1963 (((a)->u16[6]) == 0) && \
1964 (((a)->u8[14]) == 0) && \
1965 (((a)->u8[15]) == 0x01))
1968 #define uip_is_addr_linklocal_allrouters_mcast(a) \
1969 ((((a)->u8[0]) == 0xff) && \
1970 (((a)->u8[1]) == 0x02) && \
1971 (((a)->u16[1]) == 0) && \
1972 (((a)->u16[2]) == 0) && \
1973 (((a)->u16[3]) == 0) && \
1974 (((a)->u16[4]) == 0) && \
1975 (((a)->u16[5]) == 0) && \
1976 (((a)->u16[6]) == 0) && \
1977 (((a)->u8[14]) == 0) && \
1978 (((a)->u8[15]) == 0x02))
1984 #define uip_is_addr_linklocal(a) \
1985 ((a)->u8[0] == 0xfe && \
1989 #define uip_create_unspecified(a) uip_ip6addr(a, 0, 0, 0, 0, 0, 0, 0, 0)
1992 #define uip_create_linklocal_allnodes_mcast(a) uip_ip6addr(a, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001)
1995 #define uip_create_linklocal_allrouters_mcast(a) uip_ip6addr(a, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002)
1996 #define uip_create_linklocal_prefix(addr) do { \
1997 (addr)->u16[0] = UIP_HTONS(0xfe80); \
1998 (addr)->u16[1] = 0; \
1999 (addr)->u16[2] = 0; \
2000 (addr)->u16[3] = 0; \
2007 #define uip_is_addr_solicited_node(a) \
2008 ((((a)->u8[0]) == 0xFF) && \
2009 (((a)->u8[1]) == 0x02) && \
2010 (((a)->u16[1]) == 0x00) && \
2011 (((a)->u16[2]) == 0x00) && \
2012 (((a)->u16[3]) == 0x00) && \
2013 (((a)->u16[4]) == 0x00) && \
2014 (((a)->u8[10]) == 0x00) && \
2015 (((a)->u8[11]) == 0x01) && \
2016 (((a)->u8[12]) == 0xFF))
2022 #define uip_create_solicited_node(a, b) \
2023 (((b)->u8[0]) = 0xFF); \
2024 (((b)->u8[1]) = 0x02); \
2025 (((b)->u16[1]) = 0); \
2026 (((b)->u16[2]) = 0); \
2027 (((b)->u16[3]) = 0); \
2028 (((b)->u16[4]) = 0); \
2029 (((b)->u8[10]) = 0); \
2030 (((b)->u8[11]) = 0x01); \
2031 (((b)->u8[12]) = 0xFF); \
2032 (((b)->u8[13]) = ((a)->u8[13])); \
2033 (((b)->u16[7]) = ((a)->u16[7]))
2040 #define uip_is_addr_link_local(a) \
2041 ((((a)->u8[0]) == 0xFE) && \
2042 (((a)->u8[1]) == 0x80))
2049 #if UIP_CONF_LL_802154
2050 #define uip_is_addr_mac_addr_based(a, m) \
2051 ((((a)->u8[8]) == (((m)->addr[0]) ^ 0x02)) && \
2052 (((a)->u8[9]) == (m)->addr[1]) && \
2053 (((a)->u8[10]) == (m)->addr[2]) && \
2054 (((a)->u8[11]) == (m)->addr[3]) && \
2055 (((a)->u8[12]) == (m)->addr[4]) && \
2056 (((a)->u8[13]) == (m)->addr[5]) && \
2057 (((a)->u8[14]) == (m)->addr[6]) && \
2058 (((a)->u8[15]) == (m)->addr[7]))
2061 #define uip_is_addr_mac_addr_based(a, m) \
2062 ((((a)->u8[8]) == (((m)->addr[0]) | 0x02)) && \
2063 (((a)->u8[9]) == (m)->addr[1]) && \
2064 (((a)->u8[10]) == (m)->addr[2]) && \
2065 (((a)->u8[11]) == 0xff) && \
2066 (((a)->u8[12]) == 0xfe) && \
2067 (((a)->u8[13]) == (m)->addr[3]) && \
2068 (((a)->u8[14]) == (m)->addr[4]) && \
2069 (((a)->u8[15]) == (m)->addr[5]))
2077 #define uip_is_addr_mcast(a) \
2078 (((a)->u8[0]) == 0xFF)
2084 #define uip_is_mcast_group_id_all_nodes(a) \
2085 ((((a)->u16[1]) == 0) && \
2086 (((a)->u16[2]) == 0) && \
2087 (((a)->u16[3]) == 0) && \
2088 (((a)->u16[4]) == 0) && \
2089 (((a)->u16[5]) == 0) && \
2090 (((a)->u16[6]) == 0) && \
2091 (((a)->u8[14]) == 0) && \
2092 (((a)->u8[15]) == 1))
2098 #define uip_is_mcast_group_id_all_routers(a) \
2099 ((((a)->u16[1]) == 0) && \
2100 (((a)->u16[2]) == 0) && \
2101 (((a)->u16[3]) == 0) && \
2102 (((a)->u16[4]) == 0) && \
2103 (((a)->u16[5]) == 0) && \
2104 (((a)->u16[6]) == 0) && \
2105 (((a)->u8[14]) == 0) && \
2106 (((a)->u8[15]) == 2))
2113 #define uip_are_solicited_bytes_equal(a, b) \
2114 ((((a)->u8[13]) == ((b)->u8[13])) && \
2115 (((a)->u8[14]) == ((b)->u8[14])) && \
2116 (((a)->u8[15]) == ((b)->u8[15])))