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  /** Whether the option context is in use or not */
46  bool used;
47  /** The type of the TCP option */
48  uint8_t type;
49  /** The number of times the TCP option was transmitted */
50  size_t nr_trans;
51  size_t age;
52  /** The length of the TCP option */
53  size_t data_len;
54 /** The maximum size (in bytes) of one TCP option */
55 #define MAX_TCP_OPT_SIZE 40U
56  /** The TCP option data */
57  union
58  {
62  } data;
63 };
64 
65 
66 /** The temporary part of the compression context for TCP options */
68 {
69  /** Whether the structure of the list of TCP options changed in the
70  * current packet */
72  /** Whether at least one of the static TCP options changed in the
73  * current packet */
75  /** Whether the content of every TCP options was transmitted or not */
76  bool is_list_item_present[MAX_TCP_OPTION_INDEX + 1];
77 
78  /** The number of options in the list of TCP options */
79  size_t nr;
80  /** The mapping between option types and indexes */
81  uint8_t position2index[ROHC_TCP_OPTS_MAX];
82  /* The maximum index value used for the list of TCP options */
83  uint8_t idx_max;
84 
85  /** Whether the TCP option timestamp echo request is present in packet */
87  /** The value of the TCP option timestamp echo request (in HBO) */
88  uint32_t ts_req;
89  /** The value of the TCP option timestamp echo reply (in HBO) */
90  uint32_t ts_reply;
91  /** The minimal number of bits required to encode the TCP option timestamp
92  * echo request with p = -1 */
94  /** The minimal number of bits required to encode the TCP option timestamp
95  * echo request with p = 0x40000 */
97  /** The minimal number of bits required to encode the TCP option timestamp
98  * echo request with p = 0x4000000 */
100  /** The minimal number of bits required to encode the TCP option timestamp
101  * echo reply with p = -1 */
103  /** The minimal number of bits required to encode the TCP option timestamp
104  * echo reply with p = 0x40000 */
106  /** The minimal number of bits required to encode the TCP option timestamp
107  * echo reply with p = 0x4000000 */
109 };
110 
111 
112 /** The compression context for TCP options */
114 {
115  /** The number of times the structure of the list of TCP options was
116  * transmitted since it last changed */
118  size_t structure_nr;
119  uint8_t structure[ROHC_TCP_OPTS_MAX];
121 
123  struct c_wlsb ts_req_wlsb;
124  struct c_wlsb ts_reply_wlsb;
125 
126  /** The temporary part of the context, shall be reset between 2 packets */
128 };
129 
130 
131 bool rohc_comp_tcp_are_options_acceptable(const struct rohc_comp *const comp,
132  const uint8_t *const opts,
133  const size_t data_offset)
134  __attribute__((warn_unused_result, nonnull(1, 2)));
135 
136 bool tcp_detect_options_changes(struct rohc_comp_ctxt *const context,
137  const struct tcphdr *const tcp,
138  struct c_tcp_opts_ctxt *const opts_ctxt,
139  size_t *const opts_len)
140  __attribute__((warn_unused_result, nonnull(1, 2, 3)));
141 
142 int c_tcp_code_tcp_opts_list_item(const struct rohc_comp_ctxt *const context,
143  const struct tcphdr *const tcp,
144  const uint16_t msn,
145  const rohc_chain_t chain_type,
146  struct c_tcp_opts_ctxt *const opts_ctxt,
147  uint8_t *const comp_opts,
148  const size_t comp_opts_max_len,
149  bool *const no_item_needed)
150  __attribute__((warn_unused_result, nonnull(1, 2, 5, 6, 8)));
151 
152 int c_tcp_code_tcp_opts_irreg(const struct rohc_comp_ctxt *const context,
153  const struct tcphdr *const tcp,
154  const uint16_t msn,
155  struct c_tcp_opts_ctxt *const opts_ctxt,
156  uint8_t *const comp_opts,
157  const size_t comp_opts_max_len)
158  __attribute__((warn_unused_result, nonnull(1, 2, 4, 5)));
159 
160 #endif /* ROHC_COMP_TCP_OPTS_LIST_H */
161 
size_t age
Definition: c_tcp_opts_list.h:51
size_t nr_trans
Definition: c_tcp_opts_list.h:50
bool used
Definition: c_tcp_opts_list.h:46
The Selective Acknowlegment TCP option.
Definition: tcp.h:137
size_t nr_opt_ts_reply_bits_0x40000
Definition: c_tcp_opts_list.h:105
bool opt_ts_present
Definition: c_tcp_opts_list.h:86
size_t nr_opt_ts_req_bits_0x40000
Definition: c_tcp_opts_list.h:96
size_t structure_nr
Definition: c_tcp_opts_list.h:118
int c_tcp_code_tcp_opts_irreg(const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint16_t msn, struct c_tcp_opts_ctxt *const opts_ctxt, 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:888
#define MAX_TCP_OPT_SIZE
Definition: c_tcp_opts_list.h:55
uint32_t ts_reply
Definition: c_tcp_opts_list.h:90
The ROHC compressor.
Definition: rohc_comp_internals.h:129
size_t nr
Definition: c_tcp_opts_list.h:79
uint8_t raw[MAX_TCP_OPT_SIZE]
Definition: c_tcp_opts_list.h:59
size_t data_len
Definition: c_tcp_opts_list.h:53
rohc_chain_t
The different chains used by the ROHCv1 TCP and ROHCv2 profiles.
Definition: rohc_internal.h:159
size_t structure_nr_trans
Definition: c_tcp_opts_list.h:117
size_t nr_opt_ts_req_bits_minus_1
Definition: c_tcp_opts_list.h:93
bool is_timestamp_init
Definition: c_tcp_opts_list.h:122
union c_tcp_opt_ctxt::@20 data
size_t nr_opt_ts_reply_bits_0x4000000
Definition: c_tcp_opts_list.h:108
Definition: c_tcp_opts_list.h:113
One W-LSB encoding object.
Definition: comp_wlsb.h:56
bool tcp_detect_options_changes(struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, struct c_tcp_opts_ctxt *const opts_ctxt, size_t *const opts_len)
Parse the uncompressed TCP options for changes.
Definition: c_tcp_opts_list.c:471
Internal structures for ROHC compression.
The ROHC compression context.
Definition: rohc_comp_internals.h:326
#define MAX_TCP_OPTION_INDEX
The largest index that may be used to identify one TCP option.
Definition: rfc6846.h:58
ROHC packets for the ROHCv1 IP/TCP profile defined in RFC6846.
bool do_list_static_changed
Definition: c_tcp_opts_list.h:74
size_t nr_opt_ts_reply_bits_minus_1
Definition: c_tcp_opts_list.h:102
uint8_t idx_max
Definition: c_tcp_opts_list.h:83
uint32_t ts_req
Definition: c_tcp_opts_list.h:88
The TCP base header without options.
Definition: tcp.h:50
int c_tcp_code_tcp_opts_list_item(const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint16_t msn, const rohc_chain_t chain_type, struct c_tcp_opts_ctxt *const opts_ctxt, 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:706
uint8_t type
Definition: c_tcp_opts_list.h:48
struct tcp_option_timestamp timestamp
Definition: c_tcp_opts_list.h:61
Definition: c_tcp_opts_list.h:67
#define ROHC_TCP_OPTS_MAX
The maximum of TCP options supported by the TCP profile.
Definition: rfc6846.h:73
The compression context for one TCP option.
Definition: c_tcp_opts_list.h:43
bool rohc_comp_tcp_are_options_acceptable(const struct rohc_comp *const comp, const uint8_t *const opts, const size_t data_offset)
Whether TCP options are acceptable for TCP profile or not.
Definition: c_tcp_opts_list.c:285
Definition: tcp.h:149
TCP header description.
size_t nr_opt_ts_req_bits_0x4000000
Definition: c_tcp_opts_list.h:99
sack_block_t sack_blocks[4]
Definition: c_tcp_opts_list.h:60
bool do_list_struct_changed
Definition: c_tcp_opts_list.h:71