ROHC compression/decompression library
Data Structures | Defines | Typedefs | Functions | Variables
c_tcp.c File Reference

ROHC compression context for the TCP profile. More...

#include "rohc_traces_internal.h"
#include "rohc_utils.h"
#include "rohc_packets.h"
#include "protocols/tcp.h"
#include "schemes/cid.h"
#include "schemes/rfc4996.h"
#include "sdvl.h"
#include "crc.h"
#include "c_generic.h"
#include "c_ip.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
Include dependency graph for c_tcp.c:

Data Structures

struct  tcp_tmp_variables
 Define the TCP-specific temporary variables in the profile compression context. More...
struct  ipv6_option_context
 Define the IPv6 generic option context. More...
struct  ipv6_gre_option_context
 Define the IPv6 GRE option context. More...
struct  ipv6_mime_option_context
 Define the IPv6 MIME option context. More...
struct  ipv6_ah_option_context
 Define the IPv6 AH option context. More...
struct  ipvx_context
 Define the common IP header context to IPv4 and IPv6. More...
struct  ipv4_context
 Define the IPv4 header context. More...
struct  ipv6_context
 Define the IPv6 header context. More...
union  ip_context_ptr_t
 Define union of IP contexts pointers. More...
struct  tcp_opt_context
 The compression context for one TCP option. More...
struct  sc_tcp_context
 Define the TCP part of the profile decompression context. More...

Defines

#define TRACE_GOTO_CHOICE   rohc_comp_debug(context, "Compressed format choice LINE %d", __LINE__ )
#define MAX_IPV6_OPTION_LENGTH   6
#define MAX_IPV6_CONTEXT_OPTION_SIZE   (2 + ((MAX_IPV6_OPTION_LENGTH + 1) << 3))
#define MAX_TCP_OPT_SIZE   40U
#define TCP_LIST_ITEM_MAP_LEN   16U

Typedefs

typedef struct ipv6_option_context ipv6_option_context_t
 Define the IPv6 generic option context.
typedef struct
ipv6_gre_option_context 
ipv6_gre_option_context_t
 Define the IPv6 GRE option context.
typedef struct
ipv6_mime_option_context 
ipv6_mime_option_context_t
 Define the IPv6 MIME option context.
typedef struct
ipv6_ah_option_context 
ipv6_ah_option_context_t
 Define the IPv6 AH option context.
typedef struct ipvx_context ipvx_context_t
 Define the common IP header context to IPv4 and IPv6.
typedef struct ipv4_context ipv4_context_t
 Define the IPv4 header context.
typedef struct ipv6_context ipv6_context_t
 Define the IPv6 header context.

Functions

static bool c_tcp_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Create a new TCP context and initialize it thanks to the given IP/TCP packet.
static void c_tcp_destroy (struct rohc_comp_ctxt *const context)
 Destroy the TCP context.
static bool c_tcp_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to the TCP profile.
static bool c_tcp_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Check if the IP/TCP packet belongs to the context.
static int c_tcp_encode (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset)
 Encode an IP/TCP packet according to a pattern decided by several different factors.
