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