datapath-windows/ovsext/Checksum.c
/*
 *----------------------------------------------------------------------------
 * CalculateChecksum --
 *
 *   Given the start point, and length, calculate the checksum
 *   as 1's complement of 1's comlement.
 *
 *   This assume the checksum field is initailized properly.
 *
 * Input Parameter:
 *    ptr:  point to the data to be checksumed
 *    totalLength: total length of the data
 *    initial: inital value to remit the checksum. Please note this
 *             value should be network byte order value.
 *
 *    The last parameter may be useful where you don't want to set
 *    checksum field to zero, in that case you can pass ~checksum,
 *    this is equivalent of set checksum field to zero.
 *
 * Result:
 *    The result can be assigned to checksum field directly.
 *----------------------------------------------------------------------------
 */
CalculateChecksum
Given the start point, and length, calculate the checksum
as 1's complement of 1's comlement.

This assume the checksum field is initailized properly.

Input Parameter:
ptr:  point to the data to be checksumed
totalLength: total length of the data
initial: inital value to remit the checksum. Please note this
value should be network byte order value.

The last parameter may be useful where you don't want to set
checksum field to zero, in that case you can pass ~checksum,
this is equivalent of set checksum field to zero.

The result can be assigned to checksum field directly.
CalculateChecksum Given the start point and length calculate the checksum as 1 ' s complement of 1 ' s comlement . This assume the checksum field is initailized properly . Input Parameter : ptr : point to the data to be checksumed totalLength : total length of the data initial : inital value to remit the checksum . Please note this value should be network byte order value . The last parameter may be useful where you don ' t want to set checksum field to zero in that case you can pass ~checksum this is equivalent of set checksum field to zero . The result can be assigned to checksum field directly .
UINT16
CalculateChecksum(UINT8 *ptr,
                  UINT16 totalLength,
                  UINT16 initial)
{
    UINT64  sum = CalculateOnesComplement(ptr, totalLength, initial, TRUE);
    fold64(sum);
    return (UINT16)~sum;
}
UINT16 CalculateChecksum ( UINT8 * ptr , UINT16 totalLength , UINT16 initial ) { UINT64 sum = CalculateOnesComplement ( ptr , totalLength , initial , TRUE ) ; fold64 ( sum ) ; return ( UINT16 ) ~ sum ; }
CalculateChecksum
   Given the start point, and length, calculate the checksum
   as 1's complement of 1's comlement.
CalculateChecksum Given the start point and length calculate the checksum as 1 ' s complement of 1 ' s comlement .