static bool tcp_detect_changes (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Detect changes between packet and context.
static void tcp_decide_state (struct rohc_comp_ctxt *const context)
 Decide the state that should be used for the next packet.
static bool tcp_encode_uncomp_fields (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Encode uncompressed fields with the corresponding encoding scheme.
static rohc_packet_t tcp_decide_packet (const struct rohc_comp_ctxt *const context, const ip_context_ptr_t *const ip_inner_context, const tcphdr_t *const tcp)
 Decide which packet to send when in the different states.
static rohc_packet_t tcp_decide_SO_packet (const struct rohc_comp_ctxt *const context, const ip_context_ptr_t *const ip_inner_context, const tcphdr_t *const tcp)
 Decide which packet to send when in SO state.
static uint8_t * tcp_code_static_ipv6_option_part (struct rohc_comp_ctxt *const context, multi_ptr_t mptr, uint8_t protocol, base_header_ip_t base_header)
 Build the static part of the IPv6 option header.
static uint8_t * tcp_code_dynamic_ipv6_option_part (struct rohc_comp_ctxt *const context, ip_context_ptr_t ip_context, multi_ptr_t mptr, uint8_t protocol, base_header_ip_t base_header)
 Build the dynamic part of the IPv6 option header.
static uint8_t * tcp_code_irregular_ipv6_option_part (struct rohc_comp_ctxt *const context, ip_context_ptr_t ip_context, multi_ptr_t mptr, uint8_t protocol, base_header_ip_t base_header)
 Build the irregular part of the IPv6 option header.
static uint8_t * tcp_code_static_ip_part (struct rohc_comp_ctxt *const context, base_header_ip_t base_header, multi_ptr_t mptr)
 Build the static part of the IP header.
static uint8_t * tcp_code_dynamic_ip_part (const struct rohc_comp_ctxt *context, ip_context_ptr_t ip_context, base_header_ip_t base_header, multi_ptr_t mptr, int is_innermost)
 Build the dynamic part of the IP header.
static uint8_t * tcp_code_irregular_ip_part (struct rohc_comp_ctxt *const context, ip_context_ptr_t ip_context, base_header_ip_t base_header, uint8_t *rohc_data, int ecn_used, int is_innermost, int ttl_irregular_chain_flag, int ip_inner_ecn)
 Build the irregular part of the IP header.
static uint8_t * tcp_code_static_tcp_part (const struct rohc_comp_ctxt *context, const tcphdr_t *tcp, multi_ptr_t mptr)
 Build the static part of the TCP header.
static uint8_t * tcp_code_dynamic_tcp_part (const struct rohc_comp_ctxt *context, const unsigned char *next_header, multi_ptr_t mptr)
 Build the dynamic part of the TCP header.
static uint8_t * tcp_code_irregular_tcp_part (struct rohc_comp_ctxt *const context, tcphdr_t *tcp, uint8_t *const rohc_data, int ip_inner_ecn)
 Build the irregular part of the TCP header.
static int code_CO_packet (struct rohc_comp_ctxt *const context, const struct ip_packet *ip, const int packet_size, const unsigned char *next_header, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, const rohc_packet_t packet_type, size_t *const payload_offset)
 Build the CO packet.
static int co_baseheader (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, ip_context_ptr_t ip_context, base_header_ip_t base_header, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len,const rohc_packet_t packet_type, const tcphdr_t *const tcp, const uint8_t crc)
 Compress the innermost IP header AND the TCP header.
static size_t c_tcp_build_rnd_1 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_1_t *const rnd1)
 Build a TCP rnd_1 packet.
static size_t c_tcp_build_rnd_2 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_2_t *const rnd2)
 Build a TCP rnd_2 packet.
static size_t c_tcp_build_rnd_3 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_3_t *const rnd3)
 Build a TCP rnd_3 packet.
static size_t c_tcp_build_rnd_4 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_4_t *const rnd4)
 Build a TCP rnd_4 packet.
static size_t c_tcp_build_rnd_5 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_5_t *const rnd5)
 Build a TCP rnd_5 packet.
static size_t c_tcp_build_rnd_6 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_6_t *const rnd6)
 Build a TCP rnd_6 packet.
static size_t c_tcp_build_rnd_7 (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, const tcphdr_t *const tcp, const uint8_t crc, rnd_7_t *const rnd7)
 Build a TCP rnd_7 packet.
static bool c_tcp_build_rnd_8 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, rnd_8_t *const rnd8, size_t *const rnd8_len)
 Build a TCP rnd_8 packet.
static size_t c_tcp_build_seq_1 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_1_t *const seq1)
 Build a TCP seq_1 packet.
static size_t c_tcp_build_seq_2 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_2_t *const seq2)
 Build a TCP seq_2 packet.
static size_t c_tcp_build_seq_3 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_3_t *const seq3)
 Build a TCP seq_3 packet.
static size_t c_tcp_build_seq_4 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_4_t *const seq4)
 Build a TCP seq_4 packet.
static size_t c_tcp_build_seq_5 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_5_t *const seq5)
 Build a TCP seq_5 packet.
static size_t c_tcp_build_seq_6 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_6_t *const seq6)
 Build a TCP seq_6 packet.
static size_t c_tcp_build_seq_7 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_7_t *const seq7)
 Build a TCP seq_7 packet.
static bool c_tcp_build_seq_8 (struct rohc_comp_ctxt *const context, const ip_context_ptr_t ip_context, struct sc_tcp_context *const tcp_context, const base_header_ip_t ip, const tcphdr_t *const tcp, const uint8_t crc, seq_8_t *const seq8, size_t *const seq8_len)
 Build a TCP seq_8 packet.
