From: John Hodge Date: Sat, 20 Nov 2010 05:00:34 +0000 (+0800) Subject: Fixed IPv4 checksum (network byte order, dimwit) X-Git-Tag: rel0.07~58 X-Git-Url: https://git.ucc.asn.au/?p=tpg%2Facess2.git;a=commitdiff_plain;h=26e66aa0a682e2f1a5d9328b6037b5779310f8f3 Fixed IPv4 checksum (network byte order, dimwit) --- diff --git a/Modules/IPStack/ipv4.c b/Modules/IPStack/ipv4.c index e37085bf..31d6f027 100644 --- a/Modules/IPStack/ipv4.c +++ b/Modules/IPStack/ipv4.c @@ -284,9 +284,10 @@ Uint16 IPv4_Checksum(const void *Buf, int Size) Size = (Size + 1) >> 1; // 16-bit word count for(i = 0; i < Size; i++ ) { - if((int)sum + arr[i] > 0xFFFF) + Uint16 val = ntohs(arr[i]); + if((int)sum + val > 0xFFFF) sum ++; // Simulate 1's complement - sum += arr[i]; + sum += val; } return ~sum ; }