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_COMP_TCP_DEFINES_H
30 #define ROHC_COMP_TCP_DEFINES_H
31 
32 #include "protocols/ip.h"
33 #include "protocols/tcp.h"
34 #include "schemes/ip_ctxt.h"
35 #include "c_tcp_opts_list.h"
36 
37 
38 /**
39  * @brief Define the TCP-specific temporary variables in the profile
40  * compression context.
41  *
42  * This object must be used by the TCP-specific compression context
43  * sc_tcp_context.
44  *
45  * @see sc_tcp_context
46  */
48 {
49  uint32_t seq_num;
50  uint32_t ack_num;
51 
52  /** The new innermost IP-ID behavior */
54  /** The IP-ID / SN delta (with bits swapped if necessary) */
55  uint16_t ip_id_delta;
56 
57  /** The new IP-ID behaviors per IP header */
59  /** Whether the TTL/HL changed per IP header */
61 
62  /** Whether at least one of the static part of the IPv6 extensions changed
63  * in the current packet */
65  /** Whether at least one of the dynamic part of the IPv6 extensions changed
66  * in the current packet */
68  /** Whether the TCP window changed or not */
69  uint16_t tcp_window_changed:1;
70  /** Whether the sequence number changed or not */
72  /** Whether the ACK number changed or not */
74  /** Whether the behavior of the IP-ID field changed with current packet */
77  uint16_t ttl_irreg_chain_flag:1; /* outer IPv4 TTLs or IPv6 Hop Limits */
79  uint16_t ip_df_changed:1;
80  uint16_t dscp_changed:1;
84  uint16_t tcp_urg_ptr_changed:1;
85  uint16_t ecn_used_changed:1; /**< Whether the ecn_used flag changed or not */
86 
87  /** Whether the behavior of at least one of the outer IP-ID fields changed */
89 
90  /** The temporary part of the context for TCP options */
92 };
93 
94 
95 /** Define the TCP part of the profile decompression context */
97 {
98  uint16_t msn; /**< The Master Sequence Number (MSN) */
99  /** The MSN of the last packet that updated the context (used to determine
100  * if a positive ACK may cause a transition to a higher compression state) */
102 
103  uint32_t seq_num;
104  uint32_t seq_num_scaled;
105  uint32_t seq_num_residue;
106  uint32_t seq_num_factor;
107 
108  uint32_t ack_num;
109  uint16_t ack_deltas_width[20];
110  uint32_t ack_num_scaled;
111  uint32_t ack_num_residue;
112  uint16_t ack_stride;
114 
115  /** The number of TCP sequence number transmissions since last change */
117  /** The number of TCP ACK number transmissions since last change */
121  /** The number of times the window field was added to the compressed header */
123  /** The number of times the ECN fields were added to the compressed header */
125  /** The number of times the ECN fields were not needed */
128  /** The number of outer IP-ID behaviors transmissions since last change */
130  /** The number of innermost IP-ID behavior transmissions since last change */
132  /** The number of innermost DSCP transmissions since last change */
134  /** The number of IPv6 exts static transmissions since last change */
136  /** The number of IPv6 exts dynamic transmissions since last change */
138  /** The number of TCP options static transmissions since last change */
140  /** The number of TCP URG pointer transmissions since last change */
143 
144  uint8_t ecn_used:1; /**< Explicit Congestion Notification used */
145  /* Context Replication */
149 
150  uint8_t res_flags:4;
151  uint8_t urg_flag:1;
152  uint8_t ack_flag:1;
153  uint8_t unused2:6;
154 
155  struct c_wlsb msn_wlsb; /**< The W-LSB decoding context for MSN */
158  struct c_wlsb window_wlsb; /**< The W-LSB decoding context for TCP window */
159  struct c_wlsb seq_wlsb;
161  struct c_wlsb ack_wlsb;
163 
164  /** The compression context for TCP options */
166 
167  uint16_t urg_ptr_nbo;
168  uint16_t window_nbo;
169 
170  uint8_t ip_contexts_nr;
172 };
173 
174 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
175 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
176  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
177  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
178 _Static_assert((offsetof(struct sc_tcp_context, seq_num_scaled) % 8) == 0,
179  "seq_num_scaled in sc_tcp_context should be aligned on 8 bytes");
180 _Static_assert((offsetof(struct sc_tcp_context, ack_deltas_width) % 8) == 0,
181  "ack_deltas_width in sc_tcp_context should be aligned on 8 bytes");
182 _Static_assert((offsetof(struct sc_tcp_context, msn_wlsb) % 8) == 0,
183  "msn_wlsb in sc_tcp_context should be aligned on 8 bytes");
184 _Static_assert((offsetof(struct sc_tcp_context, ttl_hopl_wlsb) % 8) == 0,
185  "ttl_hopl_wlsb in sc_tcp_context should be aligned on 8 bytes");
186 _Static_assert((offsetof(struct sc_tcp_context, tcp_opts) % 8) == 0,
187  "tcp_opts in sc_tcp_context should be aligned on 8 bytes");
188 _Static_assert((offsetof(struct sc_tcp_context, ip_contexts) % 8) == 0,
189  "ip_contexts in sc_tcp_context should be aligned on 8 bytes");
190 _Static_assert((sizeof(struct sc_tcp_context) % 8) == 0,
191  "sc_tcp_context length should be multiple of 8 bytes");
192 #endif
193 
194 
195 #endif /* ROHC_COMP_TCP_DEFINES_H */
196 
struct c_wlsb ttl_hopl_wlsb
Definition: c_tcp_defines.h:156
uint16_t innermost_ip_id_behavior_changed
Definition: c_tcp_defines.h:75
uint32_t ack_num
Definition: c_tcp_defines.h:108
rohc_ip_id_behavior_t ip_id_behaviors[ROHC_MAX_IP_HDRS]
Definition: c_tcp_defines.h:58
uint8_t urg_flag
Definition: c_tcp_defines.h:151
struct c_wlsb msn_wlsb
Definition: c_tcp_defines.h:155
uint8_t ack_num_scaling_nr
Definition: c_tcp_defines.h:120
Definition: c_tcp_defines.h:96
uint8_t tcp_seq_num_trans_nr
Definition: c_tcp_defines.h:116
uint8_t ecn_used_change_count
Definition: c_tcp_defines.h:124
uint32_t seq_num_residue
Definition: c_tcp_defines.h:105
Define the TCP-specific temporary variables in the profile compression context.
Definition: c_tcp_defines.h:47
uint32_t seq_num
Definition: c_tcp_defines.h:103
struct c_tcp_opts_ctxt tcp_opts
Definition: c_tcp_defines.h:165
uint8_t ipv6_exts_list_static_trans_nr
Definition: c_tcp_defines.h:135
uint16_t tcp_urg_ptr_changed
Definition: c_tcp_defines.h:84
Handle the list of TCP options for the TCP ompression profile.
struct c_wlsb ip_id_wlsb
Definition: c_tcp_defines.h:157
uint8_t ttl_hopl_change_count[ROHC_MAX_IP_HDRS]
Definition: c_tcp_defines.h:142
ip_context_t ip_contexts[ROHC_MAX_IP_HDRS]
Definition: c_tcp_defines.h:171
uint16_t is_ipv6_exts_list_dyn_changed
Definition: c_tcp_defines.h:67
uint16_t outer_ip_ttl_changed
Definition: c_tcp_defines.h:78
uint16_t msn_of_last_ctxt_updating_pkt
Definition: c_tcp_defines.h:101
rohc_ip_id_behavior_t innermost_ip_id_behavior
Definition: c_tcp_defines.h:53
uint8_t unused2
Definition: c_tcp_defines.h:153
uint8_t cr_tcp_urg_ptr_present
Definition: c_tcp_defines.h:147
uint8_t innermost_dscp_trans_nr
Definition: c_tcp_defines.h:133
bool ttl_hopl_changed[ROHC_MAX_IP_HDRS]
Definition: c_tcp_defines.h:60
bool outer_ip_id_behavior_changed
Definition: c_tcp_defines.h:88
uint8_t tcp_opts_list_static_trans_nr
Definition: c_tcp_defines.h:139
Definition: c_tcp_opts_list.h:128
uint16_t tcp_ack_flag_changed
Definition: c_tcp_defines.h:81
uint8_t ip_contexts_nr
Definition: c_tcp_defines.h:170
uint16_t tcp_ack_num_unchanged
Definition: c_tcp_defines.h:73
One W-LSB encoding object.
Definition: comp_wlsb.h:68
uint16_t ip_id_delta
Definition: c_tcp_defines.h:55
uint8_t tcp_window_change_count
Definition: c_tcp_defines.h:122
struct c_wlsb seq_wlsb
Definition: c_tcp_defines.h:159
uint32_t seq_num_scaled
Definition: c_tcp_defines.h:104
uint8_t innermost_ttl_hopl_change_count
Definition: c_tcp_defines.h:127
rohc_ip_id_behavior_t
Definition: rohc_internal.h:236
uint16_t msn
Definition: c_tcp_defines.h:98
uint32_t ack_num_scaled
Definition: c_tcp_defines.h:110
struct c_wlsb ack_scaled_wlsb
Definition: c_tcp_defines.h:162
uint8_t ipv6_exts_list_dyn_trans_nr
Definition: c_tcp_defines.h:137
struct c_wlsb seq_scaled_wlsb
Definition: c_tcp_defines.h:160
uint8_t innermost_ip_id_behavior_trans_nr
Definition: c_tcp_defines.h:131
uint32_t ack_num_residue
Definition: c_tcp_defines.h:111
uint8_t outer_ip_id_behavior_trans_nr
Definition: c_tcp_defines.h:129
uint32_t ack_num
Definition: c_tcp_defines.h:50
uint8_t cr_tcp_window_present
Definition: c_tcp_defines.h:146
struct c_tcp_opts_ctxt_tmp tcp_opts
Definition: c_tcp_defines.h:91
uint16_t urg_ptr_nbo
Definition: c_tcp_defines.h:167
uint16_t dscp_changed
Definition: c_tcp_defines.h:80
uint16_t innermost_ttl_hopl_changed
Definition: c_tcp_defines.h:76
struct c_wlsb window_wlsb
Definition: c_tcp_defines.h:158
uint16_t tcp_seq_num_unchanged
Definition: c_tcp_defines.h:71
uint8_t res_flags
Definition: c_tcp_defines.h:150
uint16_t ip_df_changed
Definition: c_tcp_defines.h:79
uint8_t seq_num_scaling_nr
Definition: c_tcp_defines.h:119
uint16_t tcp_window_changed
Definition: c_tcp_defines.h:69
uint8_t tcp_ack_num_trans_nr
Definition: c_tcp_defines.h:118
uint16_t tcp_urg_flag_changed
Definition: c_tcp_defines.h:83
Definition: c_tcp_opts_list.h:77
uint8_t ecn_used
Definition: c_tcp_defines.h:144
uint16_t ttl_irreg_chain_flag
Definition: c_tcp_defines.h:77
uint8_t cr_tcp_ack_num_present
Definition: c_tcp_defines.h:148
uint16_t ecn_used_changed
Definition: c_tcp_defines.h:85
uint16_t tcp_urg_flag_present
Definition: c_tcp_defines.h:82
uint16_t is_ipv6_exts_list_static_changed
Definition: c_tcp_defines.h:64
uint32_t seq_num
Definition: c_tcp_defines.h:49
The TCP compression context for one IPv4 or IPv6 header.
Definition: comp/schemes/ip_ctxt.h:76
uint8_t ack_deltas_next
Definition: c_tcp_defines.h:113
Defines the common IPv4/v6 header.
uint8_t ecn_used_zero_count
Definition: c_tcp_defines.h:126
TCP header description.
uint32_t seq_num_factor
Definition: c_tcp_defines.h:106
uint16_t window_nbo
Definition: c_tcp_defines.h:168
uint16_t ack_stride
Definition: c_tcp_defines.h:112
uint16_t ack_deltas_width[20]
Definition: c_tcp_defines.h:109
uint8_t tcp_urg_ptr_trans_nr
Definition: c_tcp_defines.h:141
struct c_wlsb ack_wlsb
Definition: c_tcp_defines.h:161
#define ROHC_MAX_IP_HDRS
The maximum number of IP headers supported.
Definition: protocols/ip.h:46
uint8_t ack_flag
Definition: c_tcp_defines.h:152