ROHC compression/decompression library
rohc.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010,2011,2012,2013,2014 Didier Barvaux
3  * Copyright 2007,2009,2010,2012 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.h
22  * @brief ROHC common definitions and routines
23  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
24  * @author Didier Barvaux <didier@barvaux.org>
25  */
26 
27 #ifndef ROHC_H
28 #define ROHC_H
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 #include <rohc/rohc_profiles.h>
36 
37 #include <stdlib.h>
38 #include <stddef.h>
39 #include <stdint.h>
40 
41 
42 /** Macro that handles deprecated declarations gracefully */
43 #if defined __GNUC__ && \
44  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
45  /* __attribute__((deprecated(msg))) is supported by GCC 4.5 and later */
46  #define ROHC_DEPRECATED(msg) __attribute__((deprecated(msg)))
47 #elif defined __GNUC__ && \
48  (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
49  /* __attribute__((deprecated)) is supported by GCC 3.1 and later */
50  #define ROHC_DEPRECATED(msg) __attribute__((deprecated))
51 #else
52  /* no support */
53  #define ROHC_DEPRECATED(msg)
54 #endif
55 
56 
57 /** Macro that handles DLL export declarations gracefully */
58 #ifdef DLL_EXPORT /* passed by autotools on command line */
59 # define ROHC_EXPORT __declspec(dllexport)
60 #else
61 # define ROHC_EXPORT
62 #endif
63 
64 
65 /**
66  * @brief The Ethertype assigned to the ROHC protocol by the IEEE
67  *
68  * @see http://standards.ieee.org/regauth/ethertype/eth.txt
69  *
70  * @ingroup rohc
71  */
72 #define ROHC_ETHERTYPE 0x22f1
73 
74 
75 /**
76  * @brief The status code of several functions in the library API
77  *
78  * @ingroup rohc
79  */
80 typedef enum
81 {
82  /** The action was successful */
84  /** The action was successful but packet needs to be segmented */
86  /** The action failed due to a malformed packet */
88  /** The action failed because no matching context exists */
90  /** The action failed due to a CRC failure */
92  /** The action failed because output buffer is too small */
94  /** The action encountered an undefined problem */
96 
98 
99 
100 /**
101  * @brief ROHC operation modes
102  *
103  * The different ROHC operation modes as defined in section 4.4 of RFC 3095.
104  *
105  * If you add a new operation mode, please also add the corresponding textual
106  * description in \ref rohc_get_mode_descr.
107  *
108  * @ingroup rohc
109  *
110  * @see rohc_get_mode_descr
111  */
112 typedef enum
113 {
114  /** Unknown operational mode */
116  /** The Unidirectional mode (U-mode) */
118  /** The Bidirectional Optimistic mode (O-mode) */
120  /** The Bidirectional Reliable mode (R-mode) */
122 
123 } rohc_mode_t;
124 
125 
126 /**
127  * @brief The maximum value for large CIDs
128  *
129  * @ingroup rohc
130  *
131  * @see rohc_comp_new
132  * @see rohc_c_set_max_cid
133  * @see rohc_decomp_set_max_cid
134  */
135 #define ROHC_LARGE_CID_MAX ((1U << 14) - 1) /* 2^14 - 1 = 16383 */
136 
137 
138 /**
139  * @brief The maximum value for small CIDs
140  *
141  * @ingroup rohc
142  *
143  * @see rohc_comp_new
144  * @see rohc_c_set_max_cid
145  * @see rohc_decomp_set_max_cid
146  *
147  * \par Example:
148  * \snippet simple_rohc_program.c define ROHC compressor
149  * \snippet simple_rohc_program.c create ROHC compressor
150  */
151 #define ROHC_SMALL_CID_MAX 15U
152 
153 
154 /**
155  * @brief The different types of Context IDs (CID)
156  *
157  * The different types of Context IDs (CID) a ROHC compressor or a ROHC
158  * decompressor may use.
159  *
160  * Possible values are:
161  * \li \ref ROHC_LARGE_CID : large CID means that a ROHC compressor or a ROHC
162  * decompressor may identify contexts with IDs in the range
163  * [0, \ref ROHC_LARGE_CID_MAX ], ie. it may uniquely identify at
164  * most \e ROHC_LARGE_CID_MAX + 1 streams.
165  * \li \ref ROHC_SMALL_CID : small CID means that a ROHC compressor or a ROHC
166  * decompressor may identify contexts with IDs in the range
167  * [0, \ref ROHC_SMALL_CID_MAX ], ie. it may uniquely identify at
168  * most \e ROHC_SMALL_CID_MAX + 1 streams.
169  *
170  * In short, you choose the CID type in function of the number of simultaneous
171  * streams you have to compress efficiently.
172  *
173  * @see ROHC_SMALL_CID_MAX ROHC_LARGE_CID_MAX
174  *
175  * @ingroup rohc
176  */
177 typedef enum
178 {
179  /**
180  * @brief The context uses large CID
181  *
182  * CID values shall be in the range [0, \ref ROHC_LARGE_CID_MAX].
183  */
185  /**
186  * @brief The context uses small CID
187  *
188  * CID value shall be in the range [0, \ref ROHC_SMALL_CID_MAX].
189  */
191 
193 
194 
195 /** A ROHC Context ID (CID) */
196 typedef uint16_t rohc_cid_t;
197 
198 
199 /**
200  * @brief The different values of reordering offset
201  *
202  * @ingroup rohc_comp
203  */
204 typedef enum
205 {
206  ROHC_REORDERING_NONE = 0, /**< No reordering accepted */
207  ROHC_REORDERING_QUARTER = 1, /**< Reordering accepted on 1/4 of the WLSB */
208  ROHC_REORDERING_HALF = 2, /**< Reordering accepted on 1/2 of the WLSB */
209  ROHC_REORDERING_THREEQUARTERS = 3, /**< Reordering accepted on 3/4 of the WLSB */
211 
212 
213 /*
214  * Prototypes of public functions
215  */
216 
217 char * ROHC_EXPORT rohc_version(void)
218  __attribute__((warn_unused_result, const));
219 
220 const char * ROHC_EXPORT rohc_strerror(const rohc_status_t status)
221  __attribute__((warn_unused_result, const));
222 
224  __attribute__((warn_unused_result, const));
225 
226 
227 #undef ROHC_EXPORT /* do not pollute outside this header */
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /* ROHC_H */
234 
Definition: rohc.h:206
Definition: rohc.h:115
rohc_reordering_offset_t
The different values of reordering offset.
Definition: rohc.h:204
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:112
Definition: rohc.h:91
Definition: rohc.h:85
Definition: rohc.h:208
rohc_status_t
The status code of several functions in the library API.
Definition: rohc.h:80
rohc_cid_type_t
The different types of Context IDs (CID)
Definition: rohc.h:177
Definition: rohc.h:93
char *ROHC_EXPORT rohc_version(void)
Get the version of the ROHC library.
Definition: rohc_common.c:54
Definition: rohc.h:83
The context uses large CID.
Definition: rohc.h:184
Definition: rohc.h:117
Definition: rohc.h:87
The context uses small CID.
Definition: rohc.h:190
const char *ROHC_EXPORT rohc_strerror(const rohc_status_t status)
Give a description for the given ROHC status code.
Definition: rohc_common.c:75
Definition: rohc.h:207
const char *ROHC_EXPORT rohc_get_mode_descr(const rohc_mode_t mode)
Give a description for the given ROHC mode.
Definition: rohc_common.c:114
Definition: rohc.h:119
Definition: rohc.h:121
uint16_t rohc_cid_t
Definition: rohc.h:196
#define ROHC_EXPORT
Definition: rohc.h:61
Definition: rohc.h:209
rohc_mode_t mode
Definition: rohc_decomp_internals.h:283
Definition: rohc.h:89
Definition: rohc.h:95