作业/作业5/nack-oriented-reliable-multicast-master/norm-1.5r6/protolib/include/protoPktIP.h
void UpdateChecksum(UINT8 oldByte, UINT8 newByte, bool oddOffset)
        {
            UINT16 oldVal = (UINT16)oldByte;
            UINT16 newVal = (UINT16)newByte;
            if (!oddOffset)
            {
                oldVal <<= 8;
                newVal <<= 8;
            }
            UINT16 oldSum = GetChecksum();
            UINT32 sum = oldSum + oldVal + (~newVal & 0xffff);
            UINT16 newSum = (UINT16)(sum + (sum >> 16));
            SetChecksum(newSum);
        }
/// updates IPv4 header checksum when a byte is changed.
updates IPv4 header checksum when a byte is changed.
updates IPv4 header checksum when a byte is changed .
void UpdateChecksum(UINT8 oldByte, UINT8 newByte, bool oddOffset)
        {
            UINT16 oldVal = (UINT16)oldByte;
            UINT16 newVal = (UINT16)newByte;
            if (!oddOffset)
            {
                oldVal <<= 8;
                newVal <<= 8;
            }
            UINT16 oldSum = GetChecksum();
            UINT32 sum = oldSum + oldVal + (~newVal & 0xffff);
            UINT16 newSum = (UINT16)(sum + (sum >> 16));
            SetChecksum(newSum);
        }
void UpdateChecksum ( UINT8 oldByte , UINT8 newByte , bool oddOffset ) { UINT16 oldVal = ( UINT16 ) oldByte ; UINT16 newVal = ( UINT16 ) newByte ; if ( ! oddOffset ) { oldVal <<= 8 ; newVal <<= 8 ; } UINT16 oldSum = GetChecksum ( ) ; UINT32 sum = oldSum + oldVal + ( ~ newVal & 0xffff ) ; UINT16 newSum = ( UINT16 ) ( sum + ( sum >> 16 ) ) ; SetChecksum ( newSum ) ; }
updates IPv4 header checksum when a byte is changed.
updates IPv4 header checksum when a byte is changed .