ROHC compression/decompression library
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program; if not, write to the Free Software 00014 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00015 */ 00016 00017 /** 00018 * @file rohc.h 00019 * @brief ROHC common definitions and routines 00020 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00021 * @author Didier Barvaux <didier@barvaux.org> 00022 * @author The hackers from ROHC for Linux 00023 */ 00024 00025 #ifndef ROHC_H 00026 #define ROHC_H 00027 00028 /** 00029 * \mainpage 00030 * 00031 * <h2>Introduction</h2> 00032 * <p>The <a href="http://rohc-lib.org/" title="Official website">ROHC library</a> 00033 * provides an easy and robust way for applications to reduce their bandwidth 00034 * usage on network links with limited capacity. Headers of network packets are 00035 * compressed with the ROHC protocol and algorithms.</p> 00036 * <p><a href="http://rohc-lib.org/wiki/doku.php?id=rohc-protocol" 00037 * title="An introduction to the ROHC protocol">RObust Header Compression 00038 * (ROHC)</a> is a set of standards defined by the <a href="http://www.ietf.org/" 00039 * title="The IETF website">IETF</a>. The ROHC library is a free, opensource and 00040 * efficient implementation of them. The list of features implemented is available 00041 * on a separate page: \ref features</p> 00042 * <ul> 00043 * <li>Official website: <a href="http://rohc-lib.org/"> 00044 * http://rohc-lib.org/</a></li> 00045 * <li>Project page on Launchpad: <a href="http://rohc-lib.org/"> 00046 * http://rohc-lib.org/</a></li> 00047 * <li>Mailing list: <a href="mailto:rohc@lists.launchpad.net"> 00048 * rohc@lists.launchpad.net</a></li> 00049 * <li>Mailing list archives: <a href="http://lists.launchpad.net/rohc/"> 00050 * http://lists.launchpad.net/rohc/</a></li> 00051 * <li>Bugtracker: <a href="http://bugs.launchpad.net/rohc"> 00052 * http://bugs.launchpad.net/rohc</a></li> 00053 * </ul> 00054 * 00055 * <h2>License</h2> 00056 * <p>The project is licensed under GPL2+. 00057 * See the <a href="http://bazaar.launchpad.net/%7Edidier-barvaux/rohc/main/annotate/head%3A/COPYING">COPYING</a> 00058 * and <a href="http://bazaar.launchpad.net/%7Edidier-barvaux/rohc/main/annotate/head%3A/AUTHORS">AUTHORS</a> 00059 * files for more details.</p> 00060 * 00061 * <h2>Libraries</h2> 00062 * <p> 00063 * The sources are in the src subdirectory. The sources are separated into 00064 * three libraries: 00065 * <ul> 00066 * <li>a library that contains the routines used for both the compression 00067 * and the decompression processes</li> 00068 * <li>a library that handles the compression process</li> 00069 * <li>a library that handles the decompression process</li> 00070 * </ul> 00071 * </p> 00072 * <p>See the <a href="http://bazaar.launchpad.net/%7Edidier-barvaux/rohc/main/annotate/head%3A/INSTALL"> INSTALL file</a> 00073 * to learn to build the libraries.</p> 00074 * 00075 * <h2>API documentation</h2> 00076 * <p>The APIs for ROHC common, compression and decompression are available on 00077 * separate pages: 00078 * <ul> 00079 * <li>\ref rohc_common</li> 00080 * <li>\ref rohc_comp</li> 00081 * <li>\ref rohc_decomp</li> 00082 * </ul> 00083 * </p> 00084 * 00085 * <h2>Tests</h2> 00086 * <p> 00087 * Several tests may be run to check the library behaviour. See the 00088 * <a href="http://bazaar.launchpad.net/%7Edidier-barvaux/rohc/main/annotate/head%3A/INSTALL">INSTALL file</a> to learn how to use these tools. 00089 * </p> 00090 * 00091 * <h2>References</h2> 00092 * <dl style="padding-bottom: 1em;"> 00093 * <dt><a href="http://tools.ietf.org/html/rfc3095">RFC 3095</a></dt> 00094 * <dd>ROHC: Framework and four profiles: RTP, UDP, ESP, and uncompressed.</dd> 00095 * <dt><a href="http://tools.ietf.org/html/rfc3096">RFC 3096</a></dt> 00096 * <dd>Requirements for robust IP/UDP/RTP header compression.</dd> 00097 * <dt><a href="http://tools.ietf.org/html/rfc3843">RFC 3843</a></dt> 00098 * <dd>ROHC: A Compression Profile for IP.</dd> 00099 * <dt><a href="http://tools.ietf.org/html/rfc4019">RFC 4019</a></dt> 00100 * <dd>ROHC: Profiles for User Datagram Protocol (UDP) Lite.</dd> 00101 * <dt><a href="http://rohc-lib.org/">ROHC library</a></dt> 00102 * <dd>The Open Source ROHC library described by the documentation you are 00103 * currently reading.</dd> 00104 * <dt><a href="http://rohc.sourceforge.net/">ROHC Linux</a></dt> 00105 * <dd>A GPL-licensed implementation of ROHC over PPP for the 2.4 Linux kernel. 00106 * The ROHC library started as a fork of this project.</dd> 00107 * </dl> 00108 */ 00109 00110 00111 /** 00112 * \page features Library features 00113 * 00114 * <p>See the <a href="http://rohc-lib.org/wiki/doku.php?id=library-compliance-rfcs">dedicated Wiki page for more details</a>.</p> 00115 */ 00116 00117 00118 /** Macro that handles deprecated declarations gracefully */ 00119 #if defined __GNUC__ && \ 00120 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) 00121 /* __attribute__((deprecated(msg))) is supported by GCC 4.5 and later */ 00122 #define ROHC_DEPRECATED(msg) __attribute__((deprecated(msg))) 00123 #elif defined __GNUC__ && \ 00124 (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 00125 /* __attribute__((deprecated)) is supported by GCC 3.1 and later */ 00126 #define ROHC_DEPRECATED(msg) __attribute__((deprecated)) 00127 #else 00128 /* no support */ 00129 #define ROHC_DEPRECATED(msg) 00130 #endif 00131 00132 00133 /** Macro that handles DLL export declarations gracefully */ 00134 #ifdef DLL_EXPORT /* passed by autotools on command line */ 00135 #define ROHC_EXPORT __declspec(dllexport) 00136 #else 00137 #define ROHC_EXPORT 00138 #endif 00139 00140 00141 00142 /** 00143 * @brief The Ethertype assigned to the ROHC protocol by the IEEE 00144 * 00145 * @see http://standards.ieee.org/regauth/ethertype/eth.txt 00146 * 00147 * @ingroup rohc_common 00148 */ 00149 #define ROHC_ETHERTYPE 0x22f1 00150 00151 00152 /* 00153 * Below are some return codes: 00154 */ 00155 00156 /// Return code: the action done without problem 00157 #define ROHC_OK 1 00158 /// Return code: the action can not proceed because no context is defined 00159 #define ROHC_ERROR_NO_CONTEXT -1 00160 /// Return code: the action failed due to an unattended or malformed packet 00161 #define ROHC_ERROR_PACKET_FAILED -2 00162 /// Return code: the action failed because the packet only contains feedback info 00163 #define ROHC_FEEDBACK_ONLY -3 00164 /// Return code: the action failed due to a CRC failure 00165 #define ROHC_ERROR_CRC -4 00166 /// Return code: the action encountered a problem 00167 #define ROHC_ERROR -5 00168 /// Return code: the packet needs to be parsed again 00169 #define ROHC_NEED_REPARSE -6 00170 /// Return code: the packet needs to be segmented 00171 #define ROHC_NEED_SEGMENT -7 00172 /// Return code: the action failed because the packet is a non-final segment 00173 #define ROHC_NON_FINAL_SEGMENT -8 00174 00175 00176 /** 00177 * @brief ROHC operation modes (see 4.4 in the RFC 3095) 00178 * 00179 * If you add a new operation mode, please also add the corresponding textual 00180 * description in \ref rohc_get_mode_descr. 00181 * 00182 * @ingroup rohc_common 00183 */ 00184 typedef enum 00185 { 00186 /// The Unidirectional mode (U-mode) 00187 U_MODE = 1, 00188 /// The Bidirectional Optimistic mode (O-mode) 00189 O_MODE = 2, 00190 /// The Bidirectional Reliable mode (R-mode) 00191 R_MODE = 3, 00192 } rohc_mode; 00193 00194 00195 /** The maximum value for large CIDs */ 00196 #define ROHC_LARGE_CID_MAX ((1 << 14) - 1) /* 2^14 - 1 = 16383 */ 00197 /** The maximum value for small CIDs */ 00198 #define ROHC_SMALL_CID_MAX 15 00199 00200 00201 /** 00202 * @brief The different types of Context IDs (CID) a stream/context may use 00203 * 00204 * Possible values are: \ref ROHC_LARGE_CID, \ref ROHC_SMALL_CID. 00205 * 00206 * Small CID means CID in the \f$[0-ROHC\_SMALL\_CID\_MAX]\f$ interval. 00207 * 00208 * Large CID means CID in the \f$[0-ROHC\_LARGE\_CID\_MAX]\f$ interval. 00209 * 00210 * @see ROHC_SMALL_CID_MAX ROHC_LARGE_CID_MAX 00211 * 00212 * @ingroup rohc_common 00213 */ 00214 typedef enum 00215 { 00216 /** 00217 * @brief The context uses large CID 00218 * 00219 * Value in the \f$[0-ROHC\_LARGE\_CID\_MAX]\f$ interval. 00220 */ 00221 ROHC_LARGE_CID, 00222 /** 00223 * @brief The context uses small CID 00224 * 00225 * Value in the \f$[0-ROHC\_SMALL\_CID\_MAX]\f$ interval. 00226 */ 00227 ROHC_SMALL_CID, 00228 } rohc_cid_type_t; 00229 00230 00231 /** 00232 * @brief ROHC medium (CID characteristics). 00233 * 00234 * @ingroup rohc_common 00235 */ 00236 struct medium 00237 { 00238 /** The CID type: large or small */ 00239 rohc_cid_type_t cid_type; 00240 00241 /// The maximum CID value 00242 int max_cid; 00243 }; 00244 00245 00246 /* 00247 * ROHC profiles numbers allocated by the IANA (see 8 in the RFC 3095): 00248 */ 00249 00250 /// The number allocated for the ROHC Uncompressed profile (RFC 3095, 5.10) 00251 #define ROHC_PROFILE_UNCOMPRESSED 0x0000 00252 /// The number allocated for the ROHC RTP profile (RFC 3095, 8) 00253 #define ROHC_PROFILE_RTP 0x0001 00254 /// The number allocated for the ROHC UDP profile (RFC 3095, 5.11) 00255 #define ROHC_PROFILE_UDP 0x0002 00256 /// The number allocated for the ROHC ESP profile (RFC 3095, 5.12) 00257 #define ROHC_PROFILE_ESP 0x0003 00258 /// The number allocated for the ROHC IP-only profile (see 5 in the RFC 3843) 00259 #define ROHC_PROFILE_IP 0x0004 00260 /// The number allocated for the ROHC UDP-Lite profile (see 7 in the RFC 4019) 00261 #define ROHC_PROFILE_UDPLITE 0x0008 00262 00263 00264 #if !defined(ENABLE_DEPRECATED_API) || ENABLE_DEPRECATED_API == 1 00265 00266 /* 00267 * The different CRC types and tables for ROHC compression/decompression 00268 * 00269 * TODO API: remove these public constants since a private enum was created 00270 */ 00271 00272 /** The CRC-2 type (deprecated) */ 00273 #define CRC_TYPE_2 1 00274 /** The CRC-3 type (deprecated) */ 00275 #define CRC_TYPE_3 2 00276 /** The CRC-6 type (deprecated) */ 00277 #define CRC_TYPE_6 3 00278 /** The CRC-7 type (deprecated) */ 00279 #define CRC_TYPE_7 4 00280 /** The CRC-8 type (deprecated) */ 00281 #define CRC_TYPE_8 5 00282 00283 00284 /* TODO API: remove these variables once compatibility is not needed anymore */ 00285 00286 /** The table to enable fast CRC-2 computation 00287 * @deprecated please do not use this variable anymore */ 00288 extern unsigned char ROHC_EXPORT crc_table_2[256] 00289 ROHC_DEPRECATED("please do not use this variable anymore, simply drop it"); 00290 00291 /** The table to enable fast CRC-3 computation 00292 * @deprecated please do not use this variable anymore */ 00293 extern unsigned char ROHC_EXPORT crc_table_3[256] 00294 ROHC_DEPRECATED("please do not use this variable anymore, simply drop it"); 00295 00296 /** The table to enable fast CRC-6 computation 00297 * @deprecated please do not use this variable anymore */ 00298 extern unsigned char ROHC_EXPORT crc_table_6[256] 00299 ROHC_DEPRECATED("please do not use this variable anymore, simply drop it"); 00300 00301 /** The table to enable fast CRC-7 computation 00302 * @deprecated please do not use this variable anymore */ 00303 extern unsigned char ROHC_EXPORT crc_table_7[256] 00304 ROHC_DEPRECATED("please do not use this variable anymore, simply drop it"); 00305 00306 /** The table to enable fast CRC-8 computation 00307 * @deprecated please do not use this variable anymore */ 00308 extern unsigned char ROHC_EXPORT crc_table_8[256] 00309 ROHC_DEPRECATED("please do not use this variable anymore, simply drop it"); 00310 00311 #endif /* !defined(ENABLE_DEPRECATED_API) || ENABLE_DEPRECATED_API == 1 */ 00312 00313 00314 /* 00315 * Prototypes of public up-to-date functions 00316 */ 00317 00318 char * ROHC_EXPORT rohc_version(void); 00319 00320 const char * ROHC_EXPORT rohc_get_mode_descr(const rohc_mode mode); 00321 00322 00323 #if !defined(ENABLE_DEPRECATED_API) || ENABLE_DEPRECATED_API == 1 00324 00325 /* 00326 * Prototypes of public deprecated functions 00327 * 00328 * TODO API: remove this function once compatibility is not needed anymore 00329 */ 00330 00331 int ROHC_EXPORT crc_get_polynom(int type) 00332 ROHC_DEPRECATED("please do not use this function anymore, simply drop it"); 00333 00334 void ROHC_EXPORT crc_init_table(unsigned char *table, unsigned char polynum) 00335 ROHC_DEPRECATED("please do not use this function anymore, simply drop it"); 00336 00337 #endif /* !defined(ENABLE_DEPRECATED_API) || ENABLE_DEPRECATED_API == 1 */ 00338 00339 00340 #undef ROHC_EXPORT /* do not pollute outside this header */ 00341 00342 #endif 00343