ROHC compression/decompression library
rohc_comp_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,2014 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_comp_rfc3095.h
23  * @brief Generic framework for RFC3095-based compression 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  */
28 
29 #ifndef ROHC_COMP_RFC3095_H
30 #define ROHC_COMP_RFC3095_H
31 
32 #include "rohc_comp_internals.h"
33 #include "rohc_packets.h"
34 #include "schemes/comp_list.h"
35 #include "ip.h"
36 #include "crc.h"
37 
38 #include <stdlib.h>
39 
40 
41 /**
42  * @brief Store information about an IPv4 header between the different
43  * compressions of IP packets.
44  *
45  * Defines an object that contains counters, flags and structures related to an
46  * IPv4 header and that need to be saved between the different compressions of
47  * packets. A compression context owns objects like this for the two first
48  * IPv4 headers.
49  */
51 {
52  /// A window to store the IP-ID
54 
55  /// The previous IP header
56  struct ipv4_hdr old_ip;
57 
58  /// The number of times the DF field was added to the compressed header
59  size_t df_count;
60  /// @brief The number of times the IP-ID is specified as random in the
61  /// compressed header
62  size_t rnd_count;
63  /// @brief The number of times the IP-ID is specified as coded in Network
64  /// Byte Order (NBO) in the compressed header
65  size_t nbo_count;
66  /// @brief The number of times the IP-ID is specified as static in the
67  /// compressed header
68  size_t sid_count;
69 
70  /// Whether the IP-ID is considered as random or not
71  int rnd;
72  /// Whether the IP-ID is considered as coded in NBO or not
73  int nbo;
74  /// Whether the IP-ID is considered as static or not
75  int sid;
76  /// @brief Whether the IP-ID of the previous IP header was considered as
77  /// random or not
78  int old_rnd;
79  /// @brief Whether the IP-ID of the previous IP header was considered as
80  /// coded in NBO or not
81  int old_nbo;
82  /// @brief Whether the IP-ID of the previous IP header was considered as
83  /// static or not
84  int old_sid;
85 
86  /// The delta between the IP-ID and the current Sequence Number (SN)
87  /// (overflow over 16 bits is expected when SN > IP-ID)
88  uint16_t id_delta;
89 };
90 
91 
92 /**
93  * @brief Store information about an IPv6 header between the different
94  * compressions of IP packets.
95  *
96  * Defines an object that contains counters, flags and structures related to an
97  * IPv6 header and that need to be saved between the different compressions of
98  * packets. A compression context owns objects like this for the two first
99  * IPv6 headers.
100  */
102 {
103  /// The previous IPv6 header
104  struct ipv6_hdr old_ip;
105  /// The extension compressor
107 };
108 
109 
110 /**
111  * @brief Store information about an IP (IPv4 or IPv6) header between the
112  * different compressions of IP packets.
113  */
115 {
116  ip_version version; ///< The version of the IP header
117 
118  /// The number of times the TOS/TC field was added to the compressed header
119  size_t tos_count;
120  /// The number of times the TTL/HL field was added to the compressed header
121  size_t ttl_count;
122  /// @brief The number of times the Protocol/Next Header field was added to
123  /// the compressed header
125 
126  /** Whether the old_* members of the struct and in its children are
127  * initialized or not */
129 
130  union
131  {
132  struct ipv4_header_info v4; ///< The IPv4-specific header info
133  struct ipv6_header_info v6; ///< The IPv6-specific header info
134  } info; ///< The version specific header info
135 };
136 
137 
138 /**
139  * @brief Structure that contains variables that are used during one single
140  * compression of packet.
141  *
142  * Structure that contains variables that are temporary, i.e. variables that
143  * will only be used for the compression of the current packet. These variables
144  * must be reinitialized every time a new packet arrive.
145  *
146  * @see c_init_tmp_variables
147  */
149 {
150  /// The number of fields that changed in the outer IP header
151  unsigned short changed_fields;
152  /// The number of fields that changed in the inner IP header
153  unsigned short changed_fields2;
154  /// The number of static fields that changed in the two IP headers
156  /// The number of dynamic fields that changed in the two IP headers
158 
159  /// The number of bits needed to encode the Sequence Number (SN)
161  /// The number of bits needed to encode the Sequence Number (SN)
163 
164  /// The number of bits needed to encode the IP-ID of the outer IP header
166  /// The number of bits needed to encode the IP-ID of the inner IP header
168 
169  /// The type of packet the compressor must send: IR, IR-DYN, UO*
171 };
172 
173 
174 /**
175  * @brief The generic decompression context for RFC3095-based profiles
176  *
177  * The object defines the generic context that manages IP(/nextheader) and
178  * IP/IP(/nextheader) packets. nextheader is managed by the profile-specific
179  * part of the context.
180  */
182 {
183  /// The Sequence Number (SN), may be 16-bit or 32-bit long
184  uint32_t sn;
185  /// A window used to encode the SN
186  struct c_wlsb *sn_window;
187 
188  /** The number of IP headers */
189  size_t ip_hdr_nr;
190  /// Information about the outer IP header
192  /// Information about the inner IP header
194 
195  /// Temporary variables that are used during one single compression of packet
197 
198  /* below are some information and handlers to manage the next header
199  * (if any) located just after the IP headers (1 or 2 IP headers) */
200 
201  /// The protocol number registered by IANA for the next header protocol
202  unsigned int next_header_proto;
203  /// The length of the next header
204  unsigned int next_header_len;
205 
206  /** The handler for encoding profile-specific uncompressed header fields */
207  bool (*encode_uncomp_fields)(struct rohc_comp_ctxt *const context,
208  const struct net_pkt *const uncomp_pkt)
209  __attribute__((warn_unused_result, nonnull(1, 2)));
210 
211  /// @brief The handler used to decide the state that should be used for the
212  /// next packet
213  void (*decide_state)(struct rohc_comp_ctxt *const context);
214  /** @brief The handler used to decide which packet to send in FO state */
215  rohc_packet_t (*decide_FO_packet)(const struct rohc_comp_ctxt *context);
216  /** @brief The handler used to decide which packet to send in SO state */
217  rohc_packet_t (*decide_SO_packet)(const struct rohc_comp_ctxt *context);
218  /** The handler used to decide which extension to send */
219  rohc_ext_t (*decide_extension)(const struct rohc_comp_ctxt *context);
220 
221  /// The handler used to initialize some data just before the IR packet build
222  void (*init_at_IR)(struct rohc_comp_ctxt *const context,
223  const uint8_t *const next_header);
224 
225  /** Determine the next SN value */
226  uint32_t (*get_next_sn)(const struct rohc_comp_ctxt *const context,
227  const struct net_pkt *const uncomp_pkt)
228  __attribute__((warn_unused_result, nonnull(1, 2)));
229 
230  /// @brief The handler used to add the static part of the next header to the
231  /// ROHC packet
232  size_t (*code_static_part)(const struct rohc_comp_ctxt *const context,
233  const uint8_t *const next_header,
234  uint8_t *const dest,
235  const size_t counter)
236  __attribute__((warn_unused_result, nonnull(1, 2, 3)));
237 
238  /// @brief The handler used to add the dynamic part of the next header to the
239  /// ROHC pachet
240  size_t (*code_dynamic_part)(const struct rohc_comp_ctxt *const context,
241  const uint8_t *const next_header,
242  uint8_t *const dest,
243  const size_t counter)
244  __attribute__((warn_unused_result, nonnull(1, 2, 3)));
245 
246  /// @brief The handler used to add the IR/IR-DYN remainder header to the
247  /// ROHC pachet
248  int (*code_ir_remainder)(const struct rohc_comp_ctxt *const context,
249  uint8_t *const dest,
250  const size_t dest_max_len,
251  const size_t counter)
252  __attribute__((warn_unused_result, nonnull(1, 2)));
253 
254  /// @brief The handler used to add an additional header in the head of the
255  /// UO-0, UO-1 and UO-2 packets
256  size_t (*code_UO_packet_head)(const struct rohc_comp_ctxt *const context,
257  const uint8_t *const next_header,
258  uint8_t *const dest,
259  const size_t counter,
260  size_t *const first_position)
261  __attribute__((warn_unused_result, nonnull(1,2, 3, 5)));
262 
263  /// @brief The handler used to add an additional header in the tail of the
264  /// UO-0, UO-1 and UO-2 packets
265  size_t (*code_uo_remainder)(const struct rohc_comp_ctxt *const context,
266  const uint8_t *const next_header,
267  uint8_t *const dest,
268  const size_t counter)
269  __attribute__((warn_unused_result, nonnull(1, 2, 3)));
270 
271  /// @brief The handler used to compute the CRC-STATIC value
272  uint8_t (*compute_crc_static)(const uint8_t *const ip,
273  const uint8_t *const ip2,
274  const uint8_t *const next_header,
275  const rohc_crc_type_t crc_type,
276  const uint8_t init_val,
277  const uint8_t *const crc_table)
278  __attribute__((nonnull(1, 3, 6), warn_unused_result));
279 
280  /// @brief The handler used to compute the CRC-DYNAMIC value
281  uint8_t (*compute_crc_dynamic)(const uint8_t *const ip,
282  const uint8_t *const ip2,
283  const uint8_t *const next_header,
284  const rohc_crc_type_t crc_type,
285  const uint8_t init_val,
286  const uint8_t *const crc_table)
287  __attribute__((nonnull(1, 3, 6), warn_unused_result));
288 
289  /// Profile-specific data
290  void *specific;
291 };
292 
293 
294 /*
295  * Function prototypes.
296  */
297 
298 bool rohc_comp_rfc3095_create(struct rohc_comp_ctxt *const context,
299  const rohc_lsb_shift_t sn_shift,
300  const struct net_pkt *const packet)
301  __attribute__((warn_unused_result, nonnull(1, 3)));
302 
303 void rohc_comp_rfc3095_destroy(struct rohc_comp_ctxt *const context)
304  __attribute__((nonnull(1)));
305 
306 bool rohc_comp_rfc3095_check_profile(const struct rohc_comp *const comp,
307  const struct net_pkt *const packet)
308  __attribute__((warn_unused_result, nonnull(1, 2)));
309 
310 rohc_ext_t decide_extension(const struct rohc_comp_ctxt *const context)
311  __attribute__((warn_unused_result, nonnull(1)));
312 
313 int rohc_comp_rfc3095_encode(struct rohc_comp_ctxt *const context,
314  const struct net_pkt *const uncomp_pkt,
315  uint8_t *const rohc_pkt,
316  const size_t rohc_pkt_max_len,
317  rohc_packet_t *const packet_type,
318  size_t *const payload_offset)
319  __attribute__((warn_unused_result, nonnull(1, 2, 3, 5, 6)));
320 
321 bool rohc_comp_rfc3095_feedback(struct rohc_comp_ctxt *const context,
322  const enum rohc_feedback_type feedback_type,
323  const uint8_t *const packet,
324  const size_t packet_len,
325  const uint8_t *const feedback_data,
326  const size_t feedback_data_len)
327  __attribute__((warn_unused_result, nonnull(1, 3, 5)));
328 
329 void rohc_comp_rfc3095_decide_state(struct rohc_comp_ctxt *const context)
330  __attribute__((nonnull(1)));
331 
332 void rohc_get_ipid_bits(const struct rohc_comp_ctxt *const context,
333  size_t *const nr_innermost_bits,
334  size_t *const nr_outermost_bits)
335  __attribute__((nonnull(1, 2, 3)));
336 
337 bool rohc_comp_rfc3095_is_sn_possible(const struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt,
338  const size_t bits_nr,
339  const size_t add_bits_nr)
340  __attribute__((warn_unused_result, nonnull(1), pure));
341 
342 
343 /**
344  * @brief Does the outer IP header require to transmit no non-random IP-ID bit?
345  *
346  * @param ctxt The generic decompression context
347  * @return true if no required outer IP-ID bit shall be transmitted,
348  * false otherwise
349  */
350 static inline bool no_outer_ip_id_bits_required(const struct rohc_comp_rfc3095_ctxt *const ctxt)
351 {
352  return (ctxt->outer_ip_flags.version != IPV4 ||
353  ctxt->outer_ip_flags.info.v4.rnd == 1 ||
354  ctxt->tmp.nr_ip_id_bits == 0);
355 }
356 
357 
358 /**
359  * @brief May the outer IP header transmit the required non-random IP-ID bits?
360  *
361  * @param ctxt The generic decompression context
362  * @param max_ip_id_bits_nr The maximum number of IP-ID bits that may be transmitted
363  * @return true if the required IP-ID bits may be transmitted,
364  * false otherwise
365  */
366 static inline bool is_outer_ip_id_bits_possible(const struct rohc_comp_rfc3095_ctxt *const ctxt,
367  const size_t max_ip_id_bits_nr)
368 {
369  return (ctxt->outer_ip_flags.version == IPV4 &&
370  ctxt->outer_ip_flags.info.v4.rnd != 1 &&
371  ctxt->tmp.nr_ip_id_bits <= max_ip_id_bits_nr);
372 }
373 
374 
375 /**
376  * @brief Does the inner IP header require to transmit no non-random IP-ID bit?
377  *
378  * @param ctxt The generic decompression context
379  * @return true if no required inner IP-ID bit shall be transmitted,
380  * false otherwise
381  */
382 static inline bool no_inner_ip_id_bits_required(const struct rohc_comp_rfc3095_ctxt *const ctxt)
383 {
384  return (ctxt->inner_ip_flags.version != IPV4 ||
385  ctxt->inner_ip_flags.info.v4.rnd == 1 ||
386  ctxt->tmp.nr_ip_id_bits2 == 0);
387 }
388 
389 
390 /**
391  * @brief May the inner IP header transmit the required non-random IP-ID bits?
392  *
393  * @param ctxt The generic decompression context
394  * @param max_ip_id_bits_nr The maximum number of IP-ID bits that may be transmitted
395  * @return true if the required IP-ID bits may be transmitted,
396  * false otherwise
397  */
398 static inline bool is_inner_ip_id_bits_possible(const struct rohc_comp_rfc3095_ctxt *const ctxt,
399  const size_t max_ip_id_bits_nr)
400 {
401  return (ctxt->inner_ip_flags.version == IPV4 &&
402  ctxt->inner_ip_flags.info.v4.rnd != 1 &&
403  ctxt->tmp.nr_ip_id_bits2 <= max_ip_id_bits_nr);
404 }
405 
406 
407 /**
408  * @brief How many IP headers are IPv4 headers with non-random IP-IDs ?
409  *
410  * @param ctxt The generic decompression context
411  * @return The number of IPv4 headers with non-random IP-ID fields
412  */
413 static inline size_t get_nr_ipv4_non_rnd(const struct rohc_comp_rfc3095_ctxt *const ctxt)
414 {
415  size_t nr_ipv4_non_rnd = 0;
416 
417  /* outer IP header */
418  if(ctxt->outer_ip_flags.version == IPV4 && ctxt->outer_ip_flags.info.v4.rnd != 1)
419  {
420  nr_ipv4_non_rnd++;
421  }
422 
423  /* optional inner IP header */
424  if(ctxt->ip_hdr_nr >= 1 &&
425  ctxt->inner_ip_flags.version == IPV4 &&
426  ctxt->inner_ip_flags.info.v4.rnd != 1)
427  {
428  nr_ipv4_non_rnd++;
429  }
430 
431  return nr_ipv4_non_rnd;
432 }
433 
434 
435 /**
436  * @brief How many IP headers are IPv4 headers with non-random IP-IDs and some
437  * bits to transmit ?
438  *
439  * @param ctxt The generic decompression context
440  * @return The number of IPv4 headers with non-random IP-ID fields and some
441  * bits to transmit
442  */
443 static inline size_t get_nr_ipv4_non_rnd_with_bits(const struct rohc_comp_rfc3095_ctxt *const ctxt)
444 {
445  size_t nr_ipv4_non_rnd_with_bits = 0;
446 
447  /* outer IP header */
448  if(ctxt->outer_ip_flags.version == IPV4 &&
449  ctxt->outer_ip_flags.info.v4.rnd != 1 &&
450  ctxt->tmp.nr_ip_id_bits > 0)
451  {
452  nr_ipv4_non_rnd_with_bits++;
453  }
454 
455  /* optional inner IP header */
456  if(ctxt->ip_hdr_nr >= 1 &&
457  ctxt->inner_ip_flags.version == IPV4 &&
458  ctxt->inner_ip_flags.info.v4.rnd != 1 &&
459  ctxt->tmp.nr_ip_id_bits2 > 0)
460  {
461  nr_ipv4_non_rnd_with_bits++;
462  }
463 
464  return nr_ipv4_non_rnd_with_bits;
465 }
466 
467 
468 #endif
469 
uint32_t sn
The Sequence Number (SN), may be 16-bit or 32-bit long.
Definition: rohc_comp_rfc3095.h:184
unsigned short changed_fields2
The number of fields that changed in the inner IP header.
Definition: rohc_comp_rfc3095.h:153
rohc_lsb_shift_t
the different values of the shift parameter of the LSB algorithm
Definition: interval.h:42
unsigned int next_header_len
The length of the next header.
Definition: rohc_comp_rfc3095.h:204
bool is_first_header
Definition: rohc_comp_rfc3095.h:128
struct c_wlsb * sn_window
A window used to encode the SN.
Definition: rohc_comp_rfc3095.h:186
struct ip_header_info inner_ip_flags
Information about the inner IP header.
Definition: rohc_comp_rfc3095.h:193
size_t tos_count
The number of times the TOS/TC field was added to the compressed header.
Definition: rohc_comp_rfc3095.h:119
size_t sid_count
The number of times the IP-ID is specified as static in the compressed header.
Definition: rohc_comp_rfc3095.h:68
size_t(* code_uo_remainder)(const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
The handler used to add an additional header in the tail of the UO-0, UO-1 and UO-2 packets...
Definition: rohc_comp_rfc3095.h:265
static bool is_outer_ip_id_bits_possible(const struct rohc_comp_rfc3095_ctxt *const ctxt, const size_t max_ip_id_bits_nr)
May the outer IP header transmit the required non-random IP-ID bits?
Definition: rohc_comp_rfc3095.h:366
int send_dynamic
The number of dynamic fields that changed in the two IP headers.
Definition: rohc_comp_rfc3095.h:157
int rnd
Whether the IP-ID is considered as random or not.
Definition: rohc_comp_rfc3095.h:71
bool rohc_comp_rfc3095_is_sn_possible(const struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt, const size_t bits_nr, const size_t add_bits_nr)
Are the given SN field sizes possible?
Definition: rohc_comp_rfc3095.c:7261
static size_t get_nr_ipv4_non_rnd(const struct rohc_comp_rfc3095_ctxt *const ctxt)
How many IP headers are IPv4 headers with non-random IP-IDs ?
Definition: rohc_comp_rfc3095.h:413
void * specific
Profile-specific data.
Definition: rohc_comp_rfc3095.h:290
size_t nr_sn_bits_less_equal_than_4
The number of bits needed to encode the Sequence Number (SN)
Definition: rohc_comp_rfc3095.h:160
int old_rnd
Whether the IP-ID of the previous IP header was considered as random or not.
Definition: rohc_comp_rfc3095.h:78
rohc_packet_t(* decide_FO_packet)(const struct rohc_comp_ctxt *context)
The handler used to decide which packet to send in FO state.
Definition: rohc_comp_rfc3095.h:215
The ROHC compressor.
Definition: rohc_comp_internals.h:121
unsigned int next_header_proto
The protocol number registered by IANA for the next header protocol.
Definition: rohc_comp_rfc3095.h:202
struct ipv6_hdr old_ip
The previous IPv6 header.
Definition: rohc_comp_rfc3095.h:104
rohc_ext_t(* decide_extension)(const struct rohc_comp_ctxt *context)
Definition: rohc_comp_rfc3095.h:219
static bool no_inner_ip_id_bits_required(const struct rohc_comp_rfc3095_ctxt *const ctxt)
Does the inner IP header require to transmit no non-random IP-ID bit?
Definition: rohc_comp_rfc3095.h:382
ROHC CRC routines.
size_t(* code_dynamic_part)(const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
The handler used to add the dynamic part of the next header to the ROHC pachet.
Definition: rohc_comp_rfc3095.h:240
static bool is_inner_ip_id_bits_possible(const struct rohc_comp_rfc3095_ctxt *const ctxt, const size_t max_ip_id_bits_nr)
May the inner IP header transmit the required non-random IP-ID bits?
Definition: rohc_comp_rfc3095.h:398
size_t df_count
The number of times the DF field was added to the compressed header.
Definition: rohc_comp_rfc3095.h:59
uint16_t id_delta
Definition: rohc_comp_rfc3095.h:88
rohc_ext_t
The different types of extensions for UO-1-ID and UOR-2* packets.
Definition: rohc_packets.h:106
ROHC generic list compression.
The IPv6 header.
Definition: ipv6.h:88
size_t nr_ip_id_bits
The number of bits needed to encode the IP-ID of the outer IP header.
Definition: rohc_comp_rfc3095.h:165
Store information about an IPv6 header between the different compressions of IP packets.
Definition: rohc_comp_rfc3095.h:101
size_t nr_ip_id_bits2
The number of bits needed to encode the IP-ID of the inner IP header.
Definition: rohc_comp_rfc3095.h:167
Defines a W-LSB encoding object.
Definition: comp_wlsb.c:55
struct ipv4_header_info v4
The IPv4-specific header info.
Definition: rohc_comp_rfc3095.h:132
struct list_comp ext_comp
The extension compressor.
Definition: rohc_comp_rfc3095.h:106
The IPv4 header.
Definition: ipv4.h:53
Internal structures for ROHC compression.
The ROHC compression context.
Definition: rohc_comp_internals.h:306
int(* code_ir_remainder)(const struct rohc_comp_ctxt *const context, uint8_t *const dest, const size_t dest_max_len, const size_t counter)
The handler used to add the IR/IR-DYN remainder header to the ROHC pachet.
Definition: rohc_comp_rfc3095.h:248
Store information about an IPv4 header between the different compressions of IP packets.
Definition: rohc_comp_rfc3095.h:50
size_t protocol_count
The number of times the Protocol/Next Header field was added to the compressed header.
Definition: rohc_comp_rfc3095.h:124
size_t nr_sn_bits_more_than_4
The number of bits needed to encode the Sequence Number (SN)
Definition: rohc_comp_rfc3095.h:162
Structure that contains variables that are used during one single compression of packet.
Definition: rohc_comp_rfc3095.h:148
static bool no_outer_ip_id_bits_required(const struct rohc_comp_rfc3095_ctxt *const ctxt)
Does the outer IP header require to transmit no non-random IP-ID bit?
Definition: rohc_comp_rfc3095.h:350
size_t(* code_UO_packet_head)(const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter, size_t *const first_position)
The handler used to add an additional header in the head of the UO-0, UO-1 and UO-2 packets...
Definition: rohc_comp_rfc3095.h:256
Definition: net_pkt.h:39
struct ipv4_hdr old_ip
The previous IP header.
Definition: rohc_comp_rfc3095.h:56
size_t(* code_static_part)(const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
The handler used to add the static part of the next header to the ROHC packet.
Definition: rohc_comp_rfc3095.h:232
union ip_header_info::@21 info
The version specific header info.
bool rohc_comp_rfc3095_check_profile(const struct rohc_comp *const comp, const struct net_pkt *const packet)
Check if the given packet corresponds to an IP-based profile.
Definition: rohc_comp_rfc3095.c:693
int sid
Whether the IP-ID is considered as static or not.
Definition: rohc_comp_rfc3095.h:75
bool rohc_comp_rfc3095_create(struct rohc_comp_ctxt *const context, const rohc_lsb_shift_t sn_shift, const struct net_pkt *const packet)
Create a new context and initialize it thanks to the given IP packet.
Definition: rohc_comp_rfc3095.c:538
rohc_packet_t packet_type
The type of packet the compressor must send: IR, IR-DYN, UO*.
Definition: rohc_comp_rfc3095.h:170
size_t nbo_count
The number of times the IP-ID is specified as coded in Network Byte Order (NBO) in the compressed hea...
Definition: rohc_comp_rfc3095.h:65
rohc_ext_t decide_extension(const struct rohc_comp_ctxt *const context)
Decide what extension shall be used in the UO-1-ID/UOR-2 packet.
Definition: rohc_comp_rfc3095.c:6801
Store information about an IP (IPv4 or IPv6) header between the different compressions of IP packets...
Definition: rohc_comp_rfc3095.h:114
struct ip_header_info outer_ip_flags
Information about the outer IP header.
Definition: rohc_comp_rfc3095.h:191
rohc_crc_type_t
Definition: crc.h:56
int send_static
The number of static fields that changed in the two IP headers.
Definition: rohc_comp_rfc3095.h:155
ip_version version
The version of the IP header.
Definition: rohc_comp_rfc3095.h:116
size_t ip_hdr_nr
Definition: rohc_comp_rfc3095.h:189
struct generic_tmp_vars tmp
Temporary variables that are used during one single compression of packet.
Definition: rohc_comp_rfc3095.h:196
rohc_packet_t packet_type
Definition: rohc_comp_internals.h:338
void(* init_at_IR)(struct rohc_comp_ctxt *const context, const uint8_t *const next_header)
The handler used to initialize some data just before the IR packet build.
Definition: rohc_comp_rfc3095.h:222
uint8_t(* compute_crc_static)(const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
The handler used to compute the CRC-STATIC value.
Definition: rohc_comp_rfc3095.h:272
unsigned short changed_fields
The number of fields that changed in the outer IP header.
Definition: rohc_comp_rfc3095.h:151
static size_t get_nr_ipv4_non_rnd_with_bits(const struct rohc_comp_rfc3095_ctxt *const ctxt)
How many IP headers are IPv4 headers with non-random IP-IDs and some bits to transmit ...
Definition: rohc_comp_rfc3095.h:443
void rohc_comp_rfc3095_destroy(struct rohc_comp_ctxt *const context)
Destroy the context.
Definition: rohc_comp_rfc3095.c:652
struct ipv6_header_info v6
The IPv6-specific header info.
Definition: rohc_comp_rfc3095.h:133
void rohc_get_ipid_bits(const struct rohc_comp_ctxt *const context, size_t *const nr_innermost_bits, size_t *const nr_outermost_bits)
Get the number of non-random outer/inner IP-ID bits.
Definition: rohc_comp_rfc3095.c:7212
Definition of ROHC packets and extensions.
int nbo
Whether the IP-ID is considered as coded in NBO or not.
Definition: rohc_comp_rfc3095.h:73
void(* decide_state)(struct rohc_comp_ctxt *const context)
The handler used to decide the state that should be used for the next packet.
Definition: rohc_comp_rfc3095.h:213
size_t ttl_count
The number of times the TTL/HL field was added to the compressed header.
Definition: rohc_comp_rfc3095.h:121
bool(* encode_uncomp_fields)(struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
Definition: rohc_comp_rfc3095.h:207
int old_nbo
Whether the IP-ID of the previous IP header was considered as coded in NBO or not.
Definition: rohc_comp_rfc3095.h:81
The list compressor.
Definition: comp_list.h:42
rohc_packet_t(* decide_SO_packet)(const struct rohc_comp_ctxt *context)
The handler used to decide which packet to send in SO state.
Definition: rohc_comp_rfc3095.h:217
ip_version
IP version.
Definition: ip.h:53
IP version 4.
Definition: ip.h:56
uint32_t(* get_next_sn)(const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
Definition: rohc_comp_rfc3095.h:226
void rohc_comp_rfc3095_decide_state(struct rohc_comp_ctxt *const context)
Decide the state that should be used for the next packet.
Definition: rohc_comp_rfc3095.c:1322
rohc_feedback_type
Definition: feedback.h:42
struct c_wlsb * ip_id_window
A window to store the IP-ID.
Definition: rohc_comp_rfc3095.h:53
int old_sid
Whether the IP-ID of the previous IP header was considered as static or not.
Definition: rohc_comp_rfc3095.h:84
size_t rnd_count
The number of times the IP-ID is specified as random in the compressed header.
Definition: rohc_comp_rfc3095.h:62
int rohc_comp_rfc3095_encode(struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset)
Encode an IP packet according to a pattern decided by several different factors.
Definition: rohc_comp_rfc3095.c:826
rohc_packet_t
The different types of ROHC packets.
Definition: rohc_packets.h:49
uint8_t(* compute_crc_dynamic)(const uint8_t *const ip, const uint8_t *const ip2, const uint8_t *const next_header, const rohc_crc_type_t crc_type, const uint8_t init_val, const uint8_t *const crc_table)
The handler used to compute the CRC-DYNAMIC value.
Definition: rohc_comp_rfc3095.h:281
bool rohc_comp_rfc3095_feedback(struct rohc_comp_ctxt *const context, const enum rohc_feedback_type feedback_type, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
Update the profile when feedback is received.
Definition: rohc_comp_rfc3095.c:908
The generic decompression context for RFC3095-based profiles.
Definition: rohc_comp_rfc3095.h:181