ROHC compression/decompression library
Macros | Enumerations | Functions | Variables
crc.h File Reference

ROHC CRC routines. More...

#include "crcany.h"
#include "ip.h"
#include "protocols/uncomp_pkt_hdrs.h"
#include <rohc/rohc.h>
#include <stdbool.h>
Include dependency graph for crc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CRC_INIT_3   0x7
 The CRC-3 initial value. More...
 
#define CRC_INIT_7   0x7f
 The CRC-7 initial value. More...
 
#define CRC_INIT_8   0xff
 The CRC-8 initial value. More...
 
#define CRC_INIT_FCS32   0xffffffff
 
#define CRC_FCS32_LEN   4U
 

Enumerations

enum  rohc_crc_type_t { ROHC_CRC_TYPE_NONE = 0, ROHC_CRC_TYPE_3 = 3, ROHC_CRC_TYPE_7 = 7, ROHC_CRC_TYPE_8 = 8 }
 

Functions

uint32_t crc_calc_fcs32 (const uint8_t *const data, const size_t length, const uint32_t init_val)
 Optimized CRC FCS-32 calculation using a table. More...
 
uint8_t ip_compute_crc_static (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-STATIC part of an IP header. More...
 
uint8_t ip_compute_crc_dynamic (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-DYNAMIC part of an IP header. More...
 
static uint8_t udp_compute_crc_static (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-STATIC part of an UDP header. More...
 
static uint8_t udp_compute_crc_dynamic (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-DYNAMIC part of an UDP header. More...
 
static uint8_t esp_compute_crc_static (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-STATIC part of an ESP header. More...
 
static uint8_t esp_compute_crc_dynamic (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-DYNAMIC part of an ESP header. More...
 
static uint8_t rtp_compute_crc_static (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-STATIC part of a RTP header. More...
 
static uint8_t rtp_compute_crc_dynamic (const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-DYNAMIC part of a RTP header. More...
 
uint8_t compute_crc_ctrl_fields (const rohc_profile_t profile_id, const uint8_t reorder_ratio, const uint16_t msn, const uint8_t ip_id_behaviors[], const size_t ip_id_behaviors_nr)
 Compute the CRC-3 over control fields for ROHCv2 profiles. More...
 
static uint8_t crc_calculate (const rohc_crc_type_t crc_type, const uint8_t *const data, const size_t length, const uint8_t init_val)
 Calculate the checksum for the given data. More...
 
static uint8_t crc_calc_8 (const uint8_t *const buf, const size_t size, const uint8_t init_val)
 Optimized CRC-8 calculation using a table. More...
 
static uint8_t crc_calc_7 (const uint8_t *const buf, const size_t size, const uint8_t init_val)
 Optimized CRC-7 calculation using a table. More...
 
static uint8_t crc_calc_3 (const uint8_t *const buf, const size_t size, const uint8_t init_val)
 Optimized CRC-3 calculation using a table. More...
 

Variables

static const uint8_t crc_table_7 [256]
 
static const uint8_t crc_table_8 [256]
 

Detailed Description

ROHC CRC routines.

Author
Didier Barvaux didie.nosp@m.r.ba.nosp@m.rvaux.nosp@m.@tou.nosp@m.louse.nosp@m..viv.nosp@m.eris..nosp@m.com
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org
FWX rohc_.nosp@m.team.nosp@m.@dial.nosp@m.ine..nosp@m.fr

Macro Definition Documentation

◆ CRC_FCS32_LEN

#define CRC_FCS32_LEN   4U

The length (in bytes) of the FCS-32 CRC

◆ CRC_INIT_3

#define CRC_INIT_3   0x7

The CRC-3 initial value.

◆ CRC_INIT_7

#define CRC_INIT_7   0x7f

The CRC-7 initial value.

◆ CRC_INIT_8

#define CRC_INIT_8   0xff

The CRC-8 initial value.

◆ CRC_INIT_FCS32

#define CRC_INIT_FCS32   0xffffffff

The FCS-32 initial value

Enumeration Type Documentation

◆ rohc_crc_type_t

The different types of CRC used to protect ROHC headers

Enumerator
ROHC_CRC_TYPE_NONE 

No CRC selected

ROHC_CRC_TYPE_3 

The CRC-3 type

ROHC_CRC_TYPE_7 

The CRC-7 type

ROHC_CRC_TYPE_8 

The CRC-8 type

Function Documentation

◆ compute_crc_ctrl_fields()

uint8_t compute_crc_ctrl_fields ( const rohc_profile_t  profile_id,
const uint8_t  reorder_ratio,
const uint16_t  msn,
const uint8_t  ip_id_behaviors[],
const size_t  ip_id_behaviors_nr 
)

Compute the CRC-3 over control fields for ROHCv2 profiles.

Parameters
profile_idThe current profile ID
reorder_ratioThe 2-bit reorder_ratio control field, padded with 6 MSB of zeroes
msnThe 16-bit MSN control field
ip_id_behaviorsThe 2-bit control fields behavior of IP-ID, one per IP header, all are padded with 6 MSB of zeroes
ip_id_behaviors_nrThe number of IP headers, ie. the number of IP-ID behavior control fields to compute the CRC over
Returns
The computed CRC-3

◆ crc_calc_3()

static uint8_t crc_calc_3 ( const uint8_t *const  buf,
const size_t  size,
const uint8_t  init_val 
)
inlinestatic

Optimized CRC-3 calculation using a table.

Parameters
bufThe data to compute the CRC for
sizeThe size of the data
init_valThe initial CRC value
Returns
The CRC byte

◆ crc_calc_7()

static uint8_t crc_calc_7 ( const uint8_t *const  buf,
const size_t  size,
const uint8_t  init_val 
)
inlinestatic

Optimized CRC-7 calculation using a table.

Parameters
bufThe data to compute the CRC for
sizeThe size of the data
init_valThe initial CRC value
Returns
The CRC byte

◆ crc_calc_8()

static uint8_t crc_calc_8 ( const uint8_t *const  buf,
const size_t  size,
const uint8_t  init_val 
)
inlinestatic

Optimized CRC-8 calculation using a table.

Parameters
bufThe data to compute the CRC for
sizeThe size of the data
init_valThe initial CRC value
Returns
The CRC byte

◆ crc_calc_fcs32()

uint32_t crc_calc_fcs32 ( const uint8_t *const  data,
const size_t  length,
const uint32_t  init_val 
)

Optimized CRC FCS-32 calculation using a table.

Public functions

Parameters
dataThe data to compute the CRC for
lengthThe size of the data
init_valThe initial value of the CRC
Returns
The 32-bit CRC

◆ crc_calculate()

static uint8_t crc_calculate ( const rohc_crc_type_t  crc_type,
const uint8_t *const  data,
const size_t  length,
const uint8_t  init_val 
)
inlinestatic

Calculate the checksum for the given data.

Parameters
crc_typeThe CRC type
dataThe data to calculate the checksum on
lengthThe length of the data
init_valThe initial CRC value
Returns
The checksum

◆ esp_compute_crc_dynamic()

static uint8_t esp_compute_crc_dynamic ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
inlinestatic

Compute the CRC-DYNAMIC part of an ESP header.

Concerned fields are:

  • bytes 5-8 in original ESP header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ esp_compute_crc_static()

static uint8_t esp_compute_crc_static ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
inlinestatic

Compute the CRC-STATIC part of an ESP header.

Concerned fields are: all fields expect those for CRC-DYNAMIC

  • bytes 1-4 in original ESP header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ ip_compute_crc_dynamic()

uint8_t ip_compute_crc_dynamic ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)

Compute the CRC-DYNAMIC part of an IP header.

Concerned fields are:

  • bytes 3-4, 5-6, 11-12 in original IPv4 header
  • bytes 5-6 in original IPv6 header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ ip_compute_crc_static()

uint8_t ip_compute_crc_static ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)

Compute the CRC-STATIC part of an IP header.

Concerned fields are: all fields expect those for CRC-DYNAMIC

  • bytes 1-2, 7-10, 13-20 in original IPv4 header
  • bytes 1-4, 7-40 in original IPv6 header

This function is one of the functions that must exist in one profile for the framework to work.

Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ rtp_compute_crc_dynamic()

static uint8_t rtp_compute_crc_dynamic ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
inlinestatic

Compute the CRC-DYNAMIC part of a RTP header.

Concerned fields are:

  • bytes 2, 3-4, 5-8 in original RTP header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ rtp_compute_crc_static()

static uint8_t rtp_compute_crc_static ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
inlinestatic

Compute the CRC-STATIC part of a RTP header.

Concerned fields are: all fields expect those for CRC-DYNAMIC

  • bytes 1, 9-12 (and CSRC list) in original RTP header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ udp_compute_crc_dynamic()

static uint8_t udp_compute_crc_dynamic ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
inlinestatic

Compute the CRC-DYNAMIC part of an UDP header.

Concerned fields are:

  • bytes 5-6, 7-8 in original UDP header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

◆ udp_compute_crc_static()

static uint8_t udp_compute_crc_static ( const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
inlinestatic

Compute the CRC-STATIC part of an UDP header.

Concerned fields are: all fields expect those for CRC-DYNAMIC

  • bytes 1-4 in original UDP header
Parameters
uncomp_pkt_hdrsThe uncompressed headers to compute CRC for
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The computed CRC

Variable Documentation

◆ crc_table_7

const uint8_t crc_table_7[256]
static

The table to enable fast CRC-7 computation

◆ crc_table_8

const uint8_t crc_table_8[256]
static

The table to enable fast CRC-8 computation