30 |
* |
* |
31 |
*/ |
*/ |
32 |
|
|
33 |
/*-----------------------------------------------------------------------------------*/ |
|
34 |
/* inet6.c |
/* inet6.c |
35 |
* |
* |
36 |
* Functions common to all TCP/IP modules, such as the Internet checksum and the |
* Functions common to all TCP/IP modules, such as the Internet checksum and the |
37 |
* byte order functions. |
* byte order functions. |
38 |
* |
* |
39 |
*/ |
*/ |
40 |
/*-----------------------------------------------------------------------------------*/ |
|
41 |
|
|
42 |
#include "lwip/opt.h" |
#include "lwip/opt.h" |
43 |
|
|
45 |
#include "lwip/inet.h" |
#include "lwip/inet.h" |
46 |
|
|
47 |
|
|
48 |
/*-----------------------------------------------------------------------------------*/ |
|
49 |
/* chksum: |
/* chksum: |
50 |
* |
* |
51 |
* Sums up all 16 bit words in a memory portion. Also includes any odd byte. |
* Sums up all 16 bit words in a memory portion. Also includes any odd byte. |
54 |
* For now, this is not optimized. Must be optimized for the particular processor |
* For now, this is not optimized. Must be optimized for the particular processor |
55 |
* arcitecture on which it is to run. Preferebly coded in assembler. |
* arcitecture on which it is to run. Preferebly coded in assembler. |
56 |
*/ |
*/ |
57 |
/*-----------------------------------------------------------------------------------*/ |
|
58 |
static u32_t |
static u32_t |
59 |
chksum(void *dataptr, u16_t len) |
chksum(void *dataptr, u16_t len) |
60 |
{ |
{ |
74 |
return acc; |
return acc; |
75 |
|
|
76 |
} |
} |
77 |
/*-----------------------------------------------------------------------------------*/ |
|
78 |
/* inet_chksum_pseudo: |
/* inet_chksum_pseudo: |
79 |
* |
* |
80 |
* Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. |
* Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. |
81 |
*/ |
*/ |
82 |
/*-----------------------------------------------------------------------------------*/ |
|
83 |
u16_t |
u16_t |
84 |
inet_chksum_pseudo(struct pbuf *p, |
inet_chksum_pseudo(struct pbuf *p, |
85 |
struct ip_addr *src, struct ip_addr *dest, |
struct ip_addr *src, struct ip_addr *dest, |
122 |
} |
} |
123 |
return ~(acc & 0xffff); |
return ~(acc & 0xffff); |
124 |
} |
} |
125 |
/*-----------------------------------------------------------------------------------*/ |
|
126 |
/* inet_chksum: |
/* inet_chksum: |
127 |
* |
* |
128 |
* Calculates the Internet checksum over a portion of memory. Used primarely for IP |
* Calculates the Internet checksum over a portion of memory. Used primarely for IP |
129 |
* and ICMP. |
* and ICMP. |
130 |
*/ |
*/ |
131 |
/*-----------------------------------------------------------------------------------*/ |
|
132 |
u16_t |
u16_t |
133 |
inet_chksum(void *dataptr, u16_t len) |
inet_chksum(void *dataptr, u16_t len) |
134 |
{ |
{ |
139 |
sum += (sum >> 16); |
sum += (sum >> 16); |
140 |
return ~(sum & 0xffff); |
return ~(sum & 0xffff); |
141 |
} |
} |
142 |
/*-----------------------------------------------------------------------------------*/ |
|
143 |
u16_t |
u16_t |
144 |
inet_chksum_pbuf(struct pbuf *p) |
inet_chksum_pbuf(struct pbuf *p) |
145 |
{ |
{ |
165 |
} |
} |
166 |
return ~(acc & 0xffff); |
return ~(acc & 0xffff); |
167 |
} |
} |
168 |
/*-----------------------------------------------------------------------------------*/ |
|