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

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

#include "d_generic.h"
#include "d_rtp.h"
#include "config.h"
#include "rohc_traces.h"
#include "rohc_time.h"
#include "rohc_debug.h"
#include "rohc_packets.h"
#include "rohc_bit_ops.h"
#include "wlsb.h"
#include "sdvl.h"
#include "crc.h"
#include <assert.h>
Include dependency graph for d_generic.c:

Defines

#define IPV4_DYN_PART_SIZE   6
 The size (in bytes) of the IPv4 dynamic part.
#define WEIGHT_OLD   1
#define WEIGHT_NEW   1

Functions

int decode_irdyn (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_packet, const unsigned int rohc_length, int second_byte, unsigned char *dest)
 Decode one IR-DYN packet.
int decode_uo0 (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_packet, const unsigned int rohc_length, int second_byte, unsigned char *uncomp_packet)
 Decode one UO-0 packet.
int decode_uo1 (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_packet, const unsigned int rohc_length, int second_byte, unsigned char *uncomp_packet)
 Decode one UO-1 packet.
int decode_uor2 (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_packet, const unsigned int rohc_length, int second_byte, unsigned char *uncomp_packet)
 Decode one UOR-2 packet.
int decode_extension0 (const unsigned char *const rohc_data, const size_t rohc_data_len, const rohc_packet_t packet_type, uint16_t *const sn_bits, size_t *const sn_bits_nr, uint16_t *const ip_id_bits, size_t *const ip_id_bits_nr, uint32_t *const ts_bits, size_t *const ts_bits_nr)
 Decode the extension 0 of the UOR-2 packet.
int decode_extension1 (const unsigned char *const rohc_data, const size_t rohc_data_len, const rohc_packet_t packet_type, uint16_t *const sn_bits, size_t *const sn_bits_nr, uint16_t *const ip_id_bits, size_t *const ip_id_bits_nr, uint32_t *const ts_bits, size_t *const ts_bits_nr)
 Decode the extension 1 of the UOR-2 packet.
int decode_extension2 (const unsigned char *const rohc_data, const size_t rohc_data_len, const rohc_packet_t packet_type, const int innermost_ip_hdr, uint16_t *const sn_bits, size_t *const sn_bits_nr, uint16_t *const ip_id_bits, size_t *const ip_id_bits_nr, uint16_t *const ip_id2_bits, size_t *const ip_id2_bits_nr, uint32_t *const ts_bits, size_t *const ts_bits_nr)
 Decode the extension 2 of the UOR-2 packet.
int decode_extension3 (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_data, const size_t rohc_data_len, uint16_t *const sn_bits, size_t *const sn_bits_nr, uint16_t *const ip_id_bits, size_t *const ip_id_bits_nr, uint16_t *const ip_id2_bits, size_t *const ip_id2_bits_nr, uint32_t *const ts_bits, size_t *const ts_bits_nr, int *const is_ts_scaled, uint8_t *const rtp_m_bits, size_t *const rtp_m_bits_nr, uint8_t *const rtp_x_bits, size_t *const rtp_x_bits_nr, uint8_t *const rtp_p_bits, size_t *const rtp_p_bits_nr, uint8_t *const rtp_pt_bits, size_t *const rtp_pt_bits_nr)
 Decode the extension 3 of the UOR-2 packet.
uint8_t extension_type (const unsigned char *const rohc_extension)
 Find out which extension is carried by the UOR-2 packet.
int d_decode_static_ip (const unsigned char *packet, const unsigned int length, struct d_generic_changes *info)
 Decode the IP static part of a ROHC packet.
int d_decode_static_ip4 (const unsigned char *packet, const unsigned int length, struct ip_packet *ip)
 Decode the IPv4 static part of a ROHC packet.
int d_decode_static_ip6 (const unsigned char *packet, const unsigned int length, struct ip_packet *ip)
 Decode the IPv6 static part of a ROHC packet.
int d_decode_dynamic_ip (const unsigned char *packet, unsigned int length, struct d_generic_changes *info, struct list_decomp *decomp)
 Decode the IP dynamic part of a ROHC packet.
int d_decode_dynamic_ip4 (const unsigned char *packet, unsigned int length, struct ip_packet *ip, int *rnd, int *nbo)
 Decode the IPv4 dynamic part of a ROHC packet.
int d_decode_dynamic_ip6 (const unsigned char *packet, unsigned int length, struct ip_packet *ip, struct list_decomp *decomp, struct d_generic_changes *info)
 Decode the IPv6 dynamic part of a ROHC packet.
int decode_outer_header_flags (struct d_context *context, const unsigned char *flags, const unsigned char *fields, unsigned int length, struct d_generic_changes *info, uint16_t *const ext3_ip_id_bits, size_t *const ext3_ip_id_bits_nr)
 Decode the outer IP header flags and fields.
int decode_inner_header_flags (struct d_context *context, const unsigned char *flags, const unsigned char *fields, unsigned int length, struct d_generic_changes *info)
 Decode the inner IP header flags and fields.
unsigned int build_uncompressed_ip (struct d_generic_changes *active, unsigned char *dest, unsigned int payload_size, struct list_decomp *decomp)
 Build an uncompressed IP header.
unsigned int build_uncompressed_ip4 (struct d_generic_changes *active, unsigned char *dest, unsigned int payload_size)
 Build an uncompressed IPv4 header.
unsigned int build_uncompressed_ip6 (struct d_generic_changes *active, unsigned char *dest, unsigned int payload_size, struct list_decomp *decomp)
 Build an uncompressed IPv6 header.
void copy_generic_changes (struct d_generic_changes *dst, struct d_generic_changes *src)
 Copy the header changes object into another one.
int cmp_generic_changes (struct d_generic_changes *first, struct d_generic_changes *second)
 Compare two header changes objects.
void sync_on_failure (struct d_generic_context *context)
 Replace the active header changes with the last ones.
void synchronize (struct d_generic_context *context)
 Replace last header changes with the active ones.
