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  /* added in 0.2 */
154  /** The compressed size (in bytes) of the last decompressed packet */
155  unsigned long total_last_comp_size;
156  /** The compressed size (in bytes) of the last decompressed header */
157  unsigned long header_last_comp_size;
158  /** The uncompressed size (in bytes) of the last decompressed packet */
159  unsigned long total_last_uncomp_size;
160  /** The uncompressed size (in bytes) of the last decompressed header */
161  unsigned long header_last_uncomp_size;
162 
163 } __attribute__((packed)) rohc_decomp_last_packet_info_t;
164 
165 
166 /**
167  * @brief Some information about one decompression context
168  *
169  * The structure is used by the \ref rohc_decomp_get_context_info function
170  * to store some information about one decompression context.
171  *
172  * Versioning works as follow:
173  * - The \e version_major field defines the compatibility level. If the major
174  * number given by user does not match the one expected by the library,
175  * an error is returned.
176  * - The \e version_minor field defines the extension level. If the minor
177  * number given by user does not match the one expected by the library,
178  * only the fields supported in that minor version will be filled by
179  * \ref rohc_decomp_get_context_info.
180  *
181  * Notes for developers:
182  * - Increase the major version if a field is removed.
183  * - Increase the major version if a field is added at the beginning or in
184  * the middle of the structure.
185  * - Increase the minor version if a field is added at the very end of the
186  * structure.
187  * - The version_major and version_minor fields must be located at the very
188  * beginning of the structure.
189  * - The structure must be packed.
190  *
191  * Supported versions:
192  * - Major 0 / Minor 0 contains: version_major, version_minor, packets_nr,
193  * comp_bytes_nr, uncomp_bytes_nr, corrected_crc_failures,
194  * corrected_sn_wraparounds, and corrected_wrong_sn_updates.
195  *
196  * @ingroup rohc_decomp
197  *
198  * @see rohc_decomp_get_context_info
199  */
200 typedef struct
201 {
202  /** The major version of this structure */
203  unsigned short version_major;
204  /** The minor version of this structure */
205  unsigned short version_minor;
206  /** The number of packets processed by the context */
207  unsigned long packets_nr;
208  /** The number of compressed bytes received by the context */
209  unsigned long comp_bytes_nr;
210  /** The number of uncompressed bytes produced by the context */
211  unsigned long uncomp_bytes_nr;
212  /** The number of successful corrections upon CRC failure */
213  unsigned long corrected_crc_failures;
214  /** The number of successful corrections of SN wraparound upon CRC failure */
216  /** The number of successful corrections of incorrect SN updates upon CRC
217  * failure */
219 
220 } __attribute__((packed)) rohc_decomp_context_info_t;
221 
222 
223 /**
224  * @brief Some general information about the decompressor
225  *
226  * The structure is used by the \ref rohc_decomp_get_general_info function
227  * to store some general information about the decompressor.
228  *
229  * Versioning works as follow:
230  * - The \e version_major field defines the compatibility level. If the major
231  * number given by user does not match the one expected by the library,
232  * an error is returned.
233  * - The \e version_minor field defines the extension level. If the minor
234  * number given by user does not match the one expected by the library,
235  * only the fields supported in that minor version will be filled by
236  * \ref rohc_decomp_get_general_info.
237  *
238  * Notes for developers:
239  * - Increase the major version if a field is removed.
240  * - Increase the major version if a field is added at the beginning or in
241  * the middle of the structure.
242  * - Increase the minor version if a field is added at the very end of the
243  * structure.
244  * - The version_major and version_minor fields must be located at the very
245  * beginning of the structure.
246  * - The structure must be packed.
247  *
248  * Supported versions:
249  * - major 0 and minor = 0 contains: version_major, version_minor,
250  * contexts_nr, packets_nr, comp_bytes_nr, and uncomp_bytes_nr.
251  *
252  * @ingroup rohc_decomp
253  *
254  * @see rohc_decomp_get_general_info
255  */
256 typedef struct
257 {
258  /** The major version of this structure */
259  unsigned short version_major;
260  /** The minor version of this structure */
261  unsigned short version_minor;
262  /** The number of contexts used by the decompressor */
263  size_t contexts_nr;
264  /** The number of packets processed by the decompressor */
265  unsigned long packets_nr;
266  /** The number of compressed bytes received by the decompressor */
267  unsigned long comp_bytes_nr;
268  /** The number of uncompressed bytes produced by the decompressor */
269  unsigned long uncomp_bytes_nr;
270 
271  /* added in 0.1 */
272  /** The cumulative number of successful corrections upon CRC failure */
273  unsigned long corrected_crc_failures;
274  /** The cumulative number of successful corrections of SN wraparound
275  * upon CRC failure */
277  /** The cumulative number of successful corrections of incorrect SN updates
278  * upon CRC failure */
280 
281 } __attribute__((packed)) rohc_decomp_general_info_t;
282 
283 
284 /**
285  * @brief The different features of the ROHC decompressor
286  *
287  * Features for the ROHC decompressor control whether mechanisms defined as
288  * optional by RFCs are enabled or not. They can be set or unset with the
289  * function \ref rohc_decomp_set_features.
290  *
291  * @ingroup rohc_decomp
292  *
293  * @see rohc_decomp_set_features
294  */
295 typedef enum
296 {
297  /** No feature at all */
299  /** Attempt packet repair in case of CRC failure */
301  /** Be compatible with 1.6.x versions */
303  /** Dump content of packets in traces (beware: performance impact) */
305 
307 
308 
309 
310 /*
311  * Functions related to decompressor:
312  */
313 
315  const rohc_cid_t max_cid,
316  const rohc_mode_t mode)
317  __attribute__((warn_unused_result));
318 
319 void ROHC_EXPORT rohc_decomp_free(struct rohc_decomp *const decomp);
320 
322  const struct rohc_buf rohc_packet,
323  struct rohc_buf *const uncomp_packet,
324  struct rohc_buf *const rcvd_feedback,
325  struct rohc_buf *const feedback_send)
326  __attribute__((warn_unused_result));
327 
328 
329 
330 /*
331  * Functions related to statistics:
332  */
333 
335  __attribute__((warn_unused_result, const));
336 
337 bool ROHC_EXPORT rohc_decomp_get_general_info(const struct rohc_decomp *const decomp,
338  rohc_decomp_general_info_t *const info)
339  __attribute__((warn_unused_result));
340 
341 bool ROHC_EXPORT rohc_decomp_get_context_info(const struct rohc_decomp *const decomp,
342  const rohc_cid_t cid,
343  rohc_decomp_context_info_t *const info)
344  __attribute__((warn_unused_result));
345 
346 bool ROHC_EXPORT rohc_decomp_get_last_packet_info(const struct rohc_decomp *const decomp,
347  rohc_decomp_last_packet_info_t *const info)
348  __attribute__((warn_unused_result));
349 
350 
351 /*
352  * Functions related to user parameters
353  */
354 
355 /* CID */
356 
357 bool ROHC_EXPORT rohc_decomp_get_cid_type(const struct rohc_decomp *const decomp,
358  rohc_cid_type_t *const cid_type)
359  __attribute__((warn_unused_result));
360 
361 bool ROHC_EXPORT rohc_decomp_get_max_cid(const struct rohc_decomp *const decomp,
362  size_t *const max_cid)
363  __attribute__((warn_unused_result));
364 
365 /* MRRU */
366 
367 bool ROHC_EXPORT rohc_decomp_set_mrru(struct rohc_decomp *const decomp,
368  const size_t mrru)
369  __attribute__((warn_unused_result));
370 
371 bool ROHC_EXPORT rohc_decomp_get_mrru(const struct rohc_decomp *const decomp,
372  size_t *const mrru)
373  __attribute__((warn_unused_result));
374 
375 /* pRTT */
376 
377 bool ROHC_EXPORT rohc_decomp_set_prtt(struct rohc_decomp *const decomp,
378  const size_t prtt)
379  __attribute__((warn_unused_result));
380 
381 bool ROHC_EXPORT rohc_decomp_get_prtt(const struct rohc_decomp *const decomp,
382  size_t *const prtt)
383  __attribute__((warn_unused_result));
384 
385 /* feedback rate-limiting */
386 
387 bool ROHC_EXPORT rohc_decomp_set_rate_limits(struct rohc_decomp *const decomp,
388  const size_t k, const size_t n,
389  const size_t k_1, const size_t n_1,
390  const size_t k_2, const size_t n_2)
391  __attribute__((warn_unused_result));
392 
393 bool ROHC_EXPORT rohc_decomp_get_rate_limits(const struct rohc_decomp *const decomp,
394  size_t *const k, size_t *const n,
395  size_t *const k_1, size_t *const n_1,
396  size_t *const k_2, size_t *const n_2)
397  __attribute__((warn_unused_result));
398 
399 /* decompression library features */
400 
401 bool ROHC_EXPORT rohc_decomp_set_features(struct rohc_decomp *const decomp,
403  __attribute__((warn_unused_result));
404 
405 
406 /*
407  * Functions related to decompression profiles
408  */
409 
410 bool ROHC_EXPORT rohc_decomp_profile_enabled(const struct rohc_decomp *const decomp,
411  const rohc_profile_t profile)
412  __attribute__((warn_unused_result));
413 
414 bool ROHC_EXPORT rohc_decomp_enable_profile(struct rohc_decomp *const decomp,
415  const rohc_profile_t profile)
416  __attribute__((warn_unused_result));
417 
418 bool ROHC_EXPORT rohc_decomp_disable_profile(struct rohc_decomp *const decomp,
419  const rohc_profile_t profile)
420  __attribute__((warn_unused_result));
421 
422 bool ROHC_EXPORT rohc_decomp_enable_profiles(struct rohc_decomp *const decomp,
423  ...)
424  __attribute__((warn_unused_result));
425 
426 bool ROHC_EXPORT rohc_decomp_disable_profiles(struct rohc_decomp *const decomp,
427  ...)
428  __attribute__((warn_unused_result));
429 
430 
431 /*
432  * Functions related to traces
433  */
434 
435 bool ROHC_EXPORT rohc_decomp_set_traces_cb2(struct rohc_decomp *const decomp,
436  rohc_trace_callback2_t callback,
437  void *const priv_ctxt)
438  __attribute__((warn_unused_result));
439 
440 
441 #undef ROHC_EXPORT /* do not pollute outside this header */
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 #endif /* ROHC_DECOMP_H */
448 
unsigned long comp_bytes_nr
Definition: rohc_decomp.h:209
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:276
bool ROHC_EXPORT rohc_decomp_enable_profiles(struct rohc_decomp *const decomp,...)
Enable several decompression profiles for a decompressor.
Definition: rohc_decomp.c:3485
#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:218
size_t rohc_cid_t
Definition: rohc.h:193
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:3411
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:109
unsigned long total_last_comp_size
Definition: rohc_decomp.h:155
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:3229
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:149
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:279
rohc_status_t
The status code of several functions in the library API.
Definition: rohc.h:77
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:3182
int profile_id
Definition: rohc_decomp.h:134
Some information about one decompression context.
Definition: rohc_decomp.h:200
rohc_cid_type_t
The different types of Context IDs (CID)
Definition: rohc.h:174
bool ROHC_EXPORT rohc_decomp_disable_profiles(struct rohc_decomp *const decomp,...)
Disable several decompression profiles for a decompressor.
Definition: rohc_decomp.c:3543
Definition: rohc_decomp.h:302
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:3599
Some general information about the decompressor.
Definition: rohc_decomp.h:256
Definition: rohc_decomp.h:300
unsigned short version_minor
Definition: rohc_decomp.h:261
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:2646
unsigned long uncomp_bytes_nr
Definition: rohc_decomp.h:211
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:2446
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:2748
unsigned short version_minor
Definition: rohc_decomp.h:128
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:215
size_t mrru
Definition: rohc_decomp_internals.h:187
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:273
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:2876
Definition: rohc_decomp.h:79
Definition: rohc_decomp.h:298
unsigned long header_last_comp_size
Definition: rohc_decomp.h:157
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:3082
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:2935
unsigned long uncomp_bytes_nr
Definition: rohc_decomp.h:269
size_t contexts_nr
Definition: rohc_decomp.h:263
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:685
unsigned long packets_nr
Definition: rohc_decomp.h:265
A network buffer for the ROHC library.
Definition: rohc_buf.h:102
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:213
unsigned long header_last_uncomp_size
Definition: rohc_decomp.h:161
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:295
Some information about the last decompressed packet.
Definition: rohc_decomp.h:123
unsigned short version_major
Definition: rohc_decomp.h:259
unsigned long comp_bytes_nr
Definition: rohc_decomp.h:267
Definition: rohc_decomp.h:304
unsigned long total_last_uncomp_size
Definition: rohc_decomp.h:159
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:442
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:3281
unsigned short version_major
Definition: rohc_decomp.h:203
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:2551
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:585
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc.h:210
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:3349
unsigned long nr_misordered_packets
Definition: rohc_decomp.h:138
rohc_packet_t
The different types of ROHC packets.
Definition: rohc_packets.h:55
unsigned short version_minor
Definition: rohc_decomp.h:205
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:2719
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:2814
unsigned long packets_nr
Definition: rohc_decomp.h:207
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:3003
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:144
Definition: rohc_decomp.h:77
bool is_duplicated
Definition: rohc_decomp.h:140