ROHC compression/decompression library
Functions
rohc_comp_rfc3095.c File Reference

Generic framework for RFC3095-based compression profiles such as IP-only, UDP, UDP-Lite, ESP, and RTP profiles. More...

#include "rohc_comp_rfc3095.h"
#include "c_rtp.h"
#include "rohc_traces.h"
#include "rohc_traces_internal.h"
#include "rohc_debug.h"
#include "rohc_packets.h"
#include "rohc_utils.h"
#include "rohc_bit_ops.h"
#include "schemes/cid.h"
#include "schemes/ip_id_offset.h"
#include "schemes/comp_list_ipv6.h"
#include "sdvl.h"
#include "crc.h"
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "config.h"
Include dependency graph for rohc_comp_rfc3095.c:

Functions

static bool ip_header_info_new (struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, const size_t oa_repetitions_nr, const int profile_id, rohc_trace_callback2_t trace_cb, void *const trace_cb_priv)
 Initialize the IP header info stored in the context. More...
 
static void ip_header_info_free (struct ip_header_info *const header_info)
 Reset the given IP header info. More...
 
static void c_init_tmp_variables (struct generic_tmp_vars *const tmp_vars)
 Initialize all temporary variables stored in the context. More...
 
static rohc_packet_t decide_packet (struct rohc_comp_ctxt *const context)
 Decide which packet to send when in the different states. More...
 
static rohc_ext_t decide_extension_uor2 (const struct rohc_comp_ctxt *const context, const bool innermost_ip_id_changed, const bool innermost_ip_id_3bits_possible, const bool innermost_ip_id_8bits_possible, const bool innermost_ip_id_11bits_possible, const bool outermost_ip_id_changed, const bool outermost_ip_id_11bits_possible)
 Decide what extension shall be used in the UOR-2 packet (non-RTP). More...
 
static rohc_ext_t decide_extension_uor2rtp (const struct rohc_comp_ctxt *const context, const bool innermost_ip_id_changed, const bool outermost_ip_id_changed)
 Decide what extension shall be used in the UOR-2 packet (RTP). More...
 
static rohc_ext_t decide_extension_uor2ts (const struct rohc_comp_ctxt *const context, const bool innermost_ip_id_changed, const bool innermost_ip_id_8bits_possible, const bool outermost_ip_id_changed)
 Decide what extension shall be used in the UO-1-ID/UOR-2 packet. More...
 
static rohc_ext_t decide_extension_uor2id (const struct rohc_comp_ctxt *const context, const bool innermost_ip_id_5bits_possible, const bool innermost_ip_id_8bits_possible, const bool outermost_ip_id_changed)
 Decide what extension shall be used in the UOR-2-ID packet. More...
 
static rohc_ext_t decide_extension_uo1id (const struct rohc_comp_ctxt *const context, const bool innermost_ip_id_5bits_possible, const bool innermost_ip_id_8bits_possible, const bool outermost_ip_id_changed)
 Decide what extension shall be used in the UO-1-ID packet. More...
 
static int code_packet (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)
 Build the ROHC packet to send. More...
 
static int code_IR_packet (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)
 Build the IR packet. More...
 
static int code_IR_DYN_packet (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)
 Build the IR-DYN packet. More...
 
static int rohc_code_static_part (const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, int counter)
 Build the static part of the IR packet. More...
 
static int rohc_code_static_ip_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, uint8_t *const dest, int counter)
 Build the static part of one IP header for the IR packet. More...
 
static int code_ipv4_static_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, uint8_t *const dest, int counter)
 Build the IPv4 static part of the IR packet. More...
 
static int code_ipv6_static_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, uint8_t *const dest, int counter)
 Build the IPv6 static part of the IR packet. More...
 
static int rohc_code_dynamic_part (const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, int counter)
 Build the dynamic part of the IR and IR-DYN packets. More...
 
static int rohc_code_dynamic_ip_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const bool ext_list_changed, const struct rohc_pkt_ip_hdr *const ip, uint8_t *const dest, int counter)
 Build the dynamic part of one IP header for the IR/IR-DYN packets. More...
 
static int code_ipv4_dynamic_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, uint8_t *const dest, int counter)
 Build the IPv4 dynamic part of the IR and IR-DYN packets. More...
 
static int code_ipv6_dynamic_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const bool ext_list_changed, const struct rohc_pkt_ip_hdr *const ip, uint8_t *const dest, int counter)
 Build the IPv6 dynamic part of the IR and IR-DYN packets. More...
 
static int code_uo_remainder (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const dest, int counter)
 Build the tail of the UO packet. More...
 
static int code_UO0_packet (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)
 Build the UO-0 packet. More...
 
static int rohc_comp_rfc3095_build_uo1_pkt (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)
 Build the UO-1 packet for the non-RTP profiles. More...
 
static int rohc_comp_rfc3095_build_uo1rtp_pkt (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)
 Build the UO-1 packet for the RTP profiles. More...
 
static int rohc_comp_rfc3095_build_uo1ts_pkt (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)
 Build the UO-1-TS packet. More...
 
static int rohc_comp_rfc3095_build_uo1id_pkt (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)
 Build the UO-1-ID packet. More...
 
static int code_UO2_packet (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)
 Build the UO-2 packet. More...
 
static int code_UOR2_bytes (const struct rohc_comp_ctxt *const context, const rohc_packet_t packet_type, uint8_t *const f_byte, uint8_t *const s_byte, uint8_t *const t_byte)
 Code some fields of the UOR-2 packet. More...
 
static int code_UOR2_RTP_bytes (const struct rohc_comp_ctxt *const context, const rohc_packet_t packet_type, uint8_t *const f_byte, uint8_t *const s_byte, uint8_t *const t_byte)
 Code some fields of the UOR-2-RTP packet. More...
 
static int code_UOR2_TS_bytes (const struct rohc_comp_ctxt *const context, const rohc_packet_t packet_type, uint8_t *const f_byte, uint8_t *const s_byte, uint8_t *const t_byte)
 Code some fields of the UOR-2-TS packet. More...
 
static int code_UOR2_ID_bytes (const struct rohc_comp_ctxt *const context, const rohc_packet_t packet_type, uint8_t *const f_byte, uint8_t *const s_byte, uint8_t *const t_byte)
 Code some fields of the UOR-2-ID packet. More...
 