void update_inter_packet (struct d_generic_context *context)
 Update the inter-packet time, a sort of average over the last inter-packet times.
int get_bit_index (unsigned char byte, int index)
 Get the bit in the byte at the specified index.
int check_ip6_index (struct list_decomp *decomp, int index)
 Check if the index is correct in IPv6 table.
void ip6_d_init_table (struct list_decomp *decomp)
 Initialize the tables IPv6 extension in decompressor.
void * d_generic_create (void)
 Create the generic decompression context.
void d_generic_destroy (void *context)
 Destroy the context.
int d_generic_decode_ir (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_packet, const unsigned int rohc_length, int large_cid_len, int is_addcid_used, unsigned char *dest)
 Decode one IR packet.
unsigned int d_generic_detect_ir_size (struct d_context *context, unsigned char *packet, unsigned int plen, unsigned int large_cid_len)
 Find the length of the IR header.
unsigned int d_generic_detect_ir_dyn_size (struct d_context *context, unsigned char *packet, unsigned int plen, unsigned int large_cid_len)
 Find the length of the IR-DYN header.
int d_generic_decode (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *const rohc_packet, const unsigned int rohc_length, int second_byte, unsigned char *dest)
 Decode one IR-DYN, UO-0, UO-1 or UOR-2 packet, but not IR packet.
int d_generic_get_sn (struct d_context *context)
 Get the reference SN value of the context.
rohc_packet_t find_packet_type (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *packet, const size_t rohc_length, int second_byte)
 Find out of which type is the ROHC packet.

Detailed Description

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

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

Define Documentation

#define IPV4_DYN_PART_SIZE   6

The size (in bytes) of the IPv4 dynamic part.

According to RFC3095 section 5.7.7.4: 1 (TOS) + 1 (TTL) + 2 (IP-ID) + 1 (flags) + 1 (header list) = 6 bytes

The size of the generic extension header list field is considered constant because generic extension header list is not supported yet and thus 1 byte of zero is used.

Referenced by d_decode_dynamic_ip4(), d_generic_detect_ir_dyn_size(), and d_generic_detect_ir_size().

#define WEIGHT_NEW   1

Constant to compute inter-arrival time between the received packets

Referenced by update_inter_packet().

#define WEIGHT_OLD   1

Constant to compute inter-arrival time between the received packets

Referenced by update_inter_packet().


Function Documentation

unsigned int build_uncompressed_ip ( struct d_generic_changes active,
unsigned char *  dest,
unsigned int  payload_size,
struct list_decomp decomp 
)

Build an uncompressed IP header.

Parameters:
activeThe IP header changes
destThe buffer to store the IP header (MUST be at least of sizeof(struct iphdr) or sizeof(struct ip6_hdr) bytes depending on the IP version)
payload_sizeThe length of the IP payload
decompThe list decompressor (IPv6 only)
Returns:
The length of the IP header

References build_uncompressed_ip4(), build_uncompressed_ip6(), d_generic_changes::ip, ip_get_version(), and IPV4.

Referenced by d_generic_decode_ir(), decode_irdyn(), decode_uo0(), decode_uo1(), and decode_uor2().

unsigned int build_uncompressed_ip4 ( struct d_generic_changes active,
unsigned char *  dest,
unsigned int  payload_size 
)

Build an uncompressed IPv4 header.

Parameters:
activeThe IPv4 header changes
destThe buffer to store the IPv4 header (MUST be at least of sizeof(struct iphdr) bytes)
payload_sizeThe length of the IPv4 payload
Returns:
The length of the IPv4 header

References ip_packet::header, d_generic_changes::ip, d_generic_changes::nbo, rohc_debugf, and ip_packet::v4.

Referenced by build_uncompressed_ip().

unsigned int build_uncompressed_ip6 ( struct d_generic_changes active,
unsigned char *  dest,
unsigned int  payload_size,
struct list_decomp decomp 
)

Build an uncompressed IPv6 header.

Parameters:
activeThe IPv6 header changes
destThe buffer to store the IPv6 header (MUST be at least of sizeof(struct ip6_hdr) bytes)
payload_sizeThe length of the IPv6 payload
decompThe list decompressor
Returns:
The length of the IPv6 header

References d_generic_changes::complist, list_decomp::counter_list, list_decomp::encode_extension, c_list::first_elt, ip_packet::header, d_generic_changes::ip, list_elt::item, list_decomp::list_decomp, list_decomp::list_table, list_decomp::ref_list, list_decomp::ref_ok, rohc_debugf, d_generic_changes::size_list, size_list(), rohc_list_item::type, and ip_packet::v6.

Referenced by build_uncompressed_ip().

int check_ip6_index ( struct list_decomp decomp,
int  index 
)

Check if the index is correct in IPv6 table.

Parameters:
decompThe list decompressor
indexThe specified index
Returns:
1 if successful, 0 else

References rohc_debugf.

Referenced by d_generic_create().

int cmp_generic_changes ( struct d_generic_changes first,
struct d_generic_changes second 
)

Compare two header changes objects.

Parameters:
firstOne header changes object
secondAnother header changes object
Returns:
1 if the two objects match, 0 otherwise

References d_generic_changes::ip, d_generic_changes::nbo, d_generic_changes::next_header, d_generic_changes::next_header_len, and d_generic_changes::rnd.

Referenced by d_generic_decode().

void copy_generic_changes ( struct d_generic_changes dst,
struct d_generic_changes src 
)

Copy the header changes object into another one.

Parameters:
dstThe destination header changes
srcThe source header changes

References d_generic_changes::ip, d_generic_changes::nbo, d_generic_changes::next_header, d_generic_changes::next_header_len, d_generic_changes::rnd, and rohc_debugf.

Referenced by sync_on_failure(), and synchronize().

int d_decode_dynamic_ip ( const unsigned char *  packet,
unsigned int  length,
struct d_generic_changes info,
struct list_decomp decomp 
)

Decode the IP dynamic part of a ROHC packet.

