ROHC compression/decompression library
|
Handle the list of TCP options for the TCP compression profile. More...
#include "c_tcp_opts_list.h"
#include "schemes/tcp_ts.h"
#include "schemes/tcp_sack.h"
#include <string.h>
Data Structures | |
struct | c_tcp_opt |
Macros | |
#define | TCP_LIST_ITEM_MAP_LEN 16U |
Functions | |
static bool | c_tcp_opt_get_type_len (const uint8_t *const opts_data, const size_t opts_len, uint8_t *const opt_type, uint8_t *const opt_len) |
Get the type and length of the next TCP option. More... | |
static bool | c_tcp_opt_changed (const struct c_tcp_opts_ctxt *const opts_ctxt, const uint8_t opt_idx, const uint8_t *const pkt_opt, const size_t pkt_opt_len) |
Does the TCP option changed since last packets? More... | |
static void | c_tcp_opt_record (struct c_tcp_opts_ctxt *const opts_ctxt, const uint8_t opt_idx, const uint8_t *const pkt_opt, const size_t pkt_opt_len) |
Record the TCP option in context. More... | |
static void | c_tcp_opt_trace (const struct rohc_comp_ctxt *const context, const uint8_t opt_type, const uint8_t *const opt_data, const size_t opt_len) |
Print a trace for the given TCP option. More... | |
static uint8_t | c_tcp_get_opt_index (const struct rohc_comp_ctxt *const context, struct c_tcp_opts_ctxt *const opts_ctxt, const uint8_t opt_type, const bool indexes_in_use[MAX_TCP_OPTION_INDEX+1]) |
Determine the index of the TCP option. More... | |
static int | c_tcp_opt_compute_ps (const uint8_t idx_max) |
Determine PS for the compressed list of TCP options. More... | |
static size_t | c_tcp_opt_compute_xi_len (const int ps, const size_t m) |
Determine the length of XI indexes for the list of TCP options. More... | |
static size_t | c_tcp_opt_write_xi (const struct rohc_comp_ctxt *const context, uint8_t *const comp_opts, const int ps, const size_t opt_pos, const uint8_t opt_idx, const bool item_needed) |
Write the XI field for a TCP option. More... | |
static bool | c_tcp_is_list_item_needed (const struct rohc_comp_ctxt *const context, const rohc_chain_t chain_type, const uint8_t opt_idx, const uint8_t opt_type, const uint8_t opt_len, const uint8_t *const opt, const struct c_tcp_opts_ctxt *const opts_ctxt) |
Shall the list item be transmitted or not? More... | |
static int | c_tcp_build_nop_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP NOP option. More... | |
static int | c_tcp_build_eol_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP EOL option. More... | |
static int | c_tcp_build_mss_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP MSS option. More... | |
static int | c_tcp_build_ws_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP WS option. More... | |
static int | c_tcp_build_ts_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP TS option. More... | |
static int | c_tcp_build_sack_perm_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP SACK Permitted option. More... | |
static int | c_tcp_build_sack_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP SACK option. More... | |
static int | c_tcp_build_generic_list_item (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t *const uncomp_opt, const uint8_t uncomp_opt_len, uint8_t *const comp_opt, const size_t comp_opt_max_len) |
Build the list item for the TCP generic option. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Variables | |
static struct c_tcp_opt | c_tcp_opts [MAX_TCP_OPTION_INDEX+1] |
static int | c_tcp_type2index [TCP_LIST_ITEM_MAP_LEN] |
Table of TCP option index, from option Id. More... | |
Handle the list of TCP options for the TCP compression profile.
#define TCP_LIST_ITEM_MAP_LEN 16U |
The length of the table mapping for TCP options
|
static |
Build the list item for the TCP EOL option.
pad_len =:= compressed_value(8, nbits-8) [ 8 ];
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP generic option.
type =:= irregular(8) [ 8 ]; option_static =:= one_bit_choice [ 1 ]; length_lsb =:= irregular(7) [ 7 ]; contents =:= irregular(length_lsb.UVALUE*8-16) [ length_lsb.UVALUE*8-16 ];
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP MSS option.
mss =:= irregular(16) [ 16 ];
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP NOP option.
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP SACK option.
See RFC4996 page 67.
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP SACK Permitted option.
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP TS option.
tsval =:= irregular(32) [ 32 ]; tsecho =:= irregular(32) [ 32 ];
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the list item for the TCP WS option.
wscale =:= irregular(8) [ 8 ];
context | The compression context | |
tcp | The TCP header | |
uncomp_opt | The uncompressed TCP option to compress | |
uncomp_opt_len | The length of the uncompressed TCP option to compress | |
[out] | comp_opt | The compressed TCP option |
comp_opt_max_len | The max remaining length in the ROHC buffer |
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.
All the CO packets contains an irregular chain.
context | The compression context | |
tcp | The TCP header | |
msn | The Master Sequence Number (MSN) of the packet to compress | |
[in,out] | opts_ctxt | The compression context for TCP options |
[out] | comp_opts | The compressed TCP options |
comp_opts_max_len | The max remaining length in the ROHC buffer |
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.
The list of TCP options is used in:
context | The compression context | |
tcp | The TCP header | |
msn | The Master Sequence Number (MSN) of the packet to compress | |
chain_type | The TCP chain for which the list of items is | |
[in,out] | opts_ctxt | The compression context for TCP options |
[out] | comp_opts | The compressed TCP options |
comp_opts_max_len | The max remaining length in the ROHC buffer | |
[out] | no_item_needed | Whether no item was needed at all |
|
static |
Determine the index of the TCP option.
context | The compression context | |
[in,out] | opts_ctxt | The compression context for TCP options |
opt_type | The type of the option | |
indexes_in_use | What indexes are used by the current packet? |
|
static |
Shall the list item be transmitted or not?
context | The compression context |
chain_type | The TCP chain for which the list of items is |
opt_idx | The compression index of the TCP option to compress |
opt_type | The type of the TCP option to compress |
opt_len | The length of the TCP option to compress |
opt | The TCP option to compress |
opts_ctxt | The compression context for TCP options |
|
static |
Does the TCP option changed since last packets?
The TCP option changed if the packet TCP option do not match the TCP option that was recorded in the compression context.
opts_ctxt | The compression context of the TCP options |
opt_idx | The index of the TCP option in the TCP compression context |
pkt_opt | The TCP option as found in the TCP packet |
pkt_opt_len | The length of the TCP option as found in the TCP packet |
|
static |
Determine PS for the compressed list of TCP options.
According to RFC6846, §6.3.3, PS indicates size of XI fields:
The rational to choose is: use 4-bit XI fields if the largest option index may fit in 4 bits, otherwise fallback on the 8-bit XI fields
idx_max | The largest option index used in the compressed packet |
|
static |
Determine the length of XI indexes for the list of TCP options.
The length of the XI indexes depends on the type of XI fields we use. According to RFC6846, §6.3.3, PS indicates size of XI fields:
The computed XI length includes the first byte that contain the reserved bits, the PS flag and the number of XI indexes (m).
ps | The PS value |
m | The number of elements in the list |
|
static |
Get the type and length of the next TCP option.
opts_data | The remaining data in the TCP options | |
opts_len | The length of the remaining data in the TCP options | |
[out] | opt_type | The type of the TCP option |
[out] | opt_len | The length (in bytes) of the TCP option |
|
static |
Record the TCP option in context.
[out] | opts_ctxt | The TCP compression context |
opt_idx | The index of the TCP option in the TCP compression context | |
pkt_opt | The TCP option as found in the TCP packet | |
pkt_opt_len | The length of the TCP option as found in the TCP packet |
|
static |
Print a trace for the given TCP option.
context | The compression context |
opt_type | The type of the TCP option to print a trace for |
opt_data | The data of the TCP option to print a trace for |
opt_len | The length (in bytes) of the TCP option to print a trace for |
|
static |
Write the XI field for a TCP option.
The room available in comp_opts shall have been checked before calling this function.
context | The compression context | |
[in,out] | comp_opts | The compressed options |
ps | 0 to use 4-bit XI fields, or 1 to use 8-bit XI fields | |
opt_pos | The position of the TCP option in the list (opt_pos starts at 0) | |
opt_idx | The index of the TCP option | |
item_needed | Whether the TCP option requires its related item to be present or not |
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.
TCP options are acceptable for the TCP profile if:
The following well-known TCP options shall have expected lengths:
comp | The ROHC compressor |
opts | The beginning of the TCP options |
data_offset | The length (in 32-bit words) of the full TCP header |
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.
context | The compression context | |
tcp | The TCP header | |
[in,out] | opts_ctxt | The compression context for TCP options |
[out] | opts_len | The length (in bytes) of the TCP options |
|
static |
|
static |
Table of TCP option index, from option Id.
See RFC4996 §6.3.4 Return item index of TCP option