00001 /* 00002 * Copyright 2010,2011,2012,2013,2014 Didier Barvaux 00003 * Copyright 2007,2009,2010,2012 Viveris Technologies 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 /** 00021 * @file rohc.h 00022 * @brief ROHC common definitions and routines 00023 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00024 * @author Didier Barvaux <didier@barvaux.org> 00025 */ 00026 00027 #ifndef ROHC_H 00028 #define ROHC_H 00029 00030 #ifdef __cplusplus 00031 extern "C" 00032 { 00033 #endif 00034 00035 #include <stdlib.h> 00036 #ifndef __KERNEL__ 00037 # include <inttypes.h> 00038 #endif 00039 00040 00041 /** Macro that handles deprecated declarations gracefully */ 00042 #if defined __GNUC__ && \ 00043 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) 00044 /* __attribute__((deprecated(msg))) is supported by GCC 4.5 and later */ 00045 #define ROHC_DEPRECATED(msg) __attribute__((deprecated(msg))) 00046 #elif defined __GNUC__ && \ 00047 (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 00048 /* __attribute__((deprecated)) is supported by GCC 3.1 and later */ 00049 #define ROHC_DEPRECATED(msg) __attribute__((deprecated)) 00050 #else 00051 /* no support */ 00052 #define ROHC_DEPRECATED(msg) 00053 #endif 00054 00055 00056 /** Macro that handles DLL export declarations gracefully */ 00057 #ifdef DLL_EXPORT /* passed by autotools on command line */ 00058 # define ROHC_EXPORT __declspec(dllexport) 00059 #else 00060 # define ROHC_EXPORT 00061 #endif 00062 00063 00064 /** 00065 * @brief The Ethertype assigned to the ROHC protocol by the IEEE 00066 * 00067 * @see http://standards.ieee.org/regauth/ethertype/eth.txt 00068 * 00069 * @ingroup rohc 00070 */ 00071 #define ROHC_ETHERTYPE 0x22f1 00072 00073 00074 /** 00075 * @brief The status code of several functions in the library API 00076 * 00077 * @ingroup rohc 00078 */ 00079 typedef enum 00080 { 00081 /** The action was successful */ 00082 ROHC_STATUS_OK = 0, 00083 /** The action was successful but packet needs to be segmented */ 00084 ROHC_STATUS_SEGMENT = 1, 00085 /** The action failed due to a malformed packet */ 00086 ROHC_STATUS_MALFORMED = 2, 00087 /** The action failed because no matching context exists */ 00088 ROHC_STATUS_NO_CONTEXT = 3, 00089 /** The action failed due to a CRC failure */ 00090 ROHC_STATUS_BAD_CRC = 4, 00091 /** The action failed because output buffer is too small */ 00092 ROHC_STATUS_OUTPUT_TOO_SMALL = 5, 00093 /** The action encountered an undefined problem */ 00094 ROHC_STATUS_ERROR = 6, 00095 00096 } rohc_status_t; 00097 00098 00099 /** 00100 * @brief ROHC operation modes 00101 * 00102 * The different ROHC operation modes as defined in section 4.4 of RFC 3095. 00103 * 00104 * If you add a new operation mode, please also add the corresponding textual 00105 * description in \ref rohc_get_mode_descr. 00106 * 00107 * @ingroup rohc 00108 * 00109 * @see rohc_get_mode_descr 00110 */ 00111 typedef enum 00112 { 00113 /** Unknown operational mode */ 00114 ROHC_UNKNOWN_MODE = 0, 00115 /** The Unidirectional mode (U-mode) */ 00116 ROHC_U_MODE = 1, 00117 /** The Bidirectional Optimistic mode (O-mode) */ 00118 ROHC_O_MODE = 2, 00119 /** The Bidirectional Reliable mode (R-mode) */ 00120 ROHC_R_MODE = 3, 00121 00122 } rohc_mode_t; 00123 00124 00125 /** 00126 * @brief The maximum value for large CIDs 00127 * 00128 * @ingroup rohc 00129 * 00130 * @see rohc_comp_new 00131 * @see rohc_c_set_max_cid 00132 * @see rohc_decomp_set_max_cid 00133 */ 00134 #define ROHC_LARGE_CID_MAX ((1U << 14) - 1) /* 2^14 - 1 = 16383 */ 00135 00136 00137 /** 00138 * @brief The maximum value for small CIDs 00139 * 00140 * @ingroup rohc 00141 * 00142 * @see rohc_comp_new 00143 * @see rohc_c_set_max_cid 00144 * @see rohc_decomp_set_max_cid 00145 * 00146 * \par Example: 00147 * \snippet simple_rohc_program.c define ROHC compressor 00148 * \snippet simple_rohc_program.c create ROHC compressor 00149 */ 00150 #define ROHC_SMALL_CID_MAX 15U 00151 00152 00153 /** 00154 * @brief The different types of Context IDs (CID) 00155 * 00156 * The different types of Context IDs (CID) a ROHC compressor or a ROHC 00157 * decompressor may use. 00158 * 00159 * Possible values are: 00160 * \li \ref ROHC_LARGE_CID : large CID means that a ROHC compressor or a ROHC 00161 * decompressor may identify contexts with IDs in the range 00162 * [0, \ref ROHC_LARGE_CID_MAX ], ie. it may uniquely identify at 00163 * most \e ROHC_LARGE_CID_MAX + 1 streams. 00164 * \li \ref ROHC_SMALL_CID : small CID means that a ROHC compressor or a ROHC 00165 * decompressor may identify contexts with IDs in the range 00166 * [0, \ref ROHC_SMALL_CID_MAX ], ie. it may uniquely identify at 00167 * most \e ROHC_SMALL_CID_MAX + 1 streams. 00168 * 00169 * In short, you choose the CID type in function of the number of simultaneous 00170 * streams you have to compress efficiently. 00171 * 00172 * @see ROHC_SMALL_CID_MAX ROHC_LARGE_CID_MAX 00173 * 00174 * @ingroup rohc 00175 */ 00176 typedef enum 00177 { 00178 /** 00179 * @brief The context uses large CID 00180 * 00181 * CID values shall be in the range [0, \ref ROHC_LARGE_CID_MAX]. 00182 */ 00183 ROHC_LARGE_CID, 00184 /** 00185 * @brief The context uses small CID 00186 * 00187 * CID value shall be in the range [0, \ref ROHC_SMALL_CID_MAX]. 00188 */ 00189 ROHC_SMALL_CID, 00190 00191 } rohc_cid_type_t; 00192 00193 00194 /** A ROHC Context ID (CID) */ 00195 typedef size_t rohc_cid_t; 00196 00197 00198 /* 00199 * ROHC profiles numbers allocated by the IANA (see 8 in the RFC 3095): 00200 */ 00201 00202 /** 00203 * @brief The different ROHC compression/decompression profiles 00204 * 00205 * If you add a new compression/decompression profile, please also add the 00206 * corresponding textual description in \ref rohc_get_profile_descr. 00207 * 00208 * @ingroup rohc 00209 * 00210 * @see rohc_get_profile_descr 00211 */ 00212 typedef enum 00213 { 00214 /** The ROHC Uncompressed profile (RFC 3095, section 5.10) */ 00215 ROHC_PROFILE_UNCOMPRESSED = 0x0000, 00216 /** The ROHC RTP profile (RFC 3095, section 8) */ 00217 ROHC_PROFILE_RTP = 0x0001, 00218 /** The ROHC UDP profile (RFC 3095, section 5.11) */ 00219 ROHC_PROFILE_UDP = 0x0002, 00220 /** The ROHC ESP profile (RFC 3095, section 5.12) */ 00221 ROHC_PROFILE_ESP = 0x0003, 00222 /** The ROHC IP-only profile (RFC 3843, section 5) */ 00223 ROHC_PROFILE_IP = 0x0004, 00224 /** The ROHC IP/UDP/RTP Link-Layer Assisted Profile (LLA) profile 00225 * (RFC 4362, section 6) */ 00226 ROHC_PROFILE_RTP_LLA = 0x0005, 00227 /** The ROHC TCP profile (RFC 4996) */ 00228 ROHC_PROFILE_TCP = 0x0006, 00229 /** The ROHC UDP-Lite/RTP profile (RFC 4019, section 7) */ 00230 ROHC_PROFILE_UDPLITE_RTP = 0x0007, 00231 /** The ROHC UDP-Lite profile (RFC 4019, section 7) */ 00232 ROHC_PROFILE_UDPLITE = 0x0008, 00233 00234 ROHC_PROFILE_MAX = 0x0009, 00235 00236 } rohc_profile_t; 00237 00238 00239 00240 /* 00241 * Prototypes of public functions 00242 */ 00243 00244 char * ROHC_EXPORT rohc_version(void) 00245 __attribute__((warn_unused_result, const)); 00246 00247 const char * ROHC_EXPORT rohc_strerror(const rohc_status_t status) 00248 __attribute__((warn_unused_result, const)); 00249 00250 const char * ROHC_EXPORT rohc_get_mode_descr(const rohc_mode_t mode) 00251 __attribute__((warn_unused_result, const)); 00252 00253 const char * ROHC_EXPORT rohc_get_profile_descr(const rohc_profile_t profile) 00254 __attribute__((warn_unused_result, const)); 00255 00256 00257 00258 #undef ROHC_EXPORT /* do not pollute outside this header */ 00259 00260 #ifdef __cplusplus 00261 } 00262 #endif 00263 00264 #endif /* ROHC_H */ 00265
1.6.1