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 <stdlib.h>
36 #ifndef __KERNEL__
37 # include <inttypes.h>
38 #endif
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  * ROHC profiles numbers allocated by the IANA (see 8 in the RFC 3095):
200  */
201 
202 /**
203  * @brief The different ROHC compression/decompression profiles
204  *
205  * If you add a new compression/decompression profile, please also add the
206  * corresponding textual description in \ref rohc_get_profile_descr.
207  *
208  * @ingroup rohc
209  *
210  * @see rohc_get_profile_descr
211  */
212 typedef enum
213 {
214  /** The ROHC Uncompressed profile (RFC 3095, section 5.10) */
216  /** The ROHC RTP profile (RFC 3095, section 8) */
218  /** The ROHC UDP profile (RFC 3095, section 5.11) */
220  /** The ROHC ESP profile (RFC 3095, section 5.12) */
222  /** The ROHC IP-only profile (RFC 3843, section 5) */
223  ROHC_PROFILE_IP = 0x0004,
224  /** The ROHC IP/UDP/RTP Link-Layer Assisted Profile (LLA) profile
225  * (RFC 4362, section 6) */
227  /** The ROHC TCP profile (RFC 4996) */
229  /** The ROHC UDP-Lite/RTP profile (RFC 4019, section 7) */
231  /** The ROHC UDP-Lite profile (RFC 4019, section 7) */
233 
235 
237 
238 
239 
240 /*
241  * Prototypes of public functions
242  */
243 
244 char * ROHC_EXPORT rohc_version(void)
245  __attribute__((warn_unused_result, const));
246 
247 const char * ROHC_EXPORT rohc_strerror(const rohc_status_t status)
248  __attribute__((warn_unused_result, const));
249 
251  __attribute__((warn_unused_result, const));
252 
254  __attribute__((warn_unused_result, const));
255 
256 
257 
258 #undef ROHC_EXPORT /* do not pollute outside this header */
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* ROHC_H */
265 
Definition: rohc.h:114
size_t rohc_cid_t
Definition: rohc.h:195
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:111
Definition: rohc.h:90
Definition: rohc.h:228
Definition: rohc.h:84
Definition: rohc.h:217
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
Definition: rohc.h:234
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:230
Definition: rohc.h:223
Definition: rohc.h:232
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:215
Definition: rohc.h:118
const struct rohc_decomp_profile * profile
Definition: rohc_decomp_internals.h:283
Definition: rohc.h:120
#define ROHC_EXPORT
Definition: rohc.h:60
Definition: rohc.h:226
rohc_mode_t mode
Definition: rohc_decomp_internals.h:290
Definition: rohc.h:221
Definition: rohc.h:88
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc.h:212
const char *ROHC_EXPORT rohc_get_profile_descr(const rohc_profile_t profile)
Give a description for the given ROHC profile.
Definition: rohc_common.c:146
Definition: rohc.h:219
Definition: rohc.h:94