ROHC compression/decompression library
rohc_decomp.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014 Didier Barvaux
3  * Copyright 2007,2009,2010,2012,2014 Viveris Technologies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file rohc_decomp.h
22  * @brief ROHC decompression routines
23  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
24  * @author Didier Barvaux <didier@barvaux.org>
25  * @author David Moreau from TAS
26  */
27 
28 #ifndef ROHC_DECOMP_H
29 #define ROHC_DECOMP_H
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
36 #include <rohc/rohc.h>
37 #include <rohc/rohc_packets.h>
38 #include <rohc/rohc_traces.h>
39 #include <rohc/rohc_buf.h>
40 
41 
42 /** Macro that handles DLL export declarations gracefully */
43 #ifdef DLL_EXPORT /* passed by autotools on command line */
44 # define ROHC_EXPORT __declspec(dllexport)
45 #else
46 # define ROHC_EXPORT
47 #endif
48 
49 
50 /*
51  * Declare the private ROHC decompressor structure that is defined inside the
52  * library.
53  */
54 
55 struct rohc_decomp;
56 
57 
58 
59 /*
60  * Public structures and types
61  */
62 
63 
64 /**
65  * @brief The ROHC decompressor states
66  *
67  * The different ROHC operation states at decompressor as defined in section
68  * 4.3.2 of RFC 3095.
69  *
70  * @ingroup rohc_decomp
71  *
72  * @see rohc_decomp_get_state_descr
73  */
74 typedef enum
75 {
76  /** Unknown decompressor state */
78  /** The No Context state */
80  /** The Static Context state */
82  /** The Full Context state */
85 
86 
87 /**
88  * @brief Some information about the last decompressed packet
89  *
90  * The structure is used by the \ref rohc_decomp_get_last_packet_info function
91  * to store some information about the last decompressed packet.
92  *
93  * Versioning works as follow:
94  * - The \e version_major field defines the compatibility level. If the major
95  * number given by user does not match the one expected by the library,
96  * an error is returned.
97  * - The \e version_minor field defines the extension level. If the minor
98  * number given by user does not match the one expected by the library,
99  * only the fields supported in that minor version will be filled by
100  * \ref rohc_decomp_get_last_packet_info.
101  *
102  * Notes for developers:
103  * - Increase the major version if a field is removed.
104  * - Increase the major version if a field is added at the beginning or in
105  * the middle of the structure.
106  * - Increase the minor version if a field is added at the very end of the
107  * structure.
108  * - The version_major and version_minor fields must be located at the very
109  * beginning of the structure.
110  * - The structure must be packed.
111  *
112  * Supported versions:
113  * - Major 0 / Minor 0 contains: version_major, version_minor, context_mode,
114  * context_state, profile_id, nr_lost_packets, nr_misordered_packets, and
115  * is_duplicated
116  * - Major 0 / Minor = 1 added: corrected_crc_failures,
117  * corrected_sn_wraparounds, corrected_wrong_sn_updates, and packet_type
118  *
119  * @ingroup rohc_decomp
120  *
121  * @see rohc_decomp_get_last_packet_info
122  */
123 typedef struct
124 {
125  /** The major version of this structure */
126  unsigned short version_major;
127  /** The minor version of this structure */
128  unsigned short version_minor;
129  /** The mode of the last context used by the compressor */
131  /** The state of the last context used by the compressor */
133  /** The profile ID of the last context used by the compressor */
135  /** The number of (possible) lost packet(s) before last packet */
136  unsigned long nr_lost_packets;
137  /** The number of packet(s) before the last packet if late */
138  unsigned long nr_misordered_packets;
139  /** Is last packet a (possible) duplicated packet? */
141 
142  /* added in 0.1 */
143  /** The number of successful corrections upon CRC failure */
144  unsigned long corrected_crc_failures;
145  /** The number of successful corrections of SN wraparound upon CRC failure */
147  /** The number of successful corrections of incorrect SN updates upon CRC
148  * failure */
150  /** The type of the last decompressed ROHC packet */
152 
153 } __attribute__((packed)) rohc_decomp_last_packet_info_t;
154 
155 
156 /**
157  * @brief Some information about one decompression context
158  *
159  * The structure is used by the \ref rohc_decomp_get_context_info function
160  * to store some information about one decompression context.
161  *
162  * Versioning works as follow:
163  * - The \e version_major field defines the compatibility level. If the major
164  * number given by user does not match the one expected by the library,
165  * an error is returned.
166  * - The \e version_minor field defines the extension level. If the minor
167  * number given by user does not match the one expected by the library,
168  * only the fields supported in that minor version will be filled by
169  * \ref rohc_decomp_get_context_info.
170  *
171  * Notes for developers:
172  * - Increase the major version if a field is removed.
173  * - Increase the major version if a field is added at the beginning or in
174  * the middle of the structure.
175  * - Increase the minor version if a field is added at the very end of the
176  * structure.
177  * - The version_major and version_minor fields must be located at the very
178  * beginning of the structure.
179  * - The structure must be packed.
180  *
181  * Supported versions:
182  * - Major 0 / Minor 0 contains: version_major, version_minor, packets_nr,
183  * comp_bytes_nr, uncomp_bytes_nr, corrected_crc_failures,
184  * corrected_sn_wraparounds, and corrected_wrong_sn_updates.
185  *
186  * @ingroup rohc_decomp
187  *
188  * @see rohc_decomp_get_context_info
189  */
190 typedef struct
191 {
192  /** The major version of this structure */
193  unsigned short version_major;
194  /** The minor version of this structure */
195  unsigned short version_minor;
196  /** The number of packets processed by the context */
197  unsigned long packets_nr;
198  /** The number of compressed bytes received by the context */
199  unsigned long comp_bytes_nr;
200  /** The number of uncompressed bytes produced by the context */
201  unsigned long uncomp_bytes_nr;
202  /** The number of successful corrections upon CRC failure */
203  unsigned long corrected_crc_failures;
204  /** The number of successful corrections of SN wraparound upon CRC failure */
206  /** The number of successful corrections of incorrect SN updates upon CRC
207  * failure */
209 
210 } __attribute__((packed)) rohc_decomp_context_info_t;
211 
212 
213 /**
214  * @brief Some general information about the decompressor
215  *
216  * The structure is used by the \ref rohc_decomp_get_general_info function
217  * to store some general information about the decompressor.
218  *
219  * Versioning works as follow:
220  * - The \e version_major field defines the compatibility level. If the major
221  * number given by user does not match the one expected by the library,
222  * an error is returned.
223  * - The \e version_minor field defines the extension level. If the minor
224  * number given by user does not match the one expected by the library,
225  * only the fields supported in that minor version will be filled by
226  * \ref rohc_decomp_get_general_info.
227  *
228  * Notes for developers:
229  * - Increase the major version if a field is removed.
230  * - Increase the major version if a field is added at the beginning or in
231  * the middle of the structure.
232  * - Increase the minor version if a field is added at the very end of the
233  * structure.
234  * - The version_major and version_minor fields must be located at the very
235  * beginning of the structure.
236  * - The structure must be packed.
237  *
238  * Supported versions:
239  * - major 0 and minor = 0 contains: version_major, version_minor,
240  * contexts_nr, packets_nr, comp_bytes_nr, and uncomp_bytes_nr.
241  *
242  * @ingroup rohc_decomp
243  *
244  * @see rohc_decomp_get_general_info
245  */
246 typedef struct
247 {
248  /** The major version of this structure */
249  unsigned short version_major;
250  /** The minor version of this structure */
251  unsigned short version_minor;
252  /** The number of contexts used by the decompressor */
253  size_t contexts_nr;
254  /** The number of packets processed by the decompressor */
255  unsigned long packets_nr;
256  /** The number of compressed bytes received by the decompressor */
257  unsigned long comp_bytes_nr;
258  /** The number of uncompressed bytes produced by the decompressor */
259  unsigned long uncomp_bytes_nr;
260 
261  /* added in 0.1 */
262  /** The cumulative number of successful corrections upon CRC failure */
263  unsigned long corrected_crc_failures;
264  /** The cumulative number of successful corrections of SN wraparound
265  * upon CRC failure */
267  /** The cumulative number of successful corrections of incorrect SN updates
268  * upon CRC failure */
270 
271 } __attribute__((packed)) rohc_decomp_general_info_t;
272 
273 
274 /**
275  * @brief The different features of the ROHC decompressor
276  *
277  * Features for the ROHC decompressor control whether mechanisms defined as
278  * optional by RFCs are enabled or not. They can be set or unset with the
279  * function \ref rohc_decomp_set_features.
280  *
281  * @ingroup rohc_decomp
282  *
283  * @see rohc_decomp_set_features
284  */
285 typedef enum
286 {
287  /** No feature at all */
289  /** Attempt packet repair in case of CRC failure */
291  /** Be compatible with 1.6.x versions */
293  /** Dump content of packets in traces (beware: performance impact) */
295 
297 
298 
299 
300 /*
301  * Functions related to decompressor:
302  */
303 
305  const rohc_cid_t max_cid,
306  const rohc_mode_t mode)
307  __attribute__((warn_unused_result));
308 
309 void ROHC_EXPORT rohc_decomp_free(struct rohc_decomp *const decomp);
310 
312  const struct rohc_buf rohc_packet,
313  struct rohc_buf *const uncomp_packet,
314  struct rohc_buf *const rcvd_feedback,
315  struct rohc_buf *const feedback_send)
316  __attribute__((warn_unused_result));
317 
318 
319 
320 /*
321  * Functions related to statistics:
322  */
323 
325  __attribute__((warn_unused_result, const));
326 
327 bool ROHC_EXPORT rohc_decomp_get_general_info(const struct rohc_decomp *const decomp,
328  rohc_decomp_general_info_t *const info)
329  __attribute__((warn_unused_result));
330 
331 bool ROHC_EXPORT rohc_decomp_get_context_info(const struct rohc_decomp *const decomp,
332  const rohc_cid_t cid,
333  rohc_decomp_context_info_t *const info)
334  __attribute__((warn_unused_result));
335 
336 bool ROHC_EXPORT rohc_decomp_get_last_packet_info(const struct rohc_decomp *const decomp,
337  rohc_decomp_last_packet_info_t *const info)
338  __attribute__((warn_unused_result));
339 
340 
341 /*
342  * Functions related to user parameters
343  */
344 
345 /* CID */
346 
347 bool ROHC_EXPORT rohc_decomp_get_cid_type(const struct rohc_decomp *const decomp,
348  rohc_cid_type_t *const cid_type)
349  __attribute__((warn_unused_result));
350 
351 bool ROHC_EXPORT rohc_decomp_get_max_cid(const struct rohc_decomp *const decomp,
352  size_t *const max_cid)
353  __attribute__((warn_unused_result));
354 
355 /* MRRU */
356 
357 bool ROHC_EXPORT rohc_decomp_set_mrru(struct rohc_decomp *const decomp,
358  const size_t mrru)
359  __attribute__((warn_unused_result));
360 
361 bool ROHC_EXPORT rohc_decomp_get_mrru(const struct rohc_decomp *const decomp,
362  size_t *const mrru)
363  __attribute__((warn_unused_result));
364 
365 /* pRTT */
366 
367 bool ROHC_EXPORT rohc_decomp_set_prtt(struct rohc_decomp *const decomp,
368  const size_t prtt)
369  __attribute__((warn_unused_result));
370 
371 bool ROHC_EXPORT rohc_decomp_get_prtt(const struct rohc_decomp *const decomp,
372  size_t *const prtt)
373  __attribute__((warn_unused_result));
374 
375 /* feedback rate-limiting */
376 
377 bool ROHC_EXPORT rohc_decomp_set_rate_limits(struct rohc_decomp *const decomp,
378  const size_t k, const size_t n,
379  const size_t k_1, const size_t n_1,
380  const size_t k_2, const size_t n_2)
381  __attribute__((warn_unused_result));
382 
383 bool ROHC_EXPORT rohc_decomp_get_rate_limits(const struct rohc_decomp *const decomp,
384  size_t *const k, size_t *const n,
385  size_t *const k_1, size_t *const n_1,
386  size_t *const k_2, size_t *const n_2)
387  __attribute__((warn_unused_result));
388 
389 /* decompression library features */
390 
391 bool ROHC_EXPORT rohc_decomp_set_features(struct rohc_decomp *const decomp,
393  __attribute__((warn_unused_result));
394 
395 
396 /*
397  * Functions related to decompression profiles
398  */
399 
400 bool ROHC_EXPORT rohc_decomp_profile_enabled(const struct rohc_decomp *const decomp,
401  const rohc_profile_t profile)
402  __attribute__((warn_unused_result));
403 
404 bool ROHC_EXPORT rohc_decomp_enable_profile(struct rohc_decomp *const decomp,
405  const rohc_profile_t profile)
406  __attribute__((warn_unused_result));
407 
408 bool ROHC_EXPORT rohc_decomp_disable_profile(struct rohc_decomp *const decomp,
409  const rohc_profile_t profile)
410  __attribute__((warn_unused_result));
411 
412 bool ROHC_EXPORT rohc_decomp_enable_profiles(struct rohc_decomp *const decomp,
413  ...)
414  __attribute__((warn_unused_result));
415 
416 bool ROHC_EXPORT rohc_decomp_disable_profiles(struct rohc_decomp *const decomp,
417  ...)
418  __attribute__((warn_unused_result));
419 
420 
421 /*
422  * Functions related to traces
423  */
424 
425 bool ROHC_EXPORT rohc_decomp_set_traces_cb2(struct rohc_decomp *const decomp,
426  rohc_trace_callback2_t callback,
427  void *const priv_ctxt)
428  __attribute__((warn_unused_result));
429 
430 
431 #undef ROHC_EXPORT /* do not pollute outside this header */
432 
433 #ifdef __cplusplus
434 }
435 #endif
436 
437 #endif /* ROHC_DECOMP_H */
438 
unsigned long comp_bytes_nr
Definition: rohc_decomp.h:199
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:266
bool ROHC_EXPORT rohc_decomp_enable_profiles(struct rohc_decomp *const decomp,...)
Enable several decompression profiles for a decompressor.
Definition: rohc_decomp.c:3473
#define ROHC_EXPORT
Definition: rohc_decomp.h:46
The ROHC decompressor.
Definition: rohc_decomp_internals.h:142
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:208
size_t rohc_cid_t
Definition: rohc.h:195
const char *ROHC_EXPORT rohc_decomp_get_state_descr(const rohc_decomp_state_t state)
Give a description for the given ROHC decompression context state.
Definition: rohc_decomp.c:2405
bool ROHC_EXPORT rohc_decomp_disable_profile(struct rohc_decomp *const decomp, const rohc_profile_t profile)
Disable a decompression profile for a decompressor.
Definition: rohc_decomp.c:3399
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:111
bool ROHC_EXPORT rohc_decomp_set_features(struct rohc_decomp *const decomp, const rohc_decomp_features_t features)
Enable/disable features for ROHC decompressor.
Definition: rohc_decomp.c:3217
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:149
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:269
rohc_status_t
The status code of several functions in the library API.
Definition: rohc.h:79
bool ROHC_EXPORT rohc_decomp_get_rate_limits(const struct rohc_decomp *const decomp, size_t *const k, size_t *const n, size_t *const k_1, size_t *const n_1, size_t *const k_2, size_t *const n_2)
Get the rate limits for feedbacks currently configured.
Definition: rohc_decomp.c:3170
int profile_id
Definition: rohc_decomp.h:134
Some information about one decompression context.
Definition: rohc_decomp.h:190
rohc_cid_type_t
The different types of Context IDs (CID)
Definition: rohc.h:176
bool ROHC_EXPORT rohc_decomp_disable_profiles(struct rohc_decomp *const decomp,...)
Disable several decompression profiles for a decompressor.
Definition: rohc_decomp.c:3531
Definition: rohc_decomp.h:292
bool ROHC_EXPORT rohc_decomp_set_traces_cb2(struct rohc_decomp *const decomp, rohc_trace_callback2_t callback, void *const priv_ctxt)
Set the callback function used to manage traces in decompressor.
Definition: rohc_decomp.c:3587
Some general information about the decompressor.
Definition: rohc_decomp.h:246
Definition: rohc_decomp.h:290
unsigned short version_minor
Definition: rohc_decomp.h:251
bool ROHC_EXPORT rohc_decomp_get_general_info(const struct rohc_decomp *const decomp, rohc_decomp_general_info_t *const info)
Get some general information about the decompressor.
Definition: rohc_decomp.c:2634
unsigned long uncomp_bytes_nr
Definition: rohc_decomp.h:201
unsigned long nr_lost_packets
Definition: rohc_decomp.h:136
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 prtt
Definition: rohc_decomp_internals.h:167
bool ROHC_EXPORT rohc_decomp_get_last_packet_info(const struct rohc_decomp *const decomp, rohc_decomp_last_packet_info_t *const info)
Get some information about the last decompressed packet.
Definition: rohc_decomp.c:2445
bool ROHC_EXPORT rohc_decomp_get_max_cid(const struct rohc_decomp *const decomp, size_t *const max_cid)
Get the maximal CID value the decompressor uses.
Definition: rohc_decomp.c:2736
unsigned short version_minor
Definition: rohc_decomp.h:128
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:205
size_t mrru
Definition: rohc_decomp_internals.h:187
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:263
bool ROHC_EXPORT rohc_decomp_get_mrru(const struct rohc_decomp *const decomp, size_t *const mrru)
Get the Maximum Reconstructed Reception Unit (MRRU).
Definition: rohc_decomp.c:2864
Definition: rohc_decomp.h:79
Definition: rohc_decomp.h:288
Definition: rohc_decomp.h:83
bool ROHC_EXPORT rohc_decomp_set_rate_limits(struct rohc_decomp *const decomp, const size_t k, const size_t n, const size_t k_1, const size_t n_1, const size_t k_2, const size_t n_2)
Set the rate limits for feedbacks.
Definition: rohc_decomp.c:3070
bool ROHC_EXPORT rohc_decomp_set_prtt(struct rohc_decomp *const decomp, const size_t prtt)
Set the number of packets sent during one Round-Trip Time (RTT).
Definition: rohc_decomp.c:2923
unsigned long uncomp_bytes_nr
Definition: rohc_decomp.h:259
size_t contexts_nr
Definition: rohc_decomp.h:253
rohc_mode_t context_mode
Definition: rohc_decomp.h:130
rohc_status_t ROHC_EXPORT rohc_decompress3(struct rohc_decomp *const decomp, const struct rohc_buf rohc_packet, struct rohc_buf *const uncomp_packet, struct rohc_buf *const rcvd_feedback, struct rohc_buf *const feedback_send)
Decompress the given ROHC packet into one uncompressed packet.
Definition: rohc_decomp.c:702
unsigned long packets_nr
Definition: rohc_decomp.h:255
A network buffer for the ROHC library.
Definition: rohc_buf.h:104
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:203
rohc_packet_t packet_type
Definition: rohc_decomp.h:151
rohc_decomp_state_t
The ROHC decompressor states.
Definition: rohc_decomp.h:74
rohc_decomp_features_t
The different features of the ROHC decompressor.
Definition: rohc_decomp.h:285
Some information about the last decompressed packet.
Definition: rohc_decomp.h:123
unsigned short version_major
Definition: rohc_decomp.h:249
unsigned long comp_bytes_nr
Definition: rohc_decomp.h:257
Definition: rohc_decomp.h:294
struct rohc_decomp *ROHC_EXPORT rohc_decomp_new2(const rohc_cid_type_t cid_type, const rohc_cid_t max_cid, const rohc_mode_t mode)
Create a new ROHC decompressor.
Definition: rohc_decomp.c:445
rohc_decomp_features_t features
Definition: rohc_decomp_internals.h:148
Definition: rohc_decomp.h:81
bool ROHC_EXPORT rohc_decomp_profile_enabled(const struct rohc_decomp *const decomp, const rohc_profile_t profile)
Is the given decompression profile enabled for a decompressor?
Definition: rohc_decomp.c:3269
unsigned short version_major
Definition: rohc_decomp.h:193
rohc_decomp_state_t context_state
Definition: rohc_decomp.h:132
bool ROHC_EXPORT rohc_decomp_get_context_info(const struct rohc_decomp *const decomp, const rohc_cid_t cid, rohc_decomp_context_info_t *const info)
Get some information about the given decompression context.
Definition: rohc_decomp.c:2539
unsigned short version_major
Definition: rohc_decomp.h:126
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:146
void ROHC_EXPORT rohc_decomp_free(struct rohc_decomp *const decomp)
Destroy the given ROHC decompressor.
Definition: rohc_decomp.c:602
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc.h:212
bool ROHC_EXPORT rohc_decomp_enable_profile(struct rohc_decomp *const decomp, const rohc_profile_t profile)
Enable a decompression profile for a decompressor.
Definition: rohc_decomp.c:3337
unsigned long nr_misordered_packets
Definition: rohc_decomp.h:138
rohc_packet_t
The different types of ROHC packets.
Definition: rohc_packets.h:49
unsigned short version_minor
Definition: rohc_decomp.h:195
bool ROHC_EXPORT rohc_decomp_get_cid_type(const struct rohc_decomp *const decomp, rohc_cid_type_t *const cid_type)
Get the CID type that the decompressor uses.
Definition: rohc_decomp.c:2707
bool ROHC_EXPORT rohc_decomp_set_mrru(struct rohc_decomp *const decomp, const size_t mrru)
Set the Maximum Reconstructed Reception Unit (MRRU).
Definition: rohc_decomp.c:2802
unsigned long packets_nr
Definition: rohc_decomp.h:197
bool ROHC_EXPORT rohc_decomp_get_prtt(const struct rohc_decomp *const decomp, size_t *const prtt)
Get the number of packets sent during one Round-Trip Time (RTT).
Definition: rohc_decomp.c:2991
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:144
Definition: rohc_decomp.h:77
bool is_duplicated
Definition: rohc_decomp.h:140