Internet Checksum

Provides a function to calculate the Internet Checksum.

uint16_t inet_csum_slice(uint16_t sum, const uint8_t * buf, uint16_t len, msp430_types.h::size_t accum_len)

Calculates the unnormalized Internet Checksum of buf, where the buffer provides a slice of the full checksum domain, calculated in order.

See also

RFC 1071

The Internet Checksum is not normalized (i. e. its 1’s complement was not taken of the result) to use it for further calculation. This function handles padding an odd number of bytes across the full domain.

Parameters

sum:An initial value for the checksum.
buf:A buffer.
len:Length of buf in byte.
accum_len:Accumulated length of checksum domain that has already been checksummed.

Return values

  • The unnormalized Internet Checksum of buf.
uint16_t inet_csum(uint16_t sum, const uint8_t * buf, uint16_t len)

Calculates the unnormalized Internet Checksum of buf, where the buffer provides a standalone domain for the checksum.

See also

RFC 1071

The Internet Checksum is not normalized (i. e. its 1’s complement was not taken of the result) to use it for further calculation. This function, rather than inet_csum.h::inet_csum_slice(), has been used historically when we are not concerned with padding for an odd number of bytes.

Parameters

sum:An initial value for the checksum.
buf:A buffer.
len:Length of buf in byte.

Return values

  • The unnormalized Internet Checksum of buf.