Internet Checksum

Provides a function to calculate the Internet Checksum. More...

Detailed Description

Provides a function to calculate the Internet Checksum.

Files

file  inet_csum.h
 Internet Checksum definitions.
 

Functions

uint16_t inet_csum_slice (uint16_t sum, const uint8_t *buf, uint16_t len, 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. More...
 
static 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. More...
 

Function Documentation

◆ inet_csum()

static uint16_t inet_csum ( uint16_t  sum,
const uint8_t *  buf,
uint16_t  len 
)
inlinestatic

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_slice(), has been used historically when we are not concerned with padding for an odd number of bytes.

Parameters
[in]sumAn initial value for the checksum.
[in]bufA buffer.
[in]lenLength of buf in byte.
Returns
The unnormalized Internet Checksum of buf.

Definition at line 72 of file inet_csum.h.

◆ inet_csum_slice()

uint16_t inet_csum_slice ( uint16_t  sum,
const uint8_t *  buf,
uint16_t  len,
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
[in]sumAn initial value for the checksum.
[in]bufA buffer.
[in]lenLength of buf in byte.
[in]accum_lenAccumulated length of checksum domain that has already been checksummed.
Returns
The unnormalized Internet Checksum of buf.