ROHC compression/decompression library
|
ROHC CRC routines. More...
#include "crc.h"
#include "rohc.h"
#include "protocols/udp.h"
#include "protocols/rtp.h"
#include "protocols/esp.h"
#include <stdlib.h>
#include <assert.h>
Functions | |
static unsigned char static unsigned char static unsigned char static unsigned char static unsigned char int | crc_get_polynom (int type) |
Get the polynom for the given CRC type. | |
void | crc_init_table (unsigned char *table, unsigned char poly) |
Initialize a CRC table given a 256-byte table and the polynom to use. | |
bool | rohc_crc_init_table (unsigned char *const table, const rohc_crc_type_t crc_type) |
Initialize a CRC table given a 256-byte table and the CRC type to use. | |
unsigned int | crc_calculate (const rohc_crc_type_t crc_type, const unsigned char *const data, const int length, const unsigned int init_val, const unsigned char *const crc_table) |
Calculate the checksum for the given data. | |
unsigned int | compute_crc_static (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-STATIC part of an IP header. | |
unsigned int | compute_crc_dynamic (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-DYNAMIC part of an IP header. | |
unsigned int | udp_compute_crc_static (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-STATIC part of an UDP or UDP-Lite header. | |
unsigned int | udp_compute_crc_dynamic (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-DYNAMIC part of an UDP or UDP-Lite header. | |
unsigned int | esp_compute_crc_static (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-STATIC part of an ESP header. | |
unsigned int | esp_compute_crc_dynamic (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-DYNAMIC part of an ESP header. | |
unsigned int | rtp_compute_crc_static (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-STATIC part of a RTP header. | |
unsigned int | rtp_compute_crc_dynamic (const unsigned char *const ip, const unsigned char *const ip2, const unsigned char *const next_header, const rohc_crc_type_t crc_type, const unsigned int init_val, const unsigned char *const crc_table) |
Compute the CRC-DYNAMIC part of a RTP header. | |
Variables | |
unsigned char | crc_table_8 [256] |
unsigned char | crc_table_7 [256] |
unsigned char | crc_table_6 [256] |
unsigned char | crc_table_3 [256] |
unsigned char | crc_table_2 [256] |
static unsigned int static unsigned int static unsigned char static bool | warn_unused_result |
ROHC CRC routines.
unsigned int compute_crc_dynamic | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *const | crc_table | ||
) |
Compute the CRC-DYNAMIC part of an IP header.
Concerned fields are:
ip | The outer IP packet |
ip2 | 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 |
References ipv4_hdr::check, crc_calculate(), get_ip_version(), IPV4, ipv4_hdr::tot_len, and version.
Referenced by c_generic_create(), d_generic_create(), esp_compute_crc_dynamic(), and udp_compute_crc_dynamic().
unsigned int compute_crc_static | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *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.
ip | The outer IP packet |
ip2 | 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 |
References crc_calculate(), ipv4_hdr::frag_off, get_ip_version(), IPV4, ipv4_hdr::saddr, and version.
Referenced by c_generic_create(), d_generic_create(), esp_compute_crc_static(), and udp_compute_crc_static().
unsigned int crc_calculate | ( | const rohc_crc_type_t | crc_type, |
const unsigned char *const | data, | ||
const int | length, | ||
const unsigned int | init_val, | ||
const unsigned char *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 |
References ROHC_CRC_TYPE_2, ROHC_CRC_TYPE_3, ROHC_CRC_TYPE_6, ROHC_CRC_TYPE_7, and ROHC_CRC_TYPE_8.
Referenced by c_generic_feedback(), code_IR_DYN_packet(), code_IR_packet(), compute_crc_dynamic(), compute_crc_static(), esp_compute_crc_dynamic(), esp_compute_crc_static(), f_wrap_feedback(), rtp_compute_crc_dynamic(), rtp_compute_crc_static(), udp_compute_crc_dynamic(), and udp_compute_crc_static().
unsigned int esp_compute_crc_dynamic | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *const | crc_table | ||
) |
Compute the CRC-DYNAMIC part of an ESP header.
Concerned fields are:
ip | The outer IP packet |
ip2 | 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 |
References compute_crc_dynamic(), crc_calculate(), and esphdr::sn.
unsigned int esp_compute_crc_static | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *const | crc_table | ||
) |
Compute the CRC-STATIC part of an ESP header.
Concerned fields are: all fields expect those for CRC-DYNAMIC
ip | The outer IP packet |
ip2 | 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 |
References compute_crc_static(), crc_calculate(), and esphdr::spi.
bool rohc_crc_init_table | ( | unsigned char *const | table, |
const rohc_crc_type_t | crc_type | ||
) |
Initialize a CRC table given a 256-byte table and the CRC type to use.
table | IN/OUT: The 256-byte table to initialize |
crc_type | The type of CRC to initialize the table for |
Referenced by rohc_alloc_compressor(), and rohc_alloc_decompressor().
unsigned int rtp_compute_crc_dynamic | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *const | crc_table | ||
) |
Compute the CRC-DYNAMIC part of a RTP header.
Concerned fields are:
ip | The outer IP packet |
ip2 | 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 |
References crc_calculate(), and udp_compute_crc_dynamic().
Referenced by c_rtp_create(), and d_rtp_create().
unsigned int rtp_compute_crc_static | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *const | crc_table | ||
) |
Compute the CRC-STATIC part of a RTP header.
Concerned fields are: all fields expect those for CRC-DYNAMIC
ip | The outer IP packet |
ip2 | 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 |
References crc_calculate(), and udp_compute_crc_static().
Referenced by c_rtp_create(), and d_rtp_create().
unsigned int udp_compute_crc_dynamic | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *const | crc_table | ||
) |
Compute the CRC-DYNAMIC part of an UDP or UDP-Lite header.
Concerned fields are:
ip | The outer IP packet |
ip2 | 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 |
References compute_crc_dynamic(), crc_calculate(), and udphdr::len.
Referenced by c_udp_create(), c_udp_lite_create(), d_udp_create(), d_udp_lite_create(), and rtp_compute_crc_dynamic().
unsigned int udp_compute_crc_static | ( | const unsigned char *const | ip, |
const unsigned char *const | ip2, | ||
const unsigned char *const | next_header, | ||
const rohc_crc_type_t | crc_type, | ||
const unsigned int | init_val, | ||
const unsigned char *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
ip | The outer IP packet |
ip2 | 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 |
References compute_crc_static(), crc_calculate(), and udphdr::source.
Referenced by c_udp_create(), c_udp_lite_create(), d_udp_create(), d_udp_lite_create(), and rtp_compute_crc_static().
unsigned char crc_table_2[256] |
unsigned char ROHC_EXPORT crc_table_3 | ( | ) |
The table to enable fast CRC-3 computation
unsigned char ROHC_EXPORT crc_table_6 | ( | ) |
The table to enable fast CRC-6 computation
unsigned char ROHC_EXPORT crc_table_7 | ( | ) |
The table to enable fast CRC-7 computation
unsigned char ROHC_EXPORT crc_table_8 | ( | ) |
The table to enable fast CRC-8 computation
bool warn_unused_result |