ROHC compression/decompression library
crc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2007,2008 CNES
3  * Copyright 2011,2012,2013,2018 Didier Barvaux
4  * Copyright 2007,2008 Thales Alenia Space
5  * Copyright 2009,2010 Thales Communications
6  * Copyright 2007,2009,2010,2012,2013,2018 Viveris Technologies
7  * Copyright 2012 WBX
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 /**
25  * @file crc.h
26  * @brief ROHC CRC routines
27  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
28  * @author Didier Barvaux <didier@barvaux.org>
29  * @author FWX <rohc_team@dialine.fr>
30  */
31 
32 #ifndef ROHC_COMMON_CRC_H
33 #define ROHC_COMMON_CRC_H
34 
35 #include "crcany.h"
36 #include "ip.h"
38 
39 #include <rohc/rohc.h> /* for rohc_profile_t */
40 
41 #include <stdbool.h>
42 
43 /// The CRC-3 initial value
44 #define CRC_INIT_3 0x7
45 /// The CRC-7 initial value
46 #define CRC_INIT_7 0x7f
47 /// The CRC-8 initial value
48 #define CRC_INIT_8 0xff
49 
50 /** The FCS-32 initial value */
51 #define CRC_INIT_FCS32 0xffffffff
52 /** The length (in bytes) of the FCS-32 CRC */
53 #define CRC_FCS32_LEN 4U
54 
55 /** The different types of CRC used to protect ROHC headers */
56 typedef enum
57 {
58  ROHC_CRC_TYPE_NONE = 0, /**< No CRC selected */
59  ROHC_CRC_TYPE_3 = 3, /**< The CRC-3 type */
60  ROHC_CRC_TYPE_7 = 7, /**< The CRC-7 type */
61  ROHC_CRC_TYPE_8 = 8, /**< The CRC-8 type */
63 
64 
65 /** The table to enable fast CRC-7 computation */
66 static const uint8_t crc_table_7[256] =
67 {
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,
100 };
101 
102 
103 /** The table to enable fast CRC-8 computation */
104 static const uint8_t crc_table_8[256] =
105 {
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,
138 };
139 
140 
141 
142 /*
143  * Function prototypes.
144  */
145 
146 uint32_t crc_calc_fcs32(const uint8_t *const data,
147  const size_t length,
148  const uint32_t init_val)
149  __attribute__((nonnull(1), warn_unused_result, pure));
150 
151 uint8_t ip_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
152  const rohc_crc_type_t crc_type,
153  const uint8_t init_val)
154  __attribute__((nonnull(1), warn_unused_result));
155 uint8_t ip_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
156  const rohc_crc_type_t crc_type,
157  const uint8_t init_val)
158  __attribute__((nonnull(1), warn_unused_result));
159 
160 static inline
161 uint8_t udp_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
162  const rohc_crc_type_t crc_type,
163  const uint8_t init_val)
164  __attribute__((nonnull(1), warn_unused_result));
165 static inline
166 uint8_t udp_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
167  const rohc_crc_type_t crc_type,
168  const uint8_t init_val)
169  __attribute__((nonnull(1), warn_unused_result));
170 
171 static inline
172 uint8_t esp_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
173  const rohc_crc_type_t crc_type,
174  const uint8_t init_val)
175  __attribute__((nonnull(1), warn_unused_result));
176 static inline
177 uint8_t esp_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
178  const rohc_crc_type_t crc_type,
179  const uint8_t init_val)
180  __attribute__((nonnull(1), warn_unused_result));
181 
182 static inline
183 uint8_t rtp_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
184  const rohc_crc_type_t crc_type,
185  const uint8_t init_val)
186  __attribute__((nonnull(1), warn_unused_result));
187 static inline
188 uint8_t rtp_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
189  const rohc_crc_type_t crc_type,
190  const uint8_t init_val)
191  __attribute__((nonnull(1), warn_unused_result));
192 
193 uint8_t compute_crc_ctrl_fields(const rohc_profile_t profile_id,
194  const uint8_t reorder_ratio,
195  const uint16_t msn,
196  const uint8_t ip_id_behaviors[],
197  const size_t ip_id_behaviors_nr)
198  __attribute__((warn_unused_result));
199 
200 static inline
201 uint8_t crc_calculate(const rohc_crc_type_t crc_type,
202  const uint8_t *const data,
203  const size_t length,
204  const uint8_t init_val)
205  __attribute__((nonnull(2), warn_unused_result));
206 
207 static inline uint8_t crc_calc_8(const uint8_t *const buf,
208  const size_t size,
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,
212  const size_t size,
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,
216  const size_t size,
217  const uint8_t init_val)
218  __attribute__((nonnull(1), warn_unused_result, pure));
219 
220 
221 /**
222  * @brief Calculate the checksum for the given data.
223  *
224  * @param crc_type The CRC type
225  * @param data The data to calculate the checksum on
226  * @param length The length of the data
227  * @param init_val The initial CRC value
228  * @return The checksum
229  */
230 static inline
231 uint8_t crc_calculate(const rohc_crc_type_t crc_type,
232  const uint8_t *const data,
233  const size_t length,
234  const uint8_t init_val)
235 {
236  uint8_t crc;
237 
238  /* call the function that corresponds to the CRC type */
239  switch(crc_type)
240  {
241  case ROHC_CRC_TYPE_8:
242  crc = crc_calc_8(data, length, init_val);
243  break;
244  case ROHC_CRC_TYPE_7:
245  crc = crc_calc_7(data, length, init_val);
246  break;
247  case ROHC_CRC_TYPE_3:
248  crc = crc_calc_3(data, length, init_val);
249  break;
250  case ROHC_CRC_TYPE_NONE:
251  default:
252  crc = 0;
253  break;
254  }
255 
256  return crc;
257 }
258 
259 
260 /**
261  * @brief Optimized CRC-8 calculation using a table
262  *
263  * @param buf The data to compute the CRC for
264  * @param size The size of the data
265  * @param init_val The initial CRC value
266  * @return The CRC byte
267  */
268 static inline uint8_t crc_calc_8(const uint8_t *const buf,
269  const size_t size,
270  const uint8_t init_val)
271 {
272  uint8_t crc = init_val;
273  size_t i;
274 
275  for(i = 0; i < size; i++)
276  {
277  crc = crc_table_8[buf[i] ^ crc];
278  }
279 
280  return crc;
281 }
282 
283 
284 /**
285  * @brief Optimized CRC-7 calculation using a table
286  *
287  * @param buf The data to compute the CRC for
288  * @param size The size of the data
289  * @param init_val The initial CRC value
290  * @return The CRC byte
291  */
292 static inline uint8_t crc_calc_7(const uint8_t *const buf,
293  const size_t size,
294  const uint8_t init_val)
295 {
296  uint8_t crc = init_val;
297  size_t i;
298 
299  for(i = 0; i < size; i++)
300  {
301  crc = crc_table_7[buf[i] ^ (crc & 127)];
302  }
303 
304  return crc;
305 }
306 
307 
308 /**
309  * @brief Optimized CRC-3 calculation using a table
310  *
311  * @param buf The data to compute the CRC for
312  * @param size The size of the data
313  * @param init_val The initial CRC value
314  * @return The CRC byte
315  */
316 static inline uint8_t crc_calc_3(const uint8_t *const buf,
317  const size_t size,
318  const uint8_t init_val)
319 {
320  return crc3rohc_word(init_val, buf, size);
321 }
322 
323 
324 /**
325  * @brief Compute the CRC-STATIC part of an UDP header
326  *
327  * Concerned fields are:
328  * all fields expect those for CRC-DYNAMIC
329  * - bytes 1-4 in original UDP header
330  *
331  * @param uncomp_pkt_hdrs The uncompressed headers to compute CRC for
332  * @param crc_type The type of CRC
333  * @param init_val The initial CRC value
334  * @return The computed CRC
335  */
336 static inline
337 uint8_t udp_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
338  const rohc_crc_type_t crc_type,
339  const uint8_t init_val)
340 {
341  uint8_t crc = init_val;
342 
343  /* compute the CRC-STATIC value for IP and IP2 headers */
344  crc = ip_compute_crc_static(uncomp_pkt_hdrs, crc_type, crc);
345 
346  /* bytes 1-4 (Source Port, Destination Port) */
347  crc = crc_calculate(crc_type, (uint8_t *)(&uncomp_pkt_hdrs->udp->source), 4, crc);
348 
349  return crc;
350 }
351 
352 
353 /**
354  * @brief Compute the CRC-DYNAMIC part of an UDP header
355  *
356  * Concerned fields are:
357  * - bytes 5-6, 7-8 in original UDP header
358  *
359  * @param uncomp_pkt_hdrs The uncompressed headers to compute CRC for
360  * @param crc_type The type of CRC
361  * @param init_val The initial CRC value
362  * @return The computed CRC
363  */
364 static inline
365 uint8_t udp_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
366  const rohc_crc_type_t crc_type,
367  const uint8_t init_val)
368 {
369  uint8_t crc = init_val;
370 
371  /* compute the CRC-DYNAMIC value for IP and IP2 headers */
372  crc = ip_compute_crc_dynamic(uncomp_pkt_hdrs, crc_type, crc);
373 
374  /* bytes 5-8 (Length, Checksum) */
375  crc = crc_calculate(crc_type, (uint8_t *)(&uncomp_pkt_hdrs->udp->len), 4, crc);
376 
377  return crc;
378 }
379 
380 
381 /**
382  * @brief Compute the CRC-STATIC part of an ESP header
383  *
384  * Concerned fields are:
385  * all fields expect those for CRC-DYNAMIC
386  * - bytes 1-4 in original ESP header
387  *
388  * @param uncomp_pkt_hdrs The uncompressed headers to compute CRC for
389  * @param crc_type The type of CRC
390  * @param init_val The initial CRC value
391  * @return The computed CRC
392  */
393 static inline
394 uint8_t esp_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
395  const rohc_crc_type_t crc_type,
396  const uint8_t init_val)
397 {
398  uint8_t crc = init_val;
399 
400  /* compute the CRC-STATIC value for IP and IP2 headers */
401  crc = ip_compute_crc_static(uncomp_pkt_hdrs, crc_type, crc);
402 
403  /* bytes 1-4 (Security parameters index) */
404  crc = crc_calculate(crc_type, (uint8_t *)(&uncomp_pkt_hdrs->esp->spi), 4, crc);
405 
406  return crc;
407 }
408 
409 
410 /**
411  * @brief Compute the CRC-DYNAMIC part of an ESP header
412  *
413  * Concerned fields are:
414  * - bytes 5-8 in original ESP header
415  *
416  * @param uncomp_pkt_hdrs The uncompressed headers to compute CRC for
417  * @param crc_type The type of CRC
418  * @param init_val The initial CRC value
419  * @return The computed CRC
420  */
421 static inline
422 uint8_t esp_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
423  const rohc_crc_type_t crc_type,
424  const uint8_t init_val)
425 {
426  uint8_t crc = init_val;
427 
428  /* compute the CRC-DYNAMIC value for IP and IP2 headers */
429  crc = ip_compute_crc_dynamic(uncomp_pkt_hdrs, crc_type, crc);
430 
431  /* bytes 5-8 (Sequence number) */
432  crc = crc_calculate(crc_type, (uint8_t *)(&uncomp_pkt_hdrs->esp->sn), 4, crc);
433 
434  return crc;
435 }
436 
437 
438 /**
439  * @brief Compute the CRC-STATIC part of a RTP header
440  *
441  * Concerned fields are:
442  * all fields expect those for CRC-DYNAMIC
443  * - bytes 1, 9-12 (and CSRC list) in original RTP header
444  *
445  * @param uncomp_pkt_hdrs The uncompressed headers to compute CRC for
446  * @param crc_type The type of CRC
447  * @param init_val The initial CRC value
448  * @return The computed CRC
449  */
450 static inline
451 uint8_t rtp_compute_crc_static(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
452  const rohc_crc_type_t crc_type,
453  const uint8_t init_val)
454 {
455  uint8_t crc = init_val;
456 
457  /* compute the CRC-STATIC value for IP, IP2 and UDP headers */
458  crc = udp_compute_crc_static(uncomp_pkt_hdrs, crc_type, crc);
459 
460  /* byte 1 (Version, P, X, CC) */
461  crc = crc_calculate(crc_type, (uint8_t *)uncomp_pkt_hdrs->rtp, 1, crc);
462 
463  /* bytes 9-12 (SSRC identifier) */
464  crc = crc_calculate(crc_type, (uint8_t *)(&uncomp_pkt_hdrs->rtp->ssrc), 4, crc);
465 
466  /* TODO: CSRC identifiers */
467 
468  return crc;
469 }
470 
471 
472 /**
473  * @brief Compute the CRC-DYNAMIC part of a RTP header
474  *
475  * Concerned fields are:
476  * - bytes 2, 3-4, 5-8 in original RTP header
477  *
478  * @param uncomp_pkt_hdrs The uncompressed headers to compute CRC for
479  * @param crc_type The type of CRC
480  * @param init_val The initial CRC value
481  * @return The computed CRC
482  */
483 static inline
484 uint8_t rtp_compute_crc_dynamic(const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
485  const rohc_crc_type_t crc_type,
486  const uint8_t init_val)
487 {
488  uint8_t crc = init_val;
489 
490  /* compute the CRC-DYNAMIC value for IP, IP2 and UDP headers */
491  crc = udp_compute_crc_dynamic(uncomp_pkt_hdrs, crc_type, crc);
492 
493  /* bytes 2-8 (Marker, Payload Type, Sequence Number, Timestamp) */
494  crc = crc_calculate(crc_type, ((uint8_t *) uncomp_pkt_hdrs->rtp) + 1, 7, crc);
495 
496  return crc;
497 }
498 
499 #endif
500 
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
IP-agnostic packet.
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
bool nonnull(1)))
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 base CRC routines.
Definition: crc.h:60
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
Definition: crc.h:59
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
Definition: crc.h:58
Definition: crc.h:61
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