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

ROHC CRC routines. More...

#include "ip.h"
#include "dllexport.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.

Defines

#define CRC_INIT_3   0x7
 The CRC-3 initial value.
#define CRC_INIT_7   0x7f
 The CRC-7 initial value.
#define CRC_INIT_8   0xff
 The CRC-8 initial value.
#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

bool ROHC_EXPORT rohc_crc_init_table (uint8_t *const table, const rohc_crc_type_t crc_type)
 Initialize a CRC table given a 256-byte table and the CRC type to use.
uint8_t ROHC_EXPORT crc_calculate (const rohc_crc_type_t crc_type, const uint8_t *const data, const size_t length, const uint8_t init_val, const uint8_t *const crc_table)
 Calculate the checksum for the given data.
uint32_t ROHC_EXPORT 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.
uint8_t ROHC_EXPORT compute_crc_static (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-STATIC part of an IP header.
uint8_t ROHC_EXPORT compute_crc_dynamic (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-DYNAMIC part of an IP header.
uint8_t ROHC_EXPORT udp_compute_crc_static (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-STATIC part of an UDP or UDP-Lite header.
uint8_t ROHC_EXPORT udp_compute_crc_dynamic (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-DYNAMIC part of an UDP or UDP-Lite header.
uint8_t ROHC_EXPORT esp_compute_crc_static (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-STATIC part of an ESP header.
uint8_t ROHC_EXPORT esp_compute_crc_dynamic (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-DYNAMIC part of an ESP header.
uint8_t ROHC_EXPORT rtp_compute_crc_static (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-STATIC part of a RTP header.
uint8_t ROHC_EXPORT rtp_compute_crc_dynamic (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-DYNAMIC part of a RTP header.
uint8_t ROHC_EXPORT tcp_compute_crc_static (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-STATIC part of an TCP header.
uint8_t ROHC_EXPORT tcp_compute_crc_dynamic (const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
 Compute the CRC-DYNAMIC part of an TCP header.

Detailed Description

ROHC CRC routines.

Author:
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
Didier Barvaux <didier@barvaux.org>
FWX <rohc_team@dialine.fr>

Define Documentation

#define CRC_FCS32_LEN   4U

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

#define CRC_INIT_3   0x7

The CRC-3 initial value.

#define CRC_INIT_7   0x7f

The CRC-7 initial value.

#define CRC_INIT_8   0xff

The CRC-8 initial value.

#define CRC_INIT_FCS32   0xffffffff

The FCS-32 initial value


Enumeration Type Documentation

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

uint8_t ROHC_EXPORT compute_crc_dynamic ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

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:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT compute_crc_static ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

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:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint32_t ROHC_EXPORT 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.

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
uint8_t ROHC_EXPORT crc_calculate ( const rohc_crc_type_t  crc_type,
const uint8_t *const  data,
const size_t  length,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

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
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT esp_compute_crc_dynamic ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

Compute the CRC-DYNAMIC part of an ESP header.

Concerned fields are:

  • bytes 5-8 in original ESP header
Parameters:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT esp_compute_crc_static ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

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:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
bool ROHC_EXPORT rohc_crc_init_table ( uint8_t *const  table,
const rohc_crc_type_t  crc_type 
)

Initialize a CRC table given a 256-byte table and the CRC type to use.

Parameters:
tableIN/OUT: The 256-byte table to initialize
crc_typeThe type of CRC to initialize the table for
Returns:
true in case of success, false in case of failure
uint8_t ROHC_EXPORT rtp_compute_crc_dynamic ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

Compute the CRC-DYNAMIC part of a RTP header.

Concerned fields are:

  • bytes 2, 3-4, 5-8 in original RTP header
Parameters:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT rtp_compute_crc_static ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

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:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT tcp_compute_crc_dynamic ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

Compute the CRC-DYNAMIC part of an TCP header.

Concerned fields are:

  • bytes 5-20 in original TCP header
  • TCP options
Parameters:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT tcp_compute_crc_static ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

Compute the CRC-STATIC part of an TCP header.

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

  • bytes 1-4 in original TCP header
Parameters:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT udp_compute_crc_dynamic ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

Compute the CRC-DYNAMIC part of an UDP or UDP-Lite header.

Concerned fields are:

  • bytes 5-6, 7-8 in original UDP header
Parameters:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum
uint8_t ROHC_EXPORT udp_compute_crc_static ( const uint8_t *const  ip,
const uint8_t *const  ip2,
const uint8_t *const  next_header,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val,
const uint8_t *const  crc_table 
)

Compute the CRC-STATIC part of an UDP or UDP-Lite header.

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

  • bytes 1-4 in original UDP header
Parameters:
ipThe outer IP packet
ip2The inner IP packet if there is 2 IP headers, NULL otherwise
next_headerThe next header located after the IP header(s)
crc_typeThe type of CRC
init_valThe initial CRC value
crc_tableThe pre-computed table for fast CRC computation
Returns:
The checksum