See 5.7.7.3 and 5.7.7.4 in RFC 3095 for details.

Parameters:
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
infoThe decoded IP header information
decompThe list decompressor (only for IPv6)
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References d_decode_dynamic_ip4(), d_decode_dynamic_ip6(), d_generic_changes::ip, ip_get_version(), IPV4, d_generic_changes::nbo, and d_generic_changes::rnd.

Referenced by d_generic_decode_ir(), and decode_irdyn().

int d_decode_dynamic_ip4 ( const unsigned char *  packet,
unsigned int  length,
struct ip_packet ip,
int *  rnd,
int *  nbo 
)

Decode the IPv4 dynamic part of a ROHC packet.

See 5.7.7.4 in RFC 3095 for details. Generic extension header list is not managed yet.

Parameters:
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
ipThe decoded IP packet
rndBoolean to store whether the IP-ID is random or not
nboBoolean to store whether the IP-ID is in NBO or not
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References GET_BIT_0_7, GET_BIT_5, GET_BIT_6, GET_BIT_7, GET_NEXT_16_BITS, GET_REAL, ip_get_tos(), ip_get_ttl(), ip_set_tos(), ip_set_ttl(), IPV4_DYN_PART_SIZE, ipv4_get_df(), ipv4_get_id(), ipv4_set_df(), ipv4_set_id(), and rohc_debugf.

Referenced by d_decode_dynamic_ip().

int d_decode_dynamic_ip6 ( const unsigned char *  packet,
unsigned int  length,
struct ip_packet ip,
struct list_decomp decomp,
struct d_generic_changes info 
)

Decode the IPv6 dynamic part of a ROHC packet.

See 5.7.7.3 in RFC 3095 for details. Generic extension header list is not managed yet.

Parameters:
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
ipThe decoded IP packet
decompThe list decompressor
infoThe decoded IP header information
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References list_decomp::counter_list, c_list::first_elt, GET_BIT_0_7, get_elt(), ip_get_tos(), ip_get_ttl(), ip_set_tos(), ip_set_ttl(), list_elt::item, rohc_list_item::length, list_decomp::list_decomp, list_decomp::list_table, list_decomp::ref_list, list_decomp::ref_ok, rohc_debugf, list_decomp::size_ext, d_generic_changes::size_list, and size_list().

Referenced by d_decode_dynamic_ip().

int d_decode_static_ip ( const unsigned char *  packet,
const unsigned int  length,
struct d_generic_changes info 
)

Decode the IP static part of a ROHC packet.

See 5.7.7.3 and 5.7.7.4 in RFC 3095 for details.

Parameters:
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
infoThe decoded IP header information
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References d_decode_static_ip4(), d_decode_static_ip6(), GET_BIT_4_7, d_generic_changes::ip, ip_new(), IPV4, IPV6, and rohc_debugf.

Referenced by d_generic_decode_ir().

int d_decode_static_ip4 ( const unsigned char *  packet,
const unsigned int  length,
struct ip_packet ip 
)

Decode the IPv4 static part of a ROHC packet.

See 5.7.7.4 in RFC 3095 for details.

Parameters:
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
ipThe decoded IP packet
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References GET_BIT_0_7, GET_BIT_4_7, ip_get_protocol(), ip_set_daddr(), ip_set_protocol(), ip_set_saddr(), IPV4, ipv4_get_daddr(), ipv4_get_saddr(), rohc_debugf, version, and ip_packet::version.

Referenced by d_decode_static_ip().

int d_decode_static_ip6 ( const unsigned char *  packet,
const unsigned int  length,
struct ip_packet ip 
)

Decode the IPv6 static part of a ROHC packet.

See 5.7.7.3 in RFC 3095 for details.

Parameters:
packetThe ROHC packet to decode
lengthThe length of the ROHC packet
ipThe decoded IP packet
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

References GET_BIT_0_3, GET_BIT_0_7, GET_BIT_4_7, ip_packet::header, ip_set_daddr(), ip_set_protocol(), ip_set_saddr(), IPV6, IPV6_ADDR, IPV6_ADDR_FORMAT, ipv6_get_daddr(), ipv6_get_flow_label(), ipv6_get_saddr(), ipv6_set_flow_label(), rohc_debugf, ip_packet::v6, version, and ip_packet::version.

Referenced by d_decode_static_ip().

void* d_generic_create ( void  )
int d_generic_decode ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_packet,
const unsigned int  rohc_length,
int  second_byte,
unsigned char *  dest 
)

Decode one IR-DYN, UO-0, UO-1 or UOR-2 packet, but not IR packet.

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

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_packetThe ROHC packet to decode
rohc_lengthThe length of the ROHC packet
second_byteThe offset for the second byte of the ROHC packet (depends on the CID encoding and the packet type, may not exist in packet)
destOUT: The decoded IP packet
Returns:
The length of the uncompressed IP packet or ROHC_ERROR if an error occurs or ROHC_ERROR_CRC if a CRC error occurs

References d_generic_context::active1, d_generic_context::active2, cmp_generic_changes(), d_generic_context::current_packet_time, d_generic_decode(), decode_irdyn(), decode_uo0(), decode_uo1(), decode_uor2(), find_packet_type(), d_generic_changes::ip, ip_get_version(), IPV4, d_generic_context::last1, d_generic_context::last2, d_generic_context::multiple_ip, d_generic_changes::nbo, NO_CONTEXT, PACKET_IR_DYN, d_generic_context::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, d_generic_changes::rnd, rohc_debugf, ROHC_ERROR, rohc_get_packet_descr(), ROHC_NEED_REPARSE, d_context::specific, d_context::state, STATIC_CONTEXT, and synchronize().

Referenced by d_generic_decode(), and d_udp_lite_decode().

int d_generic_decode_ir ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_packet,
const unsigned int  rohc_length,
int  large_cid_len,
int  is_addcid_used,
unsigned char *  dest 
)

