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

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

#include "rohc_comp_internals.h"
#include "rohc_traces_internal.h"
#include "rohc_utils.h"
#include "rohc_packets.h"
#include "net_pkt.h"
#include "protocols/ip_numbers.h"
#include "protocols/ip.h"
#include "protocols/ipv4.h"
#include "protocols/ipv6.h"
#include "protocols/tcp.h"
#include "schemes/cid.h"
#include "schemes/ip_id_offset.h"
#include "schemes/rfc4996.h"
#include "c_tcp_opts_list.h"
#include "sdvl.h"
#include "crc.h"
#include "rohc_bit_ops.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_generic_option_context
 Define the IPv6 generic 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  ip_option_context_t
 
struct  ipv6_context
 Define the IPv6 header context. More...
 
struct  ip_context_t
 Define union of IP contexts. More...
 
struct  sc_tcp_context
 

Macros

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

Typedefs

typedef struct ipv6_generic_option_context ipv6_generic_option_context_t
 Define the IPv6 generic option context. More...
 
typedef struct ipvx_context ipvx_context_t
 Define the common IP header context to IPv4 and IPv6. More...
 
typedef struct ipv4_context ipv4_context_t
 Define the IPv4 header context. More...
 
typedef struct ipv6_context ipv6_context_t
 Define the IPv6 header context. More...
 

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. More...
 
static void c_tcp_destroy (struct rohc_comp_ctxt *const context)
 Destroy the TCP context. More...
 
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. More...
 
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. More...
 
