spandsp 0.0.6
crc.h File Reference

Go to the source code of this file.

Functions

uint32_t crc_itu32_calc (const uint8_t *buf, int len, uint32_t crc)
 Calculate the ITU/CCITT CRC-32 value in buffer.
int crc_itu32_append (uint8_t *buf, int len)
 Append an ITU/CCITT CRC-32 value to a frame.
int crc_itu32_check (const uint8_t *buf, int len)
 Check the ITU/CCITT CRC-32 value in a frame.
uint16_t crc_itu16_calc (const uint8_t *buf, int len, uint16_t crc)
 Calculate the ITU/CCITT CRC-16 value in buffer by whole bytes.
uint16_t crc_itu16_bits (uint8_t buf, int len, uint16_t crc)
 Calculate the ITU/CCITT CRC-16 value of some bits from a byte.
int crc_itu16_append (uint8_t *buf, int len)
 Append an ITU/CCITT CRC-16 value to a frame.
int crc_itu16_check (const uint8_t *buf, int len)
 Check the ITU/CCITT CRC-16 value in a frame.

Function Documentation

◆ crc_itu16_append()

int crc_itu16_append ( uint8_t * buf,
int len )

Append an ITU/CCITT CRC-16 value to a frame.

Parameters
bufThe buffer containing the frame. This must be at least 2 bytes longer than the frame it contains, to allow room for the CRC value.
lenThe length of the frame.
Returns
The new length of the frame.

◆ crc_itu16_bits()

uint16_t crc_itu16_bits ( uint8_t buf,
int len,
uint16_t crc )

Calculate the ITU/CCITT CRC-16 value of some bits from a byte.

Parameters
bufThe buffer containing the byte of data.
lenThe number of bits, starting from the LSB.
crcThe initial CRC value. This is usually 0xFFFF, or 0 for a new block (it depends on the application). It is previous returned CRC value for the continuation of a block.
Returns
The CRC value.

◆ crc_itu16_calc()

uint16_t crc_itu16_calc ( const uint8_t * buf,
int len,
uint16_t crc )

Calculate the ITU/CCITT CRC-16 value in buffer by whole bytes.

Parameters
bufThe buffer containing the data.
lenThe length of the frame.
crcThe initial CRC value. This is usually 0xFFFF, or 0 for a new block (it depends on the application). It is previous returned CRC value for the continuation of a block.
Returns
The CRC value.

Referenced by adsi_tx_put_message(), and hdlc_tx_frame().

◆ crc_itu16_check()

int crc_itu16_check ( const uint8_t * buf,
int len )

Check the ITU/CCITT CRC-16 value in a frame.

Parameters
bufThe buffer containing the frame.
lenThe length of the frame.
Returns
TRUE if the CRC is OK, else FALSE.

◆ crc_itu32_append()

int crc_itu32_append ( uint8_t * buf,
int len )

Append an ITU/CCITT CRC-32 value to a frame.

Parameters
bufThe buffer containing the frame. This must be at least 2 bytes longer than the frame it contains, to allow room for the CRC value.
lenThe length of the frame.
Returns
The new length of the frame.

◆ crc_itu32_calc()

uint32_t crc_itu32_calc ( const uint8_t * buf,
int len,
uint32_t crc )

Calculate the ITU/CCITT CRC-32 value in buffer.

Parameters
bufThe buffer containing the data.
lenThe length of the frame.
crcThe initial CRC value. This is usually 0xFFFFFFFF, or 0 for a new block (it depends on the application). It is previous returned CRC value for the continuation of a block.
Returns
The CRC value.

Referenced by hdlc_tx_frame().

◆ crc_itu32_check()

int crc_itu32_check ( const uint8_t * buf,
int len )

Check the ITU/CCITT CRC-32 value in a frame.

Parameters
bufThe buffer containing the frame.
lenThe length of the frame.
Returns
TRUE if the CRC is OK, else FALSE.