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