ROHC compression/decompression library
Functions | Variables
crc.c File Reference

ROHC CRC routines. More...

#include "crc.h"
#include "protocols/ip_numbers.h"
#include "protocols/ip.h"
#include "protocols/ipv4.h"
#include "protocols/ipv6.h"
#include "protocols/udp.h"
#include "protocols/rtp.h"
#include "protocols/esp.h"
#include "protocols/tcp.h"
#include <stdlib.h>
#include <assert.h>
Include dependency graph for crc.c:

Functions

static uint8_t ipv6_ext_calc_crc_static (const struct rohc_pkt_ip_hdr *const ip_hdr, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-STATIC part of IPv6 extensions. More...
 
static uint8_t ipv6_ext_calc_crc_dyn (const struct rohc_pkt_ip_hdr *const ip_hdr, const rohc_crc_type_t crc_type, const uint8_t init_val)
 Compute the CRC-DYNAMIC part of IPv6 extensions. More...
 
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...
 
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...
 

Variables

static const uint32_t crc_table_fcs32 [256]
 The pre-computed table for 32-bit Frame Check Sequence (FCS) More...
 

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

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_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

◆ 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

◆ ipv6_ext_calc_crc_dyn()

static uint8_t ipv6_ext_calc_crc_dyn ( const struct rohc_pkt_ip_hdr *const  ip_hdr,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
static

Compute the CRC-DYNAMIC part of IPv6 extensions.

Only entire AH header is concerned.

Parameters
ip_hdrThe IP header for which to compute CRC over extension headers
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The compute CRC

◆ ipv6_ext_calc_crc_static()

static uint8_t ipv6_ext_calc_crc_static ( const struct rohc_pkt_ip_hdr *const  ip_hdr,
const rohc_crc_type_t  crc_type,
const uint8_t  init_val 
)
static

Compute the CRC-STATIC part of IPv6 extensions.

Prototypes of private functions

Private functions All extensions are concerned except entire AH header.

Parameters
ip_hdrThe IP header for which to compute CRC over extension headers
crc_typeThe type of CRC
init_valThe initial CRC value
Returns
The compute CRC

Variable Documentation

◆ crc_table_fcs32

const uint32_t crc_table_fcs32[256]
static

The pre-computed table for 32-bit Frame Check Sequence (FCS)

x**0 + x**1 + x**2 + x**4 + x**5 + x**7 + x**8 + x**10 + x**11 + x**12 + x**16 + x**22 + x**23 + x**26 + x**32

Copied from RFC 1662, appendix C.3