Changeset 158 for uKadecot/trunk/uip/net/ipv4
- Timestamp:
- Feb 20, 2016, 10:43:32 PM (8 years ago)
- Location:
- uKadecot/trunk/uip/net/ipv4
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uKadecot/trunk/uip/net/ipv4/uip-fw.c
r157 r158 54 54 */ 55 55 56 #include " uip.h"57 #include " uip_arch.h"58 #include " uip-fw.h"56 #include "net/ip/uip.h" 57 #include "net/ip/uip_arch.h" 58 #include "net/ipv4/uip-fw.h" 59 59 60 60 #include <string.h> /* for memcpy() */ … … 78 78 struct tcpip_hdr { 79 79 /* IP header. */ 80 u 8_t vhl,80 uint8_t vhl, 81 81 tos; 82 u 16_t len,82 uint16_t len, 83 83 ipid, 84 84 ipoffset; 85 u 8_t ttl,85 uint8_t ttl, 86 86 proto; 87 u 16_t ipchksum;88 u 16_t srcipaddr[2],87 uint16_t ipchksum; 88 uint16_t srcipaddr[2], 89 89 destipaddr[2]; 90 90 91 91 /* TCP header. */ 92 u 16_t srcport,92 uint16_t srcport, 93 93 destport; 94 u 8_t seqno[4],94 uint8_t seqno[4], 95 95 ackno[4], 96 96 tcpoffset, 97 97 flags, 98 98 wnd[2]; 99 u 16_t tcpchksum;100 u 8_t urgp[2];101 u 8_t optdata[4];99 uint16_t tcpchksum; 100 uint8_t urgp[2]; 101 uint8_t optdata[4]; 102 102 }; 103 103 104 104 struct icmpip_hdr { 105 105 /* IP header. */ 106 u 8_t vhl,106 uint8_t vhl, 107 107 tos, 108 108 len[2], … … 111 111 ttl, 112 112 proto; 113 u 16_t ipchksum;114 u 16_t srcipaddr[2],113 uint16_t ipchksum; 114 uint16_t srcipaddr[2], 115 115 destipaddr[2]; 116 116 /* ICMP (echo) header. */ 117 u 8_t type, icode;118 u 16_t icmpchksum;119 u 16_t id, seqno;120 u 8_t payload[1];117 uint8_t type, icode; 118 uint16_t icmpchksum; 119 uint16_t id, seqno; 120 uint8_t payload[1]; 121 121 }; 122 122 … … 142 142 */ 143 143 struct fwcache_entry { 144 u 16_t timer;145 146 u 16_t srcipaddr[2];147 u 16_t destipaddr[2];148 u 16_t ipid;149 u 8_t proto;150 u 8_t unused;144 uint16_t timer; 145 146 uint16_t srcipaddr[2]; 147 uint16_t destipaddr[2]; 148 uint16_t ipid; 149 uint8_t proto; 150 uint8_t unused; 151 151 152 152 #if notdef 153 u 16_t payload[2];153 uint16_t payload[2]; 154 154 #endif 155 155 156 156 #if UIP_REASSEMBLY > 0 157 u 16_t len, offset;157 uint16_t len, offset; 158 158 #endif 159 159 }; … … 217 217 /*------------------------------------------------------------------------------*/ 218 218 static unsigned char 219 ipaddr_maskcmp(u 16_t *ipaddr, u16_t *netipaddr, u16_t *netmask)219 ipaddr_maskcmp(uint16_t *ipaddr, uint16_t *netipaddr, uint16_t *netmask) 220 220 { 221 221 return (ipaddr[0] & netmask [0]) == (netipaddr[0] & netmask[0]) && … … 234 234 time_exceeded(void) 235 235 { 236 u 16_t tmp16;236 uint16_t tmp16; 237 237 238 238 /* We don't send out ICMP errors for ICMP messages. */ … … 250 250 /* Calculate the ICMP checksum. */ 251 251 ICMPBUF->icmpchksum = 0; 252 ICMPBUF->icmpchksum = ~uip_chksum((u 16_t *)&(ICMPBUF->type), 36);252 ICMPBUF->icmpchksum = ~uip_chksum((uint16_t *)&(ICMPBUF->type), 36); 253 253 254 254 /* Set the IP destination address to be the source address of the … … 367 367 */ 368 368 /*------------------------------------------------------------------------------*/ 369 u 8_t369 uint8_t 370 370 uip_fw_output(void) 371 371 { … … 415 415 */ 416 416 /*------------------------------------------------------------------------------*/ 417 u 8_t417 uint8_t 418 418 uip_fw_forward(void) 419 419 { -
uKadecot/trunk/uip/net/ipv4/uip-fw.h
r157 r158 47 47 #define __UIP_FW_H__ 48 48 49 #include " uip.h"49 #include "net/ip/uip.h" 50 50 51 51 /** … … 55 55 struct uip_fw_netif *next; /**< Pointer to the next interface when 56 56 linked in a list. */ 57 u 16_t ipaddr[2]; /**< The IP address of this interface. */58 u 16_t netmask[2]; /**< The netmask of the interface. */59 u 8_t (* output)(void);57 uint16_t ipaddr[2]; /**< The IP address of this interface. */ 58 uint16_t netmask[2]; /**< The netmask of the interface. */ 59 uint8_t (* output)(void); 60 60 /**< A pointer to the function that 61 61 sends a packet. */ … … 94 94 */ 95 95 #define uip_fw_setipaddr(netif, addr) \ 96 do { (netif)->ipaddr[0] = ((u 16_t *)(addr))[0]; \97 (netif)->ipaddr[1] = ((u 16_t *)(addr))[1]; } while(0)96 do { (netif)->ipaddr[0] = ((uint16_t *)(addr))[0]; \ 97 (netif)->ipaddr[1] = ((uint16_t *)(addr))[1]; } while(0) 98 98 /** 99 99 * Set the netmask of a network interface. … … 106 106 */ 107 107 #define uip_fw_setnetmask(netif, addr) \ 108 do { (netif)->netmask[0] = ((u 16_t *)(addr))[0]; \109 (netif)->netmask[1] = ((u 16_t *)(addr))[1]; } while(0)108 do { (netif)->netmask[0] = ((uint16_t *)(addr))[0]; \ 109 (netif)->netmask[1] = ((uint16_t *)(addr))[1]; } while(0) 110 110 111 111 void uip_fw_init(void); 112 u 8_t uip_fw_forward(void);113 u 8_t uip_fw_output(void);112 uint8_t uip_fw_forward(void); 113 uint8_t uip_fw_output(void); 114 114 void uip_fw_register(struct uip_fw_netif *netif); 115 115 void uip_fw_default(struct uip_fw_netif *netif); -
uKadecot/trunk/uip/net/ipv4/uip-neighbor.c
r157 r158 40 40 */ 41 41 42 #include " uip-neighbor.h"42 #include "net/ipv4/uip-neighbor.h" 43 43 44 44 #include <string.h> … … 55 55 uip_ipaddr_t ipaddr; 56 56 struct uip_neighbor_addr addr; 57 u 8_t time;57 uint8_t time; 58 58 }; 59 59 static struct neighbor_entry entries[ENTRIES]; … … 86 86 { 87 87 int i, oldest; 88 u 8_t oldest_time;88 uint8_t oldest_time; 89 89 90 90 printf("Adding neighbor with link address %02x:%02x:%02x:%02x:%02x:%02x\n", -
uKadecot/trunk/uip/net/ipv4/uip-neighbor.h
r157 r158 43 43 #define __UIP_NEIGHBOR_H__ 44 44 45 #include " uip.h"45 #include "net/ip/uip.h" 46 46 47 47 struct uip_neighbor_addr { -
uKadecot/trunk/uip/net/ipv4/uip.c
r157 r158 80 80 */ 81 81 82 #include " uip.h"83 #include " uipopt.h"84 #include " uip_arch.h"82 #include "net/ip/uip.h" 83 #include "net/ip/uipopt.h" 84 #include "net/ip/uip_arch.h" 85 85 86 86 #if UIP_CONF_IPV6 87 #include " uip-neighbor.h"87 #include "net/ipv4/uip-neighbor.h" 88 88 #endif /* UIP_CONF_IPV6 */ 89 89 … … 137 137 138 138 #ifndef UIP_CONF_EXTERNAL_BUFFER 139 u 8_t uip_buf[UIP_BUFSIZE + 2]; /* The packet buffer that contains139 uint8_t uip_buf[UIP_BUFSIZE + 2]; /* The packet buffer that contains 140 140 incoming packets. */ 141 141 #endif /* UIP_CONF_EXTERNAL_BUFFER */ … … 150 150 urgent data (out-of-band data), if 151 151 present. */ 152 u 16_t uip_urglen, uip_surglen;152 uint16_t uip_urglen, uip_surglen; 153 153 #endif /* UIP_URGDATA > 0 */ 154 154 155 u 16_t uip_len, uip_slen;155 uint16_t uip_len, uip_slen; 156 156 /* The uip_len is either 8 or 16 bits, 157 157 depending on the maximum packet 158 158 size. */ 159 159 160 u 8_t uip_flags; /* The uip_flags variable is used for160 uint8_t uip_flags; /* The uip_flags variable is used for 161 161 communication between the TCP/IP stack 162 162 and the application program. */ … … 167 167 /* The uip_conns array holds all TCP 168 168 connections. */ 169 u 16_t uip_listenports[UIP_LISTENPORTS];169 uint16_t uip_listenports[UIP_LISTENPORTS]; 170 170 /* The uip_listenports list all currently 171 171 listning ports. */ … … 175 175 #endif /* UIP_UDP */ 176 176 177 static u 16_t ipid; /* Ths ipid variable is an increasing177 static uint16_t ipid; /* Ths ipid variable is an increasing 178 178 number that is used for the IP ID 179 179 field. */ 180 180 181 void uip_setipid(u 16_t id) { ipid = id; }182 183 static u 8_t iss[4]; /* The iss variable is used for the TCP181 void uip_setipid(uint16_t id) { ipid = id; } 182 183 static uint8_t iss[4]; /* The iss variable is used for the TCP 184 184 initial sequence number. */ 185 185 186 186 #if UIP_ACTIVE_OPEN 187 static u 16_t lastport; /* Keeps track of the last port used for187 static uint16_t lastport; /* Keeps track of the last port used for 188 188 a new connection. */ 189 189 #endif /* UIP_ACTIVE_OPEN */ 190 190 191 191 /* Temporary variables. */ 192 u 8_t uip_acc32[4];193 static u 8_t c, opt;194 static u 16_t tmp16;192 uint8_t uip_acc32[4]; 193 static uint8_t c, opt; 194 static uint16_t tmp16; 195 195 196 196 /* Structures and definitions. */ … … 247 247 #if ! UIP_ARCH_ADD32 248 248 void 249 uip_add32(u 8_t *op32, u16_t op16)249 uip_add32(uint8_t *op32, uint16_t op16) 250 250 { 251 251 uip_acc32[3] = op32[3] + (op16 & 0xff); … … 277 277 #if ! UIP_ARCH_CHKSUM 278 278 /*---------------------------------------------------------------------------*/ 279 static u 16_t280 chksum(u 16_t sum, const u8_t *data, u16_t len)279 static uint16_t 280 chksum(uint16_t sum, const uint8_t *data, uint16_t len) 281 281 { 282 u 16_t t;283 const u 8_t *dataptr;284 const u 8_t *last_byte;282 uint16_t t; 283 const uint8_t *dataptr; 284 const uint8_t *last_byte; 285 285 286 286 dataptr = data; … … 308 308 } 309 309 /*---------------------------------------------------------------------------*/ 310 u 16_t311 uip_chksum(u 16_t *data, u16_t len)310 uint16_t 311 uip_chksum(uint16_t *data, uint16_t len) 312 312 { 313 return htons(chksum(0, (u 8_t *)data, len));313 return htons(chksum(0, (uint8_t *)data, len)); 314 314 } 315 315 /*---------------------------------------------------------------------------*/ 316 316 #ifndef UIP_ARCH_IPCHKSUM 317 u 16_t317 uint16_t 318 318 uip_ipchksum(void) 319 319 { 320 u 16_t sum;320 uint16_t sum; 321 321 322 322 sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN); … … 326 326 #endif 327 327 /*---------------------------------------------------------------------------*/ 328 static u 16_t329 upper_layer_chksum(u 8_t proto)328 static uint16_t 329 upper_layer_chksum(uint8_t proto) 330 330 { 331 u 16_t upper_layer_len;332 u 16_t sum;331 uint16_t upper_layer_len; 332 uint16_t sum; 333 333 334 334 #if UIP_CONF_IPV6 335 upper_layer_len = (((u 16_t)(BUF->len[0]) << 8) + BUF->len[1]);335 upper_layer_len = (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1]); 336 336 #else /* UIP_CONF_IPV6 */ 337 upper_layer_len = (((u 16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN;337 upper_layer_len = (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN; 338 338 #endif /* UIP_CONF_IPV6 */ 339 339 … … 343 343 sum = upper_layer_len + proto; 344 344 /* Sum IP source and destination addresses. */ 345 sum = chksum(sum, (u 8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t));345 sum = chksum(sum, (uint8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t)); 346 346 347 347 /* Sum TCP header and data. */ … … 353 353 /*---------------------------------------------------------------------------*/ 354 354 #if UIP_CONF_IPV6 355 u 16_t355 uint16_t 356 356 uip_icmp6chksum(void) 357 357 { … … 361 361 #endif /* UIP_CONF_IPV6 */ 362 362 /*---------------------------------------------------------------------------*/ 363 u 16_t363 uint16_t 364 364 uip_tcpchksum(void) 365 365 { … … 368 368 /*---------------------------------------------------------------------------*/ 369 369 #if UIP_UDP_CHECKSUMS 370 u 16_t370 uint16_t 371 371 uip_udpchksum(void) 372 372 { … … 375 375 #endif /* UIP_UDP_CHECKSUMS */ 376 376 #endif /* UIP_ARCH_CHKSUM */ 377 u 8_t377 uint8_t 378 378 uip_ismulticast(uip_ipaddr_t ipaddr) 379 379 { … … 381 381 return 0; 382 382 #else 383 static const u 16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 };384 static const u 16_t multicast_mask[2] = { 0x00f0, 0x0000 };383 static const uint16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 }; 384 static const uint16_t multicast_mask[2] = { 0x00f0, 0x0000 }; 385 385 return uip_ipaddr_maskcmp(ipaddr, multicast_ipaddr, multicast_mask); 386 386 #endif … … 416 416 #if UIP_ACTIVE_OPEN 417 417 struct uip_conn * 418 uip_connect(uip_ipaddr_t *ripaddr, u 16_t rport)418 uip_connect(uip_ipaddr_t *ripaddr, uint16_t rport) 419 419 { 420 420 register struct uip_conn *conn, *cconn; … … 482 482 #if UIP_UDP 483 483 struct uip_udp_conn * 484 uip_udp_new(uip_ipaddr_t *ripaddr, u 16_t rport)484 uip_udp_new(uip_ipaddr_t *ripaddr, uint16_t rport) 485 485 { 486 486 register struct uip_udp_conn *conn; … … 527 527 /*---------------------------------------------------------------------------*/ 528 528 void 529 uip_unlisten(u 16_t port)529 uip_unlisten(uint16_t port) 530 530 { 531 531 for(c = 0; c < UIP_LISTENPORTS; ++c) { … … 538 538 /*---------------------------------------------------------------------------*/ 539 539 void 540 uip_listen(u 16_t port)540 uip_listen(uint16_t port) 541 541 { 542 542 for(c = 0; c < UIP_LISTENPORTS; ++c) { … … 552 552 #if UIP_REASSEMBLY && !UIP_CONF_IPV6 553 553 #define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN) 554 static u 8_t uip_reassbuf[UIP_REASS_BUFSIZE];555 static u 8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];556 static const u 8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f,554 static uint8_t uip_reassbuf[UIP_REASS_BUFSIZE]; 555 static uint8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)]; 556 static const uint8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f, 557 557 0x0f, 0x07, 0x03, 0x01}; 558 static u 16_t uip_reasslen;559 static u 8_t uip_reassflags;558 static uint16_t uip_reasslen; 559 static uint8_t uip_reassflags; 560 560 #define UIP_REASS_FLAG_LASTFRAG 0x01 561 static u 8_t uip_reasstmr;561 static uint8_t uip_reasstmr; 562 562 563 563 #define IP_MF 0x20 564 564 565 static u 8_t565 static uint8_t 566 566 uip_reass(void) 567 567 { 568 u 16_t offset, len;569 u 16_t i;568 uint16_t offset, len; 569 uint16_t i; 570 570 571 571 /* If ip_reasstmr is zero, no packet is present in the buffer, so we … … 653 653 right amount of bits. */ 654 654 if(uip_reassbitmap[uip_reasslen / (8 * 8)] != 655 (u 8_t)~bitmap_bits[uip_reasslen / 8 & 7]) {655 (uint8_t)~bitmap_bits[uip_reasslen / 8 & 7]) { 656 656 goto nullreturn; 657 657 } … … 681 681 /*---------------------------------------------------------------------------*/ 682 682 static void 683 uip_add_rcv_nxt(u 16_t n)683 uip_add_rcv_nxt(uint16_t n) 684 684 { 685 685 uip_add32(uip_conn->rcv_nxt, n); … … 691 691 /*---------------------------------------------------------------------------*/ 692 692 void 693 uip_process(u 8_t flag)693 uip_process(uint8_t flag) 694 694 { 695 695 register struct uip_conn *uip_connr = uip_conn; … … 1349 1349 uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) { 1350 1350 /* An MSS option with the right option length. */ 1351 tmp16 = ((u 16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |1352 (u 16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];1351 tmp16 = ((uint16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) | 1352 (uint16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c]; 1353 1353 uip_connr->initialmss = uip_connr->mss = 1354 1354 tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16; … … 1631 1631 "persistent timer" and uses the retransmission mechanim. 1632 1632 */ 1633 tmp16 = ((u 16_t)BUF->wnd[0] << 8) + (u16_t)BUF->wnd[1];1633 tmp16 = ((uint16_t)BUF->wnd[0] << 8) + (uint16_t)BUF->wnd[1]; 1634 1634 if(tmp16 > uip_connr->initialmss || 1635 1635 tmp16 == 0) { … … 1891 1891 } 1892 1892 /*---------------------------------------------------------------------------*/ 1893 u 16_t1894 htons(u 16_t val)1893 uint16_t 1894 htons(uint16_t val) 1895 1895 { 1896 1896 return HTONS(val); -
uKadecot/trunk/uip/net/ipv4/uip_arp.c
r157 r158 60 60 61 61 62 #include " uip_arp.h"62 #include "net/ipv4/uip_arp.h" 63 63 64 64 #include <string.h> … … 72 72 struct arp_hdr { 73 73 struct uip_eth_hdr ethhdr; 74 u 16_t hwtype;75 u 16_t protocol;76 u 8_t hwlen;77 u 8_t protolen;78 u 16_t opcode;74 uint16_t hwtype; 75 uint16_t protocol; 76 uint8_t hwlen; 77 uint8_t protolen; 78 uint16_t opcode; 79 79 struct uip_eth_addr shwaddr; 80 u 16_t sipaddr[2];80 uint16_t sipaddr[2]; 81 81 struct uip_eth_addr dhwaddr; 82 u 16_t dipaddr[2];82 uint16_t dipaddr[2]; 83 83 }; 84 84 … … 86 86 struct uip_eth_hdr ethhdr; 87 87 /* IP header. */ 88 u 8_t vhl,88 uint8_t vhl, 89 89 tos, 90 90 len[2], … … 93 93 ttl, 94 94 proto; 95 u 16_t ipchksum;96 u 16_t srcipaddr[2],95 uint16_t ipchksum; 96 uint16_t srcipaddr[2], 97 97 destipaddr[2]; 98 98 }; … … 110 110 111 111 struct arp_entry { 112 u 16_t ipaddr[2];112 uint16_t ipaddr[2]; 113 113 struct uip_eth_addr ethaddr; 114 u 8_t time;114 uint8_t time; 115 115 }; 116 116 117 117 static const struct uip_eth_addr broadcast_ethaddr = 118 118 {{0xff,0xff,0xff,0xff,0xff,0xff}}; 119 static const u 16_t broadcast_ipaddr[2] = {0xffff,0xffff};120 static const u 16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 };121 static const u 16_t multicast_mask[2] = { 0x00f0, 0x0000 };119 static const uint16_t broadcast_ipaddr[2] = {0xffff,0xffff}; 120 static const uint16_t multicast_ipaddr[2] = { 0x00e0, 0x0000 }; 121 static const uint16_t multicast_mask[2] = { 0x00f0, 0x0000 }; 122 122 123 123 static struct arp_entry arp_table[UIP_ARPTAB_SIZE]; 124 static u 16_t ipaddr[2];125 static u 8_t i, c;126 127 static u 8_t arptime;128 static u 8_t tmpage;124 static uint16_t ipaddr[2]; 125 static uint8_t i, c; 126 127 static uint8_t arptime; 128 static uint8_t tmpage; 129 129 130 130 #define BUF ((struct arp_hdr *)&uip_buf[0]) … … 170 170 /*-----------------------------------------------------------------------------------*/ 171 171 static void 172 uip_arp_update(u 16_t *ipaddr, struct uip_eth_addr *ethaddr)172 uip_arp_update(uint16_t *ipaddr, struct uip_eth_addr *ethaddr) 173 173 { 174 174 register struct arp_entry *tabptr = NULL; -
uKadecot/trunk/uip/net/ipv4/uip_arp.h
r157 r158 53 53 #define __UIP_ARP_H__ 54 54 55 #include " uip.h"55 #include "net/ip/uip.h" 56 56 57 57 #ifdef __RX … … 69 69 struct uip_eth_addr dest; 70 70 struct uip_eth_addr src; 71 u 16_t type;71 uint16_t type; 72 72 }; 73 73
Note:
See TracChangeset
for help on using the changeset viewer.