ROHC compression/decompression library
Defines | Functions
c_generic.c File Reference

ROHC generic compression context for IP-only, UDP, UDP-Lite, ESP, and RTP profiles. More...

#include "c_generic.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 "schemes/cid.h"
#include "schemes/list_ipv6.h"
#include "sdvl.h"
#include "crc.h"
#include <string.h>
#include <assert.h>
#include "config.h"
Include dependency graph for c_generic.c:

Defines

#define MOD_TOS   0x0001
#define MOD_TTL   0x0010
#define MOD_PROTOCOL   0x0020
#define MOD_IPV6_EXT_LIST_STRUCT   0x0002
#define MOD_IPV6_EXT_LIST_CONTENT   0x0004
#define MOD_ERROR   0x0008

Functions

static bool ip_header_info_new (struct ip_header_info *const header_info, const struct ip_packet *const ip, const size_t list_trans_nr, const size_t wlsb_window_width, rohc_trace_callback_t trace_cb, rohc_trace_callback2_t trace_cb2, void *const trace_cb_priv, const int profile_id)
 Initialize the IP header info stored in the context.
static void ip_header_info_free (struct ip_header_info *const header_info)
 Reset the given IP header info.
static void c_init_tmp_variables (struct generic_tmp_vars *const tmp_vars)
 Initialize all temporary variables stored in the context.
static void change_mode (struct rohc_comp_ctxt *const context, const rohc_mode_t new_mode)
 Change the mode of the context.
static rohc_packet_t decide_packet (const struct rohc_comp_ctxt *const context)
 Decide which packet to send when in the different states.
static int code_packet (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len)
 Build the ROHC packet to send.
static int code_IR_packet (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len)
 Build the IR packet.
static int code_IR_DYN_packet (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len)
 Build the IR-DYN packet.
static int rohc_code_static_part (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, int counter)
 Build the static part of the IR packet.
static int rohc_code_static_ip_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct ip_packet *const ip, unsigned char *const dest, int counter)
 Build the static part of one IP header for the IR packet.
static int code_ipv4_static_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct ip_packet *const ip, unsigned char *const dest, int counter)
 Build the IPv4 static part of the IR packet.
static int code_ipv6_static_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct ip_packet *const ip, unsigned char *const dest, int counter)
 Build the IPv6 static part of the IR packet.
static int rohc_code_dynamic_part (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, int counter)
 Build the dynamic part of the IR and IR-DYN packets.
static int rohc_code_dynamic_ip_part (const struct rohc_comp_ctxt *const context, const unsigned int hdr_pos, struct ip_header_info *const header_info, const struct ip_packet *const ip, unsigned char *const dest, int counter)
 Build the dynamic part of one IP header for the IR/IR-DYN packets.
static int code_ipv4_dynamic_part (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct ip_packet *const ip, unsigned char *const dest, int counter)
 Build the IPv4 dynamic part of the IR and IR-DYN packets.
static int code_ipv6_dynamic_part (const struct rohc_comp_ctxt *const context, const unsigned int hdr_pos, struct ip_header_info *const header_info, const struct ip_packet *const ip, unsigned char *const dest, int counter)
 Build the IPv6 dynamic part of the IR and IR-DYN packets.
static int code_uo_remainder (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const dest, int counter)
 Build the tail of the UO packet.
static int code_UO0_packet (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len)
 Build the UO-0 packet.
static int code_UO1_packet (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len)
 Build the UO-1 packet.
static int code_UO2_packet (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len)
 Build the UO-2 packet.
static int code_UOR2_bytes (const struct rohc_comp_ctxt *const context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte)
 Code some fields of the UOR-2 packet.
static int code_UOR2_RTP_bytes (const struct rohc_comp_ctxt *const context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte)
 Code some fields of the UOR-2-RTP packet.
static int code_UOR2_TS_bytes (const struct rohc_comp_ctxt *const context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte)
 Code some fields of the UOR-2-TS packet.
static int code_UOR2_ID_bytes (const struct rohc_comp_ctxt *const context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte)
 Code some fields of the UOR-2-ID packet.
static int code_EXT0_packet (const struct rohc_comp_ctxt *const context, unsigned char *const dest, int counter)
 Build the extension 0 of the UO-2 packet.
