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

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

#include "c_generic.h"
#include "c_rtp.h"
#include "config.h"
#include "rohc_traces.h"
#include "rohc_debug.h"
#include "rohc_packets.h"
#include "rohc_bit_ops.h"
#include "rohc_utils.h"
#include "cid.h"
#include "sdvl.h"
#include "crc.h"
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <math.h>
#include <assert.h>
Include dependency graph for c_generic.c:

Defines

#define MOD_TOS   0x0001
#define MOD_TTL   0x0010
#define MOD_PROTOCOL   0x0020

Functions

int code_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest)
 Build the ROHC packet to send.
int code_IR_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest)
 Build the IR packet.
int code_IR_DYN_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest)
 Build the IR-DYN packet.
int code_generic_static_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter)
 Build the static part of the IR and IR-DYN packets.
int code_ipv4_static_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter)
 Build the IPv4 static part of the IR and IR-DYN packets.
int code_ipv6_static_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter)
 Build the IPv6 static part of the IR and IR-DYN packets.
int code_generic_dynamic_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter)
int code_ipv4_dynamic_part (const struct c_context *const context, struct ip_header_info *header_info, const struct ip_packet *ip, unsigned char *const dest, int counter)
 Build the IPv4 dynamic part of the IR and IR-DYN packets.
int code_ipv6_dynamic_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter)
 Build the IPv6 dynamic part of the IR and IR-DYN packets.
int code_UO_packet_tail (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest, int counter)
 Build the tail of the UO packet.
int code_UO0_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest)
 Build the UO-0 packet.
int code_UO1_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest)
 Build the UO-1 packet.
int code_UO2_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest)
 Build the UO-2 packet.
