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