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_profiles.h>
38 #include <rohc/rohc_packets.h>
39 #include <rohc/rohc_traces.h>
40 #include <rohc/rohc_buf.h>
41 
42 
43 /** Macro that handles DLL export declarations gracefully */
44 #ifdef DLL_EXPORT /* passed by autotools on command line */
45 # define ROHC_EXPORT __declspec(dllexport)
46 #else
47 # define ROHC_EXPORT
48 #endif
49 
50 
51 /*
52  * Declare the private ROHC decompressor structure that is defined inside the
53  * library.
54  */
55 
56 struct rohc_decomp;
57 
58 
59 
60 /*
61  * Public structures and types
62  */
63 
64 
65 /**
66  * @brief The ROHC decompressor states
67  *
68  * The different ROHC operation states at decompressor as defined in section
69  * 4.3.2 of RFC 3095.
70  *
71  * @ingroup rohc_decomp
72  *
73  * @see rohc_decomp_get_state_descr
74  */
75 typedef enum
76 {
77  /** Unknown decompressor state */
79  /** The No Context state */
81  /** The Static Context state */
83  /** The Full Context state */
86 
87 
88 /**
89  * @brief Some information about the last decompressed packet
90  *
91  * The structure is used by the \ref rohc_decomp_get_last_packet_info function
92  * to store some information about the last decompressed packet.
93  *
94  * Versioning works as follow:
95  * - The \e version_major field defines the compatibility level. If the major
96  * number given by user does not match the one expected by the library,
97  * an error is returned.
98  * - The \e version_minor field defines the extension level. If the minor
99  * number given by user does not match the one expected by the library,
100  * only the fields supported in that minor version will be filled by
101  * \ref rohc_decomp_get_last_packet_info.
102  *
103  * Notes for developers:
104  * - Increase the major version if a field is removed.
105  * - Increase the major version if a field is added at the beginning or in
106  * the middle of the structure.
107  * - Increase the minor version if a field is added at the very end of the
108  * structure.
109  * - The version_major and version_minor fields must be located at the very
110  * beginning of the structure.
111  * - The structure must be packed.
112  *
113  * Supported versions:
114  * - Major 0 / Minor 0 contains: version_major, version_minor, context_mode,
115  * context_state, profile_id, nr_lost_packets, nr_misordered_packets, and
116  * is_duplicated
117  * - Major 0 / Minor = 1 added: corrected_crc_failures,
118  * corrected_sn_wraparounds, corrected_wrong_sn_updates, and packet_type
119  *
120  * @ingroup rohc_decomp
121  *
122  * @see rohc_decomp_get_last_packet_info
123  */
124 typedef struct
125 {
126  /** The major version of this structure */
127  unsigned short version_major;
128  /** The minor version of this structure */
129  unsigned short version_minor;
130  /** The mode of the last context used by the compressor */
132  /** The state of the last context used by the compressor */
134  /** The profile ID of the last context used by the compressor */
136  /** The number of (possible) lost packet(s) before last packet */
137  unsigned long nr_lost_packets;
138  /** The number of packet(s) before the last packet if late */
139  unsigned long nr_misordered_packets;
140  /** Is last packet a (possible) duplicated packet? */
142 
143  /* added in 0.1 */
144  /** The number of successful corrections upon CRC failure */
145  unsigned long corrected_crc_failures;
146  /** The number of successful corrections of SN wraparound upon CRC failure */
148  /** The number of successful corrections of incorrect SN updates upon CRC
149  * failure */
151  /** The type of the last decompressed ROHC packet */
153 
154  /* added in 0.2 */
155  /** The compressed size (in bytes) of the last decompressed packet */
156  unsigned long total_last_comp_size;
157  /** The compressed size (in bytes) of the last decompressed header */
158  unsigned long header_last_comp_size;
159  /** The uncompressed size (in bytes) of the last decompressed packet */
160  unsigned long total_last_uncomp_size;
161  /** The uncompressed size (in bytes) of the last decompressed header */
162  unsigned long header_last_uncomp_size;
163 
164 } __attribute__((packed)) rohc_decomp_last_packet_info_t;
165 
166 
167 /**
168  * @brief Some information about one decompression context
169  *
170  * The structure is used by the \ref rohc_decomp_get_context_info function
171  * to store some information about one decompression context.
172  *
173  * Versioning works as follow:
174  * - The \e version_major field defines the compatibility level. If the major
175  * number given by user does not match the one expected by the library,
176  * an error is returned.
177  * - The \e version_minor field defines the extension level. If the minor
178  * number given by user does not match the one expected by the library,
179  * only the fields supported in that minor version will be filled by
180  * \ref rohc_decomp_get_context_info.
181  *
182  * Notes for developers:
183  * - Increase the major version if a field is removed.
184  * - Increase the major version if a field is added at the beginning or in
185  * the middle of the structure.
186  * - Increase the minor version if a field is added at the very end of the
187  * structure.
188  * - The version_major and version_minor fields must be located at the very
189  * beginning of the structure.
190  * - The structure must be packed.
191  *
192  * Supported versions:
193  * - Major 0 / Minor 0 contains: version_major, version_minor, packets_nr,
194  * comp_bytes_nr, uncomp_bytes_nr, corrected_crc_failures,
195  * corrected_sn_wraparounds, and corrected_wrong_sn_updates.
196  *
197  * @ingroup rohc_decomp
198  *
199  * @see rohc_decomp_get_context_info
200  */
201 typedef struct
202 {
203  /** The major version of this structure */
204  unsigned short version_major;
205  /** The minor version of this structure */
206  unsigned short version_minor;
207  /** The number of packets processed by the context */
208  unsigned long packets_nr;
209  /** The number of compressed bytes received by the context */
210  unsigned long comp_bytes_nr;
211  /** The number of uncompressed bytes produced by the context */
212  unsigned long uncomp_bytes_nr;
213  /** The number of successful corrections upon CRC failure */
214  unsigned long corrected_crc_failures;
215  /** The number of successful corrections of SN wraparound upon CRC failure */
217  /** The number of successful corrections of incorrect SN updates upon CRC
218  * failure */
220 
221 } __attribute__((packed)) rohc_decomp_context_info_t;
222 
223 
224 /**
225  * @brief Some general information about the decompressor
226  *
227  * The structure is used by the \ref rohc_decomp_get_general_info function
228  * to store some general information about the decompressor.
229  *
230  * Versioning works as follow:
231  * - The \e version_major field defines the compatibility level. If the major
232  * number given by user does not match the one expected by the library,
233  * an error is returned.
234  * - The \e version_minor field defines the extension level. If the minor
235  * number given by user does not match the one expected by the library,
236  * only the fields supported in that minor version will be filled by
237  * \ref rohc_decomp_get_general_info.
238  *
239  * Notes for developers:
240  * - Increase the major version if a field is removed.
241  * - Increase the major version if a field is added at the beginning or in
242  * the middle of the structure.
243  * - Increase the minor version if a field is added at the very end of the
244  * structure.
245  * - The version_major and version_minor fields must be located at the very
246  * beginning of the structure.
247  * - The structure must be packed.
248  *
249  * Supported versions:
250  * - major 0 and minor = 0 contains: version_major, version_minor,
251  * contexts_nr, packets_nr, comp_bytes_nr, and uncomp_bytes_nr.
252  *
253  * @ingroup rohc_decomp
254  *
255  * @see rohc_decomp_get_general_info
256  */
257 typedef struct
258 {
259  /** The major version of this structure */
260  unsigned short version_major;
261  /** The minor version of this structure */
262  unsigned short version_minor;
263  /** The number of contexts used by the decompressor */
264  size_t contexts_nr;
265  /** The number of packets processed by the decompressor */
266  unsigned long packets_nr;
267  /** The number of compressed bytes received by the decompressor */
268  unsigned long comp_bytes_nr;
269  /** The number of uncompressed bytes produced by the decompressor */
270  unsigned long uncomp_bytes_nr;
271 
272  /* added in 0.1 */
273  /** The cumulative number of successful corrections upon CRC failure */
274  unsigned long corrected_crc_failures;
275  /** The cumulative number of successful corrections of SN wraparound
276  * upon CRC failure */
278  /** The cumulative number of successful corrections of incorrect SN updates
279  * upon CRC failure */
281 
282 } __attribute__((packed)) rohc_decomp_general_info_t;
283 
284 
285 /**
286  * @brief The different features of the ROHC decompressor
287  *
288  * Features for the ROHC decompressor control whether mechanisms defined as
289  * optional by RFCs are enabled or not. They can be set or unset with the
290  * function \ref rohc_decomp_set_features.
291  *
292  * @ingroup rohc_decomp
293  *
294  * @see rohc_decomp_set_features
295  */
296 typedef enum
297 {
298  /** No feature at all */
300  /** Attempt packet repair in case of CRC failure */
302  /** Be compatible with 1.6.x versions */
304  /** Dump content of packets in traces (beware: performance impact) */
306 
308 
309 
310 
311 /*
312  * Functions related to decompressor:
313  */
314 
316  const rohc_cid_t max_cid,
317  const rohc_mode_t mode)
318  __attribute__((warn_unused_result));
319 
320 void ROHC_EXPORT rohc_decomp_free(struct rohc_decomp *const decomp);
321 
323  const struct rohc_buf rohc_packet,
324  struct rohc_buf *const uncomp_packet,
325  struct rohc_buf *const rcvd_feedback,
326  struct rohc_buf *const feedback_send)
327  __attribute__((warn_unused_result));
328 
329 
330 
331 /*
332  * Functions related to statistics:
333  */
334 
336  __attribute__((warn_unused_result, const));
337 
338 bool ROHC_EXPORT rohc_decomp_get_general_info(const struct rohc_decomp *const decomp,
339  rohc_decomp_general_info_t *const info)
340  __attribute__((warn_unused_result));
341 
342 bool ROHC_EXPORT rohc_decomp_get_context_info(const struct rohc_decomp *const decomp,
343  const rohc_cid_t cid,
344  rohc_decomp_context_info_t *const info)
345  __attribute__((warn_unused_result));
346 
347 bool ROHC_EXPORT rohc_decomp_get_last_packet_info(const struct rohc_decomp *const decomp,
348  rohc_decomp_last_packet_info_t *const info)
349  __attribute__((warn_unused_result));
350 
351 
352 /*
353  * Functions related to user parameters
354  */
355 
356 /* CID */
357 
358 bool ROHC_EXPORT rohc_decomp_get_cid_type(const struct rohc_decomp *const decomp,
359  rohc_cid_type_t *const cid_type)
360  __attribute__((warn_unused_result));
361 
362 bool ROHC_EXPORT rohc_decomp_get_max_cid(const struct rohc_decomp *const decomp,
363  size_t *const max_cid)
364  __attribute__((warn_unused_result));
365 
366 /* MRRU */
367 
368 bool ROHC_EXPORT rohc_decomp_set_mrru(struct rohc_decomp *const decomp,
369  const size_t mrru)
370  __attribute__((warn_unused_result));
371 
372 bool ROHC_EXPORT rohc_decomp_get_mrru(const struct rohc_decomp *const decomp,
373  size_t *const mrru)
374  __attribute__((warn_unused_result));
375 
376 /* pRTT */
377 
378 bool ROHC_EXPORT rohc_decomp_set_prtt(struct rohc_decomp *const decomp,
379  const size_t prtt)
380  __attribute__((warn_unused_result));
381 
382 bool ROHC_EXPORT rohc_decomp_get_prtt(const struct rohc_decomp *const decomp,
383  size_t *const prtt)
384  __attribute__((warn_unused_result));
385 
386 /* feedback rate-limiting */
387 
388 bool ROHC_EXPORT rohc_decomp_set_rate_limits(struct rohc_decomp *const decomp,
389  const size_t k, const size_t n,
390  const size_t k_1, const size_t n_1,
391  const size_t k_2, const size_t n_2)
392  __attribute__((warn_unused_result));
393 
394 bool ROHC_EXPORT rohc_decomp_get_rate_limits(const struct rohc_decomp *const decomp,
395  size_t *const k, size_t *const n,
396  size_t *const k_1, size_t *const n_1,
397  size_t *const k_2, size_t *const n_2)
398  __attribute__((warn_unused_result));
399 
400 /* decompression library features */
401 
402 bool ROHC_EXPORT rohc_decomp_set_features(struct rohc_decomp *const decomp,
404  __attribute__((warn_unused_result));
405 
406 
407 /*
408  * Functions related to decompression profiles
409  */
410 
411 bool ROHC_EXPORT rohc_decomp_profile_enabled(const struct rohc_decomp *const decomp,
412  const rohc_profile_t profile)
413  __attribute__((warn_unused_result));
414 
415 bool ROHC_EXPORT rohc_decomp_enable_profile(struct rohc_decomp *const decomp,
416  const rohc_profile_t profile)
417  __attribute__((warn_unused_result));
418 
419 bool ROHC_EXPORT rohc_decomp_disable_profile(struct rohc_decomp *const decomp,
420  const rohc_profile_t profile)
421  __attribute__((warn_unused_result));
422 
423 bool ROHC_EXPORT rohc_decomp_enable_profiles(struct rohc_decomp *const decomp,
424  ...)
425  __attribute__((warn_unused_result));
426 
427 bool ROHC_EXPORT rohc_decomp_disable_profiles(struct rohc_decomp *const decomp,
428  ...)
429  __attribute__((warn_unused_result));
430 
431 
432 /*
433  * Functions related to traces
434  */
435 
436 bool ROHC_EXPORT rohc_decomp_set_traces_cb2(struct rohc_decomp *const decomp,
437  rohc_trace_callback2_t callback,
438  void *const priv_ctxt)
439  __attribute__((warn_unused_result));
440 
441 
442 #undef ROHC_EXPORT /* do not pollute outside this header */
443 
444 #ifdef __cplusplus
445 }
446 #endif
447 
448 #endif /* ROHC_DECOMP_H */
449 
unsigned long comp_bytes_nr
Definition: rohc_decomp.h:210
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:277
bool ROHC_EXPORT rohc_decomp_enable_profiles(struct rohc_decomp *const decomp,...)
Enable several decompression profiles for a decompressor.
Definition: rohc_decomp.c:3617
#define ROHC_EXPORT
Definition: rohc_decomp.h:47
The ROHC decompressor.
Definition: rohc_decomp_internals.h:142
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:219
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:2476
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:3551
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:111
unsigned long total_last_comp_size
Definition: rohc_decomp.h:156
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:3328
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:150
unsigned long corrected_wrong_sn_updates
Definition: rohc_decomp.h:280
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:3281
int profile_id
Definition: rohc_decomp.h:135
Some information about one decompression context.
Definition: rohc_decomp.h:201
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:3675
Definition: rohc_decomp.h:303
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:3731
Some general information about the decompressor.
Definition: rohc_decomp.h:257
Definition: rohc_decomp.h:301
unsigned short version_minor
Definition: rohc_decomp.h:262
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:2716
unsigned long uncomp_bytes_nr
Definition: rohc_decomp.h:212
unsigned long nr_lost_packets
Definition: rohc_decomp.h:137
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:2517
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:2818
unsigned short version_minor
Definition: rohc_decomp.h:129
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:216
size_t mrru
Definition: rohc_decomp_internals.h:187
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:274
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:2975
Definition: rohc_decomp.h:80
Definition: rohc_decomp.h:299
unsigned long header_last_comp_size
Definition: rohc_decomp.h:158
Definition: rohc_decomp.h:84
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:3181
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:3034
unsigned long uncomp_bytes_nr
Definition: rohc_decomp.h:270
size_t contexts_nr
Definition: rohc_decomp.h:264
rohc_mode_t context_mode
Definition: rohc_decomp.h:131
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:713
unsigned long packets_nr
Definition: rohc_decomp.h:266
A network buffer for the ROHC library.
Definition: rohc_buf.h:102
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:214
unsigned long header_last_uncomp_size
Definition: rohc_decomp.h:162
rohc_packet_t packet_type
Definition: rohc_decomp.h:152
rohc_decomp_state_t
The ROHC decompressor states.
Definition: rohc_decomp.h:75
rohc_decomp_features_t
The different features of the ROHC decompressor.
Definition: rohc_decomp.h:296
Some information about the last decompressed packet.
Definition: rohc_decomp.h:124
unsigned short version_major
Definition: rohc_decomp.h:260
unsigned long comp_bytes_nr
Definition: rohc_decomp.h:268
Definition: rohc_decomp.h:305
unsigned long total_last_uncomp_size
Definition: rohc_decomp.h:160
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:470
rohc_decomp_features_t features
Definition: rohc_decomp_internals.h:148
Definition: rohc_decomp.h:82
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:3413
unsigned short version_major
Definition: rohc_decomp.h:204
rohc_decomp_state_t context_state
Definition: rohc_decomp.h:133
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:2621
unsigned short version_major
Definition: rohc_decomp.h:127
unsigned long corrected_sn_wraparounds
Definition: rohc_decomp.h:147
void ROHC_EXPORT rohc_decomp_free(struct rohc_decomp *const decomp)
Destroy the given ROHC decompressor.
Definition: rohc_decomp.c:613
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc_profiles.h:70
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:3476
unsigned long nr_misordered_packets
Definition: rohc_decomp.h:139
rohc_packet_t
The different types of ROHC packets.
Definition: rohc_packets.h:55
unsigned short version_minor
Definition: rohc_decomp.h:206
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:2789
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:2887
unsigned long packets_nr
Definition: rohc_decomp.h:208
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:3102
unsigned long corrected_crc_failures
Definition: rohc_decomp.h:145
Definition: rohc_decomp.h:78
bool is_duplicated
Definition: rohc_decomp.h:141