static int code_EXT1_packet (const struct rohc_comp_ctxt *const context, unsigned char *const dest, int counter)
 Build the extension 1 of the UO-2 packet.
static int code_EXT2_packet (const struct rohc_comp_ctxt *const context, unsigned char *const dest, int counter)
 Build the extension 2 of the UO-2 packet.
static int code_EXT3_packet (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const dest, int counter)
 Build the extension 3 of the UO-2 packet.
static int rtp_header_flags_and_fields (const struct rohc_comp_ctxt *const context, const struct ip_packet *const ip, unsigned char *const dest, int counter)
static int header_flags (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const unsigned short changed_f, const struct ip_packet *const ip, const int ip2_or_I2, unsigned char *const dest, int counter)
 Build inner or outer IP header flags.
static int header_fields (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const unsigned short changed_f, const struct ip_packet *const ip, const int I, const ip_header_pos_t ip_hdr_pos, unsigned char *const dest, int counter)
 Build inner or outer IP header fields.
static uint8_t compute_uo_crc (const struct c_generic_context *g_context, const struct net_pkt *const uncomp_pkt, const rohc_crc_type_t crc_type, const uint8_t crc_init, const unsigned char *const crc_table)
 Compute the CRC for a UO* packet.
static void periodic_down_transition (struct rohc_comp_ctxt *const context)
 Periodically change the context state after a certain number of packets.
