32 #ifndef ROHC_COMMON_CRC_H 33 #define ROHC_COMMON_CRC_H 39 #include <rohc/rohc.h> 44 #define CRC_INIT_3 0x7 46 #define CRC_INIT_7 0x7f 48 #define CRC_INIT_8 0xff 51 #define CRC_INIT_FCS32 0xffffffff 53 #define CRC_FCS32_LEN 4U 68 0x00, 0x40, 0x73, 0x33, 0x15, 0x55, 0x66, 0x26,
69 0x2a, 0x6a, 0x59, 0x19, 0x3f, 0x7f, 0x4c, 0x0c,
70 0x54, 0x14, 0x27, 0x67, 0x41, 0x01, 0x32, 0x72,
71 0x7e, 0x3e, 0x0d, 0x4d, 0x6b, 0x2b, 0x18, 0x58,
72 0x5b, 0x1b, 0x28, 0x68, 0x4e, 0x0e, 0x3d, 0x7d,
73 0x71, 0x31, 0x02, 0x42, 0x64, 0x24, 0x17, 0x57,
74 0x0f, 0x4f, 0x7c, 0x3c, 0x1a, 0x5a, 0x69, 0x29,
75 0x25, 0x65, 0x56, 0x16, 0x30, 0x70, 0x43, 0x03,
76 0x45, 0x05, 0x36, 0x76, 0x50, 0x10, 0x23, 0x63,
77 0x6f, 0x2f, 0x1c, 0x5c, 0x7a, 0x3a, 0x09, 0x49,
78 0x11, 0x51, 0x62, 0x22, 0x04, 0x44, 0x77, 0x37,
79 0x3b, 0x7b, 0x48, 0x08, 0x2e, 0x6e, 0x5d, 0x1d,
80 0x1e, 0x5e, 0x6d, 0x2d, 0x0b, 0x4b, 0x78, 0x38,
81 0x34, 0x74, 0x47, 0x07, 0x21, 0x61, 0x52, 0x12,
82 0x4a, 0x0a, 0x39, 0x79, 0x5f, 0x1f, 0x2c, 0x6c,
83 0x60, 0x20, 0x13, 0x53, 0x75, 0x35, 0x06, 0x46,
84 0x79, 0x39, 0x0a, 0x4a, 0x6c, 0x2c, 0x1f, 0x5f,
85 0x53, 0x13, 0x20, 0x60, 0x46, 0x06, 0x35, 0x75,
86 0x2d, 0x6d, 0x5e, 0x1e, 0x38, 0x78, 0x4b, 0x0b,
87 0x07, 0x47, 0x74, 0x34, 0x12, 0x52, 0x61, 0x21,
88 0x22, 0x62, 0x51, 0x11, 0x37, 0x77, 0x44, 0x04,
89 0x08, 0x48, 0x7b, 0x3b, 0x1d, 0x5d, 0x6e, 0x2e,
90 0x76, 0x36, 0x05, 0x45, 0x63, 0x23, 0x10, 0x50,
91 0x5c, 0x1c, 0x2f, 0x6f, 0x49, 0x09, 0x3a, 0x7a,
92 0x3c, 0x7c, 0x4f, 0x0f, 0x29, 0x69, 0x5a, 0x1a,
93 0x16, 0x56, 0x65, 0x25, 0x03, 0x43, 0x70, 0x30,
94 0x68, 0x28, 0x1b, 0x5b, 0x7d, 0x3d, 0x0e, 0x4e,
95 0x42, 0x02, 0x31, 0x71, 0x57, 0x17, 0x24, 0x64,
96 0x67, 0x27, 0x14, 0x54, 0x72, 0x32, 0x01, 0x41,
97 0x4d, 0x0d, 0x3e, 0x7e, 0x58, 0x18, 0x2b, 0x6b,
98 0x33, 0x73, 0x40, 0x00, 0x26, 0x66, 0x55, 0x15,
99 0x19, 0x59, 0x6a, 0x2a, 0x0c, 0x4c, 0x7f, 0x3f,
106 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
107 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
108 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
109 0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67,
110 0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d,
111 0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43,
112 0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51,
113 0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f,
114 0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05,
115 0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b,
116 0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19,
117 0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17,
118 0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d,
119 0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33,
120 0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21,
121 0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f,
122 0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95,
123 0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b,
124 0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89,
125 0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87,
126 0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad,
127 0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3,
128 0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1,
129 0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf,
130 0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5,
131 0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb,
132 0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9,
133 0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7,
134 0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd,
135 0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3,
136 0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1,
137 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf,
148 const uint32_t init_val)
149 __attribute__((
nonnull(1), warn_unused_result, pure));
153 const uint8_t init_val)
154 __attribute__((
nonnull(1), warn_unused_result));
157 const uint8_t init_val)
158 __attribute__((
nonnull(1), warn_unused_result));
163 const uint8_t init_val)
164 __attribute__((
nonnull(1), warn_unused_result));
168 const uint8_t init_val)
169 __attribute__((
nonnull(1), warn_unused_result));
174 const uint8_t init_val)
175 __attribute__((
nonnull(1), warn_unused_result));
179 const uint8_t init_val)
180 __attribute__((
nonnull(1), warn_unused_result));
185 const uint8_t init_val)
186 __attribute__((
nonnull(1), warn_unused_result));
190 const uint8_t init_val)
191 __attribute__((
nonnull(1), warn_unused_result));
194 const uint8_t reorder_ratio,
196 const uint8_t ip_id_behaviors[],
197 const size_t ip_id_behaviors_nr)
198 __attribute__((warn_unused_result));
202 const uint8_t *
const data,
204 const uint8_t init_val)
205 __attribute__((
nonnull(2), warn_unused_result));
207 static inline uint8_t
crc_calc_8(
const uint8_t *
const buf,
209 const uint8_t init_val)
210 __attribute__((
nonnull(1), warn_unused_result, pure));
211 static inline uint8_t
crc_calc_7(
const uint8_t *
const buf,
213 const uint8_t init_val)
214 __attribute__((
nonnull(1), warn_unused_result, pure));
215 static inline uint8_t
crc_calc_3(
const uint8_t *
const buf,
217 const uint8_t init_val)
218 __attribute__((
nonnull(1), warn_unused_result, pure));
232 const uint8_t *
const data,
234 const uint8_t init_val)
270 const uint8_t init_val)
272 uint8_t crc = init_val;
275 for(i = 0; i < size; i++)
294 const uint8_t init_val)
296 uint8_t crc = init_val;
299 for(i = 0; i < size; i++)
318 const uint8_t init_val)
339 const uint8_t init_val)
341 uint8_t crc = init_val;
367 const uint8_t init_val)
369 uint8_t crc = init_val;
396 const uint8_t init_val)
398 uint8_t crc = init_val;
424 const uint8_t init_val)
426 uint8_t crc = init_val;
453 const uint8_t init_val)
455 uint8_t crc = init_val;
486 const uint8_t init_val)
488 uint8_t crc = init_val;
494 crc =
crc_calculate(crc_type, ((uint8_t *) uncomp_pkt_hdrs->
rtp) + 1, 7, crc);
static uint8_t esp_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 ESP header.
Definition: crc.h:422
const struct rtphdr * rtp
Definition: uncomp_pkt_hdrs.h:129
static uint8_t crc_calc_7(const uint8_t *const buf, const size_t size, const uint8_t init_val)
Optimized CRC-7 calculation using a table.
Definition: crc.h:292
uint16_t len
Definition: udp.h:42
static 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)
Calculate the checksum for the given data.
Definition: crc.h:231
static uint8_t rtp_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 a RTP header.
Definition: crc.h:484
static uint8_t udp_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 UDP header.
Definition: crc.h:337
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.
Definition: crc.c:232
static uint8_t crc_calc_3(const uint8_t *const buf, const size_t size, const uint8_t init_val)
Optimized CRC-3 calculation using a table.
Definition: crc.h:316
static const uint8_t crc_table_8[256]
Definition: crc.h:104
uint32_t sn
Definition: esp.h:43
uint32_t spi
Definition: esp.h:42
Information about the uncompressed packet headers.
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.
Definition: crc.c:277
const struct udphdr * udp
Definition: uncomp_pkt_hdrs.h:124
const struct esphdr * esp
Definition: uncomp_pkt_hdrs.h:125
rohc_crc_type_t
Definition: crc.h:56
static uint8_t esp_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 ESP header.
Definition: crc.h:394
static uint8_t udp_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 UDP header.
Definition: crc.h:365
static const uint8_t crc_table_7[256]
Definition: crc.h:66
The information collected about the packet headers.
Definition: uncomp_pkt_hdrs.h:102
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.
Definition: crc.c:184
static uint8_t crc_calc_8(const uint8_t *const buf, const size_t size, const uint8_t init_val)
Optimized CRC-8 calculation using a table.
Definition: crc.h:268
static uint8_t rtp_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 a RTP header.
Definition: crc.h:451
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc_profiles.h:76
uint16_t source
Definition: udp.h:40
uint32_t ssrc
Synchronization SouRCe (SSRC) identifier.
Definition: rtp.h:67
unsigned crc3rohc_word(unsigned crc, void const *mem, size_t len)
Definition: crcany.c:148
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:152