static int c_tcp_encode (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, uint8_t *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. More...
 
static uint16_t c_tcp_get_next_msn (const struct rohc_comp_ctxt *const context)
 Determine the MSN value for the next packet. More...
 
static bool rohc_comp_tcp_are_ipv6_exts_acceptable (const struct rohc_comp *const comp, uint8_t *const next_proto, const uint8_t *const exts, const size_t max_exts_len, size_t *const exts_len)
 Whether IPv6 extension headers are acceptable for TCP profile or not. More...
 
static bool tcp_detect_changes (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, ip_context_t **const ip_inner_ctxt, const struct tcphdr **const tcp)
 Detect changes between packet and context. More...
 
static bool tcp_detect_changes_ipv6_exts (struct rohc_comp_ctxt *const context, ip_context_t *const ip_context, uint8_t *const protocol, const uint8_t *const exts, const size_t max_exts_len, size_t *const exts_nr, size_t *const exts_len)
 Detect changes about IPv6 extension headers between packet and context. More...
 
static void tcp_decide_state (struct rohc_comp_ctxt *const context)
 Decide the state that should be used for the next packet. More...
 
static bool tcp_encode_uncomp_fields (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, const struct tcphdr *const tcp)
 Encode uncompressed fields with the corresponding encoding scheme. More...
 
static bool tcp_encode_uncomp_ip_fields (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Encode uncompressed IP fields with the corresponding encoding scheme. More...
 
static bool tcp_encode_uncomp_tcp_fields (struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp)
 Encode uncompressed TCP fields with the corresponding encoding scheme. More...
 
static rohc_packet_t tcp_decide_packet (struct rohc_comp_ctxt *const context, const ip_context_t *const ip_inner_context, const struct tcphdr *const tcp)
 Decide which packet to send when in the different states. More...
 
static rohc_packet_t tcp_decide_FO_packet (const struct rohc_comp_ctxt *const context, const ip_context_t *const ip_inner_context, const struct tcphdr *const tcp)
 Decide which packet to send when in FO state. More...
 
static rohc_packet_t tcp_decide_SO_packet (const struct rohc_comp_ctxt *const context, const ip_context_t *const ip_inner_context, const struct tcphdr *const tcp)
 Decide which packet to send when in SO state. More...
 
static rohc_packet_t tcp_decide_FO_SO_packet (const struct rohc_comp_ctxt *const context, const ip_context_t *const ip_inner_context, const struct tcphdr *const tcp, const bool crc7_at_least)
 Decide which packet to send when in FO or SO state. More...
 
static rohc_packet_t tcp_decide_FO_SO_packet_seq (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const bool crc7_at_least)
 Decide which seq packet to send when in FO or SO state. More...
 
static rohc_packet_t tcp_decide_FO_SO_packet_rnd (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const bool crc7_at_least)
 Decide which rnd packet to send when in FO or SO state. More...
 
static int tcp_code_static_part (struct rohc_comp_ctxt *const context, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Code the static part of an IR packet. More...
 
static int tcp_code_static_ipv4_part (const struct rohc_comp_ctxt *const context, const struct ipv4_hdr *const ipv4, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the IPv4 header. More...
 
static int tcp_code_static_ipv6_part (const struct rohc_comp_ctxt *const context, const struct ipv6_hdr *const ipv6, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the IPv6 header. More...
 
static int tcp_code_static_ipv6_opt_part (const struct rohc_comp_ctxt *const context, const struct ipv6_opt *const ipv6_opt, const uint8_t protocol, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the IPv6 option header. More...
 
static int tcp_code_static_tcp_part (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the TCP header. More...
 
static int tcp_code_dyn_part (struct rohc_comp_ctxt *const context, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, size_t *const parsed_len)
 Code the dynamic part of an IR or IR-DYN packet. More...
 
static int tcp_code_dynamic_ipv4_part (const struct rohc_comp_ctxt *const context, ip_context_t *const ip_context, const struct ipv4_hdr *const ipv4, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the IPv4 header. More...
 
static int tcp_code_dynamic_ipv6_part (const struct rohc_comp_ctxt *const context, ip_context_t *const ip_context, const struct ipv6_hdr *const ipv6, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the IPv6 header. More...
 
static int tcp_code_dynamic_ipv6_opt_part (const struct rohc_comp_ctxt *const context, const struct ipv6_opt *const ipv6_opt, const uint8_t protocol, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the IPv6 option header. More...
 
static int tcp_code_dynamic_tcp_part (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the TCP header. More...
 
static int tcp_code_irreg_chain (struct rohc_comp_ctxt *const context, const struct ip_packet *const ip, const uint8_t ip_inner_ecn, const struct tcphdr *const tcp, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Code the irregular chain of one CO packet. More...
 
static int tcp_code_irregular_ipv4_part (const struct rohc_comp_ctxt *const context, const ip_context_t *const ip_context, const struct ipv4_hdr *const ipv4, const bool is_innermost, const bool ecn_used, const uint8_t ip_inner_ecn, const bool ttl_irreg_chain_flag, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the IPv4 header. More...
 
static int tcp_code_irregular_ipv6_part (const struct rohc_comp_ctxt *const context, const ip_context_t *const ip_context, const struct ipv6_hdr *const ipv6, const bool is_innermost, const bool ecn_used, const uint8_t ip_inner_ecn, const bool ttl_irreg_chain_flag, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the IPv6 header. More...
 
static int tcp_code_irregular_ipv6_opt_part (struct rohc_comp_ctxt *const context, ip_option_context_t *const opt_ctxt, const struct ipv6_opt *const ipv6_opt, const uint8_t protocol, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the IPv6 option header. More...
 
static int tcp_code_irregular_tcp_part (const struct rohc_comp_ctxt *const context, const struct tcphdr *const tcp, const uint8_t ip_inner_ecn, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the TCP header. More...
 
static int code_IR_packet (struct rohc_comp_ctxt *const context, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const rohc_packet_t packet_type, size_t *const payload_offset)
 Encode an IP/TCP packet as IR or IR-DYN packet. More...
 
static int code_CO_packet (struct rohc_comp_ctxt *const context, const struct ip_packet *ip, uint8_t *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. More...
 
static int co_baseheader (struct rohc_comp_ctxt *const context, struct sc_tcp_context *const tcp_context, ip_context_t *const inner_ip_ctxt, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const rohc_packet_t packet_type, const struct tcphdr *const tcp, const uint8_t crc)
 Compress the innermost IP header AND the TCP header. More...
 
static int c_tcp_build_rnd_1 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_1 packet. More...
 
static int c_tcp_build_rnd_2 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_2 packet. More...
 
static int c_tcp_build_rnd_3 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_3 packet. More...
 
static int c_tcp_build_rnd_4 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_4 packet. More...
 
static int c_tcp_build_rnd_5 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_5 packet. More...
 
static int c_tcp_build_rnd_6 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_6 packet. More...
 
static int c_tcp_build_rnd_7 (const struct rohc_comp_ctxt *const context, const struct sc_tcp_context *const tcp_context, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_7 packet. More...
 
static int c_tcp_build_rnd_8 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP rnd_8 packet. More...
 
static int c_tcp_build_seq_1 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_1 packet. More...
 
static int c_tcp_build_seq_2 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_2 packet. More...
 
static int c_tcp_build_seq_3 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_3 packet. More...
 
static int c_tcp_build_seq_4 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_4 packet. More...
 
static int c_tcp_build_seq_5 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_5 packet. More...
 
static int c_tcp_build_seq_6 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_6 packet. More...
 
static int c_tcp_build_seq_7 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, const struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_7 packet. More...
 
static int c_tcp_build_seq_8 (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP seq_8 packet. More...
 
static int c_tcp_build_co_common (const struct rohc_comp_ctxt *const context, const ip_context_t *const inner_ip_ctxt, struct sc_tcp_context *const tcp_context, const struct ip_hdr *const inner_ip_hdr, const size_t inner_ip_hdr_len, const struct tcphdr *const tcp, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a TCP co_common packet. More...
 
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. More...
 
static void tcp_detect_ecn_used_behavior (struct rohc_comp_ctxt *const context, const uint8_t pkt_ecn_vals, const uint8_t pkt_outer_dscp_changed, const uint8_t pkt_res_val)
 Detect the behavior of the IP/TCP ECN flags and TCP RES flags. More...
 
static void tcp_field_descr_change (const struct rohc_comp_ctxt *const context, const char *const name, const bool changed, const size_t nr_trans)
 Print a debug trace for the field change. More...
 
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. More...
 
static bool tcp_is_ack_scaled_possible (const uint16_t ack_stride, const size_t nr_trans)
 Whether the ACK number may be transmitted scaled or not. More...
 
static bool tcp_is_ack_stride_static (const uint16_t ack_stride, const size_t nr_trans)
 Whether the ack_stride scaling factor shall be transmitted or not. More...
 
static bool c_tcp_feedback (struct rohc_comp_ctxt *const context, const enum rohc_feedback_type feedback_type, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
 Update the profile when feedback is received. More...
 
static bool c_tcp_feedback_2 (struct rohc_comp_ctxt *const context, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
 Update the profile when FEEDBACK-2 is received. More...
 
static void c_tcp_feedback_ack (struct rohc_comp_ctxt *const context, const uint32_t sn_bits, const size_t sn_bits_nr, const bool sn_not_valid)
 Perform the required actions after the reception of a positive ACK. More...
 

Variables

const struct rohc_comp_profile c_tcp_profile
 Define the compression part of the TCP profile as described in the RFC 3095. More...
 

Detailed Description

ROHC compression context for the TCP profile.

Author
FWX rohc_.nosp@m.team.nosp@m.@dial.nosp@m.ine..nosp@m.fr
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org
Didier Barvaux didie.nosp@m.r.ba.nosp@m.rvaux.nosp@m.@tou.nosp@m.louse.nosp@m..viv.nosp@m.eris..nosp@m.com

Macro Definition Documentation

#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.

typedef struct ipv6_context ipv6_context_t

Define the IPv6 header 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 int c_tcp_build_co_common ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP co_common packet.

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP text
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
true if the packet is successfully built, false otherwise
static int c_tcp_build_rnd_1 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_2 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_3 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_4 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_5 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_6 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_7 ( const struct rohc_comp_ctxt *const  context,
const struct sc_tcp_context *const  tcp_context,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_rnd_8 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_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
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_1 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_1 packet.

Send LSBs of sequence number See RFC4996 page 83

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_2 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_2 packet.

Send scaled sequence number LSBs See RFC4996 page 83

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_3 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_3 packet.

Send acknowledgment number LSBs See RFC4996 page 83

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_4 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_4 packet.

Send scaled acknowledgment number scaled See RFC4996 page 84

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_5 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_5 packet.

Send ACK and sequence number See RFC4996 page 84

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_6 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_6 packet.

See RFC4996 page 84

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_7 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
const struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a TCP seq_7 packet.

Send ACK and window See RFC4996 page 85

Parameters
contextThe compression context
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int c_tcp_build_seq_8 ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  inner_ip_ctxt,
struct sc_tcp_context *const  tcp_context,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
const struct tcphdr *const  tcp,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_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
inner_ip_ctxtThe specific IP innermost context
tcp_contextThe specific TCP context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the innermost IP header
tcpThe TCP header to compress
crcThe CRC on the uncompressed headers
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
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
Todo:
TODO: the code that parses IP headers in IP/UDP/RTP profiles could probably be re-used (and maybe enhanced if needed)
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

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
Todo:
TODO: the code that parses IP headers in IP/UDP/RTP profiles could probably be re-used (and maybe enhanced if needed)
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,
uint8_t *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
    Todo:
    TODO: the code that parses IP headers in IP/UDP/RTP profiles could probably be re-used (and maybe enhanced if needed)
static bool c_tcp_feedback ( struct rohc_comp_ctxt *const  context,
const enum rohc_feedback_type  feedback_type,
const uint8_t *const  packet,
const size_t  packet_len,
const uint8_t *const  feedback_data,
const size_t  feedback_data_len 
)
static

Update the profile when feedback is received.

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

Parameters
contextThe compression context
feedback_typeThe feedback type
packetThe whole feedback packet with CID bits
packet_lenThe length of the whole feedback packet with CID bits
feedback_dataThe feedback data without the CID bits
feedback_data_lenThe length of the feedback data without the CID bits
Returns
true if the feedback was successfully handled, false if the feedback could not be taken into account
static bool c_tcp_feedback_2 ( struct rohc_comp_ctxt *const  context,
const uint8_t *const  packet,
const size_t  packet_len,
const uint8_t *const  feedback_data,
const size_t  feedback_data_len 
)
static

Update the profile when FEEDBACK-2 is received.

Parameters
contextThe compression context
packetThe whole feedback packet with CID bits
packet_lenThe length of the whole feedback packet with CID bits
feedback_dataThe feedback data without the CID bits
feedback_data_lenThe length of the feedback data without the CID bits
Returns
true if the feedback was successfully handled, false if the feedback could not be taken into account
static void c_tcp_feedback_ack ( struct rohc_comp_ctxt *const  context,
const uint32_t  sn_bits,
const size_t  sn_bits_nr,
const bool  sn_not_valid 
)
static

Perform the required actions after the reception of a positive ACK.

Parameters
contextThe compression context that received a positive ACK
sn_bitsThe LSB bits of the acknowledged SN
sn_bits_nrThe number of LSB bits of the acknowledged SN
sn_not_validWhether the received SN may be considered as valid or not
static uint16_t c_tcp_get_next_msn ( const struct rohc_comp_ctxt *const  context)
static

Determine the MSN value for the next packet.

Profile MSN is an internal increasing 16-bit number. See RFC 6846, §6.1.1.

Parameters
contextThe compression context
Returns
The MSN value for the next ROHC packet
static int co_baseheader ( struct rohc_comp_ctxt *const  context,
struct sc_tcp_context *const  tcp_context,
ip_context_t *const  inner_ip_ctxt,
const struct ip_hdr *const  inner_ip_hdr,
const size_t  inner_ip_hdr_len,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const rohc_packet_t  packet_type,
const struct tcphdr *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
inner_ip_ctxtThe specific IP innermost context
inner_ip_hdrThe innermost IP header
inner_ip_hdr_lenThe length of the 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,
uint8_t *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
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 int code_IR_packet ( struct rohc_comp_ctxt *const  context,
const struct ip_packet *const  ip,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const rohc_packet_t  packet_type,
size_t *const  payload_offset 
)
static

Encode an IP/TCP packet as IR or IR-DYN packet.

Parameters
contextThe compression context
ipThe outer IP header
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe 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 bool rohc_comp_tcp_are_ipv6_exts_acceptable ( const struct rohc_comp *const  comp,
uint8_t *const  next_proto,
const uint8_t *const  exts,
const size_t  max_exts_len,
size_t *const  exts_len 
)
static

Whether IPv6 extension headers are acceptable for TCP profile or not.

TCP options are acceptable if:

  • the last IPv6 extension header is not truncated,
  • no more than ROHC_TCP_MAX_IP_EXT_HDRS extension headers are present,
  • each extension header is present only once (except Destination that may occur twice).
Parameters
compThe ROHC compressor
[in,out]next_protoin: the protocol type of the first extension header out: the protocol type of the transport header
extsThe beginning of the IPv6 extension headers
max_exts_lenThe maximum length (in bytes) of the extension headers
[out]exts_lenThe length (in bytes) of the IPv6 extension headers
Returns
true if the IPv6 extension headers are acceptable, false if they are not
See also
ROHC_TCP_MAX_IP_EXT_HDRS
static int tcp_code_dyn_part ( struct rohc_comp_ctxt *const  context,
const struct ip_packet *const  ip,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
size_t *const  parsed_len 
)
static

Code the dynamic part of an IR or IR-DYN packet.

Parameters
contextThe compression context
ipThe outer IP header
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
[out]parsed_lenThe length of uncompressed data parsed
Returns
The length of the ROHC packet if successful, -1 otherwise
static int tcp_code_dynamic_ipv4_part ( const struct rohc_comp_ctxt *const  context,
ip_context_t *const  ip_context,
const struct ipv4_hdr *const  ipv4,
const bool  is_innermost,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the IPv4 header.

Parameters
contextThe compression context
ip_contextThe specific IP compression context
ipv4The IPv4 header
is_innermosttrue if the IP header is the innermost of the packet, false otherwise
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_dynamic_ipv6_opt_part ( const struct rohc_comp_ctxt *const  context,
const struct ipv6_opt *const  ipv6_opt,
const uint8_t  protocol,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the IPv6 option header.

Parameters
contextThe compression context
ipv6_optThe IPv6 extension header
protocolThe protocol of the IPv6 extension header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_dynamic_ipv6_part ( const struct rohc_comp_ctxt *const  context,
ip_context_t *const  ip_context,
const struct ipv6_hdr *const  ipv6,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the IPv6 header.

Parameters
contextThe compression context
ip_contextThe specific IP compression context
ipv6The IPv6 header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_dynamic_tcp_part ( const struct rohc_comp_ctxt *const  context,
const struct tcphdr *const  tcp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the TCP header.

 Dynamic part of TCP header:

TODO
Parameters
contextThe compression context
tcpThe TCP header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_irreg_chain ( struct rohc_comp_ctxt *const  context,
const struct ip_packet *const  ip,
const uint8_t  ip_inner_ecn,
const struct tcphdr *const  tcp,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Code the irregular chain of one CO packet.

Parameters
contextThe compression context
ipThe outer IP header
ip_inner_ecnThe ECN flags of the innermost IP header
tcpThe uncompressed TCP header
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns
The length of the ROHC packet if successful, -1 otherwise
static int tcp_code_irregular_ipv4_part ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  ip_context,
const struct ipv4_hdr *const  ipv4,
const bool  is_innermost,
const bool  ecn_used,
const uint8_t  ip_inner_ecn,
const bool  ttl_irreg_chain_flag,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the IPv4 header.

See RFC 4996 page 63

Parameters
contextThe compression context
ip_contextThe specific IP compression context
ipv4The IPv4 header
is_innermostTrue if IP header is the innermost of the packet
ecn_usedThe indicator of ECN usage
ip_inner_ecnThe ECN flags of the IP innermost header
ttl_irreg_chain_flagWhether the TTL of an outer header changed
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_irregular_ipv6_opt_part ( struct rohc_comp_ctxt *const  context,
ip_option_context_t *const  opt_ctxt,
const struct ipv6_opt *const  ipv6_opt,
const uint8_t  protocol,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the IPv6 option header.

Parameters
contextThe compression context
opt_ctxtThe compression context of the IPv6 option
ipv6_optThe IPv6 extension header
protocolThe protocol of the IPv6 extension header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_irregular_ipv6_part ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  ip_context,
const struct ipv6_hdr *const  ipv6,
const bool  is_innermost,
const bool  ecn_used,
const uint8_t  ip_inner_ecn,
const bool  ttl_irreg_chain_flag,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the IPv6 header.

See RFC 4996 page 63

Parameters
contextThe compression context
ip_contextThe specific IP compression context
ipv6The IPv6 header
is_innermostTrue if IP header is the innermost of the packet
ecn_usedThe indicator of ECN usage
ip_inner_ecnThe ECN flags of the IP innermost header
ttl_irreg_chain_flagWhether the TTL of an outer header changed
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_irregular_tcp_part ( const struct rohc_comp_ctxt *const  context,
const struct tcphdr *const  tcp,
const uint8_t  ip_inner_ecn,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the TCP header.

Parameters
contextThe compression context
tcpThe TCP header
ip_inner_ecnThe ECN flags of the innermost IP header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_static_ipv4_part ( const struct rohc_comp_ctxt *const  context,
const struct ipv4_hdr *const  ipv4,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the IPv4 header.

Parameters
contextThe compression context
ipv4The IPv4 header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_static_ipv6_opt_part ( const struct rohc_comp_ctxt *const  context,
const struct ipv6_opt *const  ipv6_opt,
const uint8_t  protocol,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the IPv6 option header.

Parameters
contextThe compression context
ipv6_optThe IPv6 extension header
protocolThe protocol of the IPv6 extension header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_static_ipv6_part ( const struct rohc_comp_ctxt *const  context,
const struct ipv6_hdr *const  ipv6,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the IPv6 header.

Parameters
contextThe compression context
ipv6The IPv6 header
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static int tcp_code_static_part ( struct rohc_comp_ctxt *const  context,
const struct ip_packet *const  ip,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Code the static part of an IR packet.

Parameters
contextThe compression context
ipThe outer IP header
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns
The length of the ROHC packet if successful, -1 otherwise
static int tcp_code_static_tcp_part ( const struct rohc_comp_ctxt *const  context,
const struct tcphdr *const  tcp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
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
[out]rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length appended in the ROHC buffer if positive, -1 in case of error
static rohc_packet_t tcp_decide_FO_packet ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  ip_inner_context,
const struct tcphdr *const  tcp 
)
static

Decide which packet to send when in FO 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_8, ROHC_PACKET_TCP_SEQ_8 and ROHC_PACKET_TCP_CO_COMMON in case of success
  • ROHC_PACKET_UNKNOWN in case of failure
static rohc_packet_t tcp_decide_FO_SO_packet ( const struct rohc_comp_ctxt *const  context,
const ip_context_t *const  ip_inner_context,
const struct tcphdr *const  tcp,
const bool  crc7_at_least 
)
static

Decide which packet to send when in FO or SO state.

Parameters
contextThe compression context
ip_inner_contextThe context of the inner IP header
tcpThe TCP header to compress
crc7_at_leastWhether packet types with CRC strictly smaller than 8 bits are allowed or not
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_FO_SO_packet_rnd ( const struct rohc_comp_ctxt *const  context,
const struct tcphdr *const  tcp,
const bool  crc7_at_least 
)
static

Decide which rnd packet to send when in FO or SO state.

Parameters
contextThe compression context
tcpThe TCP header to compress
crc7_at_leastWhether packet types with CRC strictly smaller than 8 bits are allowed or not
Returns
  • The packet type among 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_FO_SO_packet_seq ( const struct rohc_comp_ctxt *const  context,
const struct tcphdr *const  tcp,
const bool  crc7_at_least 
)
static

Decide which seq packet to send when in FO or SO state.

Parameters
contextThe compression context
tcpThe TCP header to compress
crc7_at_leastWhether packet types with CRC strictly smaller than 8 bits are allowed or not
Returns
  • The packet type among 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_packet ( struct rohc_comp_ctxt *const  context,
const ip_context_t *const  ip_inner_context,
const struct tcphdr *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_t *const  ip_inner_context,
const struct tcphdr *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,
ip_context_t **const  ip_inner_ctxt,
const struct tcphdr **const  tcp 
)
static

Detect changes between packet and context.

Parameters
contextThe compression context to compare
uncomp_pktThe uncompressed packet to compare
[out]ip_inner_ctxtThe context of the inner IP header
[out]tcpThe TCP header found in uncompressed headers
Returns
true if changes were successfully detected, false if a problem occurred
static bool tcp_detect_changes_ipv6_exts ( struct rohc_comp_ctxt *const  context,
ip_context_t *const  ip_context,
uint8_t *const  protocol,
const uint8_t *const  exts,
const size_t  max_exts_len,
size_t *const  exts_nr,
size_t *const  exts_len 
)
static

Detect changes about IPv6 extension headers between packet and context.

Parameters
contextThe compression context to compare
ip_contextThe specific IP compression context
[in,out]protocolin: the protocol type of the first extension header out: the protocol type of the transport header
extsThe beginning of the IPv6 extension headers
max_exts_lenThe maximum length (in bytes) of the extension headers
[out]exts_nrThe number of IPv6 extension headers
[out]exts_lenThe length (in bytes) of the IPv6 extension headers
Returns
true if changes were successfully detected, false if a problem occurred
static void tcp_detect_ecn_used_behavior ( struct rohc_comp_ctxt *const  context,
const uint8_t  pkt_ecn_vals,
const uint8_t  pkt_outer_dscp_changed,
const uint8_t  pkt_res_val 
)
static

Detect the behavior of the IP/TCP ECN flags and TCP RES flags.

What value for ecn_used? The ecn_used controls the presence of IP ECN flags, TCP ECN flags, but also TCP RES flags.

Parameters
[in,out]contextThe compression context to compare
pkt_ecn_valsThe values of the IP/ECN flags in the current packet
pkt_outer_dscp_changedWhether at least one DSCP changed in the current packet
pkt_res_valThe TCP RES flags in the current packet
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,
const struct tcphdr *const  tcp 
)
static

Encode uncompressed fields with the corresponding encoding scheme.

Parameters
contextThe compression context
uncomp_pktThe uncompressed packet to encode
tcpThe uncompressed TCP header to encode
Returns
true in case of success, false otherwise
static bool tcp_encode_uncomp_ip_fields ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
)
static

Encode uncompressed IP 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 bool tcp_encode_uncomp_tcp_fields ( struct rohc_comp_ctxt *const  context,
const struct tcphdr *const  tcp 
)
static

Encode uncompressed TCP fields with the corresponding encoding scheme.

Parameters
contextThe compression context
tcpThe uncompressed TCP header 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,
const size_t  nr_trans 
)
static

Print a debug trace for the field change.

Parameters
contextThe compression context
nameThe name of the field
changedWhether the field changed or not
nr_transThe number of times the field was transmitted since the last change
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 bool tcp_is_ack_scaled_possible ( const uint16_t  ack_stride,
const size_t  nr_trans 
)
static

Whether the ACK number may be transmitted scaled or not.

The ACK number may be transmitted scaled if:

  • the ack_stride scaling factor is non-zero,
  • both the ack_stride scaling factor and the scaling residue didn't change in the last few packets
Parameters
ack_strideThe ack_stride scaling factor
nr_transThe number of transmissions since last change
Returns
true if the ACK number may be transmitted scaled, false if the ACK number shall be transmitted unscaled
static bool tcp_is_ack_stride_static ( const uint16_t  ack_stride,
const size_t  nr_trans 
)
static

Whether the ack_stride scaling factor shall be transmitted or not.

Parameters
ack_strideThe ack_stride scaling factor
nr_transThe number of transmissions since last change
Returns
true if the ACK number may be transmitted scaled, false if the ACK number shall be transmitted unscaled

Variable Documentation

const struct rohc_comp_profile c_tcp_profile
Initial value:
=
{
.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 = rohc_comp_reinit_context,
.feedback = c_tcp_feedback,
}
Definition: rohc.h:228
static int c_tcp_encode(struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, uint8_t *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.
Definition: c_tcp.c:1673
static bool c_tcp_feedback(struct rohc_comp_ctxt *const context, const enum rohc_feedback_type feedback_type, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
Update the profile when feedback is received.
Definition: c_tcp.c:7016
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.
Definition: c_tcp.c:1126
Definition: ip_numbers.h:60
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.
Definition: c_tcp.c:1507
bool rohc_comp_reinit_context(struct rohc_comp_ctxt *const context)
Re-initialize the given context.
Definition: rohc_comp.c:2694
static void c_tcp_destroy(struct rohc_comp_ctxt *const context)
Destroy the TCP context.
Definition: c_tcp.c:1086
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.
Definition: c_tcp.c:810

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