static void update_context (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Update the compression context with the successfully compressed packet.
static void update_context_ip_hdr (struct ip_header_info *const ip_flags, const struct ip_packet *const ip)
 Update the IP information with the IP header.
static bool c_generic_detect_changes (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Detect changes between packet and context.
static int changed_static_both_hdr (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Check if the static parts of the context changed in any of the two IP headers.
static int changed_static_one_hdr (const struct rohc_comp_ctxt *const context, const unsigned short changed_fields, struct ip_header_info *const header_info)
 Check if the static part of the context changed in the new IP packet.
static int changed_dynamic_both_hdr (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Check if the dynamic parts of the context changed in any of the two IP headers.
static int changed_dynamic_one_hdr (const struct rohc_comp_ctxt *const context, const unsigned short changed_fields, struct ip_header_info *const header_info, const struct ip_packet *const ip)
 Check if the dynamic part of the context changed in the IP packet.
static unsigned short detect_changed_fields (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info,const struct ip_packet *const ip)
 Find the IP fields that changed between the profile and a new IP packet.
static bool is_field_changed (const unsigned short changed_fields, const unsigned short check_field)
 Check if a specified IP field has changed.
static void detect_ip_id_behaviours (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Detect the behaviour of the IP-ID fields of the IPv4 headers.
static void detect_ip_id_behaviour (const struct rohc_comp_ctxt *const context, struct ip_header_info *const header_info, const struct ip_packet *const ip)
 Detect the behaviour of the IP-ID field of the given IPv4 header.
static bool is_ip_id_increasing (const uint16_t old_id, const uint16_t new_id)
 Whether the new IP-ID is increasing.
static bool encode_uncomp_fields (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Encode uncompressed fields with the corresponding encoding scheme.
static void rohc_get_innermost_ipv4_non_rnd (const struct rohc_comp_ctxt *const context, ip_header_pos_t *const pos, size_t *const nr_bits, 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.
static bool c_generic_feedback_2 (struct rohc_comp_ctxt *const context, const struct c_feedback *const feedback)
 Update the profile when FEEDBACK-2 is received.
bool c_generic_create (struct rohc_comp_ctxt *const context, const rohc_lsb_shift_t sn_shift, const struct net_pkt *const packet)
 Create a new context and initialize it thanks to the given IP packet.
void c_generic_destroy (struct rohc_comp_ctxt *const context)
 Destroy the context.
bool c_generic_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to an IP-based profile.
void change_state (struct rohc_comp_ctxt *const context, const rohc_comp_state_t new_state)
 Change the state of the context.
int c_generic_encode (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset)
 Encode an IP packet according to a pattern decided by several different factors.
bool c_generic_reinit_context (struct rohc_comp_ctxt *const context)
 Re-initialize the given context.
bool c_generic_feedback (struct rohc_comp_ctxt *const context, const struct c_feedback *const feedback)
 Update the profile when feedback is received.
bool c_generic_use_udp_port (const struct rohc_comp_ctxt *const context, const unsigned int port)
 Whether the profile uses the given UDP port.
void decide_state (struct rohc_comp_ctxt *const context)
 Decide the state that should be used for the next packet.
rohc_ext_t decide_extension (const struct rohc_comp_ctxt *const context)
 Decide what extension shall be used in the UO-1-ID/UOR-2 packet.
void rohc_get_ipid_bits (const struct rohc_comp_ctxt *const context, size_t *const nr_innermost_bits, size_t *const nr_outermost_bits)
 Get the number of non-random outer/inner IP-ID bits.

Detailed Description

ROHC generic compression context for IP-only, UDP, UDP-Lite, ESP, and RTP profiles.

Author:
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
Didier Barvaux <didier@barvaux.org>
David Moreau from TAS
Emmanuelle Pechereau <epechereau@toulouse.viveris.com>

Define Documentation

#define MOD_ERROR   0x0008

A flag to indicate that an errror occurred

#define MOD_IPV6_EXT_LIST_CONTENT   0x0004

A flag to indicate that the content of the IPv6 extension headers list changed in IP header

#define MOD_IPV6_EXT_LIST_STRUCT   0x0002

A flag to indicate that the structure of the IPv6 extension headers list changed in IP header

#define MOD_PROTOCOL   0x0020

A flag to indicate that the IPv4 Protocol field changed in IP header

#define MOD_TOS   0x0001

A flag to indicate that IPv4 Type Of Service field changed in IP header

#define MOD_TTL   0x0010

A flag to indicate that IPv4 Time To Live field changed in IP header


Function Documentation

bool c_generic_check_profile ( const struct rohc_comp *const  comp,
const struct net_pkt *const  packet 
)

Check if the given packet corresponds to an IP-based profile.

Conditions are:

  • the version of the outer IP header is 4 or 6
  • if the outer IP header is IPv4, it does not contain options
  • the outer IP header is not an IP fragment
  • if there are at least 2 IP headers, the version of the inner IP header is 4 or 6
  • if there are at least 2 IP headers and if the inner IP header is IPv4, it does not contain options
  • if there are at least 2 IP headers, the inner IP header is not an IP fragment

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

Parameters:
compThe ROHC compressor
packetThe packet to check
Returns:
Whether the IP packet corresponds to the profile:
  • true if the IP packet corresponds to the profile,
  • false if the IP packet does not correspond to the profile
bool c_generic_create ( struct rohc_comp_ctxt *const  context,
const rohc_lsb_shift_t  sn_shift,
const struct net_pkt *const  packet 
)

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

Parameters:
contextThe compression context
sn_shiftThe shift parameter (p) to use for encoding SN with W-LSB
packetThe packet given to initialize the new context
Returns:
bool if successful, false otherwise
void c_generic_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
static bool c_generic_detect_changes ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Detect changes between packet and context.

Parameters:
contextThe compression context to compare
uncomp_pktThe uncompressed packet to compare
Returns:
true if changes were successfully detected, false if a problem occurred
int c_generic_encode ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type,
size_t *const  payload_offset 
)

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

1. parse uncompressed packet (done in rohc_compress3)
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_compress3)
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_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeOUT: The type of ROHC packet that is created
payload_offsetOUT: The offset for the payload in the IP packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
bool c_generic_feedback ( struct rohc_comp_ctxt *const  context,
const struct c_feedback *const  feedback 
)

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
feedbackThe feedback information
Returns:
true if the feedback was successfully handled, false if the feedback could not be taken into account
static bool c_generic_feedback_2 ( struct rohc_comp_ctxt *const  context,
const struct c_feedback *const  feedback 
) [static]

Update the profile when FEEDBACK-2 is received.

Parameters:
contextThe compression context
feedbackThe feedback information
Returns:
true if the feedback was successfully handled, false if the feedback could not be taken into account
bool c_generic_reinit_context ( struct rohc_comp_ctxt *const  context)

Re-initialize the given context.

Make the context restart its initialization with decompressor, ie. it goes in the lowest compression state.

Parameters:
contextThe compression context to re-initialize
Returns:
true in case of success, false otherwise
bool c_generic_use_udp_port ( const struct rohc_comp_ctxt *const  context,
const unsigned int  port 
)

Whether the profile uses the given UDP port.

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

Parameters:
contextThe compression context
portThe UDP port number to check
Returns:
always return true, it is used by non-RTP profiles
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
static void change_mode ( struct rohc_comp_ctxt *const  context,
const rohc_mode_t  new_mode 
) [static]

Change the mode of the context.

Parameters:
contextThe compression context
new_modeThe new mode the context must enter in
void change_state ( struct rohc_comp_ctxt *const  context,
const rohc_comp_state_t  new_state 
)

Change the state of the context.

Parameters:
contextThe compression context
new_stateThe new state the context must enter in
static int changed_dynamic_both_hdr ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Check if the dynamic parts of the context changed in any of the two IP headers.

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet
Returns:
The number of dynamic fields that changed
static int changed_dynamic_one_hdr ( const struct rohc_comp_ctxt *const  context,
const unsigned short  changed_fields,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip 
) [static]

Check if the dynamic part of the context changed in the IP packet.

The fields classified as CHANGING by RFC need to be checked for change. The fields are:

  • the TOS, IP-ID and TTL fields for IPv4,
  • the TC and HL fields for IPv6.

The IP-ID changes are managed outside of this function.

Althought classified as STATIC, the IPv4 Don't Fragment flag is not part of the static initialization, but of the dynamic initialization. It needs to be checked for change.

Other flags are checked for change for IPv4. There are IP-ID related flags:

  • RND: is the IP-ID random?
  • NBO: is the IP-ID in Network Byte Order?
  • SID: is the IP-ID static?
Parameters:
contextThe compression context
changed_fieldsThe fields that changed, created by the function changed_fields
header_infoThe header info stored in the profile
ipThe header of the new IP packet
Returns:
The number of fields that changed
static int changed_static_both_hdr ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Check if the static parts of the context changed in any of the two IP headers.

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet
Returns:
The number of static fields that changed
static int changed_static_one_hdr ( const struct rohc_comp_ctxt *const  context,
const unsigned short  changed_fields,
struct ip_header_info *const  header_info 
) [static]

Check if the static part of the context changed in the new IP packet.

The fields classified as STATIC-DEF by RFC do not need to be checked for change. These fields are constant for all packets in a stream (ie. a profile context). So, the Source Address and Destination Address fields are not checked for change for both IPv4 and IPv6. The Flow Label is not checked for IPv6.

Althought not classified as STATIC-DEF, the Version field is the same for all packets in a stream (ie. a profile context) and therefore does not need to be checked for change neither for IPv4 nor IPv6.

Althought classified as STATIC, the IPv4 Don't Fragment flag is not part of the static initialization, but of the dynamic initialization.

Summary:

  • For IPv4, check the Protocol field for change.
  • For IPv6, check the Next Header field for change.
Parameters:
contextThe compression context
changed_fieldsThe fields that changed, created by the function changed_fields
header_infoThe header info stored in the profile
Returns:
The number of fields that changed
static int code_EXT0_packet ( const struct rohc_comp_ctxt *const  context,
unsigned char *const  dest,
int  counter 
) [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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer if successful, -1 otherwise
static int code_EXT1_packet ( const struct rohc_comp_ctxt *const  context,
unsigned char *const  dest,
int  counter 
) [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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer if successful, -1 otherwise
static int code_EXT2_packet ( const struct rohc_comp_ctxt *const  context,
unsigned char *const  dest,
int  counter 
) [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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer if successful, -1 otherwise
static int code_EXT3_packet ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  dest,
int  counter 
) [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
    +-----+-----+-----+-----+-----+-----+-----+-----+

 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
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
4.1 /                      TS                       / 1-4 octets, if R-TS = 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
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |  variable,
 8  /          RTP Header flags and fields          /  if rtp = 1
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet to encode
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer if successful, -1 otherwise
static int code_ipv4_dynamic_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
unsigned char *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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static int code_ipv4_static_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
unsigned char *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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static int code_ipv6_dynamic_part ( const struct rohc_comp_ctxt *const  context,
const unsigned int  hdr_pos,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
unsigned char *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
hdr_posThe position of the IP header: 1 for the outer header or 2 for the inner IP header
header_infoThe IP header info stored in the profile
ipThe IPv6 header the dynamic part is built for
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer, -1 in case of error
static int code_ipv6_static_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
unsigned char *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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static int code_IR_DYN_packet ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
) [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_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int code_IR_packet ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
) [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_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
int code_packet ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
) [static]

Build the ROHC packet to send.

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
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int code_UO0_packet ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
) [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_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int code_UO1_packet ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
) [static]

Build the UO-1 packet.

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

Todo:
Handle extension (X bit) for UO-1-ID 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 (5.11.3):

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

 UO-1-RTP (5.7.3):

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

 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    |
    +---+---+---+---+---+---+---+---+

 UO-1-TS (5.7.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 2  | 1   0 |T=1|        TS         |
    +===+===+===+===+===+===+===+===+
 4  | M |      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_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int code_UO2_packet ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len 
) [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_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int code_uo_remainder ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *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_pktThe uncompressed packet to encode
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static int code_UOR2_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_ext_t  extension,
unsigned char *const  f_byte,
unsigned char *const  s_byte,
unsigned char *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
extensionThe extension that will be appended to the packet
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
static int code_UOR2_ID_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_ext_t  extension,
unsigned char *const  f_byte,
unsigned char *const  s_byte,
unsigned char *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
extensionThe extension that will be appended to the packet
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
static int code_UOR2_RTP_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_ext_t  extension,
unsigned char *const  f_byte,
unsigned char *const  s_byte,
unsigned char *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
extensionThe extension that will be appended to the packet
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
static int code_UOR2_TS_bytes ( const struct rohc_comp_ctxt *const  context,
const rohc_ext_t  extension,
unsigned char *const  f_byte,
unsigned char *const  s_byte,
unsigned char *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
extensionThe extension that will be appended to the packet
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
static uint8_t compute_uo_crc ( const struct c_generic_context g_context,
const struct net_pkt *const  uncomp_pkt,
const rohc_crc_type_t  crc_type,
const uint8_t  crc_init,
const unsigned char *const  crc_table 
) [static]

Compute the CRC for a UO* packet.

Parameters:
g_contextThe generic compression context
uncomp_pktThe uncompressed packet to encode
crc_typeThe type of CRC to compute
crc_initThe initial value of the CRC
crc_tableThe table of pre-computed CRC
Returns:
The computed CRC
rohc_ext_t decide_extension ( const struct rohc_comp_ctxt *const  context)

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
Returns:
The extension code among ROHC_EXT_NONE, ROHC_EXT_0, ROHC_EXT_1 and ROHC_EXT_3 if successful, ROHC_EXT_UNKNOWN otherwise
static rohc_packet_t decide_packet ( const 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
void decide_state ( struct rohc_comp_ctxt *const  context)

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

The three states are:

  • Initialization and Refresh (IR),
  • First Order (FO),
  • Second Order (SO).
Parameters:
contextThe compression context
static unsigned short detect_changed_fields ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip 
) [static]

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

Only some fields are checked for change in the compression process, so only check these ones to avoid useless work. The fields to check are: TOS/TC, TTL/HL and Protocol/Next Header.

Parameters:
contextThe compression context
header_infoThe header info stored in the profile
ipThe header of the new IP packet
Returns:
The bitpattern that indicates which field changed
static void detect_ip_id_behaviour ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip 
) [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
ipOne IPv4 header
static void detect_ip_id_behaviours ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [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_pktThe uncompressed packet
static bool encode_uncomp_fields ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Encode uncompressed fields with the corresponding encoding scheme.

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet to encode
Returns:
true in case of success, false otherwise
static int header_fields ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const unsigned short  changed_f,
const struct ip_packet *const  ip,
const int  I,
const ip_header_pos_t  ip_hdr_pos,
unsigned char *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
changed_fThe fields that changed, created by the function changed_fields
ipOne inner or outer IP header
IThe I flag of the IP header
ip_hdr_posThe position of the IP header
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
See also:
changed_fields
static int header_flags ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const unsigned short  changed_f,
const struct ip_packet *const  ip,
const int  ip2_or_I2,
unsigned char *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
changed_fThe fields that changed, created by the function changed_fields
ipOne inner or outer IP header
ip2_or_I2Whether the ip2 (inner, RTP only) or I2 (outer) flag is set or not
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
See also:
changed_fields
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
static bool ip_header_info_new ( struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
const size_t  list_trans_nr,
const size_t  wlsb_window_width,
rohc_trace_callback_t  trace_cb,
rohc_trace_callback2_t  trace_cb2,
void *const  trace_cb_priv,
const int  profile_id 
) [static]

Initialize the IP header info stored in the context.

Parameters:
header_infoThe IP header info to initialize
ipThe IP header
list_trans_nrThe number of uncompressed transmissions for list compression (L)
wlsb_window_widthThe width of the W-LSB sliding window for IPv4 IP-ID (must be > 0)
trace_cbThe old function to call for printing traces
trace_cb2The new function to call for printing traces
trace_cb_privAn optional private context, may be NULL
profile_idThe ID of the associated compression profile
Returns:
true if successful, false otherwise
static bool is_field_changed ( const unsigned short  changed_fields,
const unsigned short  check_field 
) [static]

Check if a specified IP field has changed.

Parameters:
changed_fieldsThe fields that changed, created by the function changed_fields
check_fieldThe field for which to check a change
Returns:
1 if the field changed, 0 if not
See also:
changed_fields
static bool is_ip_id_increasing ( const uint16_t  old_id,
const uint16_t  new_id 
) [static]

Whether the new IP-ID is increasing.

The new IP-ID is considered as increasing if the new value is greater by a small delta then the previous IP-ID. Wraparound shall be taken into account.

Parameters:
old_idThe IP-ID of the previous IPv4 header
new_idThe IP-ID of the current IPv4 header
Returns:
Whether the IP-ID is increasing
static void periodic_down_transition ( struct rohc_comp_ctxt *const  context) [static]

Periodically change the context state after a certain number of packets.

Parameters:
contextThe compression context
static int rohc_code_dynamic_ip_part ( const struct rohc_comp_ctxt *const  context,
const unsigned int  hdr_pos,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
unsigned char *const  dest,
int  counter 
) [static]

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

Parameters:
contextThe compression context
hdr_posThe position of the IP header: 1 for the outer header or 2 for the inner IP header
header_infoThe IP header info stored in the profile
ipThe IP header the dynamic part is built for
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer, -1 in case of error
static int rohc_code_dynamic_part ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
int  counter 
) [static]

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

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet to encode
rohc_pktThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static int rohc_code_static_ip_part ( const struct rohc_comp_ctxt *const  context,
struct ip_header_info *const  header_info,
const struct ip_packet *const  ip,
unsigned char *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-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static int rohc_code_static_part ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
int  counter 
) [static]

Build the static part of the IR packet.

Parameters:
contextThe compression context
uncomp_pktThe uncompressed packet to encode
rohc_pktThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns:
The new position in the rohc-packet-under-build buffer
static void rohc_get_innermost_ipv4_non_rnd ( const struct rohc_comp_ctxt *const  context,
ip_header_pos_t *const  pos,
size_t *const  nr_bits,
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
posOUT: The position of the header
nr_bitsOUT: the number of IP-ID bits of the found header
offsetOUT: the IP-ID offset of the found header
void rohc_get_ipid_bits ( const struct rohc_comp_ctxt *const  context,
size_t *const  nr_innermost_bits,
size_t *const  nr_outermost_bits 
)

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

Parameters:
contextThe compression context
nr_innermost_bitsOUT: the maximum number of IP-ID bits for the innermost IPv4 header
nr_outermost_bitsOUT: the maximum number of IP-ID bits for the outermost IP header
static int rtp_header_flags_and_fields ( const struct rohc_comp_ctxt *const  context,
const struct ip_packet *const  ip,
unsigned char *const  dest,
int  counter 
) [static]
static void update_context ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
) [static]

Update the compression context with the successfully compressed packet.

Parameters:
contextThe compression context to update
uncomp_pktThe uncompressed packet that updates the context
static void update_context_ip_hdr ( struct ip_header_info *const  ip_flags,
const struct ip_packet *const  ip 
) [static]

Update the IP information with the IP header.

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