Provides a function to calculate the Internet Checksum. More...
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... | |
|
inlinestatic |
Calculates the unnormalized Internet Checksum of buf
, where the buffer provides a standalone domain for the checksum.
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.
[in] | sum | An initial value for the checksum. |
[in] | buf | A buffer. |
[in] | len | Length of buf in byte. |
buf
. Definition at line 72 of file inet_csum.h.
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.
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.
[in] | sum | An initial value for the checksum. |
[in] | buf | A buffer. |
[in] | len | Length of buf in byte. |
[in] | accum_len | Accumulated length of checksum domain that has already been checksummed. |
buf
.