ROHC compression/decompression library
|
ROHC CRC routines. More...
#include "ip.h"
#include "protocols/udp.h"
#include "protocols/rtp.h"
#include "protocols/esp.h"
#include "protocols/tcp.h"
#include <rohc/rohc.h>
#include <stdbool.h>
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 | |
void | 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. More... | |
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, const uint8_t *const crc_table) |
Calculate the checksum for the given data. 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 | compute_crc_static (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
uint8_t | compute_crc_dynamic (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
static uint8_t | udp_compute_crc_static (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
static uint8_t | udp_compute_crc_dynamic (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
static uint8_t | esp_compute_crc_static (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
static uint8_t | esp_compute_crc_dynamic (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
static uint8_t | rtp_compute_crc_static (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
static uint8_t | rtp_compute_crc_dynamic (const uint8_t *const outer_ip, const uint8_t *const inner_ip, 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. More... | |
uint8_t | compute_crc_ctrl_fields (const rohc_profile_t profile_id, const uint8_t *const crc_table, 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... | |
ROHC CRC routines.
#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
enum rohc_crc_type_t |
uint8_t compute_crc_ctrl_fields | ( | const rohc_profile_t | profile_id, |
const uint8_t *const | crc_table, | ||
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.
profile_id | The current profile ID |
crc_table | The pre-computed table for fast CRC computation |
reorder_ratio | The 2-bit reorder_ratio control field, padded with 6 MSB of zeroes |
msn | The 16-bit MSN control field |
ip_id_behaviors | The 2-bit control fields behavior of IP-ID, one per IP header, all are padded with 6 MSB of zeroes |
ip_id_behaviors_nr | The number of IP headers, ie. the number of IP-ID behavior control fields to compute the CRC over |
uint8_t compute_crc_dynamic | ( | const uint8_t *const | outer_ip, |
const uint8_t *const | inner_ip, | ||
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:
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
uint8_t compute_crc_static | ( | const uint8_t *const | outer_ip, |
const uint8_t *const | inner_ip, | ||
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
This function is one of the functions that must exist in one profile for the framework to work.
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
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.
data | The data to compute the CRC for |
length | The size of the data |
init_val | The initial value of the CRC |
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, | ||
const uint8_t *const | crc_table | ||
) |
Calculate the checksum for the given data.
crc_type | The CRC type |
data | The data to calculate the checksum on |
length | The length of the data |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Compute the CRC-DYNAMIC part of an ESP header.
Concerned fields are:
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Compute the CRC-STATIC part of an ESP header.
Concerned fields are: all fields expect those for CRC-DYNAMIC
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
void 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.
Public functions
table | IN/OUT: The 256-byte table to initialize |
crc_type | The type of CRC to initialize the table for |
|
inlinestatic |
Compute the CRC-DYNAMIC part of a RTP header.
Concerned fields are:
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Compute the CRC-STATIC part of a RTP header.
Concerned fields are: all fields expect those for CRC-DYNAMIC
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Compute the CRC-DYNAMIC part of an UDP or UDP-Lite header.
Concerned fields are:
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Compute the CRC-STATIC part of an UDP or UDP-Lite header.
Concerned fields are: all fields expect those for CRC-DYNAMIC
outer_ip | The outer IP packet |
inner_ip | The inner IP packet if there is 2 IP headers, NULL otherwise |
next_header | The next header located after the IP header(s) |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |