ROHC compression/decompression library
rohc_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 Didier Barvaux
3  * Copyright 2017 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_internal.h
22  * @brief ROHC private 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_INTERNAL_H
28 #define ROHC_INTERNAL_H
29 
30 /**
31  * \mainpage
32  *
33  * <h2>Introduction</h2>
34  * <p>The <a href="https://rohc-lib.org/" title="Official website">ROHC library</a>
35  * provides an easy and robust way for applications to reduce their bandwidth
36  * usage on network links with limited capacity. Headers of network packets are
37  * compressed with the ROHC protocol and algorithms.</p>
38  * <p><a href="https://rohc-lib.org/support/wiki/doku.php?id=rohc-protocol"
39  * title="An introduction to the ROHC protocol">RObust Header Compression
40  * (ROHC)</a> is a set of standards defined by the <a href="http://www.ietf.org/"
41  * title="The IETF website">IETF</a>. The ROHC library is a free, opensource and
42  * efficient implementation of them.
43  * <a href="https://rohc-lib.org/support/wiki/doku.php?id=library-compliance-rfcs">Many
44  * features</a>are implemented.</p>
45  * <ul>
46  * <li><a href="https://rohc-lib.org/">Official website</a></li>
47  * <li><a href="https://github.com/didier-barvaux/rohc">Project page on
48  * GitHub</a></li>
49  * <li><a href="https://launchpad.net/rohc">Project page on Launchpad</a></li>
50  * <li><a href="mailto:rohc@lists.launchpad.net">Mailing list:
51  * rohc@lists.launchpad.net</a></li>
52  * <li><a href="https://lists.launchpad.net/rohc/">Mailing list archives</a></li>
53  * <li><a href="https://bugs.launchpad.net/rohc">Bugtracker</a></li>
54  * </ul>
55  *
56  * <h2>License</h2>
57  * <p>The project is licensed under LGPL2.1+.
58  * See the <a href="https://github.com/didier-barvaux/rohc/blob/master/COPYING">COPYING</a>
59  * and <a href="https://github.com/didier-barvaux/rohc/blob/master/AUTHORS.md">AUTHORS.md</a>
60  * files for more details.</p>
61  *
62  * <h2>Library</h2>
63  * <p>
64  * The sources are in the src subdirectory. The sources are separated into
65  * three sub-directories:
66  * <ul>
67  * <li>the common/ sub-directory contains the routines used for both the
68  * compression and the decompression processes,</li>
69  * <li>the comp/ sub-directory handles the compression process,</li>
70  * <li>the decomp/ sub-directory handles the decompression process.</li>
71  * </ul>
72  * </p>
73  * <p>See the <a href="https://github.com/didier-barvaux/rohc/blob/master/INSTALL.md">INSTALL.md file</a>
74  * to learn to build the libraries. See also the <a href="https://rohc-lib.org/support/wiki/">Wiki
75  * of the project</a>.</p>
76  *
77  * <h2>API documentation, tutorials and examples</h2>
78  * <p>The APIs for ROHC common, compression and decompression parts are available on
79  * separate pages:
80  * <ul>
81  * <li>\ref rohc</li>
82  * <li>\ref rohc_comp</li>
83  * <li>\ref rohc_decomp</li>
84  * </ul>
85  * </p>
86  * <p><a href="https://rohc-lib.org/presentation/getting-started/">Some</a>
87  * <a href="https://rohc-lib.org/support/wiki/doku.php?id=library-first-application">tutorials</a>
88  * are available on the website and wiki.</p>
89  * <p><a href="https://github.com/didier-barvaux/rohc/tree/master/examples">Some examples</a>
90  * are available in the examples/ sub-directory in the sources.</p>
91  *
92  * <h2>Tests</h2>
93  * <p>
94  * Several tests may be run to check the library behaviour. See the
95  * <a href="https://github.com/didier-barvaux/rohc/blob/master/INSTALL.md">INSTALL.md file</a>
96  * to learn how to use these tools.</p>
97  *
98  * <h2>References</h2>
99  * <dl style="padding-bottom: 1em;">
100  * <dt><a href="https://tools.ietf.org/html/rfc3095">RFC&nbsp;3095</a></dt>
101  * <dd>ROHC: Framework and four profiles: RTP, UDP, ESP, and uncompressed.</dd>
102  * <dt><a href="https://tools.ietf.org/html/rfc3096">RFC&nbsp;3096</a></dt>
103  * <dd>Requirements for robust IP/UDP/RTP header compression.</dd>
104  * <dt><a href="https://tools.ietf.org/html/rfc3843">RFC&nbsp;3843</a></dt>
105  * <dd>ROHC: A Compression Profile for IP.</dd>
106  * <dt><a href="https://tools.ietf.org/html/rfc4019">RFC&nbsp;4019</a></dt>
107  * <dd>ROHC: Profiles for User Datagram Protocol (UDP) Lite.</dd>
108  * <dt><a href="https://tools.ietf.org/html/rfc6846">RFC&nbsp;6846</a></dt>
109  * <dd>ROHC: A Profile for TCP/IP (ROHC-TCP)</dd>
110  * <dt><a href="https://tools.ietf.org/html/rfc5225">RFC&nbsp;5225</a></dt>
111  * <dd>ROHCv2: Profiles for RTP, UDP, IP, ESP and UDP-Lite</dt>
112  * <dt><a href="https://rohc-lib.org/">ROHC library</a></dt>
113  * <dd>The Open Source ROHC library described by the documentation you are
114  * currently reading.</dd>
115  * <dt><a href="http://rohc.sourceforge.net/">ROHC Linux</a></dt>
116  * <dd>A GPL-licensed implementation of ROHC over PPP for the 2.4 Linux kernel.
117  * The ROHC library started as a fork of this project.</dd>
118  * </dl>
119  */
120 
121 
122 #include "rohc.h"
123 
124 
125 /**
126  * @brief The padding field defined by the ROHC protocol
127  *
128  * See RFC 3095, ยง5.2:
129  * \verbatim
130 
131  Padding Octet
132 
133  0 1 2 3 4 5 6 7
134  +---+---+---+---+---+---+---+---+
135  | 1 1 1 0 0 0 0 0 |
136  +---+---+---+---+---+---+---+---+
137 
138 \endverbatim
139  */
140 #define ROHC_PADDING_BYTE 0xe0
141 
142 
143 /**
144  * @brief ROHC medium (CID characteristics)
145  */
147 {
148  /** The CID type: large or small */
150 
151  /// The maximum CID value
153 };
154 
155 
156 /**
157  * @brief The different chains used by the ROHCv1 TCP and ROHCv2 profiles
158  */
159 typedef enum
160 {
161  ROHC_CHAIN_STATIC = 0, /**< The TCP static chain */
162  ROHC_CHAIN_DYNAMIC = 1, /**< The TCP dynamic chain */
163  ROHC_CHAIN_REPLICATE = 2, /**< The TCP replicate chain */
164  ROHC_CHAIN_IRREGULAR = 3, /**< The TCP irregular chain */
165  ROHC_CHAIN_CO = 4, /**< Not a chain, but in CO packet */
166 
167 } rohc_chain_t;
168 
169 
170 /** The different IP-ID behaviors */
171 typedef enum
172 {
173  ROHC_IP_ID_BEHAVIOR_SEQ = 0, /**< IP-ID increases */
174  ROHC_IP_ID_BEHAVIOR_SEQ_SWAP = 1, /**< IP-ID increases in little endian */
175  ROHC_IP_ID_BEHAVIOR_RAND = 2, /**< IP-ID is random */
176  ROHC_IP_ID_BEHAVIOR_ZERO = 3, /**< IP-ID is constant zero */
178 
179 
180 
181 /************************************************************************
182  * Helper functions *
183  ************************************************************************/
184 
185 static inline char * rohc_ip_id_behavior_get_descr(const rohc_ip_id_behavior_t behavior)
186  __attribute__((warn_unused_result, const));
187 
188 
189 /**
190  * @brief Get a string that describes the given IP-ID behavior
191  *
192  * @param behavior The type of the option to get a description for
193  * @return The description of the option
194  */
195 static inline char * rohc_ip_id_behavior_get_descr(const rohc_ip_id_behavior_t behavior)
196 {
197  switch(behavior)
198  {
200  return "sequential";
202  return "sequential swapped";
204  return "random";
206  return "constant zero";
207  default:
208  return "unknown IP-ID behavior";
209  }
210 }
211 
212 
213 #endif
214 
size_t rohc_cid_t
Definition: rohc.h:195
Definition: rohc_internal.h:163
Definition: rohc_internal.h:161
rohc_cid_type_t
The different types of Context IDs (CID)
Definition: rohc.h:176
Definition: rohc_internal.h:174
Definition: rohc_internal.h:176
rohc_chain_t
The different chains used by the ROHCv1 TCP and ROHCv2 profiles.
Definition: rohc_internal.h:159
ROHC common definitions and routines.
rohc_cid_t max_cid
The maximum CID value.
Definition: rohc_internal.h:152
Definition: rohc_internal.h:162
static char * rohc_ip_id_behavior_get_descr(const rohc_ip_id_behavior_t behavior)
Get a string that describes the given IP-ID behavior.
Definition: rohc_internal.h:195
rohc_cid_type_t cid_type
Definition: rohc_internal.h:149
rohc_ip_id_behavior_t
Definition: rohc_internal.h:171
Definition: rohc_internal.h:175
ROHC medium (CID characteristics)
Definition: rohc_internal.h:146
Definition: rohc_internal.h:165
Definition: rohc_internal.h:164
Definition: rohc_internal.h:173