static int code_EXT0_packet (const struct rohc_comp_ctxt *const context, uint8_t *const dest, int counter, const rohc_packet_t packet_type)
 Build the extension 0 of the UO-2 packet. More...
 
static int code_EXT1_packet (const struct rohc_comp_ctxt *const context, uint8_t *const dest, int counter, const rohc_packet_t packet_type)
 Build the extension 1 of the UO-2 packet. More...
 
static int code_EXT2_packet (const struct rohc_comp_ctxt *const context, uint8_t *const dest, int counter, const rohc_packet_t packet_type)
 Build the extension 2 of the UO-2 packet. More...
 
static int code_EXT3_packet (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const dest, int counter, const rohc_packet_t packet_type)
 Build the extension 3 of the UO* packet types. More...
 
static int code_EXT3_rtp_packet (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const dest, int counter, const rohc_packet_t packet_type)
 Build the extension 3 of the UO-2 packet. More...
 
static int code_EXT3_nortp_packet (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const dest, int counter, const rohc_packet_t packet_type)
 Build the extension 3 of the UO-2 packet. More...
 
static int rtp_header_flags_and_fields (const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const dest, int counter)
 
static int header_flags (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, const struct rfc3095_ip_hdr_changes *const changes, const int ip2_or_I2, uint8_t *const dest, int counter)
 Build inner or outer IP header flags. More...
 
static int header_fields (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, const struct rfc3095_ip_hdr_changes *const changes, const int I, const ip_header_pos_t ip_hdr_pos, uint8_t *const dest, int counter)
 Build inner or outer IP header fields. More...
 
static uint8_t compute_uo_crc (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_crc_type_t crc_type, const uint8_t crc_init)
 Compute the CRC for a UO* packet. More...
 
