ROHC compression/decompression library
|
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>
Functions | |
static uint8_t | ipv6_ext_calc_crc_static (const uint8_t *const ip, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table) |
Compute the CRC-STATIC part of IPv6 extensions. More... | |
static uint8_t | ipv6_ext_calc_crc_dyn (const uint8_t *const ip, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table) |
Compute the CRC-DYNAMIC part of IPv6 extensions. More... | |
static uint8_t * | ipv6_get_first_extension (const uint8_t *const ip, uint8_t *const type) |
Get the first extension in an IPv6 packet. More... | |
static bool | rohc_crc_get_polynom (const rohc_crc_type_t crc_type, uint8_t *const polynom) |
Get the polynom for the given CRC type. More... | |
static uint8_t | crc_calc_8 (const uint8_t *const buf, const size_t size, const uint8_t init_val, const uint8_t *const crc_table) |
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, const uint8_t *const crc_table) |
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, const uint8_t *const crc_table) |
Optimized CRC-3 calculation using a table. More... | |
bool | 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... | |
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... | |
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... | |
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... | |
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... | |
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... | |
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... | |
Variables | |
static const uint32_t | crc_table_fcs32 [256] |
The pre-computed table for 32-bit Frame Check Sequence (FCS) More... | |
ROHC CRC routines.
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 |
|
inlinestatic |
Optimized CRC-3 calculation using a table.
buf | The data to compute the CRC for |
size | The size of the data |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Optimized CRC-7 calculation using a table.
buf | The data to compute the CRC for |
size | The size of the data |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
inlinestatic |
Optimized CRC-8 calculation using a table.
buf | The data to compute the CRC for |
size | The size of the data |
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 |
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.
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 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.
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 |
|
static |
Compute the CRC-DYNAMIC part of IPv6 extensions.
Only entire AH header is concerned.
ip | The IPv6 packet |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
static |
Compute the CRC-STATIC part of IPv6 extensions.
Prototypes of private functions
Private functions All extensions are concerned except entire AH header.
ip | The IPv6 packet |
crc_type | The type of CRC |
init_val | The initial CRC value |
crc_table | The pre-computed table for fast CRC computation |
|
static |
Get the first extension in an IPv6 packet.
ip | The IPv6 packet |
type | The type of the extension |
|
static |
Get the polynom for the given CRC type.
crc_type | The CRC type |
polynom | IN/OUT: the polynom for the requested CRC type |
bool 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 |
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.
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 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.
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 |
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.
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 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.
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 |
|
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