Fixed IPv4 checksum (network byte order, dimwit)
authorJohn Hodge <[email protected]>
Sat, 20 Nov 2010 05:00:34 +0000 (13:00 +0800)
committerJohn Hodge <[email protected]>
Sat, 20 Nov 2010 05:00:34 +0000 (13:00 +0800)
Modules/IPStack/ipv4.c

index e37085b..31d6f02 100644 (file)
@@ -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 ;
 }

UCC git Repository :: git.ucc.asn.au