ROHC compression/decompression library
Data Structures | Functions | Variables
comp_rfc5225_ip_esp.c File Reference

ROHC compression context for the ROHCv2 IP/ESP profile. More...

#include "rohc_comp_internals.h"
#include "rohc_traces.h"
#include "rohc_traces_internal.h"
#include "rohc_debug.h"
#include "rohc_bit_ops.h"
#include "protocols/ip_numbers.h"
#include "protocols/ip.h"
#include "protocols/rfc5225.h"
#include "schemes/cid.h"
#include "schemes/ipv6_exts.h"
#include "schemes/ip_ctxt.h"
#include "schemes/comp_wlsb.h"
#include "schemes/ip_id_offset.h"
#include "schemes/rfc4996.h"
#include "crc.h"
#include "sdvl.h"
#include <assert.h>
Include dependency graph for comp_rfc5225_ip_esp.c:

Data Structures

struct  comp_rfc5225_tmp_variables
 Define the RFC5225-specific temporary variables in the profile compression context. More...
 
struct  rohc_comp_rfc5225_ip_esp_ctxt
 

Functions

static bool rohc_comp_rfc5225_ip_esp_create (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Create a new ROHCv2 IP/ESP context and initialize it thanks to the given uncompressed packet. More...
 
static void rohc_comp_rfc5225_ip_esp_destroy (struct rohc_comp_ctxt *const context)
 Destroy the ROHCv2 IP/ESP context. More...
 
static int rohc_comp_rfc5225_ip_esp_encode (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type)
 Encode an uncompressed packet according to a pattern decided by several different factors. More...
 
static void rohc_comp_rfc5225_ip_esp_detect_changes (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Detect changes between packet and context. More...
 
static void rohc_comp_rfc5225_ip_esp_detect_changes_ipv4 (struct rohc_comp_ctxt *const ctxt, ip_context_t *const ip_ctxt, const struct ipv4_hdr *const ipv4, const bool is_innermost)
 Detect changes for the given IPv4 header between packet and context. More...
 
static int rohc_comp_rfc5225_ip_esp_code_IR_pkt (const struct rohc_comp_ctxt *context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Encode an IP packet as IR packet. More...
 
static int rohc_comp_rfc5225_ip_esp_code_co_repair_pkt (const struct rohc_comp_ctxt *context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Encode an IP packet as co_repair packet. More...
 
static int rohc_comp_rfc5225_ip_esp_code_CO_pkt (const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const rohc_packet_t packet_type)
 Encode an IP packet as CO packet. More...
 
static int rohc_comp_rfc5225_ip_esp_build_pt_0_crc3_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a ROHCv2 pt_0_crc3 packet. More...
 
static int rohc_comp_rfc5225_ip_esp_build_pt_0_crc7_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a ROHCv2 pt_0_crc7 packet. More...
 
static int rohc_comp_rfc5225_ip_esp_build_pt_1_seq_id_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a ROHCv2 pt_1_seq_id packet. More...
 
static int rohc_comp_rfc5225_ip_esp_build_pt_2_seq_id_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a ROHCv2 pt_2_seq_id packet. More...
 
static int rohc_comp_rfc5225_ip_esp_build_co_common_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build a ROHCv2 co_common packet. More...
 
static int rohc_comp_rfc5225_ip_esp_static_chain (const struct rohc_comp_ctxt *const ctxt, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Code the static chain of an ROHCv2 IP/ESP IR packet. More...
 
static int rohc_comp_rfc5225_ip_esp_static_ipv4_part (const struct rohc_comp_ctxt *const ctxt, const struct ipv4_hdr *const ipv4, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the IPv4 header. More...
 
static int rohc_comp_rfc5225_ip_esp_static_ipv6_part (const struct rohc_comp_ctxt *const ctxt, const struct ipv6_hdr *const ipv6, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the IPv6 header. More...
 
static int rohc_comp_rfc5225_ip_esp_static_esp_part (const struct rohc_comp_ctxt *const ctxt, const struct esphdr *const esp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the ESP header. More...
 
static int rohc_comp_rfc5225_ip_esp_dyn_chain (const struct rohc_comp_ctxt *const ctxt, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Code the dynamic chain of a ROHCv2 IP/ESP IR packet. More...
 
static int rohc_comp_rfc5225_ip_esp_dyn_ipv4_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv4_hdr *const ipv4, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the IPv4 header. More...
 
static int rohc_comp_rfc5225_ip_esp_dyn_ipv6_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, 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 rohc_comp_rfc5225_ip_esp_dyn_esp_part (const struct rohc_comp_ctxt *const ctxt, const struct esphdr *const esp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the ESP header. More...
 
static int rohc_comp_rfc5225_ip_esp_irreg_chain (const struct rohc_comp_ctxt *const ctxt, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len)
 Code the irregular chain of a ROHCv2 IP/ESP IR packet. More...
 
static int rohc_comp_rfc5225_ip_esp_irreg_ipv4_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv4_hdr *const ipv4, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the IPv4 header. More...
 
static int rohc_comp_rfc5225_ip_esp_irreg_ipv6_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv6_hdr *const ipv6, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the IPv6 header. More...
 
static bool rohc_comp_rfc5225_ip_esp_feedback (struct rohc_comp_ctxt *const ctxt, 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 rohc_comp_rfc5225_ip_esp_feedback_2 (struct rohc_comp_ctxt *const ctxt, 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 rohc_comp_rfc5225_ip_esp_feedback_ack (struct rohc_comp_ctxt *const ctxt, 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...
 
static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_pkt (struct rohc_comp_ctxt *const context)
 Decide which packet to send when in the different states. More...
 
static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_FO_pkt (const struct rohc_comp_ctxt *const ctxt)
 Decide which packet to send when in FO state. More...
 
static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_SO_pkt (const struct rohc_comp_ctxt *const ctxt)
 Decide which packet to send when in SO state. More...
 
static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_FO_SO_pkt (const struct rohc_comp_ctxt *const ctxt, const bool crc7_at_least)
 Decide which packet to send when in FO or SO state. More...
 
static bool rohc_comp_rfc5225_is_msn_lsb_possible (const struct c_wlsb *const wlsb, const uint32_t value, const rohc_reordering_offset_t reorder_ratio, const size_t k)
 Define according to computed shift parameter if msn_lsb() is possible. More...
 
static bool rohc_comp_rfc5225_is_ipid_sequential (const rohc_ip_id_behavior_t behavior)
 Whether the given IP-ID is sequential (swapped or not) More...
 
static bool rohc_comp_rfc5225_is_seq_ipid_inferred (const ip_context_t *const ip_ctxt, const uint8_t ip_id_offset_trans_nr, const uint8_t oa_repetitions_nr, const uint16_t new_ip_id, const int32_t msn_offset)
 Whether the given IP-ID is inferred from SN. More...
 
static bool sdvl_sn_lsb_encode (uint8_t *const sdvl_bytes, const size_t sdvl_bytes_max_nr, size_t *const sdvl_bytes_nr, const struct c_wlsb *const sn_wlsb, const rohc_reordering_offset_t reorder_ratio, const uint32_t sn)
 Encode a SN value using the sdvl_sn_lsb encoding. More...
 

Variables

const struct rohc_comp_profile rohc_comp_rfc5225_ip_esp_profile
 Define the compression part of the ROHCv2 IP/ESP profile as described in the RFC 5225. More...
 

Detailed Description

ROHC compression context for the ROHCv2 IP/ESP profile.

Author
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

Function Documentation

◆ rohc_comp_rfc5225_ip_esp_build_co_common_pkt()

static int rohc_comp_rfc5225_ip_esp_build_co_common_pkt ( const struct rohc_comp_ctxt *const  context,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a ROHCv2 co_common packet.

Parameters
contextThe compression context
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

◆ rohc_comp_rfc5225_ip_esp_build_pt_0_crc3_pkt()

static int rohc_comp_rfc5225_ip_esp_build_pt_0_crc3_pkt ( const struct rohc_comp_ctxt *const  context,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a ROHCv2 pt_0_crc3 packet.

Parameters
contextThe compression context
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

◆ rohc_comp_rfc5225_ip_esp_build_pt_0_crc7_pkt()

static int rohc_comp_rfc5225_ip_esp_build_pt_0_crc7_pkt ( const struct rohc_comp_ctxt *const  context,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a ROHCv2 pt_0_crc7 packet.

Parameters
contextThe compression context
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

◆ rohc_comp_rfc5225_ip_esp_build_pt_1_seq_id_pkt()

static int rohc_comp_rfc5225_ip_esp_build_pt_1_seq_id_pkt ( const struct rohc_comp_ctxt *const  context,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a ROHCv2 pt_1_seq_id packet.

Parameters
contextThe compression context
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

◆ rohc_comp_rfc5225_ip_esp_build_pt_2_seq_id_pkt()

static int rohc_comp_rfc5225_ip_esp_build_pt_2_seq_id_pkt ( const struct rohc_comp_ctxt *const  context,
const uint8_t  crc,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build a ROHCv2 pt_2_seq_id packet.

Parameters
contextThe compression context
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

◆ rohc_comp_rfc5225_ip_esp_code_CO_pkt()

static int rohc_comp_rfc5225_ip_esp_code_CO_pkt ( const struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const rohc_packet_t  packet_type 
)
static

Encode an IP packet as CO packet.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe type of ROHC packet to create
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ rohc_comp_rfc5225_ip_esp_code_co_repair_pkt()

static int rohc_comp_rfc5225_ip_esp_code_co_repair_pkt ( const struct rohc_comp_ctxt context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Encode an IP packet as co_repair packet.

        0   1   2   3   4   5   6   7
       --- --- --- --- --- --- --- ---
      :         Add-CID octet         : if for small CIDs and CID 1-15
      +---+---+---+---+---+---+---+---+
      | 1   1   1   1   1   0   1   1 | discriminator
      +---+---+---+---+---+---+---+---+
      :                               :
      /   0, 1, or 2 octets of CID    / 1-2 octets if large CIDs
      :                               :
      +---+---+---+---+---+---+---+---+
      |r1 |         CRC-7             |
      +---+---+---+---+---+---+---+---+
      |        r2         |   CRC-3   |
      +---+---+---+---+---+---+---+---+
      |                               |
      /         Dynamic chain         / variable length
      |                               |
       - - - - - - - - - - - - - - - -
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
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

◆ rohc_comp_rfc5225_ip_esp_code_IR_pkt()

static int rohc_comp_rfc5225_ip_esp_code_IR_pkt ( const struct rohc_comp_ctxt context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Encode an IP packet as IR packet.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
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

◆ rohc_comp_rfc5225_ip_esp_create()

static bool rohc_comp_rfc5225_ip_esp_create ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)
static

Create a new ROHCv2 IP/ESP context and initialize it thanks to the given uncompressed packet.

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

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to initialize the new context
Returns
true if successful, false otherwise

◆ rohc_comp_rfc5225_ip_esp_decide_FO_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_FO_pkt ( const struct rohc_comp_ctxt *const  ctxt)
static

Decide which packet to send when in FO state.

Parameters
ctxtThe compression context
Returns
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_CO_REPAIR, ROHC_PACKET_CO_COMMON, ROHC_PACKET_NORTP_PT_0_CRC7, or ROHC_PACKET_NORTP_PT_2_SEQ_ID in case of success
  • ROHC_PACKET_UNKNOWN in case of failure

◆ rohc_comp_rfc5225_ip_esp_decide_FO_SO_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_FO_SO_pkt ( const struct rohc_comp_ctxt *const  ctxt,
const bool  crc7_at_least 
)
static

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

Parameters
ctxtThe compression context
crc7_at_leastWhether packet types with CRC strictly smaller than 7 bits are allowed or not
Returns
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_CO_REPAIR, ROHC_PACKET_CO_COMMON, ROHC_PACKET_PT_0_CRC3, ROHC_PACKET_NORTP_PT_0_CRC7, ROHC_PACKET_NORTP_PT_1_SEQ_ID, or ROHC_PACKET_NORTP_PT_2_SEQ_ID in case of success
  • ROHC_PACKET_UNKNOWN in case of failure

◆ rohc_comp_rfc5225_ip_esp_decide_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_pkt ( struct rohc_comp_ctxt *const  context)
static

Decide which packet to send when in the different states.

Parameters
contextThe compression context
Returns
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_PT_0_CRC3, ROHC_PACKET_NORTP_PT_0_CRC7, ROHC_PACKET_NORTP_PT_1_SEQ_ID, or ROHC_PACKET_NORTP_PT_2_SEQ_ID in case of success
  • ROHC_PACKET_UNKNOWN in case of failure

◆ rohc_comp_rfc5225_ip_esp_decide_SO_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_esp_decide_SO_pkt ( const struct rohc_comp_ctxt *const  ctxt)
static

Decide which packet to send when in SO state.

Parameters
ctxtThe compression context
Returns
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_CO_REPAIR, ROHC_PACKET_CO_COMMON, ROHC_PACKET_PT_0_CRC3, ROHC_PACKET_NORTP_PT_0_CRC7, ROHC_PACKET_NORTP_PT_1_SEQ_ID, or ROHC_PACKET_NORTP_PT_2_SEQ_ID in case of success
  • ROHC_PACKET_UNKNOWN in case of failure

◆ rohc_comp_rfc5225_ip_esp_destroy()

static void rohc_comp_rfc5225_ip_esp_destroy ( struct rohc_comp_ctxt *const  context)
static

Destroy the ROHCv2 IP/ESP context.

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

Parameters
contextThe ROHCv2 IP/ESP compression context to destroy

◆ rohc_comp_rfc5225_ip_esp_detect_changes()

static void rohc_comp_rfc5225_ip_esp_detect_changes ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)
static

Detect changes between packet and context.

Parameters
contextThe compression context to compare
uncomp_pkt_hdrsThe uncompressed headers to compare

◆ rohc_comp_rfc5225_ip_esp_detect_changes_ipv4()

static void rohc_comp_rfc5225_ip_esp_detect_changes_ipv4 ( struct rohc_comp_ctxt *const  ctxt,
ip_context_t *const  ip_ctxt,
const struct ipv4_hdr *const  ipv4,
const bool  is_innermost 
)
static

Detect changes for the given IPv4 header between packet and context.

Parameters
ctxtThe compression context
ip_ctxtThe IPv4 context to compare
ipv4The IPv4 header to compare
is_innermostWhether the IPv4 header is the innermost of all IP headers

◆ rohc_comp_rfc5225_ip_esp_dyn_chain()

static int rohc_comp_rfc5225_ip_esp_dyn_chain ( const struct rohc_comp_ctxt *const  ctxt,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Code the dynamic chain of a ROHCv2 IP/ESP IR packet.

Parameters
ctxtThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
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

◆ rohc_comp_rfc5225_ip_esp_dyn_esp_part()

static int rohc_comp_rfc5225_ip_esp_dyn_esp_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct esphdr *const  esp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the ESP header.

Parameters
ctxtThe compression context
espThe ESP 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

◆ rohc_comp_rfc5225_ip_esp_dyn_ipv4_part()

static int rohc_comp_rfc5225_ip_esp_dyn_ipv4_part ( const struct rohc_comp_ctxt *const  ctxt,
const ip_context_t *const  ip_ctxt,
const struct ipv4_hdr *const  ipv4,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the IPv4 header.

Parameters
ctxtThe compression context
ip_ctxtThe specific IP 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

◆ rohc_comp_rfc5225_ip_esp_dyn_ipv6_part()

static int rohc_comp_rfc5225_ip_esp_dyn_ipv6_part ( const struct rohc_comp_ctxt *const  ctxt,
const ip_context_t *const  ip_ctxt,
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
ctxtThe compression context
ip_ctxtThe 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

◆ rohc_comp_rfc5225_ip_esp_encode()

static int rohc_comp_rfc5225_ip_esp_encode ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type 
)
static

Encode an uncompressed packet according to a pattern decided by several different factors.

  1. Decide which packet type to send.
  2. Code packet
  3. Update context

    This function is one of the functions that must exist in one profile for the framework to work.
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers 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
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ rohc_comp_rfc5225_ip_esp_feedback()

static bool rohc_comp_rfc5225_ip_esp_feedback ( struct rohc_comp_ctxt *const  ctxt,
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
ctxtThe compression context
feedback_typeThe feedback type among ROHC_FEEDBACK_1 and ROHC_FEEDBACK_2
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

◆ rohc_comp_rfc5225_ip_esp_feedback_2()

static bool rohc_comp_rfc5225_ip_esp_feedback_2 ( struct rohc_comp_ctxt *const  ctxt,
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
ctxtThe 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

◆ rohc_comp_rfc5225_ip_esp_feedback_ack()

static void rohc_comp_rfc5225_ip_esp_feedback_ack ( struct rohc_comp_ctxt *const  ctxt,
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
ctxtThe 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

◆ rohc_comp_rfc5225_ip_esp_irreg_chain()

static int rohc_comp_rfc5225_ip_esp_irreg_chain ( const struct rohc_comp_ctxt *const  ctxt,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Code the irregular chain of a ROHCv2 IP/ESP IR packet.

Parameters
ctxtThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
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

◆ rohc_comp_rfc5225_ip_esp_irreg_ipv4_part()

static int rohc_comp_rfc5225_ip_esp_irreg_ipv4_part ( const struct rohc_comp_ctxt *const  ctxt,
const ip_context_t *const  ip_ctxt,
const struct ipv4_hdr *const  ipv4,
const bool  is_innermost,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the IPv4 header.

Parameters
ctxtThe compression context
ip_ctxtThe 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

◆ rohc_comp_rfc5225_ip_esp_irreg_ipv6_part()

static int rohc_comp_rfc5225_ip_esp_irreg_ipv6_part ( const struct rohc_comp_ctxt *const  ctxt,
const ip_context_t *const  ip_ctxt,
const struct ipv6_hdr *const  ipv6,
const bool  is_innermost,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the IPv6 header.

Parameters
ctxtThe compression context
ip_ctxtThe specific IP compression context
ipv6The IPv6 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

◆ rohc_comp_rfc5225_ip_esp_static_chain()

static int rohc_comp_rfc5225_ip_esp_static_chain ( const struct rohc_comp_ctxt *const  ctxt,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Code the static chain of an ROHCv2 IP/ESP IR packet.

Parameters
ctxtThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
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

◆ rohc_comp_rfc5225_ip_esp_static_esp_part()

static int rohc_comp_rfc5225_ip_esp_static_esp_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct esphdr *const  esp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the ESP header.

Parameters
ctxtThe compression context
espThe ESP 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

◆ rohc_comp_rfc5225_ip_esp_static_ipv4_part()

static int rohc_comp_rfc5225_ip_esp_static_ipv4_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct ipv4_hdr *const  ipv4,
const bool  is_innermost,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the IPv4 header.

Parameters
ctxtThe compression context
ipv4The IPv4 header
is_innermostWhether the IPv4 header is 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

◆ rohc_comp_rfc5225_ip_esp_static_ipv6_part()

static int rohc_comp_rfc5225_ip_esp_static_ipv6_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct ipv6_hdr *const  ipv6,
const bool  is_innermost,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the IPv6 header.

Parameters
ctxtThe compression context
ipv6The IPv6 header
is_innermostWhether the IPv6 header is 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

◆ rohc_comp_rfc5225_is_ipid_sequential()

static bool rohc_comp_rfc5225_is_ipid_sequential ( const rohc_ip_id_behavior_t  behavior)
static

Whether the given IP-ID is sequential (swapped or not)

Parameters
behaviorThe IP-ID behavior
Returns
true if the given IP-ID behavior is sequential or sequential swapped, false otherwise

◆ rohc_comp_rfc5225_is_msn_lsb_possible()

static bool rohc_comp_rfc5225_is_msn_lsb_possible ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
const rohc_reordering_offset_t  reorder_ratio,
const size_t  k 
)
static

Define according to computed shift parameter if msn_lsb() is possible.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
reorder_ratioThe reordering ratio
kThe number of bits for encoding
Returns
true if msn_lsb is possible or not

◆ rohc_comp_rfc5225_is_seq_ipid_inferred()

static bool rohc_comp_rfc5225_is_seq_ipid_inferred ( const ip_context_t *const  ip_ctxt,
const uint8_t  ip_id_offset_trans_nr,
const uint8_t  oa_repetitions_nr,
const uint16_t  new_ip_id,
const int32_t  msn_offset 
)
static

Whether the given IP-ID is inferred from SN.

The given IP-ID is inferred from SN if:

  • the IP header is IPv4,
  • the IP-ID / SN offset was transmitted enough times to gain confidence that the decompressor received the value,
  • the IP-ID behavior is sequential or sequential swapped,
  • the new IP-ID value increases from the last IP-ID by the same delta as the MSN.
Parameters
ip_ctxtThe context for the given IP header
ip_id_offset_trans_nrThe number of IP-ID offset transmissions
oa_repetitions_nrThe number of repetitions for Optimistic Approach
new_ip_idThe new value of the IP-ID
msn_offsetThe offset between the previous and current MSN
Returns
true if the given IP-ID is sequential and inferred from MSN, false otherwise

◆ sdvl_sn_lsb_encode()

static bool sdvl_sn_lsb_encode ( uint8_t *const  sdvl_bytes,
const size_t  sdvl_bytes_max_nr,
size_t *const  sdvl_bytes_nr,
const struct c_wlsb *const  sn_wlsb,
const rohc_reordering_offset_t  reorder_ratio,
const uint32_t  sn 
)
static

Encode a SN value using the sdvl_sn_lsb encoding.

See page 72 in the RFC 5525 for details about the sdvl_sn_lsb encoding.

Parameters
sdvl_bytesIN/OUT: The SDVL-encoded bytes
sdvl_bytes_max_nrThe maximum available free bytes for SDVL
sdvl_bytes_nrOUT: The number of SDVL bytes written
sn_wlsbThe W-LSB object for the SN
reorder_ratioThe reorder ratio
snThe SN value to encode
Returns
true if SDVL encoding is successful, false in case of failure

Variable Documentation

◆ rohc_comp_rfc5225_ip_esp_profile

const struct rohc_comp_profile rohc_comp_rfc5225_ip_esp_profile
Initial value:
=
{
.clone = NULL,
}
static void rohc_comp_rfc5225_ip_esp_destroy(struct rohc_comp_ctxt *const context)
Destroy the ROHCv2 IP/ESP context.
Definition: comp_rfc5225_ip_esp.c:473
static bool rohc_comp_rfc5225_ip_esp_feedback(struct rohc_comp_ctxt *const ctxt, 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: comp_rfc5225_ip_esp.c:1085
static bool rohc_comp_rfc5225_ip_esp_create(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
Create a new ROHCv2 IP/ESP context and initialize it thanks to the given uncompressed packet...
Definition: comp_rfc5225_ip_esp.c:366
static int rohc_comp_rfc5225_ip_esp_encode(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type)
Encode an uncompressed packet according to a pattern decided by several different factors...
Definition: comp_rfc5225_ip_esp.c:502
Definition: rohc_profiles.h:121

Define the compression part of the ROHCv2 IP/ESP profile as described in the RFC 5225.