Decode one IR packet.

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

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_packetThe ROHC packet to decode
rohc_lengthThe length of the ROHC packet to decode
large_cid_lenThe length of the large CID field
is_addcid_usedWhether the add-CID field is present or not
destThe decoded IP packet
Returns:
The length of the uncompressed IP packet or ROHC_ERROR if an error occurs

References d_generic_context::active1, d_generic_context::active2, d_generic_context::build_next_header, build_uncompressed_ip(), c_add_wlsb(), d_generic_context::correction_counter, d_generic_context::current_packet_time, d_decode_dynamic_ip(), d_decode_static_ip(), d_generic_context::decode_dynamic_next_header, d_generic_context::decode_static_next_header, d_generic_context::first_packet_processed, FULL_CONTEXT, GET_BIT_0, d_context::header_16_compressed, d_context::header_16_uncompressed, d_context::header_compressed_size, d_context::header_uncompressed_size, d_generic_changes::ip, ip_get_hdrlen(), ip_get_protocol(), ip_get_version(), d_generic_context::last1, d_generic_context::last2, d_generic_context::list_decomp1, d_generic_context::list_decomp2, d_generic_context::multiple_ip, d_generic_changes::next_header, d_generic_changes::next_header_len, d_generic_context::next_header_proto, PACKET_IR, d_generic_context::packet_type, rohc_debugf, ROHC_ERROR, d_generic_changes::size_list, d_context::specific, d_context::state, synchronize(), and update_inter_packet().

Referenced by d_udp_lite_decode_ir().

void d_generic_destroy ( void *  context)
unsigned int d_generic_detect_ir_dyn_size ( struct d_context context,
unsigned char *  packet,
unsigned int  plen,
unsigned int  large_cid_len 
)

Find the length of the IR-DYN header.

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


 Basic structure of the 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
    +---+---+---+---+---+---+---+---+
    :                               :
 8  /           Payload             / variable length
    :                               :
     - - - - - - - - - - - - - - - -

The function computes the length of the fields 2 + 4-7, ie. the first byte, the Profile and CRC fields and the dynamic chains (outer and inner IP headers).

Parameters:
contextThe decompression context
packetThe IR-DYN packet after the Add-CID byte if present (ie. field 2 in the figure)
plenThe length of the IR-DYN packet minus the Add-CID byte
large_cid_lenThe size of the large CID field (ie. field 3 in the figure)
Returns:
The length of the IR-DYN header, 0 if an error occurs

References d_generic_context::active1, d_generic_context::active2, d_generic_changes::ip, ip_get_protocol(), ip_get_version(), IPV4, IPV4_DYN_PART_SIZE, d_generic_context::list_decomp1, d_generic_context::list_decomp2, rohc_debugf, list_decomp::size_ext, d_context::specific, and version.

Referenced by ip_detect_ir_dyn_size(), and rtp_detect_ir_dyn_size().

unsigned int d_generic_detect_ir_size ( struct d_context context,
unsigned char *  packet,
unsigned int  plen,
unsigned int  large_cid_len 
)

Find the length of the IR header.

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


 Basic structure of the 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
    +---+---+---+---+---+---+---+---+
    |                               |
 9  |           Payload             |  variable length
    |                               |
     - - - - - - - - - - - - - - - -

The function computes the length of the fields 2 + 4-7, ie. the first byte, the Profile and CRC fields and the static and dynamic chains (outer and inner IP headers).

Parameters:
contextThe decompression context
packetThe pointer on the IR packet minus the Add-CID byte (ie. the field 2 in the figure)
plenThe length of the IR packet minus the Add-CID byte
large_cid_lenThe size of the large CID field (ie. the field 3 in the figure)
Returns:
The length of the IR header, 0 if an error occurs

References GET_BIT_0, GET_REAL, d_profile::get_static_part, IPV4, IPV4_DYN_PART_SIZE, IPV6, d_generic_context::list_decomp1, d_generic_context::list_decomp2, d_context::profile, rohc_debugf, list_decomp::size_ext, and d_context::specific.

Referenced by ip_detect_ir_size(), and rtp_detect_ir_size().

int d_generic_get_sn ( struct d_context context)

Get the reference SN value of the context.

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

Parameters:
contextThe decompression context
Returns:
The reference SN value

References d_get_lsb_ref(), d_generic_context::sn, and d_context::specific.

int decode_extension0 ( const unsigned char *const  rohc_data,
const size_t  rohc_data_len,
const rohc_packet_t  packet_type,
uint16_t *const  sn_bits,
size_t *const  sn_bits_nr,
uint16_t *const  ip_id_bits,
size_t *const  ip_id_bits_nr,
uint32_t *const  ts_bits,
size_t *const  ts_bits_nr 
)

Decode the extension 0 of the UOR-2 packet.

Bits extracted:

  • 3 bits of SN
  • UOR-2 or UOR-2-ID: 3 bits of IP-ID
  • UOR-2-RTP or UOR-2-TS: 3 bits of TS
Parameters:
rohc_dataThe ROHC packet to decode
rohc_data_lenThe length of the ROHC packet
packet_typeThe type of ROHC packet
sn_bitsOUT: The SN bits found in the extension
sn_bits_nrOUT: The number of SN bits found in the extension
ip_id_bitsOUT: The IP-ID bits found in the extension
ip_id_bits_nrOUT: The number of IP-ID bits found in the extension
ts_bitsOUT: The TS bits found in the extension
ts_bits_nrOUT: The number of TS bits found in the extension
Returns:
The data length read from the ROHC packet, -1 in case of error

References GET_BIT_0_2, GET_BIT_3_5, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, and rohc_debugf.

Referenced by decode_uor2().

int decode_extension1 ( const unsigned char *const  rohc_data,
const size_t  rohc_data_len,
const rohc_packet_t  packet_type,
uint16_t *const  sn_bits,
size_t *const  sn_bits_nr,
uint16_t *const  ip_id_bits,
size_t *const  ip_id_bits_nr,
uint32_t *const  ts_bits,
size_t *const  ts_bits_nr 
)