int code_UOR2_bytes (const struct c_context *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.
int code_UOR2_RTP_bytes (const struct c_context *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.
int code_UOR2_TS_bytes (const struct c_context *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.
int code_UOR2_ID_bytes (const struct c_context *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.
int code_EXT0_packet (const struct c_context *context, unsigned char *const dest, int counter)
 Build the extension 0 of the UO-2 packet.
int code_EXT1_packet (const struct c_context *context, unsigned char *const dest, int counter)
 Build the extension 1 of the UO-2 packet.
int code_EXT2_packet (const struct c_context *context, unsigned char *const dest, int counter)
 Build the extension 2 of the UO-2 packet.
int code_EXT3_packet (const struct c_context *context, const struct ip_packet *ip, const struct ip_packet *ip2, unsigned char *const dest, int counter)
 Build the extension 3 of the UO-2 packet.
unsigned char * get_ipv6_extension (const struct ip_packet *ip, const int index)
 Extract the Nth IP extension of the IP packet.
int ipv6_compare (const unsigned char *ext, const struct list_comp *comp, const int size, const int index_table)
 IPv6 extension comparison.
int get_index_ipv6_table (const struct ip_packet *ip, const int index)
 Return the based table index for the Nth IP extension of the IP packet.
int rtp_header_flags_and_fields (const struct c_context *context, const unsigned short changed_f, const struct ip_packet *ip, unsigned char *const dest, int counter)
int header_flags (const struct c_context *context, struct ip_header_info *const header_info, const unsigned short changed_f, const struct ip_packet *ip, const int is_outer, const size_t nr_ip_id_bits, unsigned char *const dest, int counter)
 Build inner or outer IP header flags.
int header_fields (const struct c_context *context, struct ip_header_info *const header_info, const unsigned short changed_f, const struct ip_packet *ip, const int is_outer, const size_t nr_ip_id_bits, unsigned char *const dest, int counter)
 Build inner or outer IP header fields.
int changed_static_both_hdr (const struct c_context *context, const struct ip_packet *ip, const struct ip_packet *ip2)
 Check if the static parts of the context changed in any of the two IP headers.
int changed_static_one_hdr (const unsigned short changed_fields, struct ip_header_info *const header_info, const struct ip_packet *ip, const struct c_context *context)
 Check if the static part of the context changed in the new IP packet.
int changed_dynamic_both_hdr (const struct c_context *context, const struct ip_packet *ip, const struct ip_packet *ip2)
 Check if the dynamic parts of the context changed in any of the two IP headers.
int changed_dynamic_one_hdr (const unsigned short changed_fields, struct ip_header_info *const header_info, const struct ip_packet *ip, const struct c_context *context)
 Check if the dynamic part of the context changed in the IP packet.
unsigned short changed_fields (const struct ip_header_info *header_info, const struct ip_packet *ip)
 Find the IP fields that changed between the profile and a new IP packet.
void check_ip_identification (struct ip_header_info *const header_info, const struct ip_packet *ip)
 Determine whether the IPv4 Identification field of one IPv4 header is random and/or in Network Bit Order (NBO).
int is_changed (const unsigned short changed_fields, const unsigned short check_field)
 Check if a specified IP field has changed.
void ip6_c_init_table (struct list_comp *const comp)
 Initialize the tables IPv6 extension in compressor.
int c_init_header_info (struct ip_header_info *header_info, const struct ip_packet *ip)
 Initialize the inner or outer IP header info stored in the context.
void c_init_tmp_variables (struct generic_tmp_vars *tmp_vars)
 Initialize all temporary variables stored in the context.
int c_generic_create (struct c_context *const context, const struct ip_packet *ip)
 Create a new context and initialize it thanks to the given IP packet.
void c_generic_destroy (struct c_context *const context)
 Destroy the context.
void change_mode (struct c_context *const context, const rohc_mode new_mode)
 Change the mode of the context.
void change_state (struct c_context *const context, const rohc_c_state new_state)
 Change the state of the context.
int c_generic_encode (struct c_context *const context, const struct ip_packet *ip, const int packet_size, unsigned char *const dest, const int dest_size, rohc_packet_t *const packet_type, int *const payload_offset)
 Encode an IP packet according to a pattern decided by several different factors.
int rohc_list_decide_ipv6_compression (struct list_comp *const comp, const struct ip_packet *const ip)
 Decide whether list of IPv6 extension headers shall be sent compressed.
int c_create_current_list (const int index, struct list_comp *const comp, const unsigned char *ext, const int index_table)
 Create the current list.
int rohc_list_decide_type (struct list_comp *const comp)
 Decide the encoding type for compression list.
int rohc_list_encode (struct list_comp *const comp, unsigned char *const dest, int counter, const int ps, const int size)
 Generic encoding of compressed list.
int rohc_list_encode_type_0 (struct list_comp *const comp, unsigned char *const dest, int counter, const int ps)
 Build encoding type 0 for list compression.
int rohc_list_encode_type_1 (struct list_comp *const comp, unsigned char *const dest, int counter, const int ps)
 Build encoding type 1 for list compression.
int rohc_list_encode_type_2 (struct list_comp *const comp, unsigned char *const dest, int counter, const int ps)
 Build encoding type 2 for list compression.
int rohc_list_encode_type_3 (struct list_comp *const comp, unsigned char *const dest, int counter, const int ps)
 Build encoding type 3 for list compression.
void c_generic_feedback (struct c_context *const context, const struct c_feedback *feedback)
 Update the profile when feedback arrives.
void periodic_down_transition (struct c_context *context)
 Periodically change the context state after a certain number of packets.
void decide_state (struct c_context *const context)
 Decide the state that should be used for the next packet.
int code_generic_dynamic_part (const struct c_context *context, struct ip_header_info *const header_info, const const struct ip_packet *ip, unsigned char *const dest, int counter)
 Build the dynamic part of the IR and IR-DYN packets.

Detailed Description

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

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

Define Documentation

#define MOD_PROTOCOL   0x0020

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

Referenced by changed_fields(), changed_static_one_hdr(), header_fields(), and header_flags().

#define MOD_TOS   0x0001

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

Referenced by changed_dynamic_one_hdr(), changed_fields(), header_fields(), and header_flags().

#define MOD_TTL   0x0010

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

Referenced by changed_dynamic_one_hdr(), changed_fields(), header_fields(), and header_flags().


Function Documentation

int c_create_current_list ( const int  index,
struct list_comp *const  comp,
const unsigned char *  ext,
const int  index_table 
)

Create the current list.

Parameters:
compThe list compressor which is specific to the extension type
extThe extension
indexThe number of the extension
index_tableThe index of the item in the based table
Returns:
1 if successful, 0 otherwise

References list_comp::based_table, list_comp::compare, c_translation::counter, list_comp::counter, list_comp::create_item, list_comp::curr_list, delete_elt(), elt_index(), get_elt(), list_comp::get_size, list_elt::index_table, insert_elt(), list_elt::item, c_translation::known, rohc_list_item::length, push_back(), rohc_debugf, list_comp::trans_table, and rohc_list_item::type.

Referenced by rohc_list_decide_ipv6_compression().

int c_generic_create ( struct c_context *const  context,
const struct ip_packet ip 
)
void c_generic_destroy ( struct c_context *const  context)
int c_generic_encode ( struct c_context *const  context,
const struct ip_packet ip,
const int  packet_size,
unsigned char *const  dest,
const int  dest_size,
rohc_packet_t *const  packet_type,
int *const  payload_offset 
)

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

1. Check if we have double IP headers.
2. Check if the IP-ID fields are random and if they are in NBO.
3. Decide in which state to go (IR, FO or SO).
4. Decide how many bits are needed to send the IP-ID and SN fields and more important update the sliding windows.
5. Decide which packet type to send.
6. Code the packet.

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

Parameters:
contextThe compression context
ipThe IP packet to encode
packet_sizeThe length of the IP packet to encode
destThe rohc-packet-under-build buffer
dest_sizeThe length of the rohc-packet-under-build buffer
packet_typeOUT: The type of ROHC packet that is created
payload_offsetThe offset for the payload in the IP packet
Returns:
The length of the created ROHC packet or -1 in case of failure

References c_add_ts(), c_init_header_info(), changed_dynamic_both_hdr(), generic_tmp_vars::changed_fields, changed_fields(), generic_tmp_vars::changed_fields2, changed_static_both_hdr(), check_ip_identification(), code_packet(), c_generic_context::decide_state, c_profile::id, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_hdrlen(), ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), ip_get_total_extension_size(), ip_get_version(), IPV4, ipv4_get_header(), ipv4_get_id(), ipv6_get_header(), c_generic_context::is_ip2_initialized, generic_tmp_vars::max_size, ipv4_header_info::nbo, c_generic_context::next_header_len, c_generic_context::next_header_proto, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, c_context::num_sent_ir, c_context::num_sent_ir_dyn, ipv4_header_info::old_ip, ipv6_header_info::old_ip, ipv4_header_info::old_nbo, ipv4_header_info::old_rnd, PACKET_IR, PACKET_IR_DYN, generic_tmp_vars::packet_type, PACKET_UNKNOWN, c_context::profile, ipv4_header_info::rnd, rohc_debugf, ROHC_OK, ROHC_PROFILE_RTP, generic_tmp_vars::send_dynamic, generic_tmp_vars::send_static, ip_packet::size, rtphdr::sn, c_generic_context::sn, c_context::specific, c_generic_context::specific, rtp_tmp_vars::timestamp, sc_rtp_context::tmp, c_generic_context::tmp, sc_rtp_context::ts_sc, ip_header_info::v4, and ip_header_info::v6.

Referenced by c_rtp_encode(), c_udp_encode(), and c_udp_lite_encode().

void c_generic_feedback ( struct c_context *const  context,
const struct c_feedback feedback 
)
int c_init_header_info ( struct ip_header_info header_info,
const struct ip_packet ip 
)
void c_init_tmp_variables ( struct generic_tmp_vars tmp_vars)
void change_mode ( struct c_context *const  context,
const rohc_mode  new_mode 
)

Change the mode of the context.

Parameters:
contextThe compression context
new_modeThe new mode the context must enter in

References change_state(), IR, c_context::mode, and rohc_debugf.

Referenced by c_generic_feedback().

void change_state ( struct c_context *const  context,
const rohc_c_state  new_state 
)

Change the state of the context.

Parameters:
contextThe compression context
new_stateThe new state the context must enter in

References c_generic_context::fo_count, c_generic_context::ir_count, rohc_debugf, c_generic_context::so_count, c_context::specific, and c_context::state.

Referenced by c_generic_feedback(), change_mode(), decide_state(), periodic_down_transition(), rtp_decide_state(), and udp_decide_state().

int changed_dynamic_both_hdr ( const struct c_context context,
const struct ip_packet ip,
const struct ip_packet ip2 
)

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

Parameters:
contextThe compression context
ipThe outer IP header
ip2The inner IP header
Returns:
The number of fields that changed

References changed_dynamic_one_hdr(), generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, c_generic_context::ip2_flags, c_generic_context::ip_flags, generic_tmp_vars::nr_of_ip_hdr, rohc_debugf, c_context::specific, and c_generic_context::tmp.

Referenced by c_generic_encode().

int changed_dynamic_one_hdr ( const unsigned short  changed_fields,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
const struct c_context context 
)

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 ?
Parameters:
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
contextThe compression context
Returns:
The number of fields that changed

References ipv4_header_info::df_count, c_generic_context::fo_count, ip_header_info::info, ip_get_version(), IPV4, IPV4_GET_DF, ipv4_get_df(), is_changed(), MAX_FO_COUNT, MOD_TOS, MOD_TTL, ipv4_header_info::nbo, ipv4_header_info::nbo_count, ipv4_header_info::old_ip, ipv4_header_info::old_nbo, ipv4_header_info::old_rnd, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, c_context::specific, ip_header_info::tos_count, ip_header_info::ttl_count, and ip_header_info::v4.

Referenced by changed_dynamic_both_hdr(), and code_EXT3_packet().

unsigned short changed_fields ( const struct ip_header_info header_info,
const struct ip_packet ip 
)

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:
header_infoThe header info stored in the profile
ipThe header of the new IP packet
Returns:
The bitpattern that indicates which field changed

References ip_header_info::info, ip_get_protocol(), ip_get_tos(), ip_get_ttl(), ip_get_version(), IPV4, IPV6_GET_TC, MOD_PROTOCOL, MOD_TOS, MOD_TTL, ipv4_header_info::old_ip, ipv6_header_info::old_ip, ip_header_info::v4, and ip_header_info::v6.

Referenced by c_generic_encode().

int changed_static_both_hdr ( const struct c_context context,
const struct ip_packet ip,
const struct ip_packet ip2 
)

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

Parameters:
contextThe compression context
ipThe outer IP header
ip2The inner IP header
Returns:
The number of fields that changed

References generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, changed_static_one_hdr(), c_generic_context::ip2_flags, c_generic_context::ip_flags, generic_tmp_vars::nr_of_ip_hdr, c_context::specific, and c_generic_context::tmp.

Referenced by c_generic_encode().

int changed_static_one_hdr ( const unsigned short  changed_fields,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
const struct c_context context 
)

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:
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
contextThe compression context
Returns:
The number of fields that changed

References c_generic_context::fo_count, is_changed(), MAX_FO_COUNT, MOD_PROTOCOL, ip_header_info::protocol_count, rohc_debugf, and c_context::specific.

Referenced by changed_static_both_hdr(), and code_EXT3_packet().

void check_ip_identification ( struct ip_header_info *const  header_info,
const struct ip_packet ip 
)

Determine whether the IPv4 Identification field of one IPv4 header is random and/or in Network Bit Order (NBO).

Parameters:
header_infoThe header info stored in the profile
ipOne IPv4 header

References ip_header_info::info, ip_get_version(), IPID_MAX_DELTA, IPV4, ipv4_get_id(), ipv4_header_info::nbo, ipv4_header_info::old_ip, ipv4_header_info::rnd, rohc_assert, rohc_debugf, and ip_header_info::v4.

Referenced by c_generic_encode().

int code_EXT0_packet ( const struct c_context context,
unsigned char *const  dest,
int  counter 
)

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

References generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, rohc_assert, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, and rtp_tmp_vars::ts_send.

Referenced by code_UO2_packet().

int code_EXT1_packet ( const struct c_context context,
unsigned char *const  dest,
int  counter 
)

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

References generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, rohc_assert, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, and rtp_tmp_vars::ts_send.

Referenced by code_UO2_packet().

int code_EXT2_packet ( const struct c_context context,
unsigned char *const  dest,
int  counter 
)

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

References ipv4_header_info::id_delta, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, c_generic_context::is_ip2_initialized, generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, ipv4_header_info::rnd, rohc_assert, rohc_debugf, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.

Referenced by code_UO2_packet().

int code_EXT3_packet ( const struct c_context context,
const struct ip_packet ip,
const struct ip_packet ip2,
unsigned char *const  dest,
int  counter 
)

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              |
    +-----+-----+-----+-----+-----+-----+-----+-----+
 4  |                      SN                       |  if S = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 5  /            Inner IP header fields             /  variable,
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+
 6  |                     IP-ID                     |  2 octets, if I = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
 7  /            Outer IP header fields             /  variable,
    |                                               |
    +-----+-----+-----+-----+-----+-----+-----+-----+

 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              |
    +-----+-----+-----+-----+-----+-----+-----+-----+
 4  |                      SN                       |  if S = 1
    +-----+-----+-----+-----+-----+-----+-----+-----+
    |                                               |
4.1 /                      TS                       / 1-4octets, 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
ipThe outer IP header
ip2The inner 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 if successful, -1 otherwise

References c_bytesSdvl(), c_encodeSdvl(), changed_dynamic_one_hdr(), generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, changed_static_one_hdr(), header_fields(), header_flags(), c_profile::id, ipv4_header_info::id_delta, ip_header_info::info, INIT_STRIDE, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_version(), IPV4, is_ts_constant(), MAX_FO_COUNT, c_context::mode, generic_tmp_vars::nr_ip_id_bits, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, generic_tmp_vars::packet_type, PACKET_UO_1_ID, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, c_context::profile, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_assert, rohc_debugf, ROHC_PROFILE_RTP, rtp_header_flags_and_fields(), sc_rtp_context::rtp_pt_change_count, rtp_tmp_vars::rtp_pt_changed, SEND_SCALED, c_generic_context::sn, c_context::specific, c_generic_context::specific, ts_sc_comp::state, sc_rtp_context::tmp, c_generic_context::tmp, sc_rtp_context::ts_sc, rtp_tmp_vars::ts_send, and ip_header_info::v4.

Referenced by code_UO2_packet().

int code_generic_dynamic_part ( const struct c_context context,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)
int code_generic_dynamic_part ( const struct c_context context,
struct ip_header_info *const  header_info,
const const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)

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

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

References code_ipv4_dynamic_part(), code_ipv6_dynamic_part(), ip_get_version(), and IPV4.

int code_generic_static_part ( const struct c_context context,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)

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

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

References code_ipv4_static_part(), code_ipv6_static_part(), ip_get_version(), and IPV4.

Referenced by code_IR_packet().

int code_ipv4_dynamic_part ( const struct c_context *const  context,
struct ip_header_info header_info,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)

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
    +---+---+---+---+---+---+---+---+
 4  | DF|RND|NBO|         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

References ipv4_header_info::df_count, ip_header_info::info, ip_get_tos(), ip_get_ttl(), ipv4_get_df(), ipv4_get_id_nbo(), ipv4_header_info::nbo, ipv4_header_info::nbo_count, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, ip_header_info::tos_count, ip_header_info::ttl_count, and ip_header_info::v4.

Referenced by code_generic_dynamic_part().

int code_ipv4_static_part ( const struct c_context context,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)

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


 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

References ip_get_protocol(), ipv4_get_daddr(), ipv4_get_saddr(), ip_header_info::protocol_count, and rohc_debugf.

Referenced by code_generic_static_part().

int code_ipv6_dynamic_part ( const struct c_context context,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)

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

References list_comp::curr_list, ipv6_header_info::ext_comp, ip_header_info::info, ip_get_tos(), ip_get_ttl(), list_comp::islist, list_comp::list_compress, list_comp::ref_list, rohc_debugf, rohc_list_decide_ipv6_compression(), rohc_list_encode(), size_list(), ip_header_info::tos_count, ip_header_info::ttl_count, list_comp::update_done, and ip_header_info::v6.

Referenced by code_generic_dynamic_part().

int code_ipv6_static_part ( const struct c_context context,
struct ip_header_info *const  header_info,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)

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


 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

References ip_get_protocol(), IPV6_ADDR, IPV6_ADDR_FORMAT, ipv6_get_daddr(), ipv6_get_flow_label(), ipv6_get_saddr(), ip_header_info::protocol_count, and rohc_debugf.

Referenced by code_generic_static_part().

int code_IR_DYN_packet ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest 
)

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
    +---+---+---+---+---+---+---+---+
    :                               :
    /           Payload             / variable length
    :                               :
     - - - - - - - - - - - - - - - -

Parameters:
contextThe compression context
ipThe outer IP header
ip2The inner IP header
next_headerThe next header data used to code the dynamic part of the next header for some profiles such as UDP, UDP-Lite, etc.
destThe rohc-packet-under-build buffer
Returns:
The position in the rohc-packet-under-build buffer

References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_dynamic_part, code_generic_dynamic_part(), c_context::compressor, crc_calculate(), CRC_INIT_8, rohc_comp::crc_table_8, CRC_TYPE_8, c_profile::id, c_generic_context::init_at_IR, c_generic_context::ip2_flags, c_generic_context::ip_flags, generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, c_context::profile, rohc_debugf, ROHC_PROFILE_RTP, c_generic_context::sn, c_context::specific, and c_generic_context::tmp.

Referenced by code_packet().

int code_IR_packet ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest 
)

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
    +---+---+---+---+---+---+---+---+
    |                               |
    |           Payload             |  variable length
    |                               |
     - - - - - - - - - - - - - - - -

Parameters:
contextThe compression context
ipThe outer IP header
ip2The inner IP header
next_headerThe next header data used to code the static and dynamic parts of the next header for some profiles such as UDP, UDP-Lite, and so on.
destThe rohc-packet-under-build buffer
Returns:
The position in the rohc-packet-under-build buffer

References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_dynamic_part, code_generic_dynamic_part(), code_generic_static_part(), c_generic_context::code_static_part, c_context::compressor, crc_calculate(), CRC_INIT_8, rohc_comp::crc_table_8, CRC_TYPE_8, c_profile::id, c_generic_context::init_at_IR, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_version(), IPV4, generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_ip_id_bits, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, c_context::profile, rohc_debugf, ROHC_PROFILE_RTP, sn, c_generic_context::sn, c_context::specific, and c_generic_context::tmp.

Referenced by code_packet().

int code_packet ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest 
)