static bool tcp_compress_tcp_options (struct rohc_comp_ctxt *const context, const tcphdr_t *const tcp, uint8_t *const comp_opts, size_t *const comp_opts_len)
 Compress the TCP options.
static bool c_ts_lsb (const struct rohc_comp_ctxt *const context, uint8_t **dest, const uint32_t timestamp, const size_t nr_bits_minus_1, const size_t nr_bits_0x40000)
 Compress the TimeStamp option value.
static uint8_t * c_tcp_opt_sack (const struct rohc_comp_ctxt *const context, uint8_t *ptr, uint32_t ack_value, uint8_t length, const sack_block_t *const sack_block)
 Compress the SACK TCP option.
static tcp_ip_id_behavior_t tcp_detect_ip_id_behavior (const uint16_t last_ip_id, const uint16_t new_ip_id)
 Detect the behavior of the IPv4 Identification field.
static void tcp_field_descr_change (const struct rohc_comp_ctxt *const context, const char *const name, const bool changed)
 Print a debug trace for the field change.
static void tcp_field_descr_present (const struct rohc_comp_ctxt *const context, const char *const name, const bool present)
 Print a debug trace for the field presence.
static char * tcp_ip_id_behavior_get_descr (const tcp_ip_id_behavior_t behavior)
 Get a string that describes the given IP-ID behavior.
static char * tcp_opt_get_descr (const uint8_t opt_type)
 Get a string that describes the given option type.
static uint8_t * c_sack_pure_lsb (const struct rohc_comp_ctxt *const context, uint8_t *ptr, uint32_t base, uint32_t field)
 Compress the SACK field value.
static uint8_t * c_sack_block (const struct rohc_comp_ctxt *const context, uint8_t *ptr, uint32_t reference, const sack_block_t *const sack_block)
 Compress a SACK block.
static uint8_t * c_tcp_opt_generic (struct sc_tcp_context *tcp_context, uint8_t *ptr, uint8_t *options)
 Compress a generic TCP option.

Variables

static int tcp_options_index [TCP_LIST_ITEM_MAP_LEN]
 Table of TCP option index, from option Id.
struct rohc_comp_profile c_tcp_profile
 Define the compression part of the TCP profile as described in the RFC 3095.

Detailed Description

ROHC compression context for the TCP profile.

Author:
FWX <rohc_team@dialine.fr>
Didier Barvaux <didier@barvaux.org>
Didier Barvaux <didier.barvaux@toulouse.viveris.com>

Define Documentation

#define MAX_IPV6_CONTEXT_OPTION_SIZE   (2 + ((MAX_IPV6_OPTION_LENGTH + 1) << 3))
#define MAX_IPV6_OPTION_LENGTH   6
#define MAX_TCP_OPT_SIZE   40U

The maximum size (in bytes) of one TCP option

#define TCP_LIST_ITEM_MAP_LEN   16U

The length of the table mapping for TCP options

#define TRACE_GOTO_CHOICE   rohc_comp_debug(context, "Compressed format choice LINE %d", __LINE__ )

Typedef Documentation

typedef struct ipv4_context ipv4_context_t

Define the IPv4 header context.

Define the IPv6 AH option context.

typedef struct ipv6_context ipv6_context_t

Define the IPv6 header context.

Define the IPv6 GRE option context.

Define the IPv6 MIME option context.

Define the IPv6 generic option context.

typedef struct ipvx_context ipvx_context_t

Define the common IP header context to IPv4 and IPv6.


Function Documentation

static uint8_t* c_sack_block ( const struct rohc_comp_ctxt *const  context,
uint8_t *  ptr,
uint32_t  reference,
const sack_block_t *const  sack_block 
) [static]

Compress a SACK block.

See RFC6846 page 68 (and RFC2018 for Selective Acknowledgement option)

Parameters:
contextThe compression context
ptrPointer to the compressed value
referenceThe reference value
sack_blockPointer to the SACK block to compress
Returns:
Pointer after the compressed value
static uint8_t* c_sack_pure_lsb ( const struct rohc_comp_ctxt *const  context,
uint8_t *  ptr,
uint32_t  base,
uint32_t  field 
) [static]

Compress the SACK field value.

See RFC6846 page 67 (and RFC2018 for Selective Acknowledgement option)