Decode the extension 1 of the UOR-2 packet.

Bits extracted:

  • 3 bits of SN
  • UOR-2: 11 bits of IP-ID
  • UOR-2-RTP: 11 bits of TS
  • UOR-2-TS: 3 bits of TS / 8 bits of IP-ID
  • UOR-2-ID: 3 bits of IP-ID / 8 bits of TS
Parameters:
rohc_dataThe ROHC packet to decode
rohc_data_lenThe length of the ROHC packet
packet_typeThe type of ROHC packet
sn_bitsOUT: The SN bits found in the extension
sn_bits_nrOUT: The number of SN bits found in the extension
ip_id_bitsOUT: The IP-ID bits found in the extension
ip_id_bits_nrOUT: The number of IP-ID bits found in the extension
ts_bitsOUT: The TS bits found in the extension
ts_bits_nrOUT: The number of TS bits found in the extension
Returns:
The data length read from the ROHC packet, -1 in case of error

References GET_BIT_0_2, GET_BIT_0_7, GET_BIT_3_5, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, and rohc_debugf.

Referenced by decode_uor2().

int decode_extension2 ( const unsigned char *const  rohc_data,
const size_t  rohc_data_len,
const rohc_packet_t  packet_type,
const int  innermost_ip_hdr,
uint16_t *const  sn_bits,
size_t *const  sn_bits_nr,
uint16_t *const  ip_id_bits,
size_t *const  ip_id_bits_nr,
uint16_t *const  ip_id2_bits,
size_t *const  ip_id2_bits_nr,
uint32_t *const  ts_bits,
size_t *const  ts_bits_nr 
)

Decode the extension 2 of the UOR-2 packet.

Bits extracted:

  • 3 bits of SN
  • UOR-2: 11 bits of outer IP-ID / 8 bits of inner IP-ID
  • UOR-2-RTP: 19 bits of TS
  • UOR-2-TS: 11 bits of TS / 8 bits of the innermost IP-ID
  • UOR-2-ID: 8 bits of TS / 11 bits of the innermost IP-ID
Parameters:
rohc_dataThe ROHC packet to decode
rohc_data_lenThe length of the ROHC packet
packet_typeThe type of ROHC packet
innermost_ip_hdrThe innermost IP header (0 means none, 1 means first IP header, 2 means second IP header)
sn_bitsOUT: The SN bits found in the extension
sn_bits_nrOUT: The number of SN bits found in the extension
ip_id_bitsOUT: The outer IP-ID bits found in the extension
ip_id_bits_nrOUT: The number of outer IP-ID bits found in the extension
ip_id2_bitsOUT: The inner IP-ID bits found in the extension
ip_id2_bits_nrOUT: The number of inner IP-ID bits found in the extension
ts_bitsOUT: The TS bits found in the extension
ts_bits_nrOUT: The number of TS bits found in the extension
Returns:
The data length read from the ROHC packet, -1 in case of error

References GET_BIT_0_2, GET_BIT_0_7, GET_BIT_3_5, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, and rohc_debugf.

Referenced by decode_uor2().

int decode_extension3 ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_data,
const size_t  rohc_data_len,
uint16_t *const  sn_bits,
size_t *const  sn_bits_nr,
uint16_t *const  ip_id_bits,
size_t *const  ip_id_bits_nr,
uint16_t *const  ip_id2_bits,
size_t *const  ip_id2_bits_nr,
uint32_t *const  ts_bits,
size_t *const  ts_bits_nr,
int *const  is_ts_scaled,
uint8_t *const  rtp_m_bits,
size_t *const  rtp_m_bits_nr,
uint8_t *const  rtp_x_bits,
size_t *const  rtp_x_bits_nr,
uint8_t *const  rtp_p_bits,
size_t *const  rtp_p_bits_nr,
uint8_t *const  rtp_pt_bits,
size_t *const  rtp_pt_bits_nr 
)

Decode the extension 3 of the UOR-2 packet.

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_dataThe ROHC date to decode
rohc_data_lenThe length of the ROHC data to decode
sn_bitsOUT: The SN bits found in the extension
sn_bits_nrOUT: The number of SN bits found in the extension
ip_id_bitsOUT: The outer IP-ID bits found in the extension
ip_id_bits_nrOUT: The number of outer IP-ID bits found in the extension
ip_id2_bitsOUT: The inner IP-ID bits found in the extension
ip_id2_bits_nrOUT: The number of inner IP-ID bits found in the extension
ts_bitsOUT: The TS bits found in the extension
ts_bits_nrOUT: The number of TS bits found in the extension
is_ts_scaledOUT: Whether TS is sent scaled or not
rtp_m_bitsOUT: The RTP Marker (M) bits founr in the extension
rtp_m_bits_nrOUT: The number of RTP Marker (M) bits found in the extension
rtp_x_bitsOUT: The RTP eXtension (R-X) bits found in the extension
rtp_x_bits_nrOUT: The number of RTP eXtension (R-X) bits found in the extension
rtp_p_bitsOUT: The RTP Padding (R-P) bits found in the extension
rtp_p_bits_nrOUT: The number of RTP Padding (R-P) bits found in the extension
rtp_pt_bitsOUT: The RTP Payload Type (R-PT) bits found in the extension
rtp_pt_bits_nrOUT: The number of RTP Payload Type (R-PT) bits found in the extension
Returns:
The data length read from the ROHC packet, -2 in case packet must be parsed again, -1 in case of error

References d_generic_context::active1, d_generic_context::active2, d_change_mode_feedback(), d_record_ts_stride(), d_sdvalue_decode(), d_sdvalue_size(), decode_inner_header_flags(), decode_outer_header_flags(), GET_BIT_0, GET_BIT_0_6, GET_BIT_0_7, GET_BIT_1, GET_BIT_2, GET_BIT_3, GET_BIT_3_4, GET_BIT_4, GET_BIT_5, GET_BIT_6_7, GET_BIT_7, GET_NEXT_16_BITS, GET_REAL, d_generic_changes::ip, ip_get_version(), IPV4, d_context::mode, d_generic_context::multiple_ip, d_generic_context::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, 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, d_context::specific, d_generic_context::specific, and d_rtp_context::ts_sc.

