Changeset 158 for uKadecot/trunk/uip/net/ip/uip.h
- Timestamp:
- Feb 20, 2016, 10:43:32 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uKadecot/trunk/uip/net/ip/uip.h
r157 r158 54 54 #define __UIP_H__ 55 55 56 #include " uipopt.h"56 #include "net/ip/uipopt.h" 57 57 58 58 /** … … 60 60 * 61 61 */ 62 typedef u 16_t uip_ip4addr_t[2];63 typedef u 16_t uip_ip6addr_t[8];62 typedef uint16_t uip_ip4addr_t[2]; 63 typedef uint16_t uip_ip6addr_t[8]; 64 64 #if UIP_CONF_IPV6 65 65 typedef uip_ip6addr_t uip_ipaddr_t; … … 193 193 * This function may be used at boot time to set the initial ip_id. 194 194 */ 195 void uip_setipid(u 16_t id);195 void uip_setipid(uint16_t id); 196 196 197 197 /** @} */ … … 421 421 */ 422 422 #if 0 423 extern u 8_t uip_buf[UIP_BUFSIZE+2];423 extern uint8_t uip_buf[UIP_BUFSIZE+2]; 424 424 #else 425 extern u 8_t *uip_buf;425 extern uint8_t *uip_buf; 426 426 #endif 427 427 … … 452 452 * \param port A 16-bit port number in network byte order. 453 453 */ 454 void uip_listen(u 16_t port);454 void uip_listen(uint16_t port); 455 455 456 456 /** … … 466 466 * \param port A 16-bit port number in network byte order. 467 467 */ 468 void uip_unlisten(u 16_t port);468 void uip_unlisten(uint16_t port); 469 469 470 470 /** … … 500 500 * 501 501 */ 502 struct uip_conn *uip_connect(uip_ipaddr_t *ripaddr, u 16_t port);502 struct uip_conn *uip_connect(uip_ipaddr_t *ripaddr, uint16_t port); 503 503 504 504 … … 768 768 * if no connection could be allocated. 769 769 */ 770 struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u 16_t rport);770 struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, uint16_t rport); 771 771 772 772 /** … … 843 843 */ 844 844 #define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \ 845 ((u 16_t *)(addr))[0] = HTONS(((addr0) << 8) | (addr1)); \846 ((u 16_t *)(addr))[1] = HTONS(((addr2) << 8) | (addr3)); \845 ((uint16_t *)(addr))[0] = HTONS(((addr0) << 8) | (addr1)); \ 846 ((uint16_t *)(addr))[1] = HTONS(((addr2) << 8) | (addr3)); \ 847 847 } while(0) 848 848 … … 855 855 */ 856 856 #define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \ 857 ((u 16_t *)(addr))[0] = HTONS((addr0)); \858 ((u 16_t *)(addr))[1] = HTONS((addr1)); \859 ((u 16_t *)(addr))[2] = HTONS((addr2)); \860 ((u 16_t *)(addr))[3] = HTONS((addr3)); \861 ((u 16_t *)(addr))[4] = HTONS((addr4)); \862 ((u 16_t *)(addr))[5] = HTONS((addr5)); \863 ((u 16_t *)(addr))[6] = HTONS((addr6)); \864 ((u 16_t *)(addr))[7] = HTONS((addr7)); \857 ((uint16_t *)(addr))[0] = HTONS((addr0)); \ 858 ((uint16_t *)(addr))[1] = HTONS((addr1)); \ 859 ((uint16_t *)(addr))[2] = HTONS((addr2)); \ 860 ((uint16_t *)(addr))[3] = HTONS((addr3)); \ 861 ((uint16_t *)(addr))[4] = HTONS((addr4)); \ 862 ((uint16_t *)(addr))[5] = HTONS((addr5)); \ 863 ((uint16_t *)(addr))[6] = HTONS((addr6)); \ 864 ((uint16_t *)(addr))[7] = HTONS((addr7)); \ 865 865 } while(0) 866 866 … … 885 885 #if !UIP_CONF_IPV6 886 886 #define uip_ipaddr_copy(dest, src) do { \ 887 ((u 16_t *)dest)[0] = ((u16_t *)src)[0]; \888 ((u 16_t *)dest)[1] = ((u16_t *)src)[1]; \887 ((uint16_t *)dest)[0] = ((uint16_t *)src)[0]; \ 888 ((uint16_t *)dest)[1] = ((uint16_t *)src)[1]; \ 889 889 } while(0) 890 890 #else /* !UIP_CONF_IPV6 */ … … 913 913 */ 914 914 #if !UIP_CONF_IPV6 915 #define uip_ipaddr_cmp(addr1, addr2) (((u 16_t *)addr1)[0] == ((u16_t *)addr2)[0] && \916 ((u 16_t *)addr1)[1] == ((u16_t *)addr2)[1])915 #define uip_ipaddr_cmp(addr1, addr2) (((uint16_t *)addr1)[0] == ((uint16_t *)addr2)[0] && \ 916 ((uint16_t *)addr1)[1] == ((uint16_t *)addr2)[1]) 917 917 #else /* !UIP_CONF_IPV6 */ 918 918 #define uip_ipaddr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0) … … 944 944 */ 945 945 #define uip_ipaddr_maskcmp(addr1, addr2, mask) \ 946 (((((u 16_t *)addr1)[0] & ((u16_t *)mask)[0]) == \947 (((u 16_t *)addr2)[0] & ((u16_t *)mask)[0])) && \948 ((((u 16_t *)addr1)[1] & ((u16_t *)mask)[1]) == \949 (((u 16_t *)addr2)[1] & ((u16_t *)mask)[1])))946 (((((uint16_t *)addr1)[0] & ((uint16_t *)mask)[0]) == \ 947 (((uint16_t *)addr2)[0] & ((uint16_t *)mask)[0])) && \ 948 ((((uint16_t *)addr1)[1] & ((uint16_t *)mask)[1]) == \ 949 (((uint16_t *)addr2)[1] & ((uint16_t *)mask)[1]))) 950 950 951 951 … … 975 975 */ 976 976 #define uip_ipaddr_mask(dest, src, mask) do { \ 977 ((u 16_t *)dest)[0] = ((u16_t *)src)[0] & ((u16_t *)mask)[0]; \978 ((u 16_t *)dest)[1] = ((u16_t *)src)[1] & ((u16_t *)mask)[1]; \977 ((uint16_t *)dest)[0] = ((uint16_t *)src)[0] & ((uint16_t *)mask)[0]; \ 978 ((uint16_t *)dest)[1] = ((uint16_t *)src)[1] & ((uint16_t *)mask)[1]; \ 979 979 } while(0) 980 980 … … 987 987 \code 988 988 uip_ipaddr_t ipaddr; 989 u 8_t octet;989 uint8_t octet; 990 990 991 991 uip_ipaddr(&ipaddr, 1,2,3,4); … … 997 997 * \hideinitializer 998 998 */ 999 #define uip_ipaddr1(addr) (htons(((u 16_t *)(addr))[0]) >> 8)999 #define uip_ipaddr1(addr) (htons(((uint16_t *)(addr))[0]) >> 8) 1000 1000 1001 1001 /** … … 1007 1007 \code 1008 1008 uip_ipaddr_t ipaddr; 1009 u 8_t octet;1009 uint8_t octet; 1010 1010 1011 1011 uip_ipaddr(&ipaddr, 1,2,3,4); … … 1017 1017 * \hideinitializer 1018 1018 */ 1019 #define uip_ipaddr2(addr) (htons(((u 16_t *)(addr))[0]) & 0xff)1019 #define uip_ipaddr2(addr) (htons(((uint16_t *)(addr))[0]) & 0xff) 1020 1020 1021 1021 /** … … 1027 1027 \code 1028 1028 uip_ipaddr_t ipaddr; 1029 u 8_t octet;1029 uint8_t octet; 1030 1030 1031 1031 uip_ipaddr(&ipaddr, 1,2,3,4); … … 1037 1037 * \hideinitializer 1038 1038 */ 1039 #define uip_ipaddr3(addr) (htons(((u 16_t *)(addr))[1]) >> 8)1039 #define uip_ipaddr3(addr) (htons(((uint16_t *)(addr))[1]) >> 8) 1040 1040 1041 1041 /** … … 1047 1047 \code 1048 1048 uip_ipaddr_t ipaddr; 1049 u 8_t octet;1049 uint8_t octet; 1050 1050 1051 1051 uip_ipaddr(&ipaddr, 1,2,3,4); … … 1057 1057 * \hideinitializer 1058 1058 */ 1059 #define uip_ipaddr4(addr) (htons(((u 16_t *)(addr))[1]) & 0xff)1059 #define uip_ipaddr4(addr) (htons(((uint16_t *)(addr))[1]) & 0xff) 1060 1060 1061 1061 /** … … 1072 1072 # define HTONS(n) (n) 1073 1073 # else /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ 1074 # define HTONS(n) (u 16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8))1074 # define HTONS(n) (uint16_t)((((uint16_t) (n)) << 8) | (((uint16_t) (n)) >> 8)) 1075 1075 # endif /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ 1076 1076 #else … … 1086 1086 */ 1087 1087 #ifndef htons 1088 u 16_t htons(u16_t val);1088 uint16_t htons(uint16_t val); 1089 1089 #endif /* htons */ 1090 1090 #ifndef ntohs … … 1104 1104 1105 1105 #if UIP_URGDATA > 0 1106 /* u 8_t *uip_urgdata:1106 /* uint8_t *uip_urgdata: 1107 1107 * 1108 1108 * This pointer points to any urgent data that has been received. Only … … 1136 1136 * 1137 1137 */ 1138 extern u 16_t uip_len;1138 extern uint16_t uip_len; 1139 1139 1140 1140 /** @} */ 1141 1141 1142 1142 #if UIP_URGDATA > 0 1143 extern u 16_t uip_urglen, uip_surglen;1143 extern uint16_t uip_urglen, uip_surglen; 1144 1144 #endif /* UIP_URGDATA > 0 */ 1145 1145 … … 1158 1158 uip_ipaddr_t ripaddr; /**< The IP address of the remote host. */ 1159 1159 1160 u 16_t lport; /**< The local TCP port, in network byte order. */1161 u 16_t rport; /**< The local remote TCP port, in network byte1160 uint16_t lport; /**< The local TCP port, in network byte order. */ 1161 uint16_t rport; /**< The local remote TCP port, in network byte 1162 1162 order. */ 1163 1163 1164 u 8_t rcv_nxt[4]; /**< The sequence number that we expect to1164 uint8_t rcv_nxt[4]; /**< The sequence number that we expect to 1165 1165 receive next. */ 1166 u 8_t snd_nxt[4]; /**< The sequence number that was last sent by1166 uint8_t snd_nxt[4]; /**< The sequence number that was last sent by 1167 1167 us. */ 1168 u 16_t len; /**< Length of the data that was previously sent. */1169 u 16_t mss; /**< Current maximum segment size for the1168 uint16_t len; /**< Length of the data that was previously sent. */ 1169 uint16_t mss; /**< Current maximum segment size for the 1170 1170 connection. */ 1171 u 16_t initialmss; /**< Initial maximum segment size for the1171 uint16_t initialmss; /**< Initial maximum segment size for the 1172 1172 connection. */ 1173 u 8_t sa; /**< Retransmission time-out calculation state1173 uint8_t sa; /**< Retransmission time-out calculation state 1174 1174 variable. */ 1175 u 8_t sv; /**< Retransmission time-out calculation state1175 uint8_t sv; /**< Retransmission time-out calculation state 1176 1176 variable. */ 1177 u 8_t rto; /**< Retransmission time-out. */1178 u 8_t tcpstateflags; /**< TCP state and flags. */1179 u 8_t timer; /**< The retransmission timer. */1180 u 8_t nrtx; /**< The number of retransmissions for the last1177 uint8_t rto; /**< Retransmission time-out. */ 1178 uint8_t tcpstateflags; /**< TCP state and flags. */ 1179 uint8_t timer; /**< The retransmission timer. */ 1180 uint8_t nrtx; /**< The number of retransmissions for the last 1181 1181 segment sent. */ 1182 1182 … … 1203 1203 * 4-byte array used for the 32-bit sequence number calculations. 1204 1204 */ 1205 extern u 8_t uip_acc32[4];1205 extern uint8_t uip_acc32[4]; 1206 1206 1207 1207 /** @} */ … … 1214 1214 struct uip_udp_conn { 1215 1215 uip_ipaddr_t ripaddr; /**< The IP address of the remote peer. */ 1216 u 16_t lport; /**< The local port number in network byte order. */1217 u 16_t rport; /**< The remote port number in network byte order. */1218 u 8_t ttl; /**< Default time-to-live. */1216 uint16_t lport; /**< The local port number in network byte order. */ 1217 uint16_t rport; /**< The remote port number in network byte order. */ 1218 uint8_t ttl; /**< Default time-to-live. */ 1219 1219 1220 1220 /** The application state. */ … … 1301 1301 */ 1302 1302 /*---------------------------------------------------------------------------*/ 1303 /* u 8_t uip_flags:1303 /* uint8_t uip_flags: 1304 1304 * 1305 1305 * When the application is called, uip_flags will contain the flags … … 1307 1307 * infomation. 1308 1308 */ 1309 extern u 8_t uip_flags;1309 extern uint8_t uip_flags; 1310 1310 1311 1311 /* The following flags may be set in the global variable uip_flags … … 1349 1349 * The actual uIP function which does all the work. 1350 1350 */ 1351 void uip_process(u 8_t flag);1351 void uip_process(uint8_t flag); 1352 1352 1353 1353 /* The following flags are passed as an argument to the uip_process() … … 1397 1397 #if UIP_CONF_IPV6 1398 1398 /* IPv6 header. */ 1399 u 8_t vtc,1399 uint8_t vtc, 1400 1400 tcflow; 1401 u 16_t flow;1402 u 8_t len[2];1403 u 8_t proto, ttl;1401 uint16_t flow; 1402 uint8_t len[2]; 1403 uint8_t proto, ttl; 1404 1404 uip_ip6addr_t srcipaddr, destipaddr; 1405 1405 #else /* UIP_CONF_IPV6 */ 1406 1406 /* IPv4 header. */ 1407 u 8_t vhl,1407 uint8_t vhl, 1408 1408 tos, 1409 1409 len[2], … … 1412 1412 ttl, 1413 1413 proto; 1414 u 16_t ipchksum;1415 u 16_t srcipaddr[2],1414 uint16_t ipchksum; 1415 uint16_t srcipaddr[2], 1416 1416 destipaddr[2]; 1417 1417 #endif /* UIP_CONF_IPV6 */ 1418 1418 1419 1419 /* TCP header. */ 1420 u 16_t srcport,1420 uint16_t srcport, 1421 1421 destport; 1422 u 8_t seqno[4],1422 uint8_t seqno[4], 1423 1423 ackno[4], 1424 1424 tcpoffset, 1425 1425 flags, 1426 1426 wnd[2]; 1427 u 16_t tcpchksum;1428 u 8_t urgp[2];1429 u 8_t optdata[4];1427 uint16_t tcpchksum; 1428 uint8_t urgp[2]; 1429 uint8_t optdata[4]; 1430 1430 }; 1431 1431 … … 1434 1434 #if UIP_CONF_IPV6 1435 1435 /* IPv6 header. */ 1436 u 8_t vtc,1436 uint8_t vtc, 1437 1437 tcf; 1438 u 16_t flow;1439 u 8_t len[2];1440 u 8_t proto, ttl;1438 uint16_t flow; 1439 uint8_t len[2]; 1440 uint8_t proto, ttl; 1441 1441 uip_ip6addr_t srcipaddr, destipaddr; 1442 1442 #else /* UIP_CONF_IPV6 */ 1443 1443 /* IPv4 header. */ 1444 u 8_t vhl,1444 uint8_t vhl, 1445 1445 tos, 1446 1446 len[2], … … 1449 1449 ttl, 1450 1450 proto; 1451 u 16_t ipchksum;1452 u 16_t srcipaddr[2],1451 uint16_t ipchksum; 1452 uint16_t srcipaddr[2], 1453 1453 destipaddr[2]; 1454 1454 #endif /* UIP_CONF_IPV6 */ 1455 1455 1456 1456 /* ICMP (echo) header. */ 1457 u 8_t type, icode;1458 u 16_t icmpchksum;1457 uint8_t type, icode; 1458 uint16_t icmpchksum; 1459 1459 #if !UIP_CONF_IPV6 1460 u 16_t id, seqno;1460 uint16_t id, seqno; 1461 1461 #else /* !UIP_CONF_IPV6 */ 1462 u 8_t flags, reserved1, reserved2, reserved3;1463 u 8_t icmp6data[16];1464 u 8_t options[1];1462 uint8_t flags, reserved1, reserved2, reserved3; 1463 uint8_t icmp6data[16]; 1464 uint8_t options[1]; 1465 1465 #endif /* !UIP_CONF_IPV6 */ 1466 1466 }; … … 1471 1471 #if UIP_CONF_IPV6 1472 1472 /* IPv6 header. */ 1473 u 8_t vtc,1473 uint8_t vtc, 1474 1474 tcf; 1475 u 16_t flow;1476 u 8_t len[2];1477 u 8_t proto, ttl;1475 uint16_t flow; 1476 uint8_t len[2]; 1477 uint8_t proto, ttl; 1478 1478 uip_ip6addr_t srcipaddr, destipaddr; 1479 1479 #else /* UIP_CONF_IPV6 */ 1480 1480 /* IP header. */ 1481 u 8_t vhl,1481 uint8_t vhl, 1482 1482 tos, 1483 1483 len[2], … … 1486 1486 ttl, 1487 1487 proto; 1488 u 16_t ipchksum;1489 u 16_t srcipaddr[2],1488 uint16_t ipchksum; 1489 uint16_t srcipaddr[2], 1490 1490 destipaddr[2]; 1491 1491 #endif /* UIP_CONF_IPV6 */ 1492 1492 1493 1493 /* UDP header. */ 1494 u 16_t srcport,1494 uint16_t srcport, 1495 1495 destport; 1496 u 16_t udplen;1497 u 16_t udpchksum;1496 uint16_t udplen; 1497 uint16_t udpchksum; 1498 1498 }; 1499 1499 … … 1555 1555 */ 1556 1556 struct uip_eth_addr { 1557 u 8_t addr[6];1557 uint8_t addr[6]; 1558 1558 }; 1559 1559 … … 1574 1574 * \return The Internet checksum of the buffer. 1575 1575 */ 1576 u 16_t uip_chksum(u16_t *buf, u16_t len);1576 uint16_t uip_chksum(uint16_t *buf, uint16_t len); 1577 1577 1578 1578 /** … … 1585 1585 * buffer. 1586 1586 */ 1587 u 16_t uip_ipchksum(void);1587 uint16_t uip_ipchksum(void); 1588 1588 1589 1589 /** … … 1596 1596 * to by uip_appdata. 1597 1597 */ 1598 u 16_t uip_tcpchksum(void);1598 uint16_t uip_tcpchksum(void); 1599 1599 1600 1600 /** … … 1607 1607 * to by uip_appdata. 1608 1608 */ 1609 u 16_t uip_udpchksum(void);1609 uint16_t uip_udpchksum(void); 1610 1610 1611 1611
Note:
See TracChangeset
for help on using the changeset viewer.