The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
checksum.h File Reference

the Internet checksum (RFC 1071): the ones' complement of the ones' complement sum of the 16-bit words. More...

#include "common/stdint.h"

Go to the source code of this file.

Functions

uint32_t checksum_add (uint32_t sum, const void *data, uint32_t length)
 add bytes to a partial sum.
uint16_t checksum_finish (uint32_t sum)
 fold a partial sum and complement it: the checksum to store.
uint16_t checksum (const void *data, uint32_t length)
 the checksum of one buffer.

Detailed Description

the Internet checksum (RFC 1071): the ones' complement of the ones' complement sum of the 16-bit words.

the words are added in memory order, so the result can be stored as it is, in either byte order.

Function Documentation

◆ checksum_add()

uint32_t checksum_add ( uint32_t sum,
const void * data,
uint32_t length )

add bytes to a partial sum.

an odd length pads with a zero byte, so only the last piece of a checksum may have an odd length.

◆ checksum_finish()

uint16_t checksum_finish ( uint32_t sum)

fold a partial sum and complement it: the checksum to store.

◆ checksum()

uint16_t checksum ( const void * data,
uint32_t length )

the checksum of one buffer.