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