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