Build the ROHC packet to send.

Parameters:
contextThe compression context
ipThe outer IP header
ip2The inner IP header
next_headerThe next header such as UDP or UDP-Lite
destThe rohc-packet-under-build buffer
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References code_IR_DYN_packet(), code_IR_packet(), code_UO0_packet(), code_UO1_packet(), code_UO2_packet(), PACKET_IR, PACKET_IR_DYN, generic_tmp_vars::packet_type, PACKET_UO_0, PACKET_UO_1, PACKET_UO_1_ID, PACKET_UO_1_RTP, PACKET_UO_1_TS, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, rohc_debugf, c_context::specific, and c_generic_context::tmp.

Referenced by c_generic_encode().

int code_UO0_packet ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest 
)

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
ipThe outer IP header
ip2The inner IP header
next_headerThe next header such as UDP or UDP-Lite
destThe rohc-packet-under-build buffer
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_UO_packet_head, code_UO_packet_tail(), c_context::compressor, c_generic_context::compute_crc_dynamic, c_generic_context::compute_crc_static, CRC_INIT_3, rohc_comp::crc_table_3, CRC_TYPE_3, ip_packet::data, ip_get_raw_data(), generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, rohc_debugf, c_generic_context::sn, c_context::specific, and c_generic_context::tmp.