static void update_context (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Update the compression context with the successfully compressed packet. More...
 
static void update_context_ip_hdr (const struct rohc_comp_ctxt *const context, struct ip_header_info *const ip_flags, const struct rohc_pkt_ip_hdr *const ip)
 Update the IP information with the IP header. More...
 
static void rohc_comp_rfc3095_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 detect_ip_changes (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const ip, struct rfc3095_ip_hdr_changes *const changes)
 Find the IP fields that changed between the profile and a new IP packet. More...
 
static void detect_ip_id_behaviours (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Detect the behaviour of the IP-ID fields of the IPv4 headers. More...
 
static void detect_ip_id_behaviour (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct rohc_pkt_ip_hdr *const uncomp_pkt_ip_hdr)
 Detect the behaviour of the IP-ID field of the given IPv4 header. More...
 
static bool encode_uncomp_fields (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Encode uncompressed fields with the corresponding encoding scheme. More...
 
static void rohc_get_innermost_ipv4_non_rnd (const struct rohc_comp_ctxt *const context, ip_header_pos_t *const pos, bool *const is_5bits_possible, uint16_t *const offset)
 Determine the number of IP-ID bits and the IP-ID offset of the innermost IPv4 header with non-random IP-ID. More...
 
static void rohc_comp_rfc3095_get_ext3_I_flags (const struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, const rohc_packet_t packet_type, ip_header_pos_t *const innermost_ipv4_non_rnd, uint8_t *const I, uint8_t *const I2)
 Determine the values of the I and I2 flags for UO* extension 3. More...
 
static bool rohc_comp_rfc3095_feedback_2 (struct rohc_comp_ctxt *const context, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
 Update the profile when FEEDBACK-2 is received. More...
 
static void rohc_comp_rfc3095_feedback_ack (struct rohc_comp_ctxt *const context, const uint32_t sn_bits, const size_t sn_bits_nr, const bool sn_not_valid)
 Perform the required actions after the reception of a positive ACK. More...
 
bool rohc_comp_rfc3095_create (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Create a new context and initialize it thanks to the given IP packet. More...
 
void rohc_comp_rfc3095_destroy (struct rohc_comp_ctxt *const context)
 Destroy the context. More...
 
int rohc_comp_rfc3095_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 IP packet according to a pattern decided by several different factors. More...
 
bool rohc_comp_rfc3095_feedback (struct rohc_comp_ctxt *const context, const enum rohc_feedback_type feedback_type, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
 Update the profile when feedback is received. More...
 
rohc_ext_t decide_extension (const struct rohc_comp_ctxt *const context, const rohc_packet_t packet_type)
 Decide what extension shall be used in the UO-1-ID/UOR-2 packet. More...
 
void rohc_get_ipid_bits (const struct rohc_comp_ctxt *const context, bool *const innermost_ip_id_changed, bool *const innermost_ip_id_3bits_possible, bool *const innermost_ip_id_5bits_possible, bool *const innermost_ip_id_8bits_possible, bool *const innermost_ip_id_11bits_possible, bool *const outermost_ip_id_changed, bool *const outermost_ip_id_11bits_possible)
 Get the number of non-random outer/inner IP-ID bits. More...
 

Detailed Description

Generic framework for RFC3095-based compression profiles such as IP-only, UDP, UDP-Lite, ESP, and RTP profiles.

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
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org
David Moreau from TAS
Emmanuelle Pechereau epech.nosp@m.erea.nosp@m.u@tou.nosp@m.lous.nosp@m.e.viv.nosp@m.eris.nosp@m..com

Function Documentation

◆ c_init_tmp_variables()

static void c_init_tmp_variables ( struct generic_tmp_vars *const  tmp_vars)
static

Initialize all temporary variables stored in the context.

Parameters
tmp_varsThe temporary variables to initialize

◆ code_EXT0_packet()

static int code_EXT0_packet ( const struct rohc_comp_ctxt *const  context,
uint8_t *const  dest,
int  counter,
const rohc_packet_t  packet_type 
)
static

Build the extension 0 of the UO-2 packet.

 Extension 0 for non-RTP profiles (5.11.4):

    +---+---+---+---+---+---+---+---+
 1  | 0   0 |    SN     |   IP-ID   |
    +---+---+---+---+---+---+---+---+

 Extension 0 for RTP profile (5.7.5):

    +---+---+---+---+---+---+---+---+
 1  | 0   0 |    SN     |    +T     |
    +---+---+---+---+---+---+---+---+

 if T = 0 -> +T = IP-ID
          -> -T = TS

 if T = 1 -> +T = TS
          -> -T = IP-ID

 no T bit -> +T = -T = TS
Parameters
contextThe compression context
destThe ROHC buffer
counterThe current position in the ROHC buffer
packet_typeThe type of ROHC packet that is created
Returns
The new position in the ROHC buffer if successful, -1 otherwise

◆ code_EXT1_packet()

static int code_EXT1_packet ( const struct rohc_comp_ctxt *const  context,
uint8_t *const  dest,
int  counter,
const rohc_packet_t  packet_type 
)
static

Build the extension 1 of the UO-2 packet.

 Extension 1 for non-RTP profiles (5.11.4):

    +---+---+---+---+---+---+---+---+
 1  | 0   1 |    SN     |   IP-ID   |
    +---+---+---+---+---+---+---+---+
 2  |             IP-ID             |
    +---+---+---+---+---+---+---+---+

 Extension 1 for RTP profile (5.7.5):

    +---+---+---+---+---+---+---+---+
 1  | 0   1 |    SN     |    +T     |
    +---+---+---+---+---+---+---+---+
 2  |               -T              |
    +---+---+---+---+---+---+---+---+

 if T = 0 -> +T = IP-ID
          -> -T = TS

 if T = 1 -> +T = TS
          -> -T = IP-ID

 no T bit -> +T = -T = TS
Parameters
contextThe compression context
destThe ROHC buffer
counterThe current position in the ROHC buffer
packet_typeThe type of ROHC packet that is created
Returns
The new position in the ROHC buffer if successful, -1 otherwise

◆ code_EXT2_packet()

static int code_EXT2_packet ( const struct rohc_comp_ctxt *const  context,
uint8_t *const  dest,
int  counter,
const rohc_packet_t  packet_type 
)
static

Build the extension 2 of the UO-2 packet.

 Extension 2 for non-RTP profiles (5.11.4):

    +---+---+---+---+---+---+---+---+
 1  | 1   0 |    SN     |   IP-ID2  |
    +---+---+---+---+---+---+---+---+
 2  |            IP-ID2             |
    +---+---+---+---+---+---+---+---+
 3  |             IP-ID             |
    +---+---+---+---+---+---+---+---+

 IP-ID2 is for outer IP-ID field

 Extension 2 for RTP profile (5.7.5):

    +---+---+---+---+---+---+---+---+
 1  | 1   0 |    SN     |     +T    |
    +---+---+---+---+---+---+---+---+
 2  |               +T              |
    +---+---+---+---+---+---+---+---+
 3  |               -T              |
    +---+---+---+---+---+---+---+---+

 if T = 0 -> +T = IP-ID
          -> -T = TS

 if T = 1 -> +T = TS
          -> -T = IP-ID

 no T bit -> +T = -T = TS
Parameters
contextThe compression context
destThe ROHC buffer
counterThe current position in the ROHC buffer
packet_typeThe type of ROHC packet that is created
Returns
The new position in the ROHC buffer if successful, -1 otherwise

◆ code_EXT3_nortp_packet()

static int code_EXT3_nortp_packet ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  dest,
int  counter,
const rohc_packet_t  packet_type 
)
static

Build the extension 3 of the UO-2 packet.

 Extension 3 for non-RTP profiles (5.7.5 & 5.11.4):

       0     1     2     3     4     5     6     7
    +-----+-----+-----+-----+-----+-----+-----+-----+
 1  |  1     1  |  S  |   Mode    |  I  | ip  | ip2 |
    +-----+-----+-----+-----+-----+-----+-----+-----+
 2  |            Inner IP header flags        |     |  if ip = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 3  |            Outer IP header flags              |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 4  |                      SN                       |  if S = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 5  /            Inner IP header fields             /  variable,
    |                                               |  if ip = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 6  |                     IP-ID                     |  2 octets, if I = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 7  /            Outer IP header fields             /  variable,
    |                                               |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
destThe ROHC buffer
counterThe current position in the ROHC buffer
packet_typeThe type of ROHC packet that is created
Returns
The new position in the ROHC buffer if successful, -1 otherwise

◆ code_EXT3_packet()

static int code_EXT3_packet ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  dest,
int  counter,
const rohc_packet_t  packet_type 
)
static

Build the extension 3 of the UO* packet types.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
destThe ROHC buffer
counterThe current position in the ROHC buffer
packet_typeThe type of ROHC packet that is created
Returns
The new position in the ROHC buffer if successful, -1 otherwise

◆ code_EXT3_rtp_packet()

static int code_EXT3_rtp_packet ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  dest,
int  counter,
const rohc_packet_t  packet_type 
)
static

Build the extension 3 of the UO-2 packet.

 Extension 3 for RTP profile (5.7.5):

       0     1     2     3     4     5     6     7
    +-----+-----+-----+-----+-----+-----+-----+-----+
 1  |  1     1  |  S  |R-TS | Tsc |  I  | ip  | rtp |
    +-----+-----+-----+-----+-----+-----+-----+-----+
 2  |            Inner IP header flags        | ip2 |  if ip = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 3  |            Outer IP header flags              |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 4  |                      SN                       |  if S = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 5  /                      TS                       / 1-4 octets, if R-TS = 1
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 6  /            Inner IP header fields             /  variable,
    |                                               |  if ip = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
 7  |                     IP-ID                     |  2 octets, if I = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 8  /            Outer IP header fields             /  variable,
    |                                               |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |  variable,
 9  /          RTP Header flags and fields          /  if rtp = 1
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
destThe ROHC buffer
counterThe current position in the ROHC buffer
packet_typeThe type of ROHC packet that is created
Returns
The new position in the ROHC buffer if successful, -1 otherwise

◆ code_ipv4_dynamic_part()

static int code_ipv4_dynamic_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
uint8_t *const  dest,
int  counter 
)
static

Build the IPv4 dynamic part of the IR and IR-DYN packets.

 Dynamic part IPv4 (5.7.7.4):

    +---+---+---+---+---+---+---+---+
 1  |        Type of Service        |
   +---+---+---+---+---+---+---+---+
 2  |         Time to Live          |
    +---+---+---+---+---+---+---+---+
 3  /        Identification         /   2 octets, sent verbatim
    +---+---+---+---+---+---+---+---+
 4  | DF|RND|NBO|SID|       0       |
    +---+---+---+---+---+---+---+---+
 5  / Generic extension header list /  variable length
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
header_infoThe IP header info stored in the profile
ipThe IPv4 header the dynamic part is built for
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ code_ipv4_static_part()

static int code_ipv4_static_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
uint8_t *const  dest,
int  counter 
)
static

Build the IPv4 static part of the IR packet.

 Static part IPv4 (5.7.7.4):

    +---+---+---+---+---+---+---+---+
 1  |  Version = 4  |       0       |
    +---+---+---+---+---+---+---+---+
 2  |           Protocol            |
    +---+---+---+---+---+---+---+---+
 3  /        Source Address         /   4 octets
    +---+---+---+---+---+---+---+---+
 4  /      Destination Address      /   4 octets
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
header_infoThe IP header info stored in the profile
ipThe IPv4 header the static part is built for
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ code_ipv6_dynamic_part()

static int code_ipv6_dynamic_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const bool  ext_list_changed,
const struct rohc_pkt_ip_hdr *const  ip,
uint8_t *const  dest,
int  counter 
)
static

