libosmocore  1.10.0
Osmocom core library
Osmocom CRC routines

Files

file  crc16.h
 This was copied from the linux kernel and adjusted for our types.
 
file  crcgen.h
 Osmocom generic CRC routines global header.
 
file  crc16.c
 This was copied from the linux kernel and adjusted for our types.
 

Functions

uint16_t osmo_crc16 (uint16_t crc, uint8_t const *buffer, size_t len)
 Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer. More...
 
static uint16_t osmo_crc16_byte (uint16_t crc, const uint8_t data)
 CRC-16 polynome 0x8005 (x^16 + x^15 + x^2 + 1) More...
 
uint16_t osmo_crc16_ccitt (uint16_t crc, uint8_t const *buffer, size_t len)
 Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer. More...
 
static uint16_t osmo_crc16_ccitt_byte (uint16_t crc, const uint8_t data)
 CCITT polynome 0x8408 (x^0 + x^5 + x^12) More...
 

Variables

uint16_t const osmo_crc16_table [256]
 CRC table for the CRC-16. More...
 
uint16_t const osmo_crc16_ccitt_table [256]
 CRC table for the CCITT CRC-6. More...
 
uint16_t const osmo_crc16_table [256]
 CRC table for the CRC-16. More...
 
uint16_t const osmo_crc16_ccitt_table [256]
 CRC table for the CCITT CRC-6. More...
 

Detailed Description

Function Documentation

◆ osmo_crc16()

uint16_t osmo_crc16 ( uint16_t  crc,
uint8_t const *  buffer,
size_t  len 
)

Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer.

Parameters
crc[in]previous CRC value
buffer[in]data pointer
len[in]number of bytes in input buffer
Returns
updated CRC value

References len(), and osmo_crc16_byte().

◆ osmo_crc16_byte()

static uint16_t osmo_crc16_byte ( uint16_t  crc,
const uint8_t  data 
)
inlinestatic

CRC-16 polynome 0x8005 (x^16 + x^15 + x^2 + 1)

References data, and osmo_crc16_table.

Referenced by osmo_crc16().

◆ osmo_crc16_ccitt()

uint16_t osmo_crc16_ccitt ( uint16_t  crc,
uint8_t const *  buffer,
size_t  len 
)

Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer.

Parameters
[in]crcinitial value of CRC
[in]bufferpointer to buffer of input data
[in]lenlength of buffer in bytes
Returns
16bit CRC

References len(), and osmo_crc16_ccitt_byte().

◆ osmo_crc16_ccitt_byte()

static uint16_t osmo_crc16_ccitt_byte ( uint16_t  crc,
const uint8_t  data 
)
inlinestatic

CCITT polynome 0x8408 (x^0 + x^5 + x^12)

References data, and osmo_crc16_ccitt_table.

Referenced by osmo_crc16_ccitt().

Variable Documentation

◆ osmo_crc16_ccitt_table [1/2]

uint16_t const osmo_crc16_ccitt_table[256]
extern

CRC table for the CCITT CRC-6.

The poly is 0x8408 (x^0 + x^5 + x^12)

Referenced by osmo_crc16_ccitt_byte().

◆ osmo_crc16_ccitt_table [2/2]

uint16_t const osmo_crc16_ccitt_table[256]

CRC table for the CCITT CRC-6.

The poly is 0x8408 (x^0 + x^5 + x^12)

Referenced by osmo_crc16_ccitt_byte().

◆ osmo_crc16_table [1/2]

uint16_t const osmo_crc16_table[256]
extern

CRC table for the CRC-16.

The poly is 0x8005 (x^16 + x^15 + x^2 + 1)

Referenced by osmo_crc16_byte().

◆ osmo_crc16_table [2/2]

uint16_t const osmo_crc16_table[256]

CRC table for the CRC-16.

The poly is 0x8005 (x^16 + x^15 + x^2 + 1)

Referenced by osmo_crc16_byte().