Referenced by decode_uor2().

int decode_inner_header_flags ( struct d_context context,
const unsigned char *  flags,
const unsigned char *  fields,
unsigned int  length,
struct d_generic_changes info 
)

Decode the inner IP header flags and fields.

Store the values in an IP header info structure.


  Inner IP header flags (5.7.5):

       0     1     2     3     4     5     6     7
     ..... ..... ..... ..... ..... ..... ..... .....
    | TOS | TTL | DF  | PR  | IPX | NBO | RND | ip2 |  if ip = 1
     ..... ..... ..... ..... ..... ..... ..... .....

  Inner IP header fields (5.7.5):

    ..... ..... ..... ..... ..... ..... ..... .....
   |         Type of Service/Traffic Class         |  if TOS = 1
    ..... ..... ..... ..... ..... ..... ..... .....
   |         Time to Live/Hop Limit                |  if TTL = 1
    ..... ..... ..... ..... ..... ..... ..... .....
   |         Protocol/Next Header                  |  if PR = 1
    ..... ..... ..... ..... ..... ..... ..... .....
   /         IP extension headers                  /  variable,
    ..... ..... ..... ..... ..... ..... ..... .....   if IPX = 1

Parameters:
contextThe decompression context
flagsThe ROHC flags that indicate which IP fields are present in the packet
fieldsThe ROHC packet part that contains some IP header fields
lengthThe length of the ROHC packet part that contains some IP header fields
infoThe IP header info to store the decoded values in
Returns:
The data length read from the ROHC packet, -2 in case packet must be parsed again, -1 in case of error

References GET_BIT_1, GET_BIT_2, GET_BIT_3, GET_BIT_4, GET_BIT_5, GET_BIT_6, GET_BIT_7, GET_REAL, d_profile::id, d_generic_changes::ip, ip_get_version(), ip_set_protocol(), ip_set_tos(), ip_set_ttl(), IPV4, ipv4_get_df(), ipv4_set_df(), d_generic_changes::nbo, d_context::profile, d_generic_changes::rnd, rohc_debugf, and ROHC_PROFILE_RTP.

Referenced by decode_extension3(), and decode_outer_header_flags().

int decode_irdyn ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_packet,
const unsigned int  rohc_length,
int  second_byte,
unsigned char *  dest 
)
int decode_outer_header_flags ( struct d_context context,
const unsigned char *  flags,
const unsigned char *  fields,
unsigned int  length,
struct d_generic_changes info,
uint16_t *const  ext3_ip_id_bits,
size_t *const  ext3_ip_id_bits_nr 
)

Decode the outer IP header flags and fields.

Store the values in an IP header info structure.


  Outer IP header flags (5.7.5):

       0     1     2     3     4     5     6     7
     ..... ..... ..... ..... ..... ..... ..... .....
    | TOS2| TTL2| DF2 | PR2 |IPX2 |NBO2 |RND2 |  I2 |  if ip2 = 1
     ..... ..... ..... ..... ..... ..... ..... .....

  Outer IP header fields

     ..... ..... ..... ..... ..... ..... ..... .....
    |      Type of Service/Traffic Class            |  if TOS2 = 1
     ..... ..... ..... ..... ..... ..... ..... .....
    |         Time to Live/Hop Limit                |  if TTL2 = 1
     ..... ..... ..... ..... ..... ..... ..... .....
    |         Protocol/Next Header                  |  if PR2 = 1
     ..... ..... ..... ..... ..... ..... ..... .....
    /         IP extension header(s)                /  variable,
     ..... ..... ..... ..... ..... ..... ..... .....    if IPX2 = 1
    |                  IP-ID                        |  2 octets,
     ..... ..... ..... ..... ..... ..... ..... .....    if I2 = 1

Parameters:
contextThe decompression context
flagsThe ROHC flags that indicate which IP fields are present in the packet
fieldsThe ROHC packet part that contain some IP header fields
lengthThe length of the ROHC packet part that contains some IP header fields
infoThe IP header info to store the decoded values
ext3_ip_id_bitsOUT: The outer IP-ID bits found in extension 3
ext3_ip_id_bits_nrIN/OUT: The number of outer IP-ID bits found in extension 3
Returns:
The data length read from the ROHC packet, -1 in case of error

References decode_inner_header_flags(), GET_BIT_0, GET_NEXT_16_BITS, GET_REAL, d_generic_changes::ip, ip_get_version(), IPV4, and rohc_debugf.

Referenced by decode_extension3().

int decode_uo0 ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_packet,
const unsigned int  rohc_length,
int  second_byte,
unsigned char *  uncomp_packet 
)

Decode one UO-0 packet.

Steps: A. Parsing of ROHC header B. Decode extracted bits C. Build uncompressed headers D. Check for correct decompression E. Update the compression context


      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    /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
    :   remainder of base header    :                    |
 4  /     see below for details     /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
    :                               :                    |
 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
     --- --- --- --- --- --- --- ---

Here are the first octet and remainder of UO-0 header:


 UO-0 (5.7.1)

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

 Part 4 is empty.

Parts 7, 8, 10, 11 and 12 are not supported. Parts 1 and 3 are parsed in the parent function. Parts 2, 6 and 9 are parsed in this function. Parts 4 and 5 do not exist in the UO-0 packet. Part 13 is parsed in profile-specific function.

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_packetThe ROHC packet to decode
rohc_lengthThe length of the ROHC packet
second_byteThe offset of the 2nd byte in the ROHC packet
uncomp_packetOUT: The decoded IP packet
Returns:
The length of the uncompressed IP packet ROHC_ERROR if an error occurs ROHC_ERROR_CRC if a CRC error occurs

