ROHC compression/decompression library
rohc_decomp_rfc3095.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010,2011,2012,2013,2014 Didier Barvaux
3  * Copyright 2007,2008 Thales Alenia Space
4  * Copyright 2007,2008,2009,2010,2012,2013 Viveris Technologies
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file rohc_decomp_rfc3095.c
23  * @brief Generic framework for RFC3095-based decompression profiles such as
24  * IP-only, UDP, UDP-Lite, ESP, and RTP profiles.
25  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
26  * @author Didier Barvaux <didier@barvaux.org>
27  * @author David Moreau from TAS
28  */
29 
30 #ifndef ROHC_DECOMP_RFC3095_H
31 #define ROHC_DECOMP_RFC3095_H
32 
33 #include "rohc_decomp.h"
34 #include "rohc_decomp_internals.h"
35 #include "rohc_packets.h"
36 #include "rohc_utils.h"
37 #include "schemes/decomp_wlsb.h"
38 #include "schemes/ip_id_offset.h"
39 #include "schemes/decomp_list.h"
40 #include "protocols/udp_lite.h"
41 #include "ip.h"
42 #include "crc.h"
43 
44 #include <stddef.h>
45 #include <stdbool.h>
46 
47 
48 /** The outer or inner IP bits extracted from ROHC headers */
50 {
51  uint8_t version:4; /**< The version bits found in static chain of IR
52  header */
53 
54  uint8_t tos; /**< The TOS/TC bits found in dynamic chain of IR/IR-DYN
55  header or in extension header */
56  size_t tos_nr; /**< The number of TOS/TC bits found */
57 
58  uint16_t id; /**< The IP-ID bits found in dynamic chain of IR/IR-DYN
59  header, in UO* base header, in extension header and
60  in remainder of UO* header */
61  size_t id_nr; /**< The number of IP-ID bits found */
62  bool is_id_enc; /**< Whether value(IP-ID) is encoded or not */
63 
64  uint8_t df:1; /**< The DF bits found in dynamic chain of IR/IR-DYN
65  header or in extension header */
66  size_t df_nr; /**< The number of DF bits found */
67 
68  uint8_t ttl; /**< The TTL/HL bits found in dynamic chain of IR/IR-DYN
69  header or in extension header */
70  size_t ttl_nr; /**< The number of TTL/HL bits found */
71 
72  uint8_t proto; /**< The protocol/next header bits found static chain
73  of IR header or in extension header */
74  size_t proto_nr; /**< The number of protocol/next header bits */
75 
76  uint8_t nbo:1; /**< The NBO bits found in dynamic chain of IR/IR-DYN
77  header or in extension header */
78  size_t nbo_nr; /**< The number of NBO bits found */
79 
80  uint8_t rnd:1; /**< The RND bits found in dynamic chain of IR/IR-DYN
81  header or in extension header */
82  size_t rnd_nr; /**< The number of RND bits found */
83 
84  uint8_t sid:1; /**< The SID bits found in dynamic chain of IR/IR-DYN
85  header or in extension header */
86  size_t sid_nr; /**< The number of SID bits found */
87 
88  uint32_t flowid:20; /**< The IPv6 flow ID bits found in static chain of
89  IR header */
90  size_t flowid_nr; /**< The number of flow label bits */
91 
92  uint8_t saddr[16]; /**< The source address bits found in static chain of
93  IR header */
94  size_t saddr_nr; /**< The number of source address bits */
95 
96  uint8_t daddr[16]; /**< The destination address bits found in static
97  chain of IR header */
98  size_t daddr_nr; /**< The number of source address bits */
99 };
100 
101 
102 /**
103  * @brief The bits extracted from ROHC UO* base headers
104  *
105  * @see parse_uo0
106  * @see parse_uo1
107  * @see parse_uor2
108  */
110 {
111  bool is_context_reused; /**< Whether the context is re-used or not */
112 
113  /* SN */
114  uint32_t sn; /**< The SN bits found in ROHC header */
115  size_t sn_nr; /**< The number of SN bits found in ROHC header */
116  bool is_sn_enc; /**< Whether value(SN) is encoded with W-LSB or not */
117  rohc_lsb_ref_t lsb_ref_type; /**< The reference to use for LSB decoding
118  (used for context repair after CRC failure) */
119  uint32_t sn_ref_offset; /**< Optional offset to add to the reference SN
120  (used for context repair after CRC failure) */
121 
122  /** Whether there are multiple IP headers or only one single IP header */
124 
125  /** bits related to outer IP header */
126  struct rohc_extr_ip_bits outer_ip;
127 
128  /** bits related to inner IP header */
129  struct rohc_extr_ip_bits inner_ip;
130 
131  /* X (extension) flag */
132  uint8_t ext_flag:1; /**< X (extension) flag */
133 
134  /* Mode bits */
135  uint8_t mode:2; /**< The Mode bits found in ROHC header */
136  size_t mode_nr; /**< The number of Mode bits found in ROHC header */
137 
138 
139  /* bits below are for UDP-based profiles only
140  @todo TODO should be moved in d_udp.c */
141 
142  uint16_t udp_src; /**< The UDP source port bits found in static chain
143  of IR header */
144  size_t udp_src_nr; /**< The number of UDP source port bits */
145 
146  uint16_t udp_dst; /**< The UDP destination port bits in static chain
147  of IR header */
148  size_t udp_dst_nr; /**< The number of UDP destination port bits */
149 
150  rohc_tristate_t udp_check_present; /**< Whether the UDP checksum field is
151  encoded in the ROHC packet or not */
152  uint16_t udp_check; /**< The UDP checksum bits found in dynamic chain
153  of IR/IR-DYN header or in remainder of UO*
154  header */
155  size_t udp_check_nr; /**< The number of UDP checksum bits */
156 
157 
158  /* bits below are for UDP-Lite-based profiles only
159  @todo TODO should be moved in d_udp_lite.c */
160 
162  rohc_tristate_t cfp; /**< TODO */
163  rohc_tristate_t cfi; /**< TODO */
164  uint16_t udp_lite_cc; /**< The UDP-Lite CC bits found in dynamic
165  chain of IR/IR-DYN header or in remainder
166  of UO* header */
167  size_t udp_lite_cc_nr; /**< The number of UDP-Lite CC bits */
168 
169 
170  /* bits below are for RTP profile only
171  @todo TODO should be moved in d_rtp.c */
172 
173  /* RTP version */
174  uint8_t rtp_version:2; /**< The RTP version bits found in dynamic chain
175  of IR/IR-DYN header */
176  size_t rtp_version_nr; /**< The number of RTP version bits */
177 
178  /* RTP Padding (R-P) flag */
179  uint8_t rtp_p:1; /**< The RTP Padding bits found in dynamic chain
180  of IR/IR-DYN header or in extension header */
181  size_t rtp_p_nr; /**< The number of RTP Padding bits */
182 
183  /* RTP eXtension (R-X) flag */
184  uint8_t rtp_x:1; /**< The RTP eXtension (R-X) bits found in
185  extension header */
186  size_t rtp_x_nr; /**< The number of RTP X bits */
187 
188  /* RTP CSRC Count (CC) */
189  uint8_t rtp_cc:4; /**< The RTP CSRC Count bits found in dynamic
190  chain of IR/IR-DYN header */
191  size_t rtp_cc_nr; /**< The number of the RTP CSRC Count bits */
192 
193  /* RTP Marker (M) flag */
194  uint8_t rtp_m:1; /**< The RTP Marker (M) bits found in dynamic chain
195  of IR/IR-DYN header, UO* base header and
196  extension header */
197  size_t rtp_m_nr; /**< The number of the RTP Marker (M) bits */
198 
199  /* RTP Payload Type (RTP-PT) */
200  uint8_t rtp_pt:7; /**< The RTP Payload Type (PT) bits found in
201  dynamic chain of IR/IR-DYN header or in
202  extension header */
203  size_t rtp_pt_nr; /**< The number of RTP PT bits found in header */
204 
205  /* RTP TimeStamp (TS) */
206  uint32_t ts; /**< The TS bits found in dynamic chain of
207  IR/IR-DYN header, in UO* base header or in
208  extension header */
209  size_t ts_nr; /**< The number of TS bits found in ROHC header */
210  bool is_ts_scaled; /**< Whether TS is transmitted scaled or not */
211 
212  /* RTP Synchronization SouRCe (SSRC) identifier */
213  uint32_t rtp_ssrc; /**< The SSRC bits found in static chain of
214  IR header */
215  size_t rtp_ssrc_nr; /**< The number of SSRC bits found in header */
216 
217 
218  /* bits below are for ESP profile only
219  @todo TODO should be moved in d_esp.c */
220 
221  /* ESP Security Parameters Index (SPI) */
222  uint32_t esp_spi; /**< The SPI bits found in static chain of
223  IR header */
224  size_t esp_spi_nr; /**< The number of SPI bits found in header */
225 };
226 
227 
228 /** The outer or inner IP values decoded from the extracted ROHC bits */
230 {
231  uint8_t version:4; /**< The decoded version field */
232  uint8_t tos; /**< The decoded TOS/TC field */
233  uint16_t id; /**< The decoded IP-ID field (IPv4 only) */
234  uint8_t df:1; /**< The decoded DF field (IPv4 only) */
235  uint8_t ttl; /**< The decoded TTL/HL field */
236  uint8_t proto; /**< The decoded protocol/NH field */
237  uint8_t nbo:1; /**< The decoded NBO field (IPv4 only) */
238  uint8_t rnd:1; /**< The decoded RND field (IPv4 only) */
239  uint8_t sid:1; /**< The decoded SID field (IPv4 only) */
240  uint32_t flowid:20; /**< The decoded flow ID field (IPv6 only) */
241  uint8_t saddr[16]; /**< The decoded source address field */
242  uint8_t daddr[16]; /**< The decoded destination address field */
243 };
244 
245 
246 /**
247  * @brief The values decoded from the bits extracted from ROHC header
248  *
249  * @see decode_values_from_bits
250  * @see rtp_decode_values_from_bits
251  */
253 {
254  bool is_context_reused; /**< Whether the context is re-used or not */
255 
256  uint32_t sn; /**< The decoded SN value */
257 
258  rohc_mode_t mode; /**< The operation mode asked by compressor */
259 
260  /** Whether there are multiple IP headers or only one single IP header */
262  /** The decoded values for the outer IP header */
263  struct rohc_decoded_ip_values outer_ip;
264  /** The decoded values for the inner IP header */
265  struct rohc_decoded_ip_values inner_ip;
266 
267  /* bits below are for UDP-based profile only
268  @todo TODO should be moved in d_udp.c */
269  uint16_t udp_src; /**< The decoded UDP source port */
270  uint16_t udp_dst; /**< The decoded UDP destination port bits */
271  uint16_t udp_check; /**< The decoded UDP checksum */
272  rohc_tristate_t udp_check_present; /**< Whether the UDP checksum field is
273  encoded in the ROHC packet or not */
274 
275  /* bits below are for UDP-Lite-based profile only
276  @todo TODO should be moved in d_udp_lite.c */
278  rohc_tristate_t cfp; /**< TODO */
279  rohc_tristate_t cfi; /**< TODO */
280  uint16_t udp_lite_cc; /**< The decoded UDP-Lite CC */
281 
282  /* bits below are for RTP profile only
283  @todo TODO should be moved in d_rtp.c */
284  uint8_t rtp_version:2; /**< The decoded RTP version */
285  uint8_t rtp_p:1; /**< The decoded RTP Padding (R-P) flag */
286  uint8_t rtp_x:1; /**< The decoded RTP eXtension (R-X) flag */
287  uint8_t rtp_cc:4; /**< The decoded RTP CSRC Count */
288  uint8_t rtp_m:1; /**< The decoded RTP Marker (M) flag */
289  uint8_t rtp_pt:7; /**< The decoded RTP Payload Type (RTP-PT) */
290  uint32_t ts; /**< The decoded RTP TimeStamp (TS) value */
291  uint32_t rtp_ssrc; /**< The decoded SSRC value */
292 
293  /* bits below are for ESP profile only
294  @todo TODO should be moved in d_esp.c */
295  uint32_t esp_spi; /**< The decoded ESP SPI */
296 };
297 
298 
299 /**
300  * @brief Store information about an IP header between the different
301  * decompressions of IP packets.
302  *
303  * Defines an object that contains flags and structures related to an IP header
304  * and that need to be saved between the different decompressions of packets. A
305  * decompression context owns objects like this for the two first IP headers.
306  */
308 {
309  /// The IP header
310  struct ip_packet ip;
311 
312  /// Whether the IP-ID is considered as random or not (IPv4 only)
313  int rnd;
314  /// Whether the IP-ID is considered as coded in NBO or not (IPv4 only)
315  int nbo;
316  /// Whether the IP-ID is considered as static or not (IPv4 only)
317  int sid;
318 
319  /// The next header located after the IP header(s)
320  void *next_header;
321  /// The length of the next header
322  unsigned int next_header_len;
323 };
324 
325 
326 /**
327  * @brief The generic decompression context for RFC3095-based profiles
328  *
329  * The object defines the generic context that manages IP(/nextheader) and
330  * IP/IP(/nextheader) packets. nextheader is managed by the profile-specific
331  * part of the context.
332  */
334 {
335  /// Information about the outer IP header
337  /// Information about the inner IP header
339 
340  /** The LSB shift parameter for the Sequence Number (SN) */
342  /// The LSB decoding context for the Sequence Number (SN)
343  struct rohc_lsb_decode sn_lsb_ctxt;
344  /// The IP-ID of the outer IP header
345  struct ip_id_offset_decode outer_ip_id_offset_ctxt;
346  /// The IP-ID of the inner IP header
347  struct ip_id_offset_decode inner_ip_id_offset_ctxt;
348 
349  /// The list decompressor of the outer IP header
350  struct list_decomp list_decomp1;
351  /// The list decompressor of the inner IP header
352  struct list_decomp list_decomp2;
353 
354  /// Whether the decompressed packet contains a 2nd IP header
356 
357  /** Whether the cache for the CRC-3 value on CRC-STATIC fields is initialized or not */
359  /** The cache for the CRC-3 value on CRC-STATIC fields */
361  /** Whether the cache for the CRC-7 value on CRC-STATIC fields is initialized or not */
363  /** The cache for the CRC-7 value on CRC-STATIC fields */
365 
366  /* below are some information and handlers to manage the next header
367  * (if any) located just after the IP headers (1 or 2 IP headers) */
368 
369  /// The IP protocol ID of the protocol the context is able to decompress
370  unsigned short next_header_proto;
371 
372  /// The length of the next header
373  unsigned int next_header_len;
374 
375  /// @brief The handler used to parse the static part of the next header
376  /// in the ROHC packet
377  int (*parse_static_next_hdr)(const struct rohc_decomp_ctxt *const context,
378  const uint8_t *packet,
379  size_t length,
380  struct rohc_extr_bits *const bits);
381 
382  /// @brief The handler used to parse the dynamic part of the next header
383  /// in the ROHC packet
384  int (*parse_dyn_next_hdr)(const struct rohc_decomp_ctxt *const context,
385  const uint8_t *packet,
386  const size_t length,
387  struct rohc_extr_bits *const bits);
388 
389  /**
390  * @brief The handler used to parse the extension 3 of the UO* ROHC packet
391  *
392  * @param context The decompression context
393  * @param rohc_data The ROHC data to parse
394  * @param rohc_data_len The length of the ROHC data to parse
395  * @param packet_type The type of ROHC packet to parse
396  * @param bits IN: the bits already found in base header
397  * OUT: the bits found in the extension header 3
398  * @return The data length read from the ROHC packet,
399  * -2 in case packet must be reparsed,
400  * -1 in case of error
401  */
402  int (*parse_ext3)(const struct rohc_decomp_ctxt *const context,
403  const uint8_t *const rohc_data,
404  const size_t rohc_data_len,
406  struct rohc_extr_bits *const bits)
407  __attribute__((warn_unused_result, nonnull(1, 2, 5)));
408 
409  /// The handler used to parse the tail of the UO* ROHC packet
410  int (*parse_uo_remainder)(const struct rohc_decomp_ctxt *const context,
411  const uint8_t *packet,
412  unsigned int length,
413  struct rohc_extr_bits *const bits);
414 
415  /** The handler used to decode extracted for next header */
416  bool (*decode_values_from_bits)(const struct rohc_decomp_ctxt *context,
417  const struct rohc_extr_bits *const bits,
418  struct rohc_decoded_values *const decoded)
419  __attribute__((warn_unused_result, nonnull(1, 2, 3)));
420 
421  /** The handler used to build the uncompressed next header */
422  int (*build_next_header)(const struct rohc_decomp_ctxt *const context,
423  const struct rohc_decoded_values *const decoded,
424  uint8_t *const dest,
425  const unsigned int payload_len);
426 
427  /// @brief The handler used to compute the CRC-STATIC value
428  uint8_t (*compute_crc_static)(const uint8_t *const ip,
429  const uint8_t *const ip2,
430  const uint8_t *const next_header,
431  const rohc_crc_type_t crc_type,
432  const uint8_t init_val,
433  const uint8_t *const crc_table);
434 
435  /// @brief The handler used to compute the CRC-DYNAMIC value
436  uint8_t (*compute_crc_dynamic)(const uint8_t *const ip,
437  const uint8_t *const ip2,
438  const uint8_t *const next_header,
439  const rohc_crc_type_t crc_type,
440  const uint8_t init_val,
441  const uint8_t *const crc_table);
442 
443  /** The handler used to update context with decoded next header fields */
444  void (*update_context)(struct rohc_decomp_ctxt *const context,
445  const struct rohc_decoded_values *const decoded)
446  __attribute__((nonnull(1, 2)));
447 
448  /// Profile-specific data
449  void *specific;
450 };
451 
452 
453 /*
454  * Public function prototypes.
455  */
456 
457 bool rohc_decomp_rfc3095_create(const struct rohc_decomp_ctxt *const context,
458  struct rohc_decomp_rfc3095_ctxt **const persist_ctxt,
459  struct rohc_decomp_volat_ctxt *const volat_ctxt,
460  rohc_trace_callback2_t trace_cb,
461  void *const trace_cb_priv,
462  const int profile_id)
463  __attribute__((warn_unused_result, nonnull(1, 2, 3)));
464 
465 void rohc_decomp_rfc3095_destroy(struct rohc_decomp_rfc3095_ctxt *const rfc3095_ctxt,
466  const struct rohc_decomp_volat_ctxt *const volat_ctxt)
467  __attribute__((nonnull(1, 2)));
468 
469 bool rfc3095_decomp_parse_pkt(const struct rohc_decomp_ctxt *const context,
470  const struct rohc_buf rohc_packet,
471  const size_t large_cid_len,
472  rohc_packet_t *const packet_type,
473  struct rohc_decomp_crc *const extr_crc,
474  struct rohc_extr_bits *const bits,
475  size_t *const rohc_hdr_len)
476  __attribute__((warn_unused_result, nonnull(1, 4, 5, 6, 7)));
477 
478 rohc_status_t rfc3095_decomp_build_hdrs(const struct rohc_decomp *const decomp,
479  const struct rohc_decomp_ctxt *const context,
480  const rohc_packet_t packet_type,
481  const struct rohc_decomp_crc *const extr_crc,
482  const struct rohc_decoded_values *const decoded,
483  const size_t payload_len,
484  struct rohc_buf *const uncomp_hdrs,
485  size_t *const uncomp_hdrs_len)
486  __attribute__((warn_unused_result, nonnull(1, 2, 4, 5, 7, 8)));
487 
488 bool rfc3095_decomp_decode_bits(const struct rohc_decomp_ctxt *const context,
489  const struct rohc_extr_bits *const bits,
490  const size_t payload_len __attribute__((unused)),
491  struct rohc_decoded_values *const decoded)
492  __attribute__((warn_unused_result, nonnull(1, 2, 4)));
493 
494 void rfc3095_decomp_update_ctxt(struct rohc_decomp_ctxt *const context,
495  const struct rohc_decoded_values *const decoded,
496  const size_t payload_len,
497  bool *const do_change_mode)
498  __attribute__((nonnull(1, 2, 4)));
499 
500 bool rfc3095_decomp_attempt_repair(const struct rohc_decomp *const decomp,
501  const struct rohc_decomp_ctxt *const context,
502  const struct rohc_ts pkt_arrival_time,
503  struct rohc_decomp_crc_corr_ctxt *const crc_corr,
504  struct rohc_extr_bits *const extr_bits)
505  __attribute__((warn_unused_result, nonnull(1, 2, 4, 5)));
506 
507 uint32_t rohc_decomp_rfc3095_get_sn(const struct rohc_decomp_ctxt *const context)
508  __attribute__((warn_unused_result, nonnull(1)));
509 
510 
511 
512 /*
513  * Helper functions
514  */
515 
516 
517 static inline bool is_ipv4_pkt(const struct rohc_extr_ip_bits *const bits)
518  __attribute__((warn_unused_result, pure, always_inline));
519 
520 static inline bool is_ipv4_rnd_pkt(const struct rohc_extr_ip_bits *const bits)
521  __attribute__((warn_unused_result, pure, always_inline));
522 
523 static inline bool is_ipv4_non_rnd_pkt(const struct rohc_extr_ip_bits *const bits)
524  __attribute__((warn_unused_result, pure, always_inline));
525 
526 
527 /**
528  * @brief Is the given IP header IPV4 wrt packet?
529  *
530  * @param bits The bits extracted from packet
531  * @return true if IPv4, false if IPv6
532  */
533 static inline bool is_ipv4_pkt(const struct rohc_extr_ip_bits *const bits)
534 {
535  return (bits->version == IPV4);
536 }
537 
538 
539 /**
540  * @brief Is the given IP header IPv4 and its IP-ID random wrt packet?
541  *
542  * @param bits The bits extracted from packet
543  * @return true if IPv4 and random, false otherwise
544  */
545 static inline bool is_ipv4_rnd_pkt(const struct rohc_extr_ip_bits *const bits)
546 {
547  return (is_ipv4_pkt(bits) && bits->rnd == 1);
548 }
549 
550 
551 /**
552  * @brief Is the given IP header IPv4 and its IP-ID non-random wrt packet?
553  *
554  * @param bits The bits extracted from packet
555  * @return true if IPv4 and non-random, false otherwise
556  */
557 static inline bool is_ipv4_non_rnd_pkt(const struct rohc_extr_ip_bits *const bits)
558 {
559  return (is_ipv4_pkt(bits) && bits->rnd == 0);
560 }
561 
562 
563 #endif
564 
bool rfc3095_decomp_parse_pkt(const struct rohc_decomp_ctxt *const context, const struct rohc_buf rohc_packet, const size_t large_cid_len, rohc_packet_t *const packet_type, struct rohc_decomp_crc *const extr_crc, struct rohc_extr_bits *const bits, size_t *const rohc_hdr_len)
Parse one IR, IR-DYN, UO-0, UO-1*, or UOR-2* packet.
Definition: rohc_decomp_rfc3095.c:505
rohc_lsb_shift_t
the different values of the shift parameter of the LSB algorithm
Definition: interval.h:45
static bool is_ipv4_pkt(const struct rohc_extr_ip_bits *const bits)
Is the given IP header IPV4 wrt packet?
Definition: rohc_decomp_rfc3095.h:533
uint32_t sn
Definition: rohc_decomp_rfc3095.h:256
uint8_t proto
Definition: rohc_decomp_rfc3095.h:72
uint32_t esp_spi
Definition: rohc_decomp_rfc3095.h:222
The ROHC decompressor.
Definition: rohc_decomp_internals.h:142
size_t udp_dst_nr
Definition: rohc_decomp_rfc3095.h:148
size_t rtp_ssrc_nr
Definition: rohc_decomp_rfc3095.h:215
uint8_t rtp_pt
Definition: rohc_decomp_rfc3095.h:200
rohc_tristate_t cfi
Definition: rohc_decomp_rfc3095.h:279
uint8_t crc_static_7_cached
Definition: rohc_decomp_rfc3095.h:364
bool is_crc_static_7_cached_valid
Definition: rohc_decomp_rfc3095.h:362
uint16_t udp_lite_cc
Definition: rohc_decomp_rfc3095.h:164
uint32_t sn
Definition: rohc_decomp_rfc3095.h:114
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:109
size_t rtp_pt_nr
Definition: rohc_decomp_rfc3095.h:203
static bool parse_uo_remainder(const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_packet, const size_t rohc_length, struct rohc_extr_bits *const bits, size_t *const rohc_hdr_len)
Parse the remainder of the UO* header.
Definition: rohc_decomp_rfc3095.c:4277
static bool is_ipv4_non_rnd_pkt(const struct rohc_extr_ip_bits *const bits)
Is the given IP header IPv4 and its IP-ID non-random wrt packet?
Definition: rohc_decomp_rfc3095.h:557
uint16_t udp_lite_cc
Definition: rohc_decomp_rfc3095.h:280
The generic decompression context for RFC3095-based profiles.
Definition: rohc_decomp_rfc3095.h:333
static void update_context(struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
Update the compression context with the successfully compressed packet.
Definition: rohc_comp_rfc3095.c:6150
rohc_tristate_t udp_check_present
Definition: rohc_decomp_rfc3095.h:150
The volatile part of the ROHC decompression context.
Definition: rohc_decomp_internals.h:256
bool rohc_decomp_rfc3095_create(const struct rohc_decomp_ctxt *const context, struct rohc_decomp_rfc3095_ctxt **const persist_ctxt, struct rohc_decomp_volat_ctxt *const volat_ctxt, rohc_trace_callback2_t trace_cb, void *const trace_cb_priv, const int profile_id)
Create the RFC3095 volatile and persistent parts of the context.
Definition: rohc_decomp_rfc3095.c:362
rohc_packet_t packet_type
Definition: rohc_decomp_internals.h:310
uint8_t rnd
Definition: rohc_decomp_rfc3095.h:238
size_t nbo_nr
Definition: rohc_decomp_rfc3095.h:78
uint8_t rtp_cc
Definition: rohc_decomp_rfc3095.h:189
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:391
rohc_status_t
The status code of several functions in the library API.
Definition: rohc.h:77
uint8_t version
Definition: rohc_decomp_rfc3095.h:231
size_t tos_nr
Definition: rohc_decomp_rfc3095.h:56
struct rohc_decomp_rfc3095_changes * inner_ip_changes
Information about the inner IP header.
Definition: rohc_decomp_rfc3095.h:338
unsigned int next_header_len
The length of the next header.
Definition: rohc_decomp_rfc3095.h:373
uint8_t sid
Definition: rohc_decomp_rfc3095.h:84
uint16_t udp_src
Definition: rohc_decomp_rfc3095.h:142
The bits extracted from ROHC UO* base headers.
Definition: rohc_decomp_rfc3095.h:109
The context for list decompression.
Definition: decomp_list.h:51
ROHC CRC routines.
struct rohc_decomp_rfc3095_changes * outer_ip_changes
Information about the outer IP header.
Definition: rohc_decomp_rfc3095.h:336
uint8_t rtp_m
Definition: rohc_decomp_rfc3095.h:288
rohc_packet_cce_t cce_pkt
Definition: rohc_decomp_rfc3095.h:161
size_t rtp_x_nr
Definition: rohc_decomp_rfc3095.h:186
size_t rtp_p_nr
Definition: rohc_decomp_rfc3095.h:181
bool is_crc_static_3_cached_valid
Definition: rohc_decomp_rfc3095.h:358
uint32_t ts
Definition: rohc_decomp_rfc3095.h:206
size_t rtp_m_nr
Definition: rohc_decomp_rfc3095.h:197
Internal structures for ROHC decompression.
rohc_lsb_ref_t lsb_ref_type
Definition: rohc_decomp_rfc3095.h:117
The Least Significant Bits (LSB) decoding object.
Definition: decomp_wlsb.h:57
void(* rohc_trace_callback2_t)(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...)
The function prototype for the trace callback.
Definition: rohc_traces.h:118
size_t saddr_nr
Definition: rohc_decomp_rfc3095.h:94
rohc_tristate_t cfi
Definition: rohc_decomp_rfc3095.h:163
rohc_packet_cce_t
Definition: udp_lite.h:32
Miscellaneous utils for ROHC libraries.
rohc_lsb_shift_t sn_lsb_p
Definition: rohc_decomp_rfc3095.h:341
size_t id_nr
Definition: rohc_decomp_rfc3095.h:61
Defines a IP-ID object to help computing the IP-ID value from an IP-ID offset.
Definition: decomp/schemes/ip_id_offset.h:45
uint32_t sn_ref_offset
Definition: rohc_decomp_rfc3095.h:119
uint8_t rtp_p
Definition: rohc_decomp_rfc3095.h:285
uint16_t id
Definition: rohc_decomp_rfc3095.h:233
Define the UDP-Lite protocol.
uint8_t rtp_version
Definition: rohc_decomp_rfc3095.h:284
void rfc3095_decomp_update_ctxt(struct rohc_decomp_ctxt *const context, const struct rohc_decoded_values *const decoded, const size_t payload_len, bool *const do_change_mode)
Update context with decoded values.
Definition: rohc_decomp_rfc3095.c:6141
uint8_t df
Definition: rohc_decomp_rfc3095.h:234
uint16_t udp_check
Definition: rohc_decomp_rfc3095.h:152
rohc_tristate_t cfp
Definition: rohc_decomp_rfc3095.h:162
uint8_t crc_static_3_cached
Definition: rohc_decomp_rfc3095.h:360
void * next_header
The next header located after the IP header(s)
Definition: rohc_decomp_rfc3095.h:320
bool is_sn_enc
Definition: rohc_decomp_rfc3095.h:116
rohc_status_t rfc3095_decomp_build_hdrs(const struct rohc_decomp *const decomp, const struct rohc_decomp_ctxt *const context, const rohc_packet_t packet_type, const struct rohc_decomp_crc *const extr_crc, const struct rohc_decoded_values *const decoded, const size_t payload_len, struct rohc_buf *const uncomp_hdrs, size_t *const uncomp_hdrs_len)
Build the uncompressed headers.
Definition: rohc_decomp_rfc3095.c:4961
size_t esp_spi_nr
Definition: rohc_decomp_rfc3095.h:224
size_t rnd_nr
Definition: rohc_decomp_rfc3095.h:82
uint8_t rtp_x
Definition: rohc_decomp_rfc3095.h:184
uint16_t udp_dst
Definition: rohc_decomp_rfc3095.h:270
void * specific
Profile-specific data.
Definition: rohc_decomp_rfc3095.h:449
uint8_t daddr[16]
Definition: rohc_decomp_rfc3095.h:96
uint8_t df
Definition: rohc_decomp_rfc3095.h:64
uint8_t ttl
Definition: rohc_decomp_rfc3095.h:235
uint8_t proto
Definition: rohc_decomp_rfc3095.h:236
uint16_t udp_src
Definition: rohc_decomp_rfc3095.h:269
size_t rtp_version_nr
Definition: rohc_decomp_rfc3095.h:176
uint8_t sid
Definition: rohc_decomp_rfc3095.h:239
uint32_t flowid
Definition: rohc_decomp_rfc3095.h:240
size_t daddr_nr
Definition: rohc_decomp_rfc3095.h:98
uint8_t rnd
Definition: rohc_decomp_rfc3095.h:80
size_t rtp_cc_nr
Definition: rohc_decomp_rfc3095.h:191
bool multiple_ip
Definition: rohc_decomp_rfc3095.h:123
uint16_t id
Definition: rohc_decomp_rfc3095.h:58
unsigned int next_header_len
The length of the next header.
Definition: rohc_decomp_rfc3095.h:322
uint32_t ts
Definition: rohc_decomp_rfc3095.h:290
Window-based Least Significant Bits (W-LSB) decoding.
size_t udp_check_nr
Definition: rohc_decomp_rfc3095.h:155
size_t udp_src_nr
Definition: rohc_decomp_rfc3095.h:144
size_t proto_nr
Definition: rohc_decomp_rfc3095.h:74
uint32_t rtp_ssrc
Definition: rohc_decomp_rfc3095.h:291
rohc_crc_type_t
Definition: crc.h:56
A network buffer for the ROHC library.
Definition: rohc_buf.h:102
Store information about an IP header between the different decompressions of IP packets.
Definition: rohc_decomp_rfc3095.h:307
uint8_t rtp_cc
Definition: rohc_decomp_rfc3095.h:287
unsigned short next_header_proto
The IP protocol ID of the protocol the context is able to decompress.
Definition: rohc_decomp_rfc3095.h:370
A timestamp for the ROHC library.
Definition: rohc_time.h:51
uint16_t udp_check
Definition: rohc_decomp_rfc3095.h:271
rohc_tristate_t udp_check_present
Definition: rohc_decomp_rfc3095.h:272
uint8_t tos
Definition: rohc_decomp_rfc3095.h:232
bool rfc3095_decomp_decode_bits(const struct rohc_decomp_ctxt *const context, const struct rohc_extr_bits *const bits, const size_t payload_len, struct rohc_decoded_values *const decoded)
Decode values from extracted bits.
Definition: rohc_decomp_rfc3095.c:5635
uint8_t rtp_x
Definition: rohc_decomp_rfc3095.h:286
ROHC generic list decompression.
Definition: rohc_decomp_rfc3095.h:229
static bool is_ipv4_rnd_pkt(const struct rohc_extr_ip_bits *const bits)
Is the given IP header IPv4 and its IP-ID random wrt packet?
Definition: rohc_decomp_rfc3095.h:545
size_t mode_nr
Definition: rohc_decomp_rfc3095.h:136
size_t df_nr
Definition: rohc_decomp_rfc3095.h:66
size_t ttl_nr
Definition: rohc_decomp_rfc3095.h:70
uint32_t rtp_ssrc
Definition: rohc_decomp_rfc3095.h:213
bool is_ts_scaled
Definition: rohc_decomp_rfc3095.h:210
int rnd
Whether the IP-ID is considered as random or not (IPv4 only)
Definition: rohc_decomp_rfc3095.h:313
Definition: rohc_decomp_internals.h:241
Definition of ROHC packets and extensions.
uint8_t version
Definition: rohc_decomp_rfc3095.h:51
The ROHC decompression context.
Definition: rohc_decomp_internals.h:274
uint8_t nbo
Definition: rohc_decomp_rfc3095.h:237
uint8_t rtp_m
Definition: rohc_decomp_rfc3095.h:194
rohc_tristate_t cfp
Definition: rohc_decomp_rfc3095.h:278
uint16_t udp_dst
Definition: rohc_decomp_rfc3095.h:146
bool is_context_reused
Definition: rohc_decomp_rfc3095.h:111
Definition: rohc_decomp_internals.h:223
uint8_t rtp_p
Definition: rohc_decomp_rfc3095.h:179
int nbo
Whether the IP-ID is considered as coded in NBO or not (IPv4 only)
Definition: rohc_decomp_rfc3095.h:315
rohc_lsb_ref_t
Definition: decomp_wlsb.h:43
void rohc_decomp_rfc3095_destroy(struct rohc_decomp_rfc3095_ctxt *const rfc3095_ctxt, const struct rohc_decomp_volat_ctxt *const volat_ctxt)
Destroy the context.
Definition: rohc_decomp_rfc3095.c:460
bool multiple_ip
Definition: rohc_decomp_rfc3095.h:261
size_t flowid_nr
Definition: rohc_decomp_rfc3095.h:90
bool is_context_reused
Definition: rohc_decomp_rfc3095.h:254
Defines an IP-agnostic packet that can handle an IPv4 or IPv6 packet.
Definition: ip.h:77
IP version 4.
Definition: ip.h:52
size_t udp_lite_cc_nr
Definition: rohc_decomp_rfc3095.h:167
uint8_t saddr[16]
Definition: rohc_decomp_rfc3095.h:92
uint8_t ext_flag
Definition: rohc_decomp_rfc3095.h:132
size_t sid_nr
Definition: rohc_decomp_rfc3095.h:86
rohc_mode_t mode
Definition: rohc_decomp_rfc3095.h:258
The values decoded from the bits extracted from ROHC header.
Definition: rohc_decomp_rfc3095.h:252
uint32_t rohc_decomp_rfc3095_get_sn(const struct rohc_decomp_ctxt *const context)
Get the reference SN value of the context.
Definition: rohc_decomp_rfc3095.c:1327
uint32_t flowid
Definition: rohc_decomp_rfc3095.h:88
size_t sn_nr
Definition: rohc_decomp_rfc3095.h:115
uint8_t rtp_version
Definition: rohc_decomp_rfc3095.h:174
uint8_t nbo
Definition: rohc_decomp_rfc3095.h:76
uint8_t ttl
Definition: rohc_decomp_rfc3095.h:68
rohc_tristate_t
Definition: rohc_utils.h:33
rohc_packet_cce_t cce_pkt
Definition: rohc_decomp_rfc3095.h:277
uint8_t tos
Definition: rohc_decomp_rfc3095.h:54
ROHC decompression routines.
uint8_t rtp_pt
Definition: rohc_decomp_rfc3095.h:289
Definition: rohc_decomp_rfc3095.h:49
rohc_packet_t
The different types of ROHC packets.
Definition: rohc_packets.h:55
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:298
uint8_t mode
Definition: rohc_decomp_rfc3095.h:135
int sid
Whether the IP-ID is considered as static or not (IPv4 only)
Definition: rohc_decomp_rfc3095.h:317
uint32_t esp_spi
Definition: rohc_decomp_rfc3095.h:295
bool is_id_enc
Definition: rohc_decomp_rfc3095.h:62
int multiple_ip
Whether the decompressed packet contains a 2nd IP header.
Definition: rohc_decomp_rfc3095.h:355
bool rfc3095_decomp_attempt_repair(const struct rohc_decomp *const decomp, const struct rohc_decomp_ctxt *const context, const struct rohc_ts pkt_arrival_time, struct rohc_decomp_crc_corr_ctxt *const crc_corr, struct rohc_extr_bits *const extr_bits)
Attempt a packet/context repair upon CRC failure.
Definition: rohc_decomp_rfc3095.c:5438
size_t ts_nr
Definition: rohc_decomp_rfc3095.h:209