Build the IPv6 dynamic part of the IR and IR-DYN packets.

 Dynamic part IPv6 (5.7.7.3):

    +---+---+---+---+---+---+---+---+
 1  |         Traffic Class         |   1 octet
    +---+---+---+---+---+---+---+---+
 2  |           Hop Limit           |   1 octet
    +---+---+---+---+---+---+---+---+
 3  / Generic extension header list /   variable length
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
header_infoThe IP header info stored in the profile
ext_list_changedWhether extension header list changed
ipThe IPv6 header the dynamic part is built for
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer, -1 in case of error

◆ code_ipv6_static_part()

static int code_ipv6_static_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
uint8_t *const  dest,
int  counter 
)
static

Build the IPv6 static part of the IR packet.

 Static part IPv6 (5.7.7.3):

    +---+---+---+---+---+---+---+---+
 1  |  Version = 6  |Flow Label(msb)|   1 octet
    +---+---+---+---+---+---+---+---+
 2  /        Flow Label (lsb)       /   2 octets
    +---+---+---+---+---+---+---+---+
 3  |          Next Header          |   1 octet
    +---+---+---+---+---+---+---+---+
 4  /        Source Address         /   16 octets
    +---+---+---+---+---+---+---+---+
 5  /      Destination Address      /   16 octets
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
header_infoThe IP header info stored in the profile
ipThe IPv6 header the static part is built for
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ code_IR_DYN_packet()

