datapath-windows/ovsext/Checksum.c
/*
 *----------------------------------------------------------------------------
 * IPChecksum --
 *
 *   Give IP header, calculate the IP checksum.
 *   We assume IP checksum field is initialized properly
 *
 *  Input Pramater:
 *   ipHdr: IP header start point
 *   length: IP header length (potentially include IP options)
 *   initial: same as CalculateChecksum
 *
 *  Result:
 *   The result is already 1's complement, so can be assigned
 *   to checksum field directly
 *----------------------------------------------------------------------------
 */
IPChecksum
Give IP header, calculate the IP checksum.
We assume IP checksum field is initialized properly

Input Pramater:
ipHdr: IP header start point
length: IP header length (potentially include IP options)
initial: same as CalculateChecksum

The result is already 1's complement, so can be assigned
to checksum field directly
IPChecksum Give IP header calculate the IP checksum . We assume IP checksum field is initialized properly Input Pramater : ipHdr : IP header start point length : IP header length ( potentially include IP options ) initial : same as CalculateChecksum The result is already 1 ' s complement so can be assigned to checksum field directly
UINT16
IPChecksum(UINT8 *ipHdr,
           UINT16 length,
           UINT16 initial)
{
    UINT32 sum = initial;
    UINT16 *ptr = (UINT16 *)ipHdr;
    ASSERT((length & 0x3) == 0);
    while (length > 1) {
        sum += ptr[0];
        ptr++;
        length -= 2;
    }
    fold32(sum);
    return (UINT16)~sum;
}
UINT16 IPChecksum ( UINT8 * ipHdr , UINT16 length , UINT16 initial ) { UINT32 sum = initial ; UINT16 * ptr = ( UINT16 * ) ipHdr ; ASSERT ( ( length & 0x3 ) == 0 ) ; while ( length > 1 ) { sum += ptr [ 0 ] ; ptr ++ ; length -= 2 ; } fold32 ( sum ) ; return ( UINT16 ) ~ sum ; }
IPChecksum
   Give IP header, calculate the IP checksum.
IPChecksum Give IP header calculate the IP checksum .