Parameters:
contextThe compression context
ptrPointer to the compressed value
baseThe base value
fieldThe value to compress
Returns:
Pointer after the compressed value
static size_t c_tcp_build_rnd_1 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_1_t *const  rnd1 
) [static]

Build a TCP rnd_1 packet.

Send LSBs of sequence number See RFC4996 page 81

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd1IN/OUT: The rnd_1 packet to build
Returns:
The length (in bytes) of the rnd_1 packet
static size_t c_tcp_build_rnd_2 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_2_t *const  rnd2 
) [static]

Build a TCP rnd_2 packet.

Send scaled sequence number LSBs See RFC4996 page 81

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd2IN/OUT: The rnd_2 packet to build
Returns:
The length (in bytes) of the rnd_2 packet
static size_t c_tcp_build_rnd_3 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_3_t *const  rnd3 
) [static]

Build a TCP rnd_3 packet.

Send acknowlegment number LSBs See RFC4996 page 81

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd3IN/OUT: The rnd_3 packet to build
Returns:
The length (in bytes) of the rnd_3 packet
static size_t c_tcp_build_rnd_4 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_4_t *const  rnd4 
) [static]

Build a TCP rnd_4 packet.

Send acknowlegment number scaled See RFC4996 page 81

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd4IN/OUT: The rnd_4 packet to build
Returns:
The length (in bytes) of the rnd_4 packet
static size_t c_tcp_build_rnd_5 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_5_t *const  rnd5 
) [static]

Build a TCP rnd_5 packet.

Send ACK and sequence number See RFC4996 page 82

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd5IN/OUT: The rnd_5 packet to build
Returns:
The length (in bytes) of the rnd_5 packet
static size_t c_tcp_build_rnd_6 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_6_t *const  rnd6 
) [static]

Build a TCP rnd_6 packet.

Send both ACK and scaled sequence number LSBs See RFC4996 page 82

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd6IN/OUT: The rnd_6 packet to build
Returns:
The length (in bytes) of the rnd_6 packet
static size_t c_tcp_build_rnd_7 ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_7_t *const  rnd7 
) [static]

Build a TCP rnd_7 packet.

Send ACK and window See RFC4996 page 82

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd7IN/OUT: The rnd_7 packet to build
Returns:
The length (in bytes) of the rnd_7 packet
static bool c_tcp_build_rnd_8 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
rnd_8_t *const  rnd8,
size_t *const  rnd8_len 
) [static]

Build a TCP rnd_8 packet.

Send LSBs of TTL, RSF flags, change ECN behavior and options list See RFC4996 page 82

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
rnd8IN/OUT: The rnd_8 packet to build
rnd8_lenOUT: The length (in bytes) of the rnd_8 packet
Returns:
true if the packet is successfully built, false otherwise
static size_t c_tcp_build_seq_1 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_1_t *const  seq1 
) [static]

Build a TCP seq_1 packet.

Send LSBs of sequence number See RFC4996 page 83

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq1IN/OUT: The seq_1 packet to build
Returns:
The length (in bytes) of the seq_1 packet
static size_t c_tcp_build_seq_2 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_2_t *const  seq2 
) [static]

Build a TCP seq_2 packet.

Send scaled sequence number LSBs See RFC4996 page 83

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq2IN/OUT: The seq_2 packet to build
Returns:
The length (in bytes) of the seq_2 packet
static size_t c_tcp_build_seq_3 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_3_t *const  seq3 
) [static]

Build a TCP seq_3 packet.

Send acknowledgment number LSBs See RFC4996 page 83

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq3IN/OUT: The seq_3 packet to build
Returns:
The length (in bytes) of the seq_3 packet
static size_t c_tcp_build_seq_4 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_4_t *const  seq4 
) [static]

Build a TCP seq_4 packet.

Send scaled acknowledgment number scaled See RFC4996 page 84

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq4IN/OUT: The seq_4 packet to build
Returns:
The length (in bytes) of the seq_4 packet
static size_t c_tcp_build_seq_5 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_5_t *const  seq5 
) [static]

Build a TCP seq_5 packet.

Send ACK and sequence number See RFC4996 page 84

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq5IN/OUT: The seq_5 packet to build
Returns:
The length (in bytes) of the seq_5 packet
static size_t c_tcp_build_seq_6 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_6_t *const  seq6 
) [static]

