2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: tcpip/checksum.c
5 * PURPOSE: Checksum routines
6 * NOTES: The checksum routine is from RFC 1071
7 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 * CSH 01/08-2000 Created
18 /* Fold 32-bit sum to 16 bits */
21 Sum
= (Sum
& 0xFFFF) + (Sum
>> 16);
27 ULONG
ChecksumCompute(
32 * FUNCTION: Calculate checksum of a buffer
34 * Data = Pointer to buffer with data
35 * Count = Number of bytes in buffer
36 * Seed = Previously calculated checksum (if any)
41 register ULONG Sum
= Seed
;
45 Sum
+= *(PUSHORT
)Data
;
47 Data
= (PVOID
)((ULONG_PTR
) Data
+ 2);
50 /* Add left-over byte, if any */