References d_generic_context::active1, d_generic_context::active2, d_generic_context::build_next_header, build_uncompressed_ip(), c_add_wlsb(), d_generic_changes::complist, d_generic_context::compute_crc_dynamic, d_generic_context::compute_crc_static, d_generic_context::correction_counter, CRC_INIT_3, rohc_decomp::crc_table_3, CRC_TYPE_3, d_ip_id_decode(), d_ip_id_update(), d_lsb_decode16(), d_lsb_sync_ref(), d_lsb_update(), d_generic_context::decode_uo_tail, GET_BIT_0_2, GET_BIT_3_6, GET_BIT_7, GET_NEXT_16_BITS, d_context::header_16_compressed, d_context::header_16_uncompressed, d_context::header_compressed_size, d_context::header_uncompressed_size, d_profile::id, d_generic_changes::ip, ip_get_hdrlen(), ip_get_version(), d_generic_context::ip_id1, d_generic_context::ip_id2, IPV4, ipv4_get_id(), ipv4_set_id(), d_generic_context::list_decomp1, d_generic_context::list_decomp2, d_generic_context::multiple_ip, d_generic_changes::next_header, d_generic_changes::next_header_len, d_context::profile, list_decomp::ref_ok, d_generic_changes::rnd, rohc_debugf, rohc_debugf_, ROHC_ERROR, ROHC_ERROR_CRC, ROHC_PROFILE_RTP, d_generic_changes::size_list, d_generic_context::sn, d_context::specific, d_generic_context::specific, synchronize(), rtphdr::timestamp, ts_deduce_from_sn(), d_rtp_context::ts_sc, ts_update_context(), and update_inter_packet().

Referenced by d_generic_decode().

int decode_uo1 ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_packet,
const unsigned int  rohc_length,
int  second_byte,
unsigned char *  uncomp_packet 
)

Decode one UO-1 packet.

Steps: A. Parsing of ROHC header B. Decode extracted bits C. Build uncompressed headers D. Check for correct decompression E. Update the compression context


      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    /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
    :   remainder of base header    :                    |
 4  /     see below for details     /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
    :                               :                    |
 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
     --- --- --- --- --- --- --- ---

Here are the first octet and remainder of UO-1 base headers:


 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.

 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.

Parts 7, 8, 10, 11 and 12 are not supported. Parts 1 and 3 are parsed in the parent function. Parts 2, 4, 6 and 9 are parsed in this function. Part 5 does not exist in the UO-1 packet. Part 13 is parsed in profile-specific function.

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_packetThe ROHC packet to decode
rohc_lengthThe length of the ROHC packet
second_byteThe offset of the 2nd byte in the ROHC packet
uncomp_packetOUT: The decoded IP packet
Returns:
The length of the uncompressed IP packet ROHC_ERROR if an error occurs ROHC_ERROR_CRC if a CRC error occurs

References d_generic_context::active1, d_generic_context::active2, d_generic_context::build_next_header, build_uncompressed_ip(), c_add_wlsb(), d_generic_changes::complist, d_generic_context::compute_crc_dynamic, d_generic_context::compute_crc_static, d_generic_context::correction_counter, CRC_INIT_3, rohc_decomp::crc_table_3, CRC_TYPE_3, d_ip_id_decode(), d_ip_id_update(), d_lsb_decode16(), d_lsb_sync_ref(), d_lsb_update(), d_generic_context::decode_uo_tail, GET_BIT_0_2, GET_BIT_0_4, GET_BIT_0_5, GET_BIT_3_6, GET_BIT_3_7, GET_BIT_5, GET_BIT_6_7, GET_BIT_7, GET_NEXT_16_BITS, GET_REAL, d_context::header_16_compressed, d_context::header_16_uncompressed, d_context::header_compressed_size, d_context::header_uncompressed_size, d_profile::id, d_generic_changes::ip, ip_get_hdrlen(), ip_get_version(), d_generic_context::ip_id1, d_generic_context::ip_id2, IPV4, ipv4_get_id(), ipv4_set_id(), d_generic_context::list_decomp1, d_generic_context::list_decomp2, d_generic_context::multiple_ip, d_generic_changes::next_header, d_generic_changes::next_header_len, d_generic_context::packet_type, PACKET_UO_1, PACKET_UO_1_ID, PACKET_UO_1_RTP, PACKET_UO_1_TS, d_context::profile, list_decomp::ref_ok, d_generic_changes::rnd, rohc_assert, rohc_debugf, rohc_debugf_, ROHC_ERROR, ROHC_ERROR_CRC, ROHC_PROFILE_RTP, d_generic_changes::size_list, d_generic_context::sn, d_context::specific, d_generic_context::specific, synchronize(), rtphdr::timestamp, ts_decode_scaled(), ts_decode_unscaled(), ts_deduce_from_sn(), d_rtp_context::ts_sc, ts_update_context(), and update_inter_packet().

Referenced by d_generic_decode().

int decode_uor2 ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *const  rohc_packet,
const unsigned int  rohc_length,
int  second_byte,
unsigned char *  uncomp_packet 
)

Decode one UOR-2 packet.

Steps: A. Parsing of ROHC base header B. Parsing of ROHC extension header C. Parsing of ROHC tail of header D. Decode extracted bits E. Build uncompressed headers F. Check for correct decompression G. Update the compression context


      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    /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
    :   remainder of base header    :                    |
 4  /     see below for details     /                    |
    :                               :                    |
    +---+---+---+---+---+---+---+---+                    |
    :                               :                    |
 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
     --- --- --- --- --- --- --- ---

Here are the first octet and remainder of UOR-2 base headers:


 UOR-2 (5.11.3):

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

 UOR-2-RTP (5.7.4):

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

 UOR-2-TS (5.7.4):

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

 UOR-2-ID (5.7.4):

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

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

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_packetThe ROHC packet to decode
rohc_lengthThe length of the ROHC packet
second_byteThe offset of the 2nd byte in the ROHC packet
uncomp_packetOUT: The decoded IP packet
Returns:
The length of the uncompressed IP packet ROHC_ERROR if an error occurs ROHC_ERROR_CRC if a CRC error occurs ROHC_NEED_REPARSE if packet needs to be parsed again