Build a TCP seq_6 packet.

See RFC4996 page 84

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq6IN/OUT: The seq_6 packet to build
Returns:
The length (in bytes) of the seq_6 packet
static size_t c_tcp_build_seq_7 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_7_t *const  seq7 
) [static]

Build a TCP seq_7 packet.

Send ACK and window See RFC4996 page 85

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq7IN/OUT: The seq_7 packet to build
Returns:
The length (in bytes) of the seq_7 packet
static bool c_tcp_build_seq_8 ( struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t  ip_context,
struct sc_tcp_context *const  tcp_context,
const base_header_ip_t  ip,
const tcphdr_t *const  tcp,
const uint8_t  crc,
seq_8_t *const  seq8,
size_t *const  seq8_len 
) [static]

Build a TCP seq_8 packet.

Send LSBs of TTL, RSF flags, change ECN behavior, and options list See RFC4996 page 85

Parameters:
contextThe compression context
ip_contextThe specific IP innermost context
tcp_contextThe specific TCP context
ipThe IPv4 or IPv6 header to compress
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
seq8IN/OUT: The seq_8 packet to build
seq8_lenOUT: The length (in bytes) of the seq_8 packet
Returns:
true if the packet is successfully built, false otherwise
static bool c_tcp_check_context ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
) [static]

Check if the IP/TCP packet belongs to the context.

Conditions are:

  • the number of IP headers must be the same as in context
  • IP version of the two IP headers must be the same as in context
  • IP packets must not be fragmented
  • the source and destination addresses of the two IP headers must match the ones in the context
  • the transport protocol must be TCP
  • the source and destination ports of the TCP header must match the ones in the context
  • IPv6 only: the Flow Label of the two IP headers must match the ones the context

This function is one of the functions that must exist in one profile for the framework to work.

Parameters:
contextThe compression context
packetThe IP/TCP packet to check
Returns:
true if the IP/TCP packet belongs to the context false if it does not belong to the context
static bool c_tcp_check_profile ( const struct rohc_comp *const  comp,
const struct net_pkt *const  packet 
) [static]

Check if the given packet corresponds to the TCP profile.

Conditions are:

  • the transport protocol is TCP
  • the version of the outer IP header is 4 or 6
  • the outer IP header is not an IP fragment
  • if there are at least 2 IP headers, the version of the inner IP header is 4 or 6
  • if there are at least 2 IP headers, the inner IP header is not an IP fragment
See also:
c_generic_check_profile

This function is one of the functions that must exist in one profile for the framework to work.

Parameters:
compThe ROHC compressor
packetThe packet to check
Returns:
Whether the IP packet corresponds to the profile:
  • true if the IP packet corresponds to the profile,
  • false if the IP packet does not correspond to the profile
static bool c_tcp_create ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
) [static]

Create a new TCP context and initialize it thanks to the given IP/TCP packet.

This function is one of the functions that must exist in one profile for the framework to work.

Parameters:
contextThe compression context
packetThe IP/TCP packet given to initialize the new context
Returns:
true if successful, false otherwise
static void c_tcp_destroy ( struct rohc_comp_ctxt *const  context) [static]

Destroy the TCP context.

Parameters:
contextThe TCP compression context to destroy
static int c_tcp_encode ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type,
size_t *const  payload_offset 
) [static]

Encode an IP/TCP packet according to a pattern decided by several different factors.

1. Check if we have double IP headers.
2. Check if the IP-ID fields are random and if they are in NBO.
3. Decide in which state to go (IR, FO or SO).
4. Decide how many bits are needed to send the IP-ID and SN fields and more important update the sliding windows.
5. Decide which packet type to send.
6. Code the packet.

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeOUT: The type of ROHC packet that is created
payload_offsetOUT: The offset for the payload in the IP packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
static uint8_t* c_tcp_opt_generic ( struct sc_tcp_context tcp_context,
uint8_t *  ptr,
uint8_t *  options 
) [static]

Compress a generic TCP option.

See RFC4996 page 67

Parameters:
tcp_contextThe specific TCP context
ptrPointer where to compress the option
optionsPointer to the TCP option to compress
Returns:
Pointer after the compressed value
static uint8_t * c_tcp_opt_sack ( const struct rohc_comp_ctxt *const  context,
uint8_t *  ptr,
uint32_t  ack_value,
uint8_t  length,
const sack_block_t *const  sack_block 
) [static]