static int code_IR_DYN_packet ( 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

Build the IR-DYN packet.

 IR-DYN packet (5.7.7.2):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         : if for small CIDs and CID != 0
    +---+---+---+---+---+---+---+---+
 2  | 1   1   1   1   1   0   0   0 | IR-DYN packet type
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /     0-2 octets of CID info    / 1-2 octets if for large CIDs
    :                               :
    +---+---+---+---+---+---+---+---+
 4  |            Profile            | 1 octet
    +---+---+---+---+---+---+---+---+
 5  |              CRC              | 1 octet
    +---+---+---+---+---+---+---+---+
    |                               |
 6  /         Dynamic chain         / variable length
    |                               |
    +---+---+---+---+---+---+---+---+
 7  |             SN                | 2 octets if not RTP nor ESP
    +---+---+---+---+---+---+---+---+
    :                               :
    /           Payload             / 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
packet_typeThe type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ code_IR_packet()

static int code_IR_packet ( 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

Build the IR packet.

 IR packet (5.7.7.1):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  |         Add-CID octet         |  if for small CIDs and CID != 0
    +---+---+---+---+---+---+---+---+
 2  | 1   1   1   1   1   1   0 | D |
    +---+---+---+---+---+---+---+---+
    |                               |
 3  /    0-2 octets of CID info     /  1-2 octets if for large CIDs
    |                               |
    +---+---+---+---+---+---+---+---+
 4  |            Profile            |  1 octet
    +---+---+---+---+---+---+---+---+
 5  |              CRC              |  1 octet
    +---+---+---+---+---+---+---+---+
    |                               |
 6  |         Static chain          |  variable length
    |                               |
    +---+---+---+---+---+---+---+---+
    |                               |
 7  |         Dynamic chain         |  present if D = 1, variable length
    |                               |
    +---+---+---+---+---+---+---+---+
 8  |             SN                |  2 octets if not RTP nor ESP
    +---+---+---+---+---+---+---+---+
    |                               |
    |           Payload             |  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
packet_typeThe type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ code_packet()

static int code_packet ( 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

Build the ROHC packet to send.

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

◆ code_UO0_packet()

static int code_UO0_packet ( 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

Build the UO-0 packet.

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :
    +---+---+---+---+---+---+---+---+
 2  |   first octet of base header  |
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /
    :                               :
    +---+---+---+---+---+---+---+---+

 UO-0 (5.7.1)

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 0 |      SN       |    CRC    |
    +===+===+===+===+===+===+===+===+
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 that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ code_UO2_packet()

static int code_UO2_packet ( 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

Build the UO-2 packet.

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :
    +---+---+---+---+---+---+---+---+
 2  |   first octet of base header  |
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /
    :                               :
    +---+---+---+---+---+---+---+---+

 UOR-2 (5.11.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |        SN         |
    +===+===+===+===+===+===+===+===+
 5  | X |            CRC            |
    +---+---+---+---+---+---+---+---+

 UOR-2-RTP (5.7.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |        TS         |
    +===+===+===+===+===+===+===+===+
 4  | TS| M |       SN              |
    +---+---+---+---+---+---+---+---+
 5  | X |            CRC            |
    +---+---+---+---+---+---+---+---+

 UOR-2-TS (5.7.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |        TS         |
    +===+===+===+===+===+===+===+===+
 4  |T=1| M |          SN           |
    +---+---+---+---+---+---+---+---+
 5  | X |           CRC             |
    +---+---+---+---+---+---+---+---+

 UOR-2-ID (5.7.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |      IP-ID        |
    +===+===+===+===+===+===+===+===+
 4  |T=0| M |          SN           |
    +---+---+---+---+---+---+---+---+
 5  | X |           CRC             |
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    :                               :
 6  /           Extension           /
    :                               :
     --- --- --- --- --- --- --- ---

 X: X = 0 indicates that no extension is present;
    X = 1 indicates that an extension is present.

 T: T = 0 indicates format UOR-2-ID;
    T = 1 indicates format UOR-2-TS.
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 that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ code_uo_remainder()

static int code_uo_remainder ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  dest,
int  counter 
)
static

Build the tail of the UO packet.

 The general format for the UO packets is:

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :                    |
    +---+---+---+---+---+---+---+---+                    |
 2  |   first octet of base header  |                    |
    +---+---+---+---+---+---+---+---+                    |
    :                               :                    |
 3  /   0, 1, or 2 octets of CID    /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
 4  /   remainder of base header    /                    |
    +---+---+---+---+---+---+---+---+                    |
    :                               :                    |
 5  /           Extension           /                    |
    :                               :                    |
     --- --- --- --- --- --- --- ---                     |
    :                               :                    |
 6  +   IP-ID of outer IPv4 header  +
    :                               :     (see section 5.7 or [RFC-3095])
     --- --- --- --- --- --- --- ---
 7  /    AH data for outer list     /                    |
     --- --- --- --- --- --- --- ---                     |
    :                               :                    |
 8  +         GRE checksum          +                    |
    :                               :                    |
     --- --- --- --- --- --- --- ---                     |
    :                               :                    |
 9  +   IP-ID of inner IPv4 header  +                    |
    :                               :                    |
     --- --- --- --- --- --- --- ---                     |
 10 /    AH data for inner list     /                    |
     --- --- --- --- --- --- --- ---                     |
    :                               :                    |
 11 +         GRE checksum          +                    |
    :                               :                    |
     --- --- --- --- --- --- --- ---
    :            List of            :
 12 /        Dynamic chains         /  variable, given by static chain
    :   for additional IP headers   :  (includes no SN)
     --- --- --- --- --- --- --- ---

     --- --- --- --- --- --- --- ---
    :                               :  RTP/UDP profiles only [RFC-3095]
 13 +         UDP Checksum          +  2 octets,
    :                               :  if context(UDP Checksum) != 0
     --- --- --- --- --- --- --- ---

Parts 7, 8, 10, 11 and 12 are not supported. Parts 1, 2, 3, 4 and 5 are built in packet-specific functions. Parts 6 and 9 are built in this function. Part 13 is built in profile-specific function.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ code_UOR2_bytes()

static int code_UOR2_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_packet_t  packet_type,
uint8_t *const  f_byte,
uint8_t *const  s_byte,
uint8_t *const  t_byte 
)
static

Code some fields of the UOR-2 packet.

This function is called by code_UO2_packet. It should not be called directly.

See also
code_UO2_packet
 UOR-2 (5.11.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |        SN         |
    +===+===+===+===+===+===+===+===+
 5  | X |            CRC            |
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
packet_typeThe packet type to build
f_byteIN/OUT: The first byte of the UOR-2 packet
s_byteIN/OUT: Not used by the UOR-2 packet
t_byteIN/OUT: The second byte of the UOR-2 packet
Returns
1 if successful, 0 otherwise

◆ code_UOR2_ID_bytes()

static int code_UOR2_ID_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_packet_t  packet_type,
uint8_t *const  f_byte,
uint8_t *const  s_byte,
uint8_t *const  t_byte 
)
static

Code some fields of the UOR-2-ID packet.

This function is called by code_UO2_packet. It should not be called directly.

See also
code_UO2_packet
 UOR-2-ID (5.7.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |      IP-ID        |
    +===+===+===+===+===+===+===+===+
 4  |T=0| M |          SN           |
    +---+---+---+---+---+---+---+---+
 5  | X |           CRC             |
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
packet_typeThe packet type to build
f_byteIN/OUT: The first byte of the UOR-2-ID packet
s_byteIN/OUT: The second byte of the UOR-2-ID packet
t_byteIN/OUT: The third byte of the UOR-2-ID packet
Returns
1 if successful, 0 otherwise

◆ code_UOR2_RTP_bytes()

static int code_UOR2_RTP_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_packet_t  packet_type,
uint8_t *const  f_byte,
uint8_t *const  s_byte,
uint8_t *const  t_byte 
)
static

Code some fields of the UOR-2-RTP packet.

This function is called by code_UO2_packet. It should not be called directly.

See also
code_UO2_packet
 UOR-2-RTP (5.7.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |        TS         |
    +===+===+===+===+===+===+===+===+
 4  | TS| M |       SN              |
    +---+---+---+---+---+---+---+---+
 5  | X |            CRC            |
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
packet_typeThe packet type to build
f_byteIN/OUT: The first byte of the UOR-2-RTP packet
s_byteIN/OUT: The second byte of the UOR-2-RTP packet
t_byteIN/OUT: The third byte of the UOR-2-RTP packet
Returns
1 if successful, 0 otherwise

◆ code_UOR2_TS_bytes()

static int code_UOR2_TS_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_packet_t  packet_type,
uint8_t *const  f_byte,
uint8_t *const  s_byte,
uint8_t *const  t_byte 
)
static

Code some fields of the UOR-2-TS packet.

This function is called by code_UO2_packet. It should not be called directly.

See also
code_UO2_packet
 UOR-2-TS (5.7.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   1   0 |        TS         |
    +===+===+===+===+===+===+===+===+
 4  |T=1| M |          SN           |
    +---+---+---+---+---+---+---+---+
 5  | X |           CRC             |
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
packet_typeThe packet type to build
f_byteIN/OUT: The first byte of the UOR-2-TS packet
s_byteIN/OUT: The second byte of the UOR-2-TS packet
t_byteIN/OUT: The third byte of the UOR-2-TS packet
Returns
1 if successful, 0 otherwise

◆ compute_uo_crc()

static uint8_t compute_uo_crc ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_crc_type_t  crc_type,
const uint8_t  crc_init 
)
static

Compute the CRC for a UO* packet.

Parameters
contextThe compression context to update
uncomp_pkt_hdrsThe uncompressed headers to encode
crc_typeThe type of CRC to compute
crc_initThe initial value of the CRC
Returns
The computed CRC

◆ decide_extension()

rohc_ext_t decide_extension ( const struct rohc_comp_ctxt *const  context,
const rohc_packet_t  packet_type 
)

Decide what extension shall be used in the UO-1-ID/UOR-2 packet.

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
packet_typeThe type of ROHC packet that is created
Returns
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3 if successful, ROHC_EXT_UNKNOWN otherwise

◆ decide_extension_uo1id()

static rohc_ext_t decide_extension_uo1id ( const struct rohc_comp_ctxt *const  context,
const bool  innermost_ip_id_5bits_possible,
const bool  innermost_ip_id_8bits_possible,
const bool  outermost_ip_id_changed 
)
static

Decide what extension shall be used in the UO-1-ID packet.

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
innermost_ip_id_5bits_possibleWhether the innermost IP-ID may be encoded on 5 bits
innermost_ip_id_8bits_possibleWhether the innermost IP-ID may be encoded on 8 bits
outermost_ip_id_changedWhether the outermost IP-ID changed
Returns
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3

◆ decide_extension_uor2()

static rohc_ext_t decide_extension_uor2 ( const struct rohc_comp_ctxt *const  context,
const bool  innermost_ip_id_changed,
const bool  innermost_ip_id_3bits_possible,
const bool  innermost_ip_id_8bits_possible,
const bool  innermost_ip_id_11bits_possible,
const bool  outermost_ip_id_changed,
const bool  outermost_ip_id_11bits_possible 
)
static

Decide what extension shall be used in the UOR-2 packet (non-RTP).

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
innermost_ip_id_changedWhether the innermost IP-ID changed
innermost_ip_id_3bits_possibleWhether the innermost IP-ID may be encoded on 3 bits
innermost_ip_id_8bits_possibleWhether the innermost IP-ID may be encoded on 8 bits
innermost_ip_id_11bits_possibleWhether the innermost IP-ID may be encoded on 11 bits
outermost_ip_id_changedWhether the outermost IP-ID changed
outermost_ip_id_11bits_possibleWhether the outermost IP-ID may be encoded on 11 bits
Returns
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3

◆ decide_extension_uor2id()

static rohc_ext_t decide_extension_uor2id ( const struct rohc_comp_ctxt *const  context,
const bool  innermost_ip_id_5bits_possible,
const bool  innermost_ip_id_8bits_possible,
const bool  outermost_ip_id_changed 
)
static

Decide what extension shall be used in the UOR-2-ID packet.

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
innermost_ip_id_5bits_possibleWhether the innermost IP-ID may be encoded on 5 bits
innermost_ip_id_8bits_possibleWhether the innermost IP-ID may be encoded on 8 bits
outermost_ip_id_changedWhether the outermost IP-ID changed
Returns
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3

◆ decide_extension_uor2rtp()

static rohc_ext_t decide_extension_uor2rtp ( const struct rohc_comp_ctxt *const  context,
const bool  innermost_ip_id_changed,
const bool  outermost_ip_id_changed 
)
static

Decide what extension shall be used in the UOR-2 packet (RTP).

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
innermost_ip_id_changedWhether the innermost IP-ID changed
outermost_ip_id_changedWhether the outermost IP-ID changed
Returns
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3

◆ decide_extension_uor2ts()

static rohc_ext_t decide_extension_uor2ts ( const struct rohc_comp_ctxt *const  context,
const bool  innermost_ip_id_changed,
const bool  innermost_ip_id_8bits_possible,
const bool  outermost_ip_id_changed 
)
static

Decide what extension shall be used in the UO-1-ID/UOR-2 packet.

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters
contextThe compression context
innermost_ip_id_changedWhether the innermost IP-ID changed
innermost_ip_id_8bits_possibleWhether the innermost IP-ID may be encoded on 8 bits
outermost_ip_id_changedWhether the outermost IP-ID changed
Returns
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3

◆ decide_packet()

static rohc_packet_t decide_packet ( struct rohc_comp_ctxt *const  context)
static

Decide which packet to send when in the different states.

In IR state, IR packets are used. In FO and SO, the profile-specific functions are called if they are defined, otherwise IR packets are used.

Parameters
contextThe compression context
Returns
  • The packet type among ROHC_PACKET_IR, ROHC_PACKET_IR_DYN, ROHC_PACKET_UO_0, ROHC_PACKET_UO_1* and ROHC_PACKET_UOR_2* in case of success
  • ROHC_PACKET_UNKNOWN in case of failure

◆ detect_ip_changes()

static void detect_ip_changes ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
struct rfc3095_ip_hdr_changes *const  changes 
)
static

Find the IP fields that changed between the profile and a new IP packet.

Parameters
contextThe compression context
header_infoThe header info stored in the profile
ipThe header of the new IP packet
[out]changesThe detected changes

◆ detect_ip_id_behaviour()

static void detect_ip_id_behaviour ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  uncomp_pkt_ip_hdr 
)
static

Detect the behaviour of the IP-ID field of the given IPv4 header.

Detect how the IP-ID field behave:

  • constant,
  • increase in Network Bit Order (NBO),
  • increase in Little Endian,
  • randomly.
Parameters
contextThe compression context
header_infoThe header info stored in the profile
uncomp_pkt_ip_hdrThe uncompressed IP header to encode

◆ detect_ip_id_behaviours()

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

Detect the behaviour of the IP-ID fields of the IPv4 headers.

Detect how the IP-ID fields behave:

  • constant (not handled yet),
  • increase in Network Bit Order (NBO),
  • increase in Little Endian,
  • randomly.
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode

◆ encode_uncomp_fields()

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

Encode uncompressed fields with the corresponding encoding scheme.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
Returns
true in case of success, false otherwise

◆ header_fields()

static int header_fields ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
const struct rfc3095_ip_hdr_changes *const  changes,
const int  I,
const ip_header_pos_t  ip_hdr_pos,
uint8_t *const  dest,
int  counter 
)
static

Build inner or outer IP header fields.

This function is used to code the IP header fields of the extension 3 of the UO-2 packet. The function is called twice (one for inner IP header and one for outer IP header) with different arguments.

See also
code_EXT3_packet
    +-----+-----+-----+-----+-----+-----+-----+-----+
 1  |         Type of Service/Traffic Class         |  if TOS = 1
     ..... ..... ..... ..... ..... ..... ..... .....
 2  |         Time to Live/Hop Limit                |  if TTL = 1
     ..... ..... ..... ..... ..... ..... ..... .....
 3  |         Protocol/Next Header                  |  if PR = 1
     ..... ..... ..... ..... ..... ..... ..... .....
 4  /         IP extension headers                  /  variable, if IPX = 1
     ..... ..... ..... ..... ..... ..... ..... .....

 For outer IP-ID:
     ..... ..... ..... ..... ..... ..... ..... .....
 5  |                  IP-ID                        |  2 octets,
     ..... ..... ..... ..... ..... ..... ..... .....    if I2 = 1

Part 4 is not supported.

Parameters
contextThe compression context
header_infoThe header info stored in the profile
ipOne inner or outer IP header
changesThe IP fields that changed
IThe I flag of the IP header
ip_hdr_posThe position of the IP header
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer
See also
changed_fields

◆ header_flags()

static int header_flags ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
const struct rfc3095_ip_hdr_changes *const  changes,
const int  ip2_or_I2,
uint8_t *const  dest,
int  counter 
)
static

Build inner or outer IP header flags.

This function is used to code the IP header fields of the extension 3 of the UO-2 packet. The function is called twice (one for inner IP header and one for outer IP header) with different arguments.

See also
code_EXT3_packet
 Header flags for IP and UDP profiles (5.11.4):

 For inner flags:

    +-----+-----+-----+-----+-----+-----+-----+-----+
 1  |            Inner IP header flags        |     |  if ip = 1
    | TOS | TTL | DF  | PR  | IPX | NBO | RND | ip2 |  ip2 = 0 if non-RTP
    +-----+-----+-----+-----+-----+-----+-----+-----+

 or for outer flags:

    +-----+-----+-----+-----+-----+-----+-----+-----+
 2  |            Outer IP header flags              |
    | TOS2| TTL2| DF2 | PR2 |IPX2 |NBO2 |RND2 |  I2 |  if ip2 = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
Parameters
contextThe compression context
header_infoThe header info stored in the profile
ipOne inner or outer IP header
changesThe IP fields that changed
ip2_or_I2Whether the ip2 (inner, RTP only) or I2 (outer) flag is set or not
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer
See also
changed_fields

◆ ip_header_info_free()

static void ip_header_info_free ( struct ip_header_info *const  header_info)
static

Reset the given IP header info.

Parameters
header_infoThe IP header info to reset

◆ ip_header_info_new()

static bool ip_header_info_new ( struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
const size_t  oa_repetitions_nr,
const int  profile_id,
rohc_trace_callback2_t  trace_cb,
void *const  trace_cb_priv 
)
static

Initialize the IP header info stored in the context.

Parameters
header_infoThe IP header info to initialize
ipThe IP header
oa_repetitions_nrThe number of repetitions for Optimistic Approach
profile_idThe ID of the associated compression profile
trace_cbThe function to call for printing traces
trace_cb_privAn optional private context, may be NULL
Returns
true if successful, false otherwise

◆ rohc_code_dynamic_ip_part()

static int rohc_code_dynamic_ip_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const bool  ext_list_changed,
const struct rohc_pkt_ip_hdr *const  ip,
uint8_t *const  dest,
int  counter 
)
static

Build the dynamic part of one IP header for the IR/IR-DYN packets.

Parameters
contextThe compression context
header_infoThe IP header info stored in the profile
ext_list_changedWhether extension header list changed
ipThe IP header the dynamic part is built for
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer, -1 in case of error

◆ rohc_code_dynamic_part()

static int rohc_code_dynamic_part ( const struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
int  counter 
)
static

Build the dynamic part of the IR and IR-DYN packets.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
rohc_pktThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ rohc_code_static_ip_part()

static int rohc_code_static_ip_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct rohc_pkt_ip_hdr *const  ip,
uint8_t *const  dest,
int  counter 
)
static

Build the static part of one IP header for the IR packet.

Parameters
contextThe compression context
header_infoThe IP header info stored in the profile
ipThe IP header the static part is built for
destThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ rohc_code_static_part()

static int rohc_code_static_part ( const struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
int  counter 
)
static

Build the static part of the IR packet.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
rohc_pktThe ROHC buffer
counterThe current position in the ROHC buffer
Returns
The new position in the ROHC buffer

◆ rohc_comp_rfc3095_build_uo1_pkt()

static int rohc_comp_rfc3095_build_uo1_pkt ( 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

Build the UO-1 packet for the non-RTP profiles.

The UO-1 packet type cannot be used if there is no IPv4 header in the context or if value(RND) and value(RND2) are both 1.

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :
    +---+---+---+---+---+---+---+---+
 2  |   first octet of base header  |
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /
    :                               :
    +---+---+---+---+---+---+---+---+

 UO-1 (5.11.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   0 |         IP-ID         |
    +===+===+===+===+===+===+===+===+
 4  |        SN         |    CRC    |
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
[out]rohc_pktThe ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ rohc_comp_rfc3095_build_uo1id_pkt()

static int rohc_comp_rfc3095_build_uo1id_pkt ( 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

Build the UO-1-ID packet.

The UO-1-ID packet type cannot be used if there is no IPv4 header in the context or if value(RND) and value(RND2) are both 1.

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :
    +---+---+---+---+---+---+---+---+
 2  |   first octet of base header  |
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /
    :                               :
    +---+---+---+---+---+---+---+---+

 UO-1-ID (5.7.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   0 |T=0|      IP-ID        |
    +===+===+===+===+===+===+===+===+
 4  | X |      SN       |    CRC    |
    +---+---+---+---+---+---+---+---+

 X: X = 0 indicates that no extension is present;
    X = 1 indicates that an extension is present.

 T: T = 0 indicates format UO-1-ID;
    T = 1 indicates format UO-1-TS.
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
[out]rohc_pktThe ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ rohc_comp_rfc3095_build_uo1rtp_pkt()

static int rohc_comp_rfc3095_build_uo1rtp_pkt ( 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

Build the UO-1 packet for the RTP profiles.

The UO-1 packet type cannot be used if there is no IPv4 header in the context or if value(RND) and value(RND2) are both 1.

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :
    +---+---+---+---+---+---+---+---+
 2  |   first octet of base header  |
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /
    :                               :
    +---+---+---+---+---+---+---+---+

 UO-1 (5.7.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   0 |          TS           |
    +===+===+===+===+===+===+===+===+
 4  | M |      SN       |    CRC    |
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
[out]rohc_pktThe ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ rohc_comp_rfc3095_build_uo1ts_pkt()

static int rohc_comp_rfc3095_build_uo1ts_pkt ( 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

Build the UO-1-TS packet.

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :
    +---+---+---+---+---+---+---+---+
 2  |   first octet of base header  |
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /
    :                               :
    +---+---+---+---+---+---+---+---+

 UO-1-TS (5.7.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   0 |T=1|        TS         |
    +===+===+===+===+===+===+===+===+
 4  | M |      SN       |    CRC    |
    +---+---+---+---+---+---+---+---+

 T: T = 0 indicates format UO-1-ID;
    T = 1 indicates format UO-1-TS.
Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
[out]rohc_pktThe ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeThe type of ROHC packet that is created
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ rohc_comp_rfc3095_create()

bool rohc_comp_rfc3095_create ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)

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

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

◆ rohc_comp_rfc3095_destroy()

void rohc_comp_rfc3095_destroy ( struct rohc_comp_ctxt *const  context)

Destroy the context.

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

Parameters
contextThe compression context

◆ rohc_comp_rfc3095_detect_changes()

static void rohc_comp_rfc3095_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 encode

◆ rohc_comp_rfc3095_encode()

int rohc_comp_rfc3095_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 IP packet according to a pattern decided by several different factors.

  1. parse uncompressed packet (done in rohc_compress4)
  2. detect changes between the new uncompressed packet and the context
  3. decide new compressor state
  4. determine how many bytes are required for every field
  5. decide which packet to send
  6. code the ROHC header
  7. copy the packet payload (done in rohc_compress4)
  8. update the context with the new headers

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

bool rohc_comp_rfc3095_feedback ( struct rohc_comp_ctxt *const  context,
const enum rohc_feedback_type  feedback_type,
const uint8_t *const  packet,
const size_t  packet_len,
const uint8_t *const  feedback_data,
const size_t  feedback_data_len 
)

Update the profile when feedback is received.

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

Parameters
contextThe compression context
feedback_typeThe feedback type
packetThe whole feedback packet with CID bits
packet_lenThe length of the whole feedback packet with CID bits
feedback_dataThe feedback data without the CID bits
feedback_data_lenThe length of the feedback data without the CID bits
Returns
true if the feedback was successfully handled, false if the feedback could not be taken into account

◆ rohc_comp_rfc3095_feedback_2()

static bool rohc_comp_rfc3095_feedback_2 ( struct rohc_comp_ctxt *const  context,
const uint8_t *const  packet,
const size_t  packet_len,
const uint8_t *const  feedback_data,
const size_t  feedback_data_len 
)
static

Update the profile when FEEDBACK-2 is received.

Parameters
contextThe compression context
packetThe whole feedback packet with CID bits
packet_lenThe length of the whole feedback packet with CID bits
feedback_dataThe feedback data without the CID bits
feedback_data_lenThe length of the feedback data without the CID bits
Returns
true if the feedback was successfully handled, false if the feedback could not be taken into account

◆ rohc_comp_rfc3095_feedback_ack()

static void rohc_comp_rfc3095_feedback_ack ( struct rohc_comp_ctxt *const  context,
const uint32_t  sn_bits,
const size_t  sn_bits_nr,
const bool  sn_not_valid 
)
static

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

Parameters
contextThe compression context that received a positive ACK
sn_bitsThe LSB bits of the acknowledged SN
sn_bits_nrThe number of LSB bits of the acknowledged SN
sn_not_validWhether the received SN may be considered as valid or not

◆ rohc_comp_rfc3095_get_ext3_I_flags()

static void rohc_comp_rfc3095_get_ext3_I_flags ( const struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
const rohc_packet_t  packet_type,
ip_header_pos_t *const  innermost_ipv4_non_rnd,
uint8_t *const  I,
uint8_t *const  I2 
)
static

Determine the values of the I and I2 flags for UO* extension 3.

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to encode
packet_typeThe type of packet that is being built
[out]innermost_ipv4_non_rndThe position of the innermost IPv4 header with a non-random IP-ID field
[out]IThe value of the I flag in UO extension 3, ie. whether the innermost IPv4 header with a non-random IP-ID needs to transmit some IP-ID bits
[out]I2The value of the I2 flag in UO extension 3, ie. whether the 2nd innermost IPv4 header with a non-random IP-ID needs to transmit some IP-ID bits

◆ rohc_get_innermost_ipv4_non_rnd()

static void rohc_get_innermost_ipv4_non_rnd ( const struct rohc_comp_ctxt *const  context,
ip_header_pos_t *const  pos,
bool *const  is_5bits_possible,
uint16_t *const  offset 
)
static

Determine the number of IP-ID bits and the IP-ID offset of the innermost IPv4 header with non-random IP-ID.

Parameters
contextThe compression context
[out]posThe position of the innermost IP header
[out]is_5bits_possibleWhether the innermost IP-ID may be encoded on 5 bits
[out]offsetThe IP-ID offset of the innermost IP header

◆ rohc_get_ipid_bits()

void rohc_get_ipid_bits ( const struct rohc_comp_ctxt *const  context,
bool *const  innermost_ip_id_changed,
bool *const  innermost_ip_id_3bits_possible,
bool *const  innermost_ip_id_5bits_possible,
bool *const  innermost_ip_id_8bits_possible,
bool *const  innermost_ip_id_11bits_possible,
bool *const  outermost_ip_id_changed,
bool *const  outermost_ip_id_11bits_possible 
)

Get the number of non-random outer/inner IP-ID bits.

Parameters
contextThe compression context
[out]innermost_ip_id_changedWhether the innermost IP-ID changed
[out]innermost_ip_id_3bits_possibleWhether the innermost IP-ID may be encoded on 3 bits
[out]innermost_ip_id_5bits_possibleWhether the innermost IP-ID may be encoded on 5 bits
[out]innermost_ip_id_8bits_possibleWhether the innermost IP-ID may be encoded on 8 bits
[out]innermost_ip_id_11bits_possibleWhether the innermost IP-ID may be encoded on 11 bits
[out]outermost_ip_id_changedWhether the outermost IP-ID changed
[out]outermost_ip_id_11bits_possibleWhether the outermost IP-ID may be encoded on 11 bits

◆ rtp_header_flags_and_fields()

static int rtp_header_flags_and_fields ( const struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  dest,
int  counter 
)
static

◆ update_context()

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

Update the compression context with the successfully compressed packet.

Parameters
contextThe compression context to update
uncomp_pkt_hdrsThe uncompressed headers to encode

◆ update_context_ip_hdr()

static void update_context_ip_hdr ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  ip_flags,
const struct rohc_pkt_ip_hdr *const  ip 
)
static

Update the IP information with the IP header.

Parameters
contextThe compression context
ip_flagsThe IP context to update
ipThe uncompressed IP header that updates the context