References d_generic_context::active1, d_generic_context::active2, d_generic_context::build_next_header, build_uncompressed_ip(), c_add_wlsb(), d_generic_changes::complist, d_generic_context::compute_crc_dynamic, d_generic_context::compute_crc_static, d_generic_context::correction_counter, CRC_INIT_6, CRC_INIT_7, rohc_decomp::crc_table_6, rohc_decomp::crc_table_7, CRC_TYPE_6, CRC_TYPE_7, d_ip_id_decode(), d_ip_id_update(), d_lsb_decode16(), d_lsb_sync_ref(), d_lsb_update(), decode_extension0(), decode_extension1(), decode_extension2(), decode_extension3(), d_generic_context::decode_uo_tail, extension_type(), FULL_CONTEXT, GET_BIT_0_4, GET_BIT_0_5, GET_BIT_0_6, GET_BIT_0_7, GET_BIT_5_7, GET_BIT_6, GET_BIT_7, GET_NEXT_16_BITS, GET_REAL, d_context::header_16_compressed, d_context::header_16_uncompressed, d_context::header_compressed_size, d_context::header_uncompressed_size, d_profile::id, d_generic_changes::ip, ip_get_hdrlen(), ip_get_version(), d_generic_context::ip_id1, d_generic_context::ip_id2, IPV4, ipv4_get_id(), ipv4_set_id(), d_generic_context::list_decomp1, d_generic_context::list_decomp2, d_generic_context::multiple_ip, d_generic_changes::next_header, d_generic_changes::next_header_len, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, d_generic_context::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, d_context::profile, list_decomp::ref_ok, d_generic_changes::rnd, rohc_debugf, rohc_debugf_, ROHC_ERROR, ROHC_ERROR_CRC, ROHC_NEED_REPARSE, ROHC_PROFILE_RTP, d_generic_changes::size_list, d_generic_context::sn, d_context::specific, d_generic_context::specific, d_context::state, synchronize(), rtphdr::timestamp, ts_decode_scaled(), ts_decode_unscaled(), ts_deduce_from_sn(), d_rtp_context::ts_sc, ts_update_context(), and update_inter_packet().

Referenced by d_generic_decode().

uint8_t extension_type ( const unsigned char *const  rohc_extension)

Find out which extension is carried by the UOR-2 packet.

Parameters:
rohc_extensionThe ROHC UOR-2 packet
Returns:
The UOR-2 extension type among:
  • PACKET_EXT_0
  • PACKET_EXT_1
  • PACKET_EXT_2
  • PACKET_EXT_3

References GET_BIT_6_7.

Referenced by decode_uor2().

rohc_packet_t find_packet_type ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *  packet,
const size_t  rohc_length,
int  second_byte 
)

Find out of which type is the ROHC packet.

Parameters:
decompThe ROHC decompressor
contextThe decompression context
packetThe ROHC packet
rohc_lengthThe length of the ROHC packet
second_byteThe offset for the second byte of the ROHC packet (depends on the CID encoding and the packet type, may not exist in packet)
Returns:
The packet type among PACKET_UO_0, PACKET_UO_1, PACKET_UO_1_RTP, PACKET_UO_1_TS, PACKET_UO_1_ID, PACKET_UOR_2, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, PACKET_UOR_2_ID, PACKET_IR_DYN, PACKET_IR or PACKET_UNKNOWN

References GET_BIT_5, GET_BIT_5_7, GET_BIT_6, GET_BIT_6_7, GET_BIT_7, d_profile::id, d_generic_changes::ip, ip_get_version(), IPV4, d_generic_context::last1, d_generic_context::last2, d_generic_context::multiple_ip, PACKET_IR, PACKET_IR_DYN, PACKET_UNKNOWN, 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, d_context::profile, d_generic_changes::rnd, rohc_debugf, ROHC_PROFILE_RTP, and d_context::specific.

Referenced by d_generic_decode(), and d_udp_lite_decode().

int get_bit_index ( unsigned char  byte,
int  index 
)

Get the bit in the byte at the specified index.

Parameters:
bytethe byte to analyse
indexthe specified index
Returns:
the bit

References GET_BIT_0, GET_BIT_1, GET_BIT_2, GET_BIT_3, GET_BIT_4, GET_BIT_5, GET_BIT_6, GET_BIT_7, and rohc_debugf.

void ip6_d_init_table ( struct list_decomp decomp)

Initialize the tables IPv6 extension in decompressor.

Parameters:
decompThe list decompressor

References AH, list_decomp::based_table, rohc_list_item::data, DEST, HBH, d_translation::item, d_translation::known, rohc_list_item::length, RTHDR, list_decomp::trans_table, and rohc_list_item::type.

Referenced by d_generic_create().

void sync_on_failure ( struct d_generic_context context)

Replace the active header changes with the last ones.

Parameters:
contextThe generic decompression context

References d_generic_context::active1, d_generic_context::active2, copy_generic_changes(), d_generic_context::last1, and d_generic_context::last2.

void synchronize ( struct d_generic_context context)

Replace last header changes with the active ones.

Parameters:
contextThe generic decompression context

References d_generic_context::active1, d_generic_context::active2, copy_generic_changes(), d_generic_context::last1, and d_generic_context::last2.

Referenced by d_generic_decode(), d_generic_decode_ir(), decode_irdyn(), decode_uo0(), decode_uo1(), and decode_uor2().

void update_inter_packet ( struct d_generic_context context)

Update the inter-packet time, a sort of average over the last inter-packet times.

Parameters:
contextThe generic decompression context

References d_generic_context::current_packet_time, d_generic_context::inter_arrival_time, d_generic_context::last_packet_time, rohc_debugf, WEIGHT_NEW, and WEIGHT_OLD.

Referenced by d_generic_decode_ir(), decode_irdyn(), decode_uo0(), decode_uo1(), and decode_uor2().