ROHC compression/decompression library
c_tcp_opts_list.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014,2015 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_opts_list.h
23  * @brief Handle the list of TCP options for the TCP ompression 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_OPTS_LIST_H
30 #define ROHC_COMP_TCP_OPTS_LIST_H
31 
32 #include "rohc_comp_internals.h"
33 #include "protocols/tcp.h"
34 #include "protocols/rfc6846.h"
35 
36 #include <stdint.h>
37 #include <stddef.h>
38 
39 
40 /**
41  * @brief The compression context for one TCP option
42  */
44 {
45  /** The TCP option data */
46  union
47  {
51  } data;
52  /** The number of times the full TCP option was transmitted */
53  uint8_t full_trans_nr;
54  /** The number of times the dynamic part of TCP option was transmitted */
55  uint8_t dyn_trans_nr;
56  /** Whether the option context is in use or not */
57  bool used;
58  /** The type of the TCP option */
59  uint8_t type;
60  uint8_t age;
61  /** The length of the TCP option */
62  uint8_t data_len;
63 };
64 
65 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
66 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
67  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
68  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
69 _Static_assert((offsetof(struct c_tcp_opt_ctxt, data) % 8) == 0,
70  "data in c_tcp_opt_ctxt should be aligned on 8 bytes");
71 _Static_assert((sizeof(struct c_tcp_opt_ctxt) % 8) == 0,
72  "c_tcp_opt_ctxt length should be multiple of 8 bytes");
73 #endif
74 
75 
76 /** The temporary part of the compression context for TCP options */
78 {
79  /** The value of the TCP option timestamp echo request (in HBO) */
80  uint32_t ts_req;
81  /** The value of the TCP option timestamp echo reply (in HBO) */
82  uint32_t ts_reply;
83 
84  /** Whether the content of every TCP options was transmitted or not */
86 
87  /** The mapping between option types and indexes */
89 
90  /** The number of options in the list of TCP options */
91  uint8_t nr;
92  /* The maximum index value used for the list of TCP options */
93  uint8_t idx_max;
94 
95  /** Whether the structure of the list of TCP options changed in the
96  * current packet */
98  /** Whether at least one of the static TCP options changed in the
99  * current packet */
101  /** Whether the TCP option timestamp echo request is present in packet */
102  uint8_t opt_ts_present:1;
104  uint8_t unused:4;
105 
106  uint8_t ts_req_bytes_nr:4;
107  uint8_t ts_reply_bytes_nr:4;
108 
109  uint8_t unused4[4];
110 };
111 
112 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
113 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
114  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
115  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
116 _Static_assert((offsetof(struct c_tcp_opts_ctxt_tmp, ts_req) % 8) == 0,
117  "ts_req in c_tcp_opts_ctxt_tmp should be aligned on 8 bytes");
118 _Static_assert((offsetof(struct c_tcp_opts_ctxt_tmp, is_list_item_present) % 8) == 0,
119  "is_list_item_present in c_tcp_opts_ctxt_tmp should be aligned on 8 bytes");
120 _Static_assert((offsetof(struct c_tcp_opts_ctxt_tmp, position2index) % 8) == 0,
121  "position2index in c_tcp_opts_ctxt_tmp should be aligned on 8 bytes");
122 _Static_assert((sizeof(struct c_tcp_opts_ctxt_tmp) % 8) == 0,
123  "c_tcp_opts_ctxt_tmp length should be multiple of 8 bytes");
124 #endif
125 
126 
127 /** The compression context for TCP options */
129 {
131  uint8_t structure_nr;
133 
136 
137  /** The number of times the structure of the list of TCP options was
138  * transmitted since it last changed */
140  uint8_t unused[6];
141 };
142 
143 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
144 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
145  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
146  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
147 _Static_assert((offsetof(struct c_tcp_opts_ctxt, structure) % 8) == 0,
148  "structure in c_tcp_opts_ctxt should be aligned on 8 bytes");
149 _Static_assert((offsetof(struct c_tcp_opts_ctxt, list) % 8) == 0,
150  "list in c_tcp_opts_ctxt should be aligned on 8 bytes");
151 _Static_assert((offsetof(struct c_tcp_opts_ctxt, ts_req_wlsb) % 8) == 0,
152  "ts_req_wlsb in c_tcp_opts_ctxt should be aligned on 8 bytes");
153 _Static_assert((offsetof(struct c_tcp_opts_ctxt, ts_reply_wlsb) % 8) == 0,
154  "ts_reply_wlsb in c_tcp_opts_ctxt should be aligned on 8 bytes");
155 _Static_assert((sizeof(struct c_tcp_opts_ctxt) % 8) == 0,
156  "c_tcp_opts_ctxt length should be multiple of 8 bytes");
157 #endif
158 
159 
160 bool rohc_comp_tcp_are_options_acceptable(const struct rohc_comp *const comp,
161  const uint8_t *const opts,
162  const size_t data_offset,
163  struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
164  __attribute__((warn_unused_result, nonnull(1, 2, 4)));
165 
166 void tcp_detect_options_changes(struct rohc_comp_ctxt *const context,
167  const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
168  struct c_tcp_opts_ctxt *const opts_ctxt,
169  struct c_tcp_opts_ctxt_tmp *const tmp,
170  const bool tcp_ack_num_changed)
171  __attribute__((nonnull(1, 2, 3, 4)));
172 
173 int c_tcp_code_tcp_opts_list_item(const struct rohc_comp_ctxt *const context,
174  const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
175  const rohc_chain_t chain_type,
176  struct c_tcp_opts_ctxt *const opts_ctxt,
177  struct c_tcp_opts_ctxt_tmp *const tmp,
178  uint8_t *const comp_opts,
179  const size_t comp_opts_max_len,
180  bool *const no_item_needed)
181  __attribute__((warn_unused_result, nonnull(1, 2, 4, 5, 6, 8)));
182 
183 int c_tcp_code_tcp_opts_irreg(const struct rohc_comp_ctxt *const context,
184  const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs,
185  struct c_tcp_opts_ctxt *const opts_ctxt,
186  const struct c_tcp_opts_ctxt_tmp *const tmp,
187  uint8_t *const comp_opts,
188  const size_t comp_opts_max_len)
189  __attribute__((warn_unused_result, nonnull(1, 2, 3, 4, 5)));
190 
191 #endif /* ROHC_COMP_TCP_OPTS_LIST_H */
192 
uint8_t unused[6]
Definition: c_tcp_opts_list.h:140
uint8_t unused
Definition: c_tcp_opts_list.h:104
uint8_t raw[ROHC_TCP_OPT_MAX_LEN]
Definition: c_tcp_opts_list.h:48
bool used
Definition: c_tcp_opts_list.h:57
#define ROHC_TCP_OPT_MAX_LEN
The maximum length of TCP options supported by the TCP profile.
Definition: rfc6846.h:58
The Selective Acknowlegment TCP option.
Definition: tcp.h:160
uint8_t structure[ROHC_TCP_OPTS_MAX]
Definition: c_tcp_opts_list.h:130
uint32_t ts_reply
Definition: c_tcp_opts_list.h:82
The ROHC compressor.
Definition: rohc_comp_internals.h:107
uint8_t opt_ts_present
Definition: c_tcp_opts_list.h:102
union c_tcp_opt_ctxt::@35 data
uint8_t position2index[ROHC_TCP_OPTS_MAX]
Definition: c_tcp_opts_list.h:88
struct c_tcp_opt_ctxt list[MAX_TCP_OPTION_INDEX+1]
Definition: c_tcp_opts_list.h:132
int c_tcp_code_tcp_opts_list_item(const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_chain_t chain_type, struct c_tcp_opts_ctxt *const opts_ctxt, struct c_tcp_opts_ctxt_tmp *const tmp, uint8_t *const comp_opts, const size_t comp_opts_max_len, bool *const no_item_needed)
Build the list of TCP options items.
Definition: c_tcp_opts_list.c:805
struct c_wlsb ts_reply_wlsb
Definition: c_tcp_opts_list.h:135
rohc_chain_t
The different chains used by the ROHCv1 TCP and ROHCv2 profiles.
Definition: rohc_internal.h:224
bool is_list_item_present[MAX_TCP_OPTION_INDEX+1]
Definition: c_tcp_opts_list.h:85
uint8_t dyn_trans_nr
Definition: c_tcp_opts_list.h:55
uint8_t ts_reply_bytes_nr
Definition: c_tcp_opts_list.h:107
Definition: c_tcp_opts_list.h:128
One W-LSB encoding object.
Definition: comp_wlsb.h:68
Internal structures for ROHC compression.
The ROHC compression context.
Definition: rohc_comp_internals.h:278
bool nonnull(1)))
#define MAX_TCP_OPTION_INDEX
The largest index that may be used to identify one TCP option.
Definition: rfc6846.h:67
ROHC packets for the ROHCv1 IP/TCP profile defined in RFC6846.
uint8_t idx_max
Definition: c_tcp_opts_list.h:93
uint32_t ts_req
Definition: c_tcp_opts_list.h:80
uint8_t do_list_static_changed
Definition: c_tcp_opts_list.h:100
void tcp_detect_options_changes(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, struct c_tcp_opts_ctxt *const opts_ctxt, struct c_tcp_opts_ctxt_tmp *const tmp, const bool tcp_ack_num_changed)
Parse the uncompressed TCP options for changes.
Definition: c_tcp_opts_list.c:495
uint8_t nr
Definition: c_tcp_opts_list.h:91
The information collected about the packet headers.
Definition: uncomp_pkt_hdrs.h:102
uint8_t unused4[4]
Definition: c_tcp_opts_list.h:109
uint8_t do_list_struct_changed
Definition: c_tcp_opts_list.h:97
uint8_t type
Definition: c_tcp_opts_list.h:59
struct tcp_option_timestamp timestamp
Definition: c_tcp_opts_list.h:50
uint8_t opt_ts_do_transmit_item
Definition: c_tcp_opts_list.h:103
uint8_t age
Definition: c_tcp_opts_list.h:60
Definition: c_tcp_opts_list.h:77
uint8_t ts_req_bytes_nr
Definition: c_tcp_opts_list.h:106
int c_tcp_code_tcp_opts_irreg(const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, struct c_tcp_opts_ctxt *const opts_ctxt, const struct c_tcp_opts_ctxt_tmp *const tmp, uint8_t *const comp_opts, const size_t comp_opts_max_len)
Build the list of TCP options for the irregular chain.
Definition: c_tcp_opts_list.c:953
struct c_wlsb ts_req_wlsb
Definition: c_tcp_opts_list.h:134
bool rohc_comp_tcp_are_options_acceptable(const struct rohc_comp *const comp, const uint8_t *const opts, const size_t data_offset, struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
Whether TCP options are acceptable for TCP profile or not.
Definition: c_tcp_opts_list.c:291
The compression context for one TCP option.
Definition: c_tcp_opts_list.h:43
uint8_t structure_nr
Definition: c_tcp_opts_list.h:131
uint8_t full_trans_nr
Definition: c_tcp_opts_list.h:53
#define ROHC_TCP_OPTS_MAX
The maximum of TCP options supported by the TCP profile.
Definition: tcp.h:124
Definition: tcp.h:172
TCP header description.
uint8_t data_len
Definition: c_tcp_opts_list.h:62
sack_block_t sack_blocks[4]
Definition: c_tcp_opts_list.h:49
uint8_t structure_nr_trans
Definition: c_tcp_opts_list.h:139