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 net_pkt *const packet)
 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 bool rohc_comp_rfc5225_ip_esp_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to the ROHCv2 IP/ESP profile. More...
 
static bool rohc_comp_rfc5225_ip_esp_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const cr_score)
 Check if the IP packet belongs to the given ROHCv2 IP/ESP context. More...
 
static int rohc_comp_rfc5225_ip_esp_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 uncompressed packet according to a pattern decided by several different factors. More...
 
static bool rohc_comp_rfc5225_ip_esp_detect_changes (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, size_t *const payload_offset)
 Detect changes between packet and context. More...
 
static int rohc_comp_rfc5225_ip_esp_detect_changes_ipv4 (struct rohc_comp_ctxt *const ctxt, ip_context_t *const ip_ctxt, const struct ip_hdr *const ip_hdr, const bool is_innermost)
 Detect changes for the given IPv4 header between packet and context. More...
 
static int rohc_comp_rfc5225_ip_esp_detect_changes_ipv6 (struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ip_hdr *const ip_hdr, const bool is_innermost)
 Detect changes for the given IPv6 header between packet and context. More...
 
static int rohc_comp_rfc5225_ip_esp_code_IR_pkt (const struct rohc_comp_ctxt *context, const struct ip_packet *const ip, 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 ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const size_t payload_offset)
 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 ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const rohc_packet_t packet_type, const size_t payload_offset)
 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 ip_packet *const ip, 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 ip_packet *const ip, 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 ip_packet *const ip, 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 void rohc_comp_rfc5225_ip_esp_decide_state (struct rohc_comp_ctxt *const context, const struct rohc_ts pkt_time)
 Decide the state that should be used for the next packet. 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 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_check_context()

static bool rohc_comp_rfc5225_ip_esp_check_context ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet,
size_t *const  cr_score 
)
static

Check if the IP packet belongs to the given ROHCv2 IP/ESP context.

Conditions are:

  • the number of IP headers must be the same as in context
  • IP version of all the 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
  • IPv6 only: the Flow Label of all the IP headers must match the ones the context
  • the ESP SPI must be the same as in 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 packet to check
[out]cr_scoreThe score of the context for Context Replication (CR)
Returns
true if the IP 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)

◆ rohc_comp_rfc5225_ip_esp_check_profile()

static bool rohc_comp_rfc5225_ip_esp_check_profile ( const struct rohc_comp *const  comp,
const struct net_pkt *const  packet 
)
static

Check if the given packet corresponds to the ROHCv2 IP/ESP profile.

Conditions are:

  • the versions of the IP headers are all 4 or 6
  • none of the IP headers is an IP fragment
  • the transport header is one ESP header

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 packet corresponds to the profile:
  • true if the packet corresponds to the profile,
  • false if the packet does not correspond to the profile

◆ 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 ip_packet *const  ip,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const rohc_packet_t  packet_type,
const size_t  payload_offset 
)
static

Encode an IP packet as CO 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 to create
payload_offsetThe offset for the payload in the IP packet
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 ip_packet *const  ip,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
const size_t  payload_offset 
)
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
ipThe outer IP header
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
payload_offsetThe offset for the payload in the IP 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 ip_packet *const  ip,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
)
static

Encode an IP packet as 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

◆ rohc_comp_rfc5225_ip_esp_create()

static bool rohc_comp_rfc5225_ip_esp_create ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
)
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
packetThe packet given 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_decide_state()

static void rohc_comp_rfc5225_ip_esp_decide_state ( struct rohc_comp_ctxt *const  context,
const struct rohc_ts  pkt_time 
)
static

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

Parameters
contextThe compression context
pkt_timeThe time of packet arrival

◆ 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 bool rohc_comp_rfc5225_ip_esp_detect_changes ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
size_t *const  payload_offset 
)
static

Detect changes between packet and context.

Parameters
contextThe compression context to compare
uncomp_pktThe uncompressed packet to compare
[out]payload_offsetThe offset for the payload in the uncompressed packet
Returns
true if changes were successfully detected, false if a problem occurred

◆ rohc_comp_rfc5225_ip_esp_detect_changes_ipv4()

static int rohc_comp_rfc5225_ip_esp_detect_changes_ipv4 ( struct rohc_comp_ctxt *const  ctxt,
ip_context_t *const  ip_ctxt,
const struct ip_hdr *const  ip_hdr,
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
ip_hdrThe IPv4 header to compare
is_innermostWhether the IPv4 header is the innermost of all IP headers
Returns
The length of the IPv4 header, -1 if a problem occurred

◆ rohc_comp_rfc5225_ip_esp_detect_changes_ipv6()

static int rohc_comp_rfc5225_ip_esp_detect_changes_ipv6 ( struct rohc_comp_ctxt *const  ctxt,
const ip_context_t *const  ip_ctxt,
const struct ip_hdr *const  ip_hdr,
const bool  is_innermost 
)
static

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

Parameters
ctxtThe compression context
ip_ctxtThe IPv6 context to compare
ip_hdrThe IPv6 header to compare
is_innermostWhether the IPv6 header is the innermost of all IP headers
Returns
The length of the IPv6 header, -1 if a problem occurred

◆ 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 ip_packet *const  ip,
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
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

◆ 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 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 uncompressed packet according to a pattern decided by several different factors.

  1. Decide state
  2. Decide which packet type to send.
  3. Code packet
  4. 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_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 uncompressed packet
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 ip_packet *const  ip,
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
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

◆ 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 ip_packet *const  ip,
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
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

◆ 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 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 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
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:
=
{
.protocol = ROHC_IPPROTO_ESP,
.clone = NULL,
}
static bool rohc_comp_rfc5225_ip_esp_create(struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
Create a new ROHCv2 IP/ESP context and initialize it thanks to the given uncompressed packet...
Definition: comp_rfc5225_ip_esp.c:382
Definition: ip_numbers.h:68
static int rohc_comp_rfc5225_ip_esp_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 uncompressed packet according to a pattern decided by several different factors...
Definition: comp_rfc5225_ip_esp.c:935
static bool rohc_comp_rfc5225_ip_esp_check_profile(const struct rohc_comp *const comp, const struct net_pkt *const packet)
Check if the given packet corresponds to the ROHCv2 IP/ESP profile.
Definition: comp_rfc5225_ip_esp.c:549
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:522
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:1633
static bool rohc_comp_rfc5225_ip_esp_check_context(const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const cr_score)
Check if the IP packet belongs to the given ROHCv2 IP/ESP context.
Definition: comp_rfc5225_ip_esp.c:753
Definition: rohc_profiles.h:115

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