The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
checksum.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file checksum.h
5 * @brief the Internet checksum (RFC 1071): the ones' complement of the
6 * ones' complement sum of the 16-bit words.
7 *
8 * the words are added in memory order, so the result can be stored as it
9 * is, in either byte order.
10 */
11
12#include "common/stdint.h"
13
14/**
15 * add bytes to a partial sum. an odd length pads with a zero byte, so
16 * only the last piece of a checksum may have an odd length.
17 */
18uint32_t checksum_add(uint32_t sum, const void *data, uint32_t length);
19
20/**
21 * fold a partial sum and complement it: the checksum to store.
22 */
24
25/**
26 * the checksum of one buffer.
27 */
28uint16_t checksum(const void *data, uint32_t length);
uint32_t checksum_add(uint32_t sum, const void *data, uint32_t length)
add bytes to a partial sum.
Definition checksum.c:8
uint16_t checksum_finish(uint32_t sum)
fold a partial sum and complement it: the checksum to store.
Definition checksum.c:28
uint16_t checksum(const void *data, uint32_t length)
the checksum of one buffer.
Definition checksum.c:37
unsigned int uint32_t
Definition fb.h:17
unsigned short uint16_t
Definition stdint.h:13