Compress the SACK TCP option.

See RFC6846 page 68 (and RFC2018 for Selective Acknowledgement option)

Parameters:
contextThe compression context
ptrPointer to the compressed value
ack_valueThe ack value
lengthThe length of the sack block
sack_blockPointer to the first SACK block to compress
Returns:
Pointer after the compressed value
static bool c_ts_lsb ( const struct rohc_comp_ctxt *const  context,
uint8_t **  dest,
const uint32_t  timestamp,
const size_t  nr_bits_minus_1,
const size_t  nr_bits_0x40000 
) [static]

Compress the TimeStamp option value.

See RFC4996 page 65

Parameters:
contextThe compression context
[out]destPointer to the compressed value
timestampThe timestamp value to compress
nr_bits_minus_1The minimal number of required bits for p = -1
nr_bits_0x40000The minimal number of required bits for p = 0x40000
Returns:
true if compression was successful, false otherwise
static int co_baseheader ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
ip_context_ptr_t  ip_context,
base_header_ip_t  base_header,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const rohc_packet_t  packet_type,
const tcphdr_t *const  tcp,
const uint8_t  crc 
) [static]

Compress the innermost IP header AND the TCP header.

See RFC4996 page 77

Parameters:
contextThe compression context
tcp_contextThe specific TCP context
ip_contextThe specific IP innermost context
base_headerThe innermost IP header
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeOUT: The type of ROHC packet that is created
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
Returns:
The position in the rohc-packet-under-build buffer -1 in case of problem
static int code_CO_packet ( struct rohc_comp_ctxt *const  context,
const struct ip_packet ip,
const int  packet_size,
const unsigned char *  next_header,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const rohc_packet_t  packet_type,
size_t *const  payload_offset 
) [static]

Build the CO packet.

See RFC4996 page 46


 CO packet (RFC4996 ยง7.3 page 41):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :  if for small CIDs and CID != 0
    +---+---+---+---+---+---+---+---+
 2  |   First octet of base header  |  (with type indication)
    +---+---+---+---+---+---+---+---+
    |                               |
 3  /    0-2 octets of CID info     /  1-2 octets if for large CIDs
    |                               |
    +---+---+---+---+---+---+---+---+
 4  /   Remainder of base header    /  variable number of octets
    +---+---+---+---+---+---+---+---+
    :        Irregular chain        :
 5  /   (including irregular chain  /  variable
    :    items for TCP options)     :
    +---+---+---+---+---+---+---+---+
    |                               |
 6  /           Payload             /  variable length
    |                               |
     - - - - - - - - - - - - - - - -

Parameters:
contextThe compression context
ipThe outer IP header
packet_sizeThe length of the uncompressed packet (in bytes)
next_headerThe next header data used to code the static and dynamic parts of the next header for some profiles such as UDP, UDP-Lite, and so on.
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe type of ROHC packet to create
payload_offsetOUT: The offset for the payload in the IP packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
static uint8_t * tcp_code_dynamic_ip_part ( const struct rohc_comp_ctxt context,
ip_context_ptr_t  ip_context,
base_header_ip_t  base_header,
multi_ptr_t  mptr,
int  is_innermost 
) [static]

Build the dynamic part of the IP header.

Parameters:
contextThe compression context
ip_contextThe specific IP compression context
base_headerThe IP header
mptrThe current pointer in the rohc-packet-under-build buffer
is_innermostTrue if the IP header is the innermost of the packet
Returns:
The new pointer in the rohc-packet-under-build buffer
static uint8_t * tcp_code_dynamic_ipv6_option_part ( struct rohc_comp_ctxt *const  context,
ip_context_ptr_t  ip_context,
multi_ptr_t  mptr,
uint8_t  protocol,
base_header_ip_t  base_header 
) [static]

Build the dynamic part of the IPv6 option header.

Parameters:
contextThe compression context
ip_contextThe specific IP compression context
mptrThe current pointer in the rohc-packet-under-build buffer
protocolThe IPv6 protocol option
base_headerThe IP header
Returns:
The new pointer in the rohc-packet-under-build buffer, NULL if a problem occurs
static uint8_t * tcp_code_dynamic_tcp_part ( const struct rohc_comp_ctxt context,
const unsigned char *  next_header,
multi_ptr_t  mptr 
) [static]

