KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
checksum.h File Reference

This module provides checksum functions. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define ADLER32_INIT_VAL   1
 Value to which the Adler32 checksum should be initialized.
 
#define CRC32_INIT_VAL   0xFFFFFFFF
 Value to which the CRC32 checksum should be initialized.
 

Functions

uint32_t adler32 (uint32_t adler, const uint8_t *buf, int len)
 Update the adler32 checkum with the new data. More...
 
uint32_t crc32 (uint32_t crc, const uint8_t *ptr, int cnt, bool dbg)
 Lightweight CRC32 algorithm, using Ethernet polynomial. More...
 

Detailed Description

This module provides checksum functions.

Definition in file checksum.h.

Function Documentation

uint32_t adler32 ( uint32_t  adler,
const uint8_t *  buf,
int  len 
)

Update the adler32 checkum with the new data.

Adler32 is a very simple to implement checksum but still quite effective. Its much lighter than CRC32, since this required division. However CRC32 is capable of detecting more errors.

Parameters
adlerPrevious adler32 output, or ADLER32_INIT_VAL to start.
bufA pointer to the buffer data to add
lenThe length of the buffer
Returns
The updated adler32 checksum

Definition at line 23 of file checksum.c.

uint32_t crc32 ( uint32_t  crc,
const uint8_t *  ptr,
int  cnt,
bool  dbg 
)

Lightweight CRC32 algorithm, using Ethernet polynomial.

Same as used everywhere.

Parameters
adlerPrevious crc32 output, or CRC32_INIT_VAL to start.
bufA pointer to the buffer data to add
lenThe length of the buffer
Returns
The updated crc32 checksum

Definition at line 57 of file checksum.c.