ROHC compression/decompression library
d_tcp_defines.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014 Didier Barvaux
3  * Copyright 2013,2014 Viveris Technologies
4  * Copyright 2012 WBX
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file d_tcp_defines.h
23  * @brief Main definitions for the TCP decompression profile
24  * @author FWX <rohc_team@dialine.fr>
25  * @author Didier Barvaux <didier@barvaux.org>
26  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
27  */
28 
29 #ifndef ROHC_DECOMP_TCP_DEFINES_H
30 #define ROHC_DECOMP_TCP_DEFINES_H
31 
32 #include "ip.h"
33 #include "interval.h"
34 #include "protocols/ip.h"
35 #include "protocols/tcp.h"
36 #include "protocols/rfc6846.h"
37 #include "schemes/ip_ctxt.h"
38 #include "schemes/decomp_wlsb.h"
39 #include "schemes/tcp_ts.h"
40 #include "schemes/tcp_sack.h"
41 
42 #include <stdint.h>
43 
44 
45 /** The decompression context for one TCP option */
46 struct d_tcp_opt_ctxt /* TODO: doxygen */
47 {
48  bool used;
49  uint8_t type;
50  union
51  {
52  struct
53  {
54  bool is_static;
55  uint8_t len;
56  } eol;
57  struct
58  {
59  bool is_static;
60  uint16_t value;
61  } mss;
62  struct
63  {
64  bool is_static;
65  uint8_t value;
66  } ws;
67  struct
68  {
69  struct rohc_lsb_field32 req; /**< The context for the TS request field */
70  struct rohc_lsb_field32 rep; /**< The context for the TS reply field */
71  } ts;
72  struct d_tcp_opt_sack sack; /* TODO: ptr inside is not needed */
73  struct
74  {
75  enum
76  {
80  } type;
81  uint8_t load_len;
82 #define ROHC_TCP_OPT_HDR_LEN 2U
83 #define ROHC_TCP_OPT_MAX_LEN 0xffU
84 #define ROHC_TCP_OPT_GENERIC_DATA_MAX_LEN \
85  (ROHC_TCP_OPT_MAX_LEN - ROHC_TCP_OPT_HDR_LEN)
87  } generic;
88  } data;
89 };
90 
91 
92 /** The decompression context for TCP options */
94 {
95  /** The number of options in the list of TCP options */
96  size_t nr;
97 
98  /** The structure of the list of TCP options */
99  uint8_t structure[ROHC_TCP_OPTS_MAX];
100  /** Whether the TCP options are expected in the dynamic part? */
101  bool expected_dynamic[ROHC_TCP_OPTS_MAX];
102  /** The TCP options that were found or not */
103  bool found[ROHC_TCP_OPTS_MAX];
104 
105  /** The bits of TCP options extracted from the dynamic chain, the tail of
106  * co_common/seq_8/rnd_8 packets, or the irregular chain */
108 };
109 
110 
111 /** Define the TCP part of the decompression profile context */
113 {
114  /** The LSB decoding context of MSN */
115  struct rohc_lsb_decode msn_lsb_ctxt;
116 
117  /** The LSB decoding context of innermost IP-ID */
118  struct rohc_lsb_decode ip_id_lsb_ctxt;
119  /** The LSB decoding context of innermost TTL/HL */
120  struct rohc_lsb_decode ttl_hl_lsb_ctxt;
121 
122  /* TCP static part */
123  uint16_t tcp_src_port; /**< The TCP source port */
124  uint16_t tcp_dst_port; /**< The TCP dest port */
125 
126  uint32_t seq_num_residue;
127  struct rohc_lsb_decode seq_lsb_ctxt;
128  struct rohc_lsb_decode seq_scaled_lsb_ctxt;
129 
130  uint16_t ack_stride;
131  uint16_t ack_num_residue;
132  struct rohc_lsb_decode ack_lsb_ctxt;
133  struct rohc_lsb_decode ack_scaled_lsb_ctxt;
134 
135  /* TCP flags */
136  uint8_t res_flags:4; /**< The TCP reserved flags */
137  bool ecn_used; /**< Whether ECN flag is used */
138  uint8_t ecn_flags:2; /**< The TCP ECN flags */
139  bool urg_flag; /**< The TCP URG flag */
140  bool ack_flag; /**< The TCP ACK flag */
141  uint8_t rsf_flags:3; /**< The TCP RSF flag */
142 
143  /** The LSB decoding context of TCP window */
144  struct rohc_lsb_decode window_lsb_ctxt;
145 
146  /** The URG pointer */
147  uint16_t urg_ptr;
148 
149  /** The decoded values of TCP options */
150  struct d_tcp_opts_ctxt tcp_opts;
151  /* TCP TS option */
152  struct rohc_lsb_decode opt_ts_req_lsb_ctxt;
153  struct rohc_lsb_decode opt_ts_rep_lsb_ctxt;
154  /* TCP SACK option */
155  struct d_tcp_opt_sack opt_sack_blocks; /**< The TCP SACK blocks */
156 
159 };
160 
161 
162 /** The outer or inner IP bits extracted from ROHC headers */
164 {
165  uint8_t version:4; /**< The version bits found in static chain of IR header */
166 
167  uint8_t dscp_bits:6; /**< The IP DSCP bits */
168  size_t dscp_bits_nr; /**< The number of IP DSCP bits */
169  uint8_t ecn_flags_bits:2; /**< The IP ECN flag bits */
170  size_t ecn_flags_bits_nr; /**< The number of IP ECN flag bits */
171 
172  uint8_t id_behavior:2; /**< The IP-ID behavior bits */
173  size_t id_behavior_nr; /**< The number of IP-ID behavior bits */
174  struct rohc_lsb_field16 id; /**< The IP-ID bits */
175 
176  uint8_t df:1; /**< The DF bits found in dynamic chain of IR/IR-DYN
177  header or in extension header */
178  size_t df_nr; /**< The number of DF bits found */
179 
180  struct rohc_lsb_field8 ttl_hl; /**< The IP TTL/HL bits */
181  uint8_t proto; /**< The protocol/next header bits found static chain
182  of IR header or in extension header */
183  size_t proto_nr; /**< The number of protocol/next header bits */
184 
185  uint32_t flowid:20; /**< The IPv6 flow ID bits found in static chain of
186  IR header */
187  size_t flowid_nr; /**< The number of flow label bits */
188 
189  uint8_t saddr[16]; /**< The source address bits found in static chain of
190  IR header */
191  size_t saddr_nr; /**< The number of source address bits */
192 
193  uint8_t daddr[16]; /**< The destination address bits found in static
194  chain of IR header */
195  size_t daddr_nr; /**< The number of source address bits */
196 
197  /** The parsed IP extension headers */
199  size_t opts_nr; /**< The number of parsed IP extension headers */
200  size_t opts_len; /**< The length of the parsed IP extension headers */
201 };
202 
203 
204 /** The bits extracted from ROHC TCP header */
206 {
207  /** Whether Context Replication (CR) is used */
209  /** The base context for Context Replication (CR) */
211 
212  /** The extracted bits related to the IP headers */
214  size_t ip_nr; /**< The number of parsed IP headers */
215 
216  /** The extracted bits of the Master Sequence Number (MSN) of the packet */
217  struct rohc_lsb_field16 msn;
218 
219  /** Whether TTL/HL of outer IP headers is included in the dynamic chain */
221  /** Whether TTL/HL of outer IP headers is included in the irregular chain */
223 
224  /* TCP header */
225  uint16_t src_port; /**< The TCP source port bits found in static chain */
226  size_t src_port_nr; /**< The number of TCP source port bits */
227  uint16_t dst_port; /**< The TCP destination port bits in static chain */
228  size_t dst_port_nr; /**< The number of TCP destination port bits */
229  struct rohc_lsb_field32 seq; /**< The TCP sequence number bits */
230  struct rohc_lsb_field32 seq_scaled; /**< The TCP scaled sequence number bits */
231  struct rohc_lsb_field32 ack; /**< The TCP acknowledgment number bits */
232  struct rohc_lsb_field16 ack_stride; /**< The TCP ACK stride bits */
233  struct rohc_lsb_field32 ack_scaled; /**< The TCP scaled ACK number bits */
234  uint8_t ecn_used_bits; /**< The TCP ECN used flag bits */
235  size_t ecn_used_bits_nr; /**< The number of ECN used flag bits */
236  uint8_t res_flags_bits; /**< The TCP reserved flag bits */
237  size_t res_flags_bits_nr; /**< The number of TCP reserved flag bits */
238  uint8_t ecn_flags_bits; /**< The TCP ECN flag bits */
239  size_t ecn_flags_bits_nr; /**< The number of TCP ECN flag bits */
240  uint8_t urg_flag_bits; /**< The TCP URG flag bits */
241  size_t urg_flag_bits_nr; /**< The number of TCP URG flag bits */
242  uint8_t ack_flag_bits; /**< The TCP ACK flag bits */
243  size_t ack_flag_bits_nr; /**< The number of TCP ACK flag bits */
244  uint8_t psh_flag_bits; /**< The TCP PSH flag bits */
245  size_t psh_flag_bits_nr; /**< The number of TCP PSG flag bits */
246  uint8_t rsf_flags_bits; /**< The TCP RSF flag bits */
247  size_t rsf_flags_bits_nr; /**< The number of TCP RSF flag bits */
248  struct rohc_lsb_field16 window; /**< The TCP window bits */
249  uint16_t tcp_check; /**< The TCP checksum bits found in dynamic chain of
250  IR/IR-DYN header or in irregular chain of CO header */
251  struct rohc_lsb_field16 urg_ptr; /**< The TCP Urgent pointer bits */
252 
253  /** The bits of TCP options extracted from the dynamic chain, the tail of
254  * co_common/seq_8/rnd_8 packets, or the irregular chain */
255  struct d_tcp_opts_ctxt tcp_opts;
256 };
257 
258 
259 /** The IP values decoded from the extracted ROHC bits */
261 {
262  uint8_t version:4; /**< The decoded version field */
263  uint8_t ecn_flags:2; /**< The decoded ECN flags */
264  uint8_t dscp:6; /**< The decoded DSCP field */
265  rohc_ip_id_behavior_t id_behavior; /**< The decoded IP-ID behavior (IPv4 only) */
266  uint16_t id; /**< The decoded IP-ID field (IPv4 only) */
267  uint8_t df:1; /**< The decoded DF field (IPv4 only) */
268  uint8_t ttl; /**< The decoded TTL/HL field */
269  uint8_t proto; /**< The decoded protocol/NH field */
270  uint8_t nbo:1; /**< The decoded NBO field (IPv4 only) */
271  uint8_t rnd:1; /**< The decoded RND field (IPv4 only) */
272  uint32_t flowid:20; /**< The decoded flow ID field (IPv6 only) */
273  uint8_t saddr[16]; /**< The decoded source address field */
274  uint8_t daddr[16]; /**< The decoded destination address field */
275 
276  /** The decoded IP extension headers */
278  size_t opts_nr; /**< The number of decoded IP extension headers */
279  size_t opts_len; /**< The length of the decoded IP extension headers */
280 };
281 
282 
283 /** The values decoded from the bits extracted from ROHC TCP header */
285 {
286  /** Whether Context Replication (CR) is used */
288  /** The base context for Context Replication (CR) */
290 
291  /** The decoded values related to the IP headers */
293  size_t ip_nr; /**< The number of the decoded IP headers */
294 
295  /** The Master Sequence Number (MSN) of the packet */
296  uint16_t msn;
297 
298  /** Whether TTL/HL of outer IP headers is included in the dynamic chain */
300  /** Whether TTL/HL of outer IP headers is included in the irregular chain */
302 
303  /* TCP source & destination ports */
304  uint16_t src_port; /**< The TCP source port */
305  uint16_t dst_port; /**< The TCP destination port */
306 
307  /* TCP sequence & acknowledgment numbers */
308  uint32_t seq_num; /**< The TCP sequence number */
309  uint32_t seq_num_scaled; /**< The scaled TCP sequence number */
310  uint32_t seq_num_residue; /**< The residue of the scaled TCP sequence number */
311  uint32_t ack_num; /**< The TCP acknowledgment number */
312  uint32_t ack_num_scaled; /**< The scaled TCP acknowledgment number */
313  uint16_t ack_num_residue; /**< The residue of the scaled TCP ACK number */
314  uint16_t ack_stride; /**< The ACK stride */
315 
316  /* TCP flags */
317  bool ecn_used; /**< Whether the TCP ECN flags are used */
318  uint8_t res_flags:4; /**< The TCP reserved flags */
319  uint8_t ecn_flags:2; /**< The TCP ECN flags */
320  bool urg_flag; /**< The TCP URG flag */
321  bool ack_flag; /**< The TCP ACK flag */
322  bool psh_flag; /**< The TCP PSH flag */
323  uint8_t rsf_flags:3; /**< The TCP RSF flags */
324 
325  /* TCP window, checksum and Urgent pointer */
326  uint16_t window; /**< The TCP window */
327  uint16_t tcp_check; /**< The TCP checksum */
328  uint16_t urg_ptr; /**< The TCP Urgent pointer */
329 
330  /** The decoded values of TCP options */
331  struct d_tcp_opts_ctxt tcp_opts;
332  /* TCP TS option */
333  uint32_t opt_ts_req; /**< The echo request value of the TCP TS option */
334  uint32_t opt_ts_rep; /**< The echo reply value of the TCP TS option */
335  /* TCP SACK option */
336  struct d_tcp_opt_sack opt_sack_blocks; /**< The TCP SACK blocks */
337 };
338 
339 #endif /* ROHC_DECOMP_TCP_DEFINES_H */
340 
uint8_t urg_flag_bits
Definition: d_tcp_defines.h:240
uint8_t len
Definition: d_tcp_defines.h:55
size_t flowid_nr
Definition: d_tcp_defines.h:187
uint32_t ack_num
Definition: d_tcp_defines.h:311
size_t urg_flag_bits_nr
Definition: d_tcp_defines.h:241
uint8_t rsf_flags
Definition: d_tcp_defines.h:323
bool ecn_used
Definition: d_tcp_defines.h:137
uint8_t rsf_flags_bits
Definition: d_tcp_defines.h:246
size_t src_port_nr
Definition: d_tcp_defines.h:226
rohc_cid_t cr_base_cid
Definition: d_tcp_defines.h:289
size_t rohc_cid_t
Definition: rohc.h:195
Definition: d_tcp_defines.h:284
uint8_t ack_flag_bits
Definition: d_tcp_defines.h:242
bool ack_flag
Definition: d_tcp_defines.h:321
size_t opts_len
Definition: d_tcp_defines.h:200
size_t res_flags_bits_nr
Definition: d_tcp_defines.h:237
uint16_t tcp_check
Definition: d_tcp_defines.h:327
bool urg_flag
Definition: d_tcp_defines.h:139
uint8_t dscp_bits
Definition: d_tcp_defines.h:167
size_t ecn_used_bits_nr
Definition: d_tcp_defines.h:235
uint16_t msn
Definition: d_tcp_defines.h:296
rohc_ip_id_behavior_t id_behavior
Definition: d_tcp_defines.h:265
uint32_t flowid
Definition: d_tcp_defines.h:185
bool used
Definition: d_tcp_defines.h:48
uint32_t opt_ts_rep
Definition: d_tcp_defines.h:334
uint16_t dst_port
Definition: d_tcp_defines.h:305
uint16_t urg_ptr
Definition: d_tcp_defines.h:147
uint8_t proto
Definition: d_tcp_defines.h:181
size_t daddr_nr
Definition: d_tcp_defines.h:195
uint8_t ttl
Definition: d_tcp_defines.h:268
uint16_t tcp_check
Definition: d_tcp_defines.h:249
uint8_t ecn_flags_bits
Definition: d_tcp_defines.h:238
bool ttl_dyn_chain_flag
Definition: d_tcp_defines.h:220
Definition: decomp_wlsb.h:77
uint8_t proto
Definition: d_tcp_defines.h:269
size_t opts_nr
Definition: d_tcp_defines.h:278
size_t dscp_bits_nr
Definition: d_tcp_defines.h:168
bool urg_flag
Definition: d_tcp_defines.h:320
size_t ecn_flags_bits_nr
Definition: d_tcp_defines.h:170
size_t proto_nr
Definition: d_tcp_defines.h:183
uint16_t window
Definition: d_tcp_defines.h:326
union d_tcp_opt_ctxt::@35 data
size_t ecn_flags_bits_nr
Definition: d_tcp_defines.h:239
struct d_tcp_opt_ctxt::@35::@37 mss
bool ttl_dyn_chain_flag
Definition: d_tcp_defines.h:299
uint8_t psh_flag_bits
Definition: d_tcp_defines.h:244
Definition: d_tcp_defines.h:163
uint8_t ecn_used_bits
Definition: d_tcp_defines.h:234
uint8_t value
Definition: d_tcp_defines.h:65
uint8_t res_flags
Definition: d_tcp_defines.h:318
uint8_t dscp
Definition: d_tcp_defines.h:264
bool do_ctxt_replication
Definition: d_tcp_defines.h:208
uint8_t ecn_flags
Definition: d_tcp_defines.h:319
uint8_t df
Definition: d_tcp_defines.h:176
#define ROHC_TCP_OPT_GENERIC_DATA_MAX_LEN
Definition: d_tcp_defines.h:84
uint16_t dst_port
Definition: d_tcp_defines.h:227
Definition: decomp/schemes/tcp_sack.h:38
size_t df_nr
Definition: d_tcp_defines.h:178
The Least Significant Bits (LSB) decoding object.
Definition: decomp_wlsb.h:57
uint16_t value
Definition: d_tcp_defines.h:60
Definition: d_tcp_defines.h:77
uint16_t src_port
Definition: d_tcp_defines.h:225
Definition: comp/schemes/ip_ctxt.h:110
uint16_t src_port
Definition: d_tcp_defines.h:304
size_t dst_port_nr
Definition: d_tcp_defines.h:228
Definition: decomp_wlsb.h:86
uint8_t df
Definition: d_tcp_defines.h:267
size_t rsf_flags_bits_nr
Definition: d_tcp_defines.h:247
bool psh_flag
Definition: d_tcp_defines.h:322
uint8_t load[ROHC_TCP_OPT_GENERIC_DATA_MAX_LEN]
Definition: d_tcp_defines.h:86
bool do_ctxt_replication
Definition: d_tcp_defines.h:287
size_t ip_nr
Definition: d_tcp_defines.h:293
rohc_ip_id_behavior_t
Definition: rohc_internal.h:171
#define MAX_TCP_OPTION_INDEX
The largest index that may be used to identify one TCP option.
Definition: rfc6846.h:58
struct d_tcp_opt_sack sack
Definition: d_tcp_defines.h:72
uint32_t seq_num_residue
Definition: d_tcp_defines.h:310
bool is_static
Definition: d_tcp_defines.h:54
ROHC packets for the ROHCv1 IP/TCP profile defined in RFC6846.
uint16_t ack_stride
Definition: d_tcp_defines.h:130
bool ttl_irreg_chain_flag
Definition: d_tcp_defines.h:301
bool ack_flag
Definition: d_tcp_defines.h:140
Definition: d_tcp_defines.h:46
Window-based Least Significant Bits (W-LSB) decoding.
size_t ack_flag_bits_nr
Definition: d_tcp_defines.h:243
size_t ip_contexts_nr
Definition: d_tcp_defines.h:157
size_t id_behavior_nr
Definition: d_tcp_defines.h:173
Definition: d_tcp_defines.h:112
#define ROHC_MAX_IP_EXT_HDRS
The maximum number of IP extension headers supported.
Definition: protocols/ip.h:58
uint8_t load_len
Definition: d_tcp_defines.h:81
uint16_t ack_num_residue
Definition: d_tcp_defines.h:313
uint32_t seq_num_scaled
Definition: d_tcp_defines.h:309
uint8_t rsf_flags
Definition: d_tcp_defines.h:141
uint16_t ack_num_residue
Definition: d_tcp_defines.h:131
uint8_t version
Definition: d_tcp_defines.h:262
uint32_t opt_ts_req
Definition: d_tcp_defines.h:333
struct d_tcp_opt_ctxt::@35::@36 eol
uint16_t ack_stride
Definition: d_tcp_defines.h:314
uint8_t res_flags
Definition: d_tcp_defines.h:136
uint8_t version
Definition: d_tcp_defines.h:165
struct d_tcp_opt_ctxt::@35::@38 ws
Definition: decomp_wlsb.h:68
struct rohc_lsb_field32 req
Definition: d_tcp_defines.h:69
Definition: d_tcp_defines.h:260
size_t opts_len
Definition: d_tcp_defines.h:279
uint8_t ecn_flags
Definition: d_tcp_defines.h:138
#define ROHC_TCP_OPTS_MAX
The maximum of TCP options supported by the TCP profile.
Definition: rfc6846.h:73
rohc_cid_t cr_base_cid
Definition: d_tcp_defines.h:210
uint8_t type
Definition: d_tcp_defines.h:49
uint32_t ack_num_scaled
Definition: d_tcp_defines.h:312
uint8_t rnd
Definition: d_tcp_defines.h:271
uint8_t ecn_flags_bits
Definition: d_tcp_defines.h:169
Define union of IP contexts.
Definition: comp/schemes/ip_ctxt.h:155
uint8_t id_behavior
Definition: d_tcp_defines.h:172
uint16_t tcp_src_port
Definition: d_tcp_defines.h:123
uint16_t urg_ptr
Definition: d_tcp_defines.h:328
size_t opts_nr
Definition: d_tcp_defines.h:199
Defines the common IPv4/v6 header.
Definition: d_tcp_defines.h:93
Definition: d_tcp_defines.h:79
size_t ip_nr
Definition: d_tcp_defines.h:214
TCP header description.
bool ttl_irreg_chain_flag
Definition: d_tcp_defines.h:222
uint8_t nbo
Definition: d_tcp_defines.h:270
struct rohc_lsb_field32 rep
Definition: d_tcp_defines.h:70
struct d_tcp_opt_ctxt::@35::@39 ts
uint16_t id
Definition: d_tcp_defines.h:266
size_t psh_flag_bits_nr
Definition: d_tcp_defines.h:245
uint32_t seq_num
Definition: d_tcp_defines.h:308
size_t saddr_nr
Definition: d_tcp_defines.h:191
size_t nr
Definition: d_tcp_defines.h:96
uint8_t ecn_flags
Definition: d_tcp_defines.h:263
uint32_t seq_num_residue
Definition: d_tcp_defines.h:126
#define ROHC_MAX_IP_HDRS
The maximum number of IP headers supported.
Definition: protocols/ip.h:46
Definition: d_tcp_defines.h:205
uint8_t res_flags_bits
Definition: d_tcp_defines.h:236
uint32_t flowid
Definition: d_tcp_defines.h:272
bool ecn_used
Definition: d_tcp_defines.h:317
uint16_t tcp_dst_port
Definition: d_tcp_defines.h:124
Compute the interpretation interval for LSB and W-LSB encoding.
Definition: d_tcp_defines.h:78