32 #ifndef ROHC_COMMON_CRC_H 33 #define ROHC_COMMON_CRC_H 41 #include <rohc/rohc.h> 46 #define CRC_INIT_3 0x7 48 #define CRC_INIT_7 0x7f 50 #define CRC_INIT_8 0xff 53 #define CRC_INIT_FCS32 0xffffffff 55 #define CRC_FCS32_LEN 4U 73 __attribute__((nonnull(1)));
76 const uint8_t *
const data,
78 const uint8_t init_val,
79 const uint8_t *
const crc_table)
80 __attribute__((nonnull(2, 5), warn_unused_result));
84 const uint32_t init_val)
85 __attribute__((nonnull(1), warn_unused_result, pure));
88 const uint8_t *
const inner_ip,
89 const uint8_t *
const next_header,
91 const uint8_t init_val,
92 const uint8_t *
const crc_table)
93 __attribute__((nonnull(1, 6), warn_unused_result));
95 const uint8_t *
const inner_ip,
96 const uint8_t *
const next_header,
98 const uint8_t init_val,
99 const uint8_t *
const crc_table)
100 __attribute__((nonnull(1, 6), warn_unused_result));
104 const uint8_t *
const inner_ip,
105 const uint8_t *
const next_header,
107 const uint8_t init_val,
108 const uint8_t *
const crc_table)
109 __attribute__((nonnull(1, 3, 6), warn_unused_result));
112 const uint8_t *
const inner_ip,
113 const uint8_t *
const next_header,
115 const uint8_t init_val,
116 const uint8_t *
const crc_table)
117 __attribute__((nonnull(1, 3, 6), warn_unused_result));
121 const uint8_t *
const inner_ip,
122 const uint8_t *
const next_header,
124 const uint8_t init_val,
125 const uint8_t *
const crc_table)
126 __attribute__((nonnull(1, 3, 6), warn_unused_result));
129 const uint8_t *
const inner_ip,
130 const uint8_t *
const next_header,
132 const uint8_t init_val,
133 const uint8_t *
const crc_table)
134 __attribute__((nonnull(1, 3, 6), warn_unused_result));
138 const uint8_t *
const inner_ip,
139 const uint8_t *
const next_header,
141 const uint8_t init_val,
142 const uint8_t *
const crc_table)
143 __attribute__((nonnull(1, 3, 6), warn_unused_result));
146 const uint8_t *
const inner_ip,
147 const uint8_t *
const next_header,
149 const uint8_t init_val,
150 const uint8_t *
const crc_table)
151 __attribute__((nonnull(1, 3, 6), warn_unused_result));
154 const uint8_t *
const crc_table,
155 const uint8_t reorder_ratio,
157 const uint8_t ip_id_behaviors[],
158 const size_t ip_id_behaviors_nr)
159 __attribute__((nonnull(2), warn_unused_result));
179 const uint8_t *
const inner_ip,
180 const uint8_t *
const next_header,
182 const uint8_t init_val,
183 const uint8_t *
const crc_table)
185 uint8_t crc = init_val;
190 crc_type, crc, crc_table);
193 udp = (
struct udphdr *) next_header;
219 const uint8_t *
const inner_ip,
220 const uint8_t *
const next_header,
222 const uint8_t init_val,
223 const uint8_t *
const crc_table)
225 uint8_t crc = init_val;
230 crc_type, crc, crc_table);
233 udp = (
struct udphdr *) next_header;
260 const uint8_t *
const inner_ip,
261 const uint8_t *
const next_header,
263 const uint8_t init_val,
264 const uint8_t *
const crc_table)
266 uint8_t crc = init_val;
271 crc_type, crc, crc_table);
274 esp = (
struct esphdr *) next_header;
300 const uint8_t *
const inner_ip,
301 const uint8_t *
const next_header,
303 const uint8_t init_val,
304 const uint8_t *
const crc_table)
306 uint8_t crc = init_val;
311 crc_type, crc, crc_table);
314 esp = (
struct esphdr *) next_header;
341 const uint8_t *
const inner_ip,
342 const uint8_t *
const next_header,
344 const uint8_t init_val,
345 const uint8_t *
const crc_table)
347 uint8_t crc = init_val;
352 crc_type, crc, crc_table);
355 rtp = (
struct rtphdr *) (next_header +
sizeof(
struct udphdr));
358 crc =
crc_calculate(crc_type, (uint8_t *)rtp, 1, crc, crc_table);
386 const uint8_t *
const inner_ip,
387 const uint8_t *
const next_header,
389 const uint8_t init_val,
390 const uint8_t *
const crc_table)
392 uint8_t crc = init_val;
397 crc_type, crc, crc_table);
400 rtp = (
struct rtphdr *) (next_header +
sizeof(
struct udphdr));
uint16_t len
Definition: udp.h:42
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.
Definition: crc.c:220
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.
Definition: crc.c:464
uint32_t sn
Definition: esp.h:43
uint32_t spi
Definition: esp.h:42
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.
Definition: crc.c:295
The RTP header.
Definition: rtp.h:48
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.
Definition: crc.h:299
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.
Definition: crc.h:178
rohc_crc_type_t
Definition: crc.h:58
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.
Definition: crc.c:388
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.
Definition: crc.h:385
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.
Definition: crc.h:218
RTP header.
Definition: esp.h:40
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.
Definition: crc.c:176
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.
Definition: crc.h:259
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.
Definition: crc.h:340
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc_profiles.h:70
uint16_t source
Definition: udp.h:40
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.
Definition: crc.c:260