Build the dynamic part of the TCP header.


 Dynamic part of TCP header:

TODO
 
Parameters:
contextThe compression context
next_headerThe TCP header
mptrThe current pointer in the rohc-packet-under-build buffer
Returns:
The new pointer in the rohc-packet-under-build buffer
static uint8_t * tcp_code_irregular_ip_part ( struct rohc_comp_ctxt *const  context,
ip_context_ptr_t  ip_context,
base_header_ip_t  base_header,
uint8_t *  rohc_data,
int  ecn_used,
int  is_innermost,
int  ttl_irregular_chain_flag,
int  ip_inner_ecn 
) [static]

Build the irregular part of the IP header.

See Rfc4996 page 63

Parameters:
contextThe compression context
ip_contextThe specific IP compression context
base_headerThe IP header
rohc_dataThe current pointer in the rohc-packet-under-build buffer
ecn_usedThe indicator of ECN usage
is_innermostTrue if IP header is the innermost of the packet
ttl_irregular_chain_flagWhether he TTL/Hop Limit of an outer header changed
ip_inner_ecnThe ECN flags of the IP innermost header
Returns:
The new pointer in the rohc-packet-under-build buffer
static uint8_t * tcp_code_irregular_ipv6_option_part ( struct rohc_comp_ctxt *const  context,
ip_context_ptr_t  ip_context,
multi_ptr_t  mptr,
uint8_t  protocol,
base_header_ip_t  base_header 
) [static]

Build the irregular part of the IPv6 option header.

Parameters:
contextThe compression context
ip_contextThe specific IP compression context
mptrThe current pointer in the rohc-packet-under-build buffer
protocolThe IPv6 protocol option
base_headerThe IP header
Returns:
The new pointer in the rohc-packet-under-build buffer, NULL if a problem occurs
static uint8_t * tcp_code_irregular_tcp_part ( struct rohc_comp_ctxt *const  context,
tcphdr_t tcp,
uint8_t *const  rohc_data,
int  ip_inner_ecn 
) [static]

Build the irregular part of the TCP header.

Parameters:
contextThe compression context
tcpThe TCP header
rohc_dataThe current pointer in the rohc-packet-under-build buffer
ip_inner_ecnThe ecn flags of the ip inner
Returns:
The new pointer in the rohc-packet-under-build buffer, NULL in case of problem
static uint8_t * tcp_code_static_ip_part ( struct rohc_comp_ctxt *const  context,
base_header_ip_t  base_header,
multi_ptr_t  mptr 
) [static]

Build the static part of the IP header.

Parameters:
contextThe compression context
base_headerThe IP header
mptrThe current pointer in the rohc-packet-under-build buffer
Returns:
The new pointer in the rohc-packet-under-build buffer
static uint8_t * tcp_code_static_ipv6_option_part ( struct rohc_comp_ctxt *const  context,
multi_ptr_t  mptr,
uint8_t  protocol,
base_header_ip_t  base_header 
) [static]

Build the static part of the IPv6 option header.

Parameters:
contextThe compression context
mptrThe current pointer in the rohc-packet-under-build buffer
protocolThe IPv6 protocol option
base_headerThe IP header
Returns:
The new pointer in the rohc-packet-under-build buffer, NULL if a problem occurs
static uint8_t * tcp_code_static_tcp_part ( const struct rohc_comp_ctxt context,
const tcphdr_t tcp,
multi_ptr_t  mptr 
) [static]

Build the static part of the TCP header.


 Static part of TCP header:

    +---+---+---+---+---+---+---+---+
 1  /  Source port                  /   2 octets
    +---+---+---+---+---+---+---+---+
 2  /  Destination port             /   2 octets
    +---+---+---+---+---+---+---+---+

Parameters:
contextThe compression context
tcpThe TCP header
mptrThe current pointer in the rohc-packet-under-build buffer
Returns:
The new pointer in the rohc-packet-under-build buffer
static bool tcp_compress_tcp_options ( struct rohc_comp_ctxt *const  context,
const tcphdr_t *const  tcp,
uint8_t *const  comp_opts,
size_t *const  comp_opts_len 
) [static]

Compress the TCP options.

