ROHC compression/decompression library
c_tcp_defines.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014,2015,2016 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 c_tcp_defines.h
23  * @brief Main definitions for the TCP compression 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 "protocols/tcp.h"
33 #include "c_tcp_opts_list.h"
34 
35 /**
36  * @brief Define the TCP-specific temporary variables in the profile
37  * compression context.
38  *
39  * This object must be used by the TCP-specific decompression context
40  * sc_tcp_context.
41  *
42  * @see sc_tcp_context
43  */
45 {
46  /** Whether at least one of the static part of the IPv6 extensions changed
47  * in the current packet */
49  /** Whether at least one of the dynamic part of the IPv6 extensions changed
50  * in the current packet */
52  /** The new number of IP extensions headers (for every IP header) */
54 
55  /* the length of the TCP payload (headers and options excluded) */
56  size_t payload_len;
57 
58  /** The minimal number of bits required to encode the MSN value */
59  size_t nr_msn_bits;
60 
61  /** Whether the TCP window changed or not */
63  /** The minimal number of bits required to encode the TCP window */
65 
66  /** Whether the TCP sequence number changed or not */
68  /** The minimal number of bits required to encode the TCP scaled sequence
69  * number */
71 
72  /** Whether the ACK number changed or not */
74  /** The minimal number of bits required to encode the TCP ACK number
75  * with p = 16383 */
77  /** The minimal number of bits required to encode the TCP scaled ACK
78  * number */
80 
81  /** The IP-ID / SN delta (with bits swapped if necessary) */
82  uint16_t ip_id_delta;
83  /** Whether the behavior of the IP-ID field changed with current packet */
85  /** The minimal number of bits required to encode the innermost IP-ID value
86  * with p = 3 */
88  /** The minimal number of bits required to encode the innermost IP-ID value
89  * with p = 1 */
91 
92  /* innermost IPv4 TTL or IPv6 Hop Limit */
93  uint8_t ttl_hopl;
96  /* outer IPv4 TTLs or IPv6 Hop Limits */
99 
102 
106 
107  /** Whether the ecn_used flag changed or not */
109 };
110 
111 
112 /**
113  * @brief Define the IPv6 generic option context.
114  */
115 typedef struct __attribute__((packed)) ipv6_generic_option_context
116 {
118  uint8_t next_header;
119  uint8_t data[IPV6_OPT_CTXT_LEN_MAX];
120 
122 
123 
124 /**
125  * @brief Define the common IP header context to IPv4 and IPv6.
126  */
127 typedef struct __attribute__((packed)) ipvx_context
128 {
129  uint8_t version:4;
130  uint8_t unused:4;
131 
132  uint8_t dscp:6;
133  uint8_t ip_ecn_flags:2;
134 
135  uint8_t next_header;
136 
137  uint8_t ttl_hopl;
138 
139  uint8_t ip_id_behavior;
141 
143 
144 
145 /**
146  * @brief Define the IPv4 header context.
147  */
148 typedef struct __attribute__((packed)) ipv4_context
149 {
150  uint8_t version:4;
151  uint8_t df:1;
152  uint8_t unused:3;
153 
154  uint8_t dscp:6;
155  uint8_t ip_ecn_flags:2;
156 
157  uint8_t protocol;
158 
159  uint8_t ttl_hopl;
160 
161  uint8_t ip_id_behavior;
163  uint16_t last_ip_id;
164 
165  uint32_t src_addr;
166  uint32_t dst_addr;
167 
169 
170 
171 /** The compression context for one IPv6 extension header */
172 typedef union
173 {
174  ipv6_generic_option_context_t generic; /**< IPv6 generic extension header */
175  /* TODO: GRE not yet supported */
176  /* TODO: MINE not yet supported */
177  /* TODO: AH not yet supported */
179 
180 
181 /**
182  * @brief Define the IPv6 header context.
183  */
184 typedef struct __attribute__((packed)) ipv6_context
185 {
186  uint8_t version:4;
187  uint8_t unused:4;
188 
189  uint8_t dscp:6;
190  uint8_t ip_ecn_flags:2;
191 
192  uint8_t next_header;
193 
194  uint8_t ttl_hopl;
195 
196  uint8_t ip_id_behavior;
198 
199  uint32_t flow_label:20;
200 
201  uint32_t src_addr[4];
202  uint32_t dest_addr[4];
203 
205 
206 
207 /**
208  * @brief Define union of IP contexts
209  */
210 typedef struct
211 {
213  union
214  {
218  } ctxt;
219 
220  /* Context Replication */
222 
223  size_t opts_nr;
225 
226 } ip_context_t;
227 
228 
229 /** Define the TCP part of the profile decompression context */
231 {
232  /// The number of times the sequence number field was added to the compressed header
234  /** The number of times the window field was added to the compressed header */
236 
237  /** Explicit Congestion Notification used */
238  bool ecn_used;
239  /** The number of times the ECN fields were added to the compressed header */
241  /** The number of times the ECN fields were not needed */
243 
244  uint16_t msn; /**< The Master Sequence Number (MSN) */
245  struct c_wlsb msn_wlsb; /**< The W-LSB decoding context for MSN */
246 
247  /** The MSN of the last packet that updated the context (used to determine
248  * if a positive ACK may cause a transition to a higher compression state) */
250 
251  struct c_wlsb ttl_hopl_wlsb;
253 
254  struct c_wlsb ip_id_wlsb;
255 
256 // lsb(15, 16383)
257  struct c_wlsb window_wlsb; /**< The W-LSB decoding context for TCP window */
258 
259  uint32_t seq_num;
260  struct c_wlsb seq_wlsb;
261  struct c_wlsb seq_scaled_wlsb;
262 
263  uint32_t seq_num_scaled;
264  uint32_t seq_num_residue;
267 
268  uint32_t ack_num;
269  struct c_wlsb ack_wlsb;
270  struct c_wlsb ack_scaled_wlsb;
271 
273  uint16_t ack_deltas_width[20];
274  uint16_t ack_stride;
275  uint32_t ack_num_scaled;
276  uint16_t ack_num_residue;
278 
279  /* Context Replication */
283 
284  /** The compression context for TCP options */
285  struct c_tcp_opts_ctxt tcp_opts;
286 
287  /// The previous TCP header
288  struct tcphdr old_tcphdr;
289 
290  /// @brief TCP-specific temporary variables that are used during one single
291  /// compression of packet
292  struct tcp_tmp_variables tmp;
293 
296 };
297 
298 #endif /* ROHC_DECOMP_TCP_DEFINES_H */
299 
bool cr_ttl_hopl_present
Definition: c_tcp_defines.h:221
size_t seq_num_scaling_nr
Definition: c_tcp_defines.h:266
bool ecn_used_changed
Definition: c_tcp_defines.h:108
size_t nr_seq_scaled_bits
Definition: c_tcp_defines.h:70
uint8_t ttl_hopl
Definition: c_tcp_defines.h:159
uint32_t ack_num
Definition: c_tcp_defines.h:268
uint8_t dscp
Definition: c_tcp_defines.h:132
size_t nr_ip_id_bits_3
Definition: c_tcp_defines.h:87
Define the IPv6 generic option context.
Definition: c_tcp_defines.h:115
Definition: c_tcp_defines.h:230
uint8_t dscp
Definition: c_tcp_defines.h:189
uint32_t seq_num_residue
Definition: c_tcp_defines.h:264
Define the TCP-specific temporary variables in the profile compression context.
Definition: c_tcp_defines.h:44
bool ecn_used
Definition: c_tcp_defines.h:238
size_t ack_num_scaling_nr
Definition: c_tcp_defines.h:277
uint32_t seq_num
Definition: c_tcp_defines.h:259
uint8_t version
Definition: c_tcp_defines.h:186
bool cr_tcp_ack_num_present
Definition: c_tcp_defines.h:282
Define the IPv6 option context for Destination, Hop-by-Hop and Routing option.
Definition: d_tcp_defines.h:45
bool tcp_urg_flag_changed
Definition: c_tcp_defines.h:105
uint8_t protocol
Definition: c_tcp_defines.h:157
Handle the list of TCP options for the TCP ompression profile.
size_t ack_deltas_next
Definition: c_tcp_defines.h:272
size_t ecn_used_zero_count
Definition: c_tcp_defines.h:242
uint8_t next_header
Definition: c_tcp_defines.h:135
bool is_ipv6_exts_list_dyn_changed
Definition: c_tcp_defines.h:51
size_t nr_ttl_hopl_bits
Definition: c_tcp_defines.h:94
bool outer_ip_ttl_changed
Definition: c_tcp_defines.h:98
uint8_t version
Definition: c_tcp_defines.h:129
bool tcp_urg_flag_present
Definition: c_tcp_defines.h:104
uint8_t ip_ecn_flags
Definition: c_tcp_defines.h:133
uint8_t ip_ecn_flags
Definition: c_tcp_defines.h:190
ipv6_context_t v6
Definition: c_tcp_defines.h:217
uint8_t ttl_hopl
Definition: c_tcp_defines.h:194
int ttl_irreg_chain_flag
Definition: c_tcp_defines.h:97
Define the common IP header context to IPv4 and IPv6.
Definition: c_tcp_defines.h:127
uint16_t msn_of_last_ctxt_updating_pkt
Definition: c_tcp_defines.h:249
uint8_t next_header
Definition: c_tcp_defines.h:192
uint8_t version
Definition: c_tcp_defines.h:150
ipvx_context_t vx
Definition: c_tcp_defines.h:215
Definition: c_tcp_defines.h:172
uint8_t ip_id_behavior
Definition: c_tcp_defines.h:196
#define IPV6_OPT_CTXT_LEN_MAX
Definition: ipv6.h:154
ipv4_context_t v4
Definition: c_tcp_defines.h:216
struct ipv6_generic_option_context ipv6_generic_option_context_t
Define the IPv6 generic option context.
Definition: c_tcp_opts_list.h:112
One W-LSB encoding object.
Definition: comp_wlsb.h:56
uint16_t ip_id_delta
Definition: c_tcp_defines.h:82
uint32_t seq_num_scaled
Definition: c_tcp_defines.h:263
uint16_t msn
Definition: c_tcp_defines.h:244
uint32_t ack_num_scaled
Definition: c_tcp_defines.h:275
bool ip_df_changed
Definition: c_tcp_defines.h:100
size_t opts_nr
Definition: c_tcp_defines.h:223
size_t seq_num_factor
Definition: c_tcp_defines.h:265
size_t ecn_used_change_count
Definition: c_tcp_defines.h:240
Define the IPv6 header context.
Definition: c_tcp_defines.h:184
ip_version version
Definition: c_tcp_defines.h:212
uint8_t df
Definition: c_tcp_defines.h:151
uint32_t dst_addr
Definition: c_tcp_defines.h:166
size_t tcp_window_changed
Definition: c_tcp_defines.h:62
The TCP base header without options.
Definition: tcp.h:115
size_t nr_ip_id_bits_1
Definition: c_tcp_defines.h:90
Define the IPv4 header context.
Definition: c_tcp_defines.h:148
#define ROHC_TCP_MAX_IP_HDRS
The maximum number of IP headers supported by the TCP profile.
Definition: tcp.h:58
size_t ttl_hopl_change_count
Definition: c_tcp_defines.h:252
struct ipv4_context ipv4_context_t
Define the IPv4 header context.
size_t nr_msn_bits
Definition: c_tcp_defines.h:59
size_t nr_window_bits_16383
Definition: c_tcp_defines.h:64
size_t nr_ack_bits_16383
Definition: c_tcp_defines.h:76
int tcp_seq_num_change_count
The number of times the sequence number field was added to the compressed header. ...
Definition: c_tcp_defines.h:233
uint8_t next_header
Definition: c_tcp_defines.h:118
struct ipvx_context ipvx_context_t
Define the common IP header context to IPv4 and IPv6.
uint8_t unused
Definition: c_tcp_defines.h:130
uint8_t dscp
Definition: c_tcp_defines.h:154
uint8_t unused
Definition: c_tcp_defines.h:152
uint8_t unused
Definition: c_tcp_defines.h:187
bool cr_tcp_urg_ptr_present
Definition: c_tcp_defines.h:281
bool ttl_hopl_changed
Definition: c_tcp_defines.h:95
uint32_t src_addr
Definition: c_tcp_defines.h:165
ip_version
IP version.
Definition: ip.h:49
uint8_t ip_id_behavior
Definition: c_tcp_defines.h:139
bool ip_id_behavior_changed
Definition: c_tcp_defines.h:84
size_t tcp_window_change_count
Definition: c_tcp_defines.h:235
uint8_t ip_id_behavior
Definition: c_tcp_defines.h:161
Define union of IP contexts.
Definition: c_tcp_defines.h:210
size_t nr_ack_scaled_bits
Definition: c_tcp_defines.h:79
bool cr_tcp_window_present
Definition: c_tcp_defines.h:280
uint8_t ttl_hopl
Definition: c_tcp_defines.h:137
uint8_t ip_ecn_flags
Definition: c_tcp_defines.h:155
bool tcp_ack_flag_changed
Definition: c_tcp_defines.h:103
uint32_t flow_label
Definition: c_tcp_defines.h:199
uint8_t last_ip_id_behavior
Definition: c_tcp_defines.h:162
uint8_t last_ip_id_behavior
Definition: c_tcp_defines.h:140
bool tcp_ack_num_changed
Definition: c_tcp_defines.h:73
bool is_ipv6_exts_list_static_changed
Definition: c_tcp_defines.h:48
TCP header description.
#define ROHC_TCP_MAX_IP_EXT_HDRS
The maximum number of IP extension header supported by the TCP profile.
Definition: tcp.h:67
uint8_t last_ip_id_behavior
Definition: c_tcp_defines.h:197
size_t option_length
Definition: c_tcp_defines.h:117
uint8_t ttl_hopl
Definition: c_tcp_defines.h:93
uint16_t ack_stride
Definition: c_tcp_defines.h:274
uint16_t last_ip_id
Definition: c_tcp_defines.h:163
size_t ip_contexts_nr
Definition: c_tcp_defines.h:294
size_t ip_exts_nr[ROHC_TCP_MAX_IP_HDRS]
Definition: c_tcp_defines.h:53
uint16_t ack_num_residue
Definition: c_tcp_defines.h:276
bool dscp_changed
Definition: c_tcp_defines.h:101
size_t payload_len
Definition: c_tcp_defines.h:56
struct ipv6_context ipv6_context_t
Define the IPv6 header context.
bool tcp_seq_num_changed
Definition: c_tcp_defines.h:67