Referenced by code_packet().

int code_UO1_packet ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest 
)

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
ipThe outer IP header
ip2The inner IP header
next_headerThe next header such as UDP or UDP-Lite
destThe rohc-packet-under-build buffer
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_UO_packet_head, code_UO_packet_tail(), c_context::compressor, c_generic_context::compute_crc_dynamic, c_generic_context::compute_crc_static, CRC_INIT_3, rohc_comp::crc_table_3, CRC_TYPE_3, ip_packet::data, c_profile::id, ipv4_header_info::id_delta, ip_header_info::info, c_generic_context::ip_flags, ip_get_raw_data(), IPV4, rtp_tmp_vars::m_set, generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::packet_type, PACKET_UO_1, PACKET_UO_1_ID, PACKET_UO_1_RTP, PACKET_UO_1_TS, c_context::profile, rohc_assert, rohc_debugf, ROHC_PROFILE_RTP, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.

Referenced by code_packet().

int code_UO2_packet ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest 
)

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
ipThe outer IP header
ip2The inner IP header
next_headerThe next header such as UDP or UDP-Lite
destThe rohc-packet-under-build buffer
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References c_context::cid, medium::cid_type, code_cid_values(), code_EXT0_packet(), code_EXT1_packet(), code_EXT2_packet(), code_EXT3_packet(), c_generic_context::code_UO_packet_head, code_UO_packet_tail(), code_UOR2_bytes(), code_UOR2_ID_bytes(), code_UOR2_RTP_bytes(), code_UOR2_TS_bytes(), c_context::compressor, c_generic_context::compute_crc_dynamic, c_generic_context::compute_crc_static, CRC_INIT_6, CRC_INIT_7, rohc_comp::crc_table_6, rohc_comp::crc_table_7, CRC_TYPE_6, CRC_TYPE_7, ip_packet::data, extension, c_profile::id, ip_get_raw_data(), generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_EXT_UNKNOWN, PACKET_NOEXT, generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, c_context::profile, rohc_assert, rohc_debugf, rohc_get_ext_descr(), ROHC_PROFILE_RTP, c_context::specific, and c_generic_context::tmp.