Parameters:
contextThe compression context
tcpThe TCP header
comp_optsIN/OUT: The compressed TCP options
comp_opts_lenOUT: The length (in bytes) of the compressed TCP options
Returns:
true if the TCP options were successfully compressed, false otherwise
static rohc_packet_t tcp_decide_packet ( const struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t *const  ip_inner_context,
const tcphdr_t *const  tcp 
) [static]

Decide which packet to send when in the different states.

Parameters:
contextThe compression context
ip_inner_contextThe context of the inner IP header
tcpThe TCP header to compress
Returns:
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_IR_DYN, ROHC_PACKET_TCP_RND_[1-8], ROHC_PACKET_TCP_SEQ_[1-8] and ROHC_PACKET_TCP_CO_COMMON in case of success
  • ROHC_PACKET_UNKNOWN in case of failure
static rohc_packet_t tcp_decide_SO_packet ( const struct rohc_comp_ctxt *const  context,
const ip_context_ptr_t *const  ip_inner_context,
const tcphdr_t *const  tcp 
) [static]

Decide which packet to send when in SO state.

Parameters:
contextThe compression context
ip_inner_contextThe context of the inner IP header
tcpThe TCP header to compress
Returns:
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_IR_DYN, ROHC_PACKET_TCP_RND_[1-8], ROHC_PACKET_TCP_SEQ_[1-8] and ROHC_PACKET_TCP_CO_COMMON in case of success
  • ROHC_PACKET_UNKNOWN in case of failure
static void tcp_decide_state ( struct rohc_comp_ctxt *const  context) [static]

Decide the state that should be used for the next packet.

The three states are:

  • Initialization and Refresh (IR),
  • First Order (FO),
  • Second Order (SO).
Parameters:
contextThe compression context
static bool tcp_detect_changes ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Detect changes between packet and context.

Parameters:
contextThe compression context to compare
uncomp_pktThe uncompressed packet to compare
Returns:
true if changes were successfully detected, false if a problem occurred
static tcp_ip_id_behavior_t tcp_detect_ip_id_behavior ( const uint16_t  last_ip_id,
const uint16_t  new_ip_id 
) [static]

Detect the behavior of the IPv4 Identification field.

Parameters:
last_ip_idThe IP-ID value of the previous packet (in HBO)
new_ip_idThe IP-ID value of the current packet (in HBO)
Returns:
The IP-ID behavior among: IP_ID_BEHAVIOR_SEQ, IP_ID_BEHAVIOR_SEQ_SWAP, IP_ID_BEHAVIOR_ZERO, or IP_ID_BEHAVIOR_RAND
static bool tcp_encode_uncomp_fields ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Encode uncompressed fields with the corresponding encoding scheme.

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet to encode
Returns:
true in case of success, false otherwise
static void tcp_field_descr_change ( const struct rohc_comp_ctxt *const  context,
const char *const  name,
const bool  changed 
) [static]

Print a debug trace for the field change.

Parameters:
contextThe compression context
nameThe name of the field
changedWhether the field changed or not
static void tcp_field_descr_present ( const struct rohc_comp_ctxt *const  context,
const char *const  name,
const bool  present 
) [static]

Print a debug trace for the field presence.

Parameters:
contextThe compression context
nameThe name of the field
presentWhether the field is present or not
static char * tcp_ip_id_behavior_get_descr ( const tcp_ip_id_behavior_t  behavior) [static]

Get a string that describes the given IP-ID behavior.

Parameters:
behaviorThe type of the option to get a description for
Returns:
The description of the option
static char * tcp_opt_get_descr ( const uint8_t  opt_type) [static]

Get a string that describes the given option type.

Parameters:
opt_typeThe type of the option to get a description for
Returns:
The description of the option

Variable Documentation

Initial value:
{
        .id             = ROHC_PROFILE_TCP, 
        .protocol       = ROHC_IPPROTO_TCP, 
        .create         = c_tcp_create,     
        .destroy        = c_tcp_destroy,
        .check_profile  = c_tcp_check_profile,
        .check_context  = c_tcp_check_context,
        .encode         = c_tcp_encode,
        .reinit_context = c_generic_reinit_context,
        .feedback       = c_generic_feedback,
        .use_udp_port   = c_generic_use_udp_port,
}

Define the compression part of the TCP profile as described in the RFC 3095.

Initial value:

Table of TCP option index, from option Id.

See RFC4996 6.3.4 Return item index of TCP option