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

ROHC compression context for the ROHCv2 IP/UDP 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 <assert.h>
Include dependency graph for comp_rfc5225_ip_udp.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_udp_ctxt
 

Functions

static bool rohc_comp_rfc5225_ip_udp_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Create a new ROHCv2 IP/UDP context and initialize it thanks to the given uncompressed packet. More...
 
static void rohc_comp_rfc5225_ip_udp_destroy (struct rohc_comp_ctxt *const context)
 Destroy the ROHCv2 IP/UDP context. More...
 
static bool rohc_comp_rfc5225_ip_udp_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to the ROHCv2 IP/UDP profile. More...
 
static bool rohc_comp_rfc5225_ip_udp_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/UDP context. More...
 
static int rohc_comp_rfc5225_ip_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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/UDP IR packet. More...
 
static int rohc_comp_rfc5225_ip_udp_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_udp_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_udp_static_udp_part (const struct rohc_comp_ctxt *const ctxt, const struct udphdr *const udp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the static part of the UDP header. More...
 
static int rohc_comp_rfc5225_ip_udp_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/UDP IR packet. More...
 
static int rohc_comp_rfc5225_ip_udp_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_udp_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_udp_dyn_udp_part (const struct rohc_comp_ctxt *const ctxt, const struct udphdr *const udp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the dynamic part of the UDP header. More...
 
static int rohc_comp_rfc5225_ip_udp_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/UDP IR packet. More...
 
static int rohc_comp_rfc5225_ip_udp_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_udp_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 int rohc_comp_rfc5225_ip_udp_irreg_udp_part (const struct rohc_comp_ctxt *const ctxt, const struct udphdr *const udp, uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the irregular part of the UDP header. More...
 
static bool rohc_comp_rfc5225_ip_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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_udp_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 uint16_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 int16_t msn_offset)
 Whether the given IP-ID is inferred from SN. More...
 

Variables

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

Detailed Description

ROHC compression context for the ROHCv2 IP/UDP 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_udp_build_co_common_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_build_pt_0_crc3_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_build_pt_0_crc7_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_build_pt_1_seq_id_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_build_pt_2_seq_id_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_check_context()

static bool rohc_comp_rfc5225_ip_udp_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/UDP 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 UDP source port must be the same as in context
  • the UDP destination port 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_udp_check_profile()

static bool rohc_comp_rfc5225_ip_udp_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/UDP 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 UDP header
  • the UDP length field shall be correct in order to be inferred

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_udp_code_CO_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_code_co_repair_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_code_IR_pkt()

static int rohc_comp_rfc5225_ip_udp_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_udp_create()

static bool rohc_comp_rfc5225_ip_udp_create ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
)
static

Create a new ROHCv2 IP/UDP 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_udp_decide_FO_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_udp_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_udp_decide_FO_SO_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_udp_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_udp_decide_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_udp_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_udp_decide_SO_pkt()

static rohc_packet_t rohc_comp_rfc5225_ip_udp_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_udp_decide_state()

static void rohc_comp_rfc5225_ip_udp_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_udp_destroy()

static void rohc_comp_rfc5225_ip_udp_destroy ( struct rohc_comp_ctxt *const  context)
static

Destroy the ROHCv2 IP/UDP context.

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

Parameters
contextThe ROHCv2 IP/UDP compression context to destroy

◆ rohc_comp_rfc5225_ip_udp_detect_changes()

static bool rohc_comp_rfc5225_ip_udp_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_udp_detect_changes_ipv4()

static int rohc_comp_rfc5225_ip_udp_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_udp_detect_changes_ipv6()

static int rohc_comp_rfc5225_ip_udp_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_udp_dyn_chain()

static int rohc_comp_rfc5225_ip_udp_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/UDP 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_udp_dyn_ipv4_part()

static int rohc_comp_rfc5225_ip_udp_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_udp_dyn_ipv6_part()

static int rohc_comp_rfc5225_ip_udp_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_udp_dyn_udp_part()

static int rohc_comp_rfc5225_ip_udp_dyn_udp_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct udphdr *const  udp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the dynamic part of the UDP header.

Parameters
ctxtThe compression context
udpThe UDP 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_udp_encode()

static int rohc_comp_rfc5225_ip_udp_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_udp_feedback()

static bool rohc_comp_rfc5225_ip_udp_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_udp_feedback_2()

static bool rohc_comp_rfc5225_ip_udp_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_udp_feedback_ack()

static void rohc_comp_rfc5225_ip_udp_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_udp_irreg_chain()

static int rohc_comp_rfc5225_ip_udp_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/UDP 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_udp_irreg_ipv4_part()

static int rohc_comp_rfc5225_ip_udp_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_udp_irreg_ipv6_part()

static int rohc_comp_rfc5225_ip_udp_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_udp_irreg_udp_part()

static int rohc_comp_rfc5225_ip_udp_irreg_udp_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct udphdr *const  udp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the irregular part of the UDP header.

Parameters
ctxtThe compression context
udpThe UDP 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_udp_static_chain()

static int rohc_comp_rfc5225_ip_udp_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/UDP 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_udp_static_ipv4_part()

static int rohc_comp_rfc5225_ip_udp_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_udp_static_ipv6_part()

static int rohc_comp_rfc5225_ip_udp_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_ip_udp_static_udp_part()

static int rohc_comp_rfc5225_ip_udp_static_udp_part ( const struct rohc_comp_ctxt *const  ctxt,
const struct udphdr *const  udp,
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the static part of the UDP header.

Parameters
ctxtThe compression context
udpThe UDP 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 uint16_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 int16_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

Variable Documentation

◆ rohc_comp_rfc5225_ip_udp_profile

const struct rohc_comp_profile rohc_comp_rfc5225_ip_udp_profile
Initial value:
=
{
.protocol = ROHC_IPPROTO_UDP,
.clone = NULL,
}
static bool rohc_comp_rfc5225_ip_udp_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_udp.c:1694
static int rohc_comp_rfc5225_ip_udp_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_udp.c:961
Definition: ip_numbers.h:58
static bool rohc_comp_rfc5225_ip_udp_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/UDP context.
Definition: comp_rfc5225_ip_udp.c:771
static void rohc_comp_rfc5225_ip_udp_destroy(struct rohc_comp_ctxt *const context)
Destroy the ROHCv2 IP/UDP context.
Definition: comp_rfc5225_ip_udp.c:529
static bool rohc_comp_rfc5225_ip_udp_create(struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
Create a new ROHCv2 IP/UDP context and initialize it thanks to the given uncompressed packet...
Definition: comp_rfc5225_ip_udp.c:389
Definition: rohc_profiles.h:113
static bool rohc_comp_rfc5225_ip_udp_check_profile(const struct rohc_comp *const comp, const struct net_pkt *const packet)
Check if the given packet corresponds to the ROHCv2 IP/UDP profile.
Definition: comp_rfc5225_ip_udp.c:557

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