Referenced by code_packet().

int code_UO_packet_tail ( struct c_context *const  context,
const struct ip_packet ip,
const struct ip_packet ip2,
const unsigned char *  next_header,
unsigned char *const  dest,
int  counter 
)

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
ipThe outer IP header
ip2The inner IP header
next_headerThe next header such as UDP or UDP-Lite
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

References c_generic_context::code_UO_packet_tail, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_version(), IPV4, ipv4_get_id(), generic_tmp_vars::nr_of_ip_hdr, ipv4_header_info::rnd, rohc_debugf, c_context::specific, c_generic_context::tmp, and ip_header_info::v4.

Referenced by code_UO0_packet(), code_UO1_packet(), and code_UO2_packet().

int code_UOR2_bytes ( const struct c_context 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.

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

References generic_tmp_vars::nr_sn_bits, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, rohc_debugf, c_generic_context::sn, c_context::specific, and c_generic_context::tmp.

Referenced by code_UO2_packet().

int code_UOR2_ID_bytes ( const struct c_context 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.

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

References rtp_tmp_vars::m_set, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, rohc_assert, rohc_debugf, ROHC_SDVL_MAX_BITS_IN_1_BYTE, ROHC_SDVL_MAX_BITS_IN_2_BYTES, ROHC_SDVL_MAX_BITS_IN_3_BYTES, ROHC_SDVL_MAX_BITS_IN_4_BYTES, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, and rtp_tmp_vars::ts_send.

Referenced by code_UO2_packet().

int code_UOR2_RTP_bytes ( const struct c_context 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.

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

References ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, rtp_tmp_vars::m_set, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, ipv4_header_info::rnd, rohc_assert, rohc_debugf, ROHC_SDVL_MAX_BITS_IN_1_BYTE, ROHC_SDVL_MAX_BITS_IN_2_BYTES, ROHC_SDVL_MAX_BITS_IN_3_BYTES, ROHC_SDVL_MAX_BITS_IN_4_BYTES, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.

Referenced by code_UO2_packet().

int code_UOR2_TS_bytes ( const struct c_context 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.

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

References ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, rtp_tmp_vars::m_set, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, ipv4_header_info::rnd, rohc_assert, rohc_debugf, rohc_min, ROHC_SDVL_MAX_BITS_IN_1_BYTE, ROHC_SDVL_MAX_BITS_IN_2_BYTES, ROHC_SDVL_MAX_BITS_IN_3_BYTES, ROHC_SDVL_MAX_BITS_IN_4_BYTES, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.

Referenced by code_UO2_packet().

void decide_state ( struct c_context *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

References change_state(), FO, c_generic_context::fo_count, IR, c_generic_context::ir_count, MAX_FO_COUNT, MAX_IR_COUNT, c_context::mode, periodic_down_transition(), generic_tmp_vars::send_dynamic, generic_tmp_vars::send_static, SO, c_context::specific, c_context::state, c_generic_context::tmp, and U_MODE.

Referenced by c_generic_create(), c_udp_lite_create(), rtp_decide_state(), and udp_decide_state().

int get_index_ipv6_table ( const struct ip_packet ip,
const int  index 
)

Return the based table index for the Nth IP extension of the IP packet.

Parameters:
ipThe IP packet to analyse
indexThe index of the extension to retrieve in the IP packet
Returns:
the based table index

References list_elt::index_table, ip_get_next_ext_header_from_ext(), ip_get_next_ext_header_from_ip(), IPV6_EXT_AUTH, IPV6_EXT_DESTINATION, IPV6_EXT_HOP_BY_HOP, and IPV6_EXT_ROUTING.

Referenced by c_init_header_info().

unsigned char * get_ipv6_extension ( const struct ip_packet ip,
const int  index 
)

Extract the Nth IP extension of the IP packet.

Extract the IP extension at the given index.

Parameters:
ipThe IP packet to analyse
indexThe index of the extension to retrieve in the IP packet
Returns:
the extension

References ip_get_next_ext_header_from_ext(), and ip_get_next_ext_header_from_ip().

Referenced by c_init_header_info().

int header_fields ( const struct c_context context,
struct ip_header_info *const  header_info,
const unsigned short  changed_f,
const struct ip_packet ip,
const int  is_outer,
const size_t  nr_ip_id_bits,
unsigned char *const  dest,
int  counter 
)

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

    IP-ID is coded here for outer header fields although it doesn't look that
    way in the extension 3 picture in 5.7.5 and 5.11.4 of RFC 3095.
    +-----+-----+-----+-----+-----+-----+-----+-----+
 5  |                  IP-ID                        |  2 octets, if I = 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
is_outerWhether the IP header is the outer header or not
nr_ip_id_bitsThe number of bits needed to transmit the IP-ID field
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

References ip_header_info::info, ip_get_protocol(), ip_get_tos(), ip_get_ttl(), IPV4, ipv4_get_id_nbo(), is_changed(), MAX_FO_COUNT, MOD_PROTOCOL, MOD_TOS, MOD_TTL, ipv4_header_info::nbo, ip_header_info::protocol_count, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, ip_header_info::tos_count, ip_header_info::ttl_count, ip_header_info::v4, and ip_header_info::version.

Referenced by code_EXT3_packet().

int header_flags ( const struct c_context context,
struct ip_header_info *const  header_info,
const unsigned short  changed_f,
const struct ip_packet ip,
const int  is_outer,
const size_t  nr_ip_id_bits,
unsigned char *const  dest,
int  counter 
)

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 | 0** |  0** reserved
    +-----+-----+-----+-----+-----+-----+-----+-----+

 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
is_outerWhether the IP header is the outer header or not
nr_ip_id_bitsThe number of bits needed to transmit the IP-ID field
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

References ipv4_header_info::df_count, ip_header_info::info, IPV4, ipv4_get_df(), is_changed(), MAX_FO_COUNT, MOD_PROTOCOL, MOD_TOS, MOD_TTL, ipv4_header_info::nbo, ipv4_header_info::nbo_count, ip_header_info::protocol_count, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, ip_header_info::tos_count, ip_header_info::ttl_count, ip_header_info::v4, and ip_header_info::version.

Referenced by code_EXT3_packet().

void ip6_c_init_table ( struct list_comp *const  comp)

Initialize the tables IPv6 extension in compressor.

Parameters:
compThe list compressor

References AH, list_comp::based_table, c_translation::counter, rohc_list_item::data, DEST, HBH, c_translation::item, c_translation::known, rohc_list_item::length, RTHDR, list_comp::trans_table, and rohc_list_item::type.

Referenced by c_init_header_info().

int ipv6_compare ( const unsigned char *  ext,
const struct list_comp comp,
const int  size,
const int  index_table 
)

IPv6 extension comparison.

Parameters:
extThe IPv6 extension to compare
compThe list compressor
sizeThe size of the IPv6 extension to compare
index_tableThe index of the IPv6 extention in based table
Returns:
1 if equal, 0 otherwise

References list_comp::based_table, and rohc_list_item::data.

Referenced by c_init_header_info().

int is_changed ( const unsigned short  changed_fields,
const unsigned short  check_field 
) [inline]

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

Referenced by changed_dynamic_one_hdr(), changed_static_one_hdr(), header_fields(), and header_flags().

void periodic_down_transition ( struct c_context context)

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

Parameters:
contextThe compression context

References change_state(), CHANGE_TO_FO_COUNT, CHANGE_TO_IR_COUNT, FO, c_generic_context::go_back_fo_count, c_generic_context::go_back_ir_count, IR, c_generic_context::ir_dyn_count, rohc_debugf, SO, c_context::specific, and c_context::state.

Referenced by decide_state().

int rohc_list_decide_ipv6_compression ( struct list_comp *const  comp,
const struct ip_packet *const  ip 
)

Decide whether list of IPv6 extension headers shall be sent compressed.

Parameters:
compThe list compressor which is specific to the extension type
ipThe IP packet to compress
Returns:
  • 1 if a compressed list must be sent,
  • 0 if not,
  • -1 if error

References c_create_current_list(), c_translation::counter, list_comp::counter, list_comp::curr_list, delete_elt(), empty_list(), c_list::gen_id, get_elt(), list_comp::get_extension, list_comp::get_index_table, list_elt::index_table, insert_elt(), ip_get_raw_data(), list_comp::islist, list_elt::item, c_translation::known, L, MAX_ITEM, list_comp::ref_list, rohc_debugf, size_list(), list_comp::trans_table, rohc_list_item::type, and list_comp::update_done.

Referenced by code_ipv6_dynamic_part().

int rohc_list_decide_type ( struct list_comp *const  comp)

Decide the encoding type for compression list.

Parameters:
compThe list compressor
Returns:
the encoding type among [0-3]

References list_comp::curr_list, c_list::first_elt, get_elt(), list_elt::index_table, list_comp::islist, list_elt::item, c_translation::known, list_comp::list_compress, list_comp::ref_list, rohc_debugf, size_list(), list_comp::trans_table, and type_is_present().

Referenced by rohc_list_encode().

int rohc_list_encode ( struct list_comp *const  comp,
unsigned char *const  dest,
int  counter,
const int  ps,
const int  size 
)

Generic encoding of compressed list.

Parameters:
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
psThe size of the index
sizeThe number of element in current list
Returns:
The new position in the rohc-packet-under-build buffer, -1 in case of error

References rohc_debugf, rohc_list_decide_type(), rohc_list_encode_type_0(), rohc_list_encode_type_1(), rohc_list_encode_type_2(), and rohc_list_encode_type_3().

Referenced by code_ipv6_dynamic_part().

int rohc_list_encode_type_0 ( struct list_comp *const  comp,
unsigned char *const  dest,
int  counter,
const int  ps 
)

Build encoding type 0 for list compression.

Todo:
this function is inefficient as it loops many times on the same list (see get_elt especially)

 Encoding type 0 (5.8.6.1):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  | ET = 0| GP| PS|   CC = m      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
    |       XI 1, ..., XI m         | m octets, or m * 4 bits
 3  /               --- --- --- --- /
    |               :    Padding    : if PS = 0 and m is odd
    +---+---+---+---+---+---+---+---+
    |                               |
 4  /      item 1, ..., item n      / variable length
    |                               |
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is zero.

 GP: Indicates presence of gen_id field.

 PS: Indicates size of XI fields:
     PS = 0 indicates 4-bit XI fields;
     PS = 1 indicates 8-bit XI fields.

 CC: CSRC counter from original RTP header.

 gen_id: Identifier for a sequence of identical lists.  It is
     present in U/O-mode when the compressor decides that it may use
     this list as a future reference list.

 XI 1, ..., XI m: m XI items. The format of an XI item is as
     follows:

              +---+---+---+---+
     PS = 0:  | X |   Index   |
              +---+---+---+---+

                0   1   2   3   4   5   6   7
              +---+---+---+---+---+---+---+---+
     PS = 1:  | X |           Index           |
              +---+---+---+---+---+---+---+---+

     X = 1 indicates that the item corresponding to the Index
           is sent in the item 0, ..., item n list.
     X = 0 indicates that the item corresponding to the Index is
               not sent.

     When 4-bit XI items are used and m > 1, the XI items are placed in
     octets in the following manner:

          0   1   2   3   4   5   6   7
        +---+---+---+---+---+---+---+---+
        |     XI k      |    XI k + 1   |
        +---+---+---+---+---+---+---+---+

 Padding: A 4-bit padding field is present when PS = 0 and m is
     odd.  The Padding field is set to zero when sending and ignored
     when receiving.

 Item 1, ..., item n:
     Each item corresponds to an XI with X = 1 in XI 1, ..., XI m.

Parameters:
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
psThe size of the index
Returns:
The new position in the rohc-packet-under-build buffer

References list_comp::curr_list, rohc_list_item::data, c_list::gen_id, get_elt(), list_elt::index_table, list_elt::item, c_translation::known, rohc_list_item::length, m, rohc_debugf, size_list(), list_comp::trans_table, and rohc_list_item::type.

Referenced by rohc_list_encode().

int rohc_list_encode_type_1 ( struct list_comp *const  comp,
unsigned char *const  dest,
int  counter,
const int  ps 
)

Build encoding type 1 for list compression.

Todo:
this function is inefficient as it loops many times in the current and reference lists (see get_elt and type_is_present especially)

 Encoding type 1 (5.8.6.2):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  | ET = 1| GP| PS|     XI 1      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
 3  |            ref_id             |
    +---+---+---+---+---+---+---+---+
 4  /       insertion bit mask      / 1-2 octets
    +---+---+---+---+---+---+---+---+
    |           XI list             | k octets, or (k - 1) * 4 bits
 5  /               --- --- --- --- /
    |               :    Padding    : if PS = 0 and k is even
    +---+---+---+---+---+---+---+---+
    |                               |
 6  /      item 1, ..., item n      / variable
    |                               |
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is one (1).

 GP: Indicates presence of gen_id field.

 PS: Indicates size of XI fields:
     PS = 0 indicates 4-bit XI fields;
     PS = 1 indicates 8-bit XI fields.

 XI 1: When PS = 0, the first 4-bit XI item is placed here.
       When PS = 1, the field is set to zero when sending, and
       ignored when receiving.

 ref_id: The identifier of the reference CSRC list used when the
       list was compressed.  It is the 8 least significant bits of
       the RTP Sequence Number in R-mode and gen_id (see section
       5.8.2) in U/O-mode.

 insertion bit mask: Bit mask indicating the positions where new
           items are to be inserted.  See Insertion Only scheme in
           section 5.8.3.  The bit mask can have either of the
           following two formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

 XI list: XI fields for items to be inserted.  When the insertion
    bit mask has k ones, the total number of XI fields is k.  When
    PS = 1, all XI fields are in the XI list.  When PS = 0, the
    first XI field is in the XI 1 field, and the remaining k - 1
    XI fields are in the XI list.

 Padding: Present when PS = 0 and k is even.

 item 1, ..., item n: One item for each XI field with the X bit set.

Parameters:
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
psThe size of the index
Returns:
The new position in the rohc-packet-under-build buffer

References list_comp::curr_list, rohc_list_item::data, c_list::gen_id, get_elt(), list_elt::index_table, list_elt::item, c_translation::known, rohc_list_item::length, m, list_comp::ref_list, rohc_debugf, size_list(), list_comp::trans_table, rohc_list_item::type, and type_is_present().

Referenced by rohc_list_encode().

int rohc_list_encode_type_2 ( struct list_comp *const  comp,
unsigned char *const  dest,
int  counter,
const int  ps 
)

Build encoding type 2 for list compression.

Todo:
this function is inefficient as it loops many times in the current and reference lists (see get_elt and type_is_present especially)

 Encoding type 2 (5.8.6.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 1  | ET = 2| GP|res|    Count      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
 3  |            ref_id             |
    +---+---+---+---+---+---+---+---+
 4  /        removal bit mask       / 1-2 octets
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is 2.

 GP: Indicates presence of gen_id field.

 res: Reserved.  Set to zero when sending, ignored when
      received.

 Count: Number of elements in ref_list.

 removal bit mask: Indicates the elements in ref_list to be
    removed in order to obtain the current list.  See section
    5.8.3.  The bit mask can have either of the following two
    formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

Parameters:
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
psThe size of the index
Returns:
The new position in the rohc-packet-under-build buffer

References list_comp::curr_list, c_list::gen_id, get_elt(), list_elt::item, list_comp::ref_list, rohc_debugf, size_list(), and type_is_present().

Referenced by rohc_list_encode().

int rohc_list_encode_type_3 ( struct list_comp *const  comp,
unsigned char *const  dest,
int  counter,
const int  ps 
)

Build encoding type 3 for list compression.

Todo:
this function is inefficient as it loops many times in the current and reference lists (see get_elt and type_is_present especially)

 Encoding type 3 (5.8.6.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 1  | ET=3  |GP |PS |     XI 1      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
 3  |            ref_id             |
    +---+---+---+---+---+---+---+---+
 4  /        removal bit mask       / 1-2 octets
    +---+---+---+---+---+---+---+---+
 5  /       insertion bit mask      / 1-2 octets
    +---+---+---+---+---+---+---+---+
    |           XI list             | k octets, or (k - 1) * 4 bits
 6  /               --- --- --- --- /
    |               :    Padding    : if PS = 0 and k is even
    +---+---+---+---+---+---+---+---+
    |                               |
 7  /      item 1, ..., item n      / variable
    |                               |
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is 3.

 GP: Indicates presence of gen_id field.

 PS: Indicates size of XI fields:
     PS = 0 indicates 4-bit XI fields;
     PS = 1 indicates 8-bit XI fields.

 gen_id: Identifier for a sequence of identical lists.  It is
     present in U/O-mode when the compressor decides that it may use
     this list as a future reference list.

 ref_id: The identifier of the reference CSRC list used when the
       list was compressed.  It is the 8 least significant bits of
       the RTP Sequence Number in R-mode and gen_id (see section
       5.8.2) in U/O-mode.

 removal bit mask: Indicates the elements in ref_list to be
    removed in order to obtain the current list.  See section
    5.8.3.  The bit mask can have either of the following two
    formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

 insertion bit mask: Bit mask indicating the positions where new
           items are to be inserted.  See Insertion Only scheme in
           section 5.8.3.  The bit mask can have either of the
           following two formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

 XI list: XI fields for items to be inserted.  When the insertion
    bit mask has k ones, the total number of XI fields is k.  When
    PS = 1, all XI fields are in the XI list.  When PS = 0, the
    first XI field is in the XI 1 field, and the remaining k - 1
    XI fields are in the XI list.

 Padding: Present when PS = 0 and k is even.

 item 1, ..., item n: One item for each XI field with the X bit set.

Parameters:
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
psThe size of the index
Returns:
The new position in the rohc-packet-under-build buffer

References list_comp::curr_list, rohc_list_item::data, c_list::gen_id, get_elt(), list_elt::index_table, list_elt::item, c_translation::known, rohc_list_item::length, m, list_comp::ref_list, rohc_debugf, size_list(), list_comp::trans_table, rohc_list_item::type, and type_is_present().

Referenced by rohc_list_encode().

int rtp_header_flags_and_fields ( const struct c_context context,
const unsigned short  changed_f,
const struct ip_packet ip,
unsigned char *const  dest,
int  counter 
)