git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
IPStack - Fixed TCP checksuming
[tpg/acess2.git]
/
Modules
/
IPStack
/
ipv4.c
diff --git
a/Modules/IPStack/ipv4.c
b/Modules/IPStack/ipv4.c
index
b77581e
..
6c387cc
100644
(file)
--- a/
Modules/IPStack/ipv4.c
+++ b/
Modules/IPStack/ipv4.c
@@
-317,12
+317,15
@@
Uint16 IPv4_Checksum(const void *Buf, int Size)
const Uint16 *arr = Buf;
int i;
const Uint16 *arr = Buf;
int i;
- Size = (Size + 1) >> 1; // 16-bit word count
- for(i = 0; i < Size; i++ )
+ // Sum all whole words
+ for(i = 0; i < Size
/2
; i++ )
{
Uint16 val = ntohs(arr[i]);
sum += val;
}
{
Uint16 val = ntohs(arr[i]);
sum += val;
}
+ // Add the tail word
+// if( i*2 != Size )
+// sum += arr[i]&0xFF;
// Apply one's complement
while (sum >> 16)
// Apply one's complement
while (sum >> 16)
UCC
git Repository :: git.ucc.asn.au