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

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

#include <stdlib.h>
#include "rohc_decomp.h"
#include "comp_list.h"
Include dependency graph for d_generic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  d_generic_changes
 Store information about an IP header between the different decompressions of IP packets. More...
struct  d_generic_context
 The generic decompression context. More...
struct  list_decomp
 The list decompressor. More...

Defines

#define MAX_ITEM   15
#define LIST_COMP_WINDOW   100
#define L   5

Functions

void * d_generic_create (void)
 Create the generic decompression context.
void d_generic_destroy (void *context)
 Destroy the context.
int d_generic_decode (struct rohc_decomp *decomp, struct d_context *context, unsigned char *packet, int size, 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_decode_ir (struct rohc_decomp *decomp, struct d_context *context, unsigned char *packet, int plen, 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 *first_byte, unsigned int plen, unsigned int large_cid_len)
 Find the length of the IR-DYN header.
int d_algo_list_decompress (struct list_decomp *decomp, const unsigned char *packet)
 Algorithm of list decompression.
int decode_type_0 (struct list_decomp *decomp, const unsigned char *packet, int gen_id, int ps, int m)
 Decode an extension list type 0.
int decode_type_1 (struct list_decomp *decomp, const unsigned char *packet, int gen_id, int ps, int m, int ref_id)
 Decode an extension list type 1.
int decode_type_2 (struct list_decomp *decomp, const unsigned char *packet, int gen_id, int ps, int ref_id)
 Decode an extension list type 2.
int decode_type_3 (struct list_decomp *decomp, const unsigned char *packet, int gen_id, int ps, int m, int ref_id)
 Decode an extension list type 3.
int d_generic_get_sn (struct d_context *context)
 Get the reference SN value of the context.
int find_packet_type (struct rohc_decomp *decomp, struct d_context *context, const unsigned char *packet, 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>
The hackers from ROHC for Linux
David Moreau from TAS

Define Documentation

#define L   5
#define LIST_COMP_WINDOW   100
#define MAX_ITEM   15

Function Documentation

int d_algo_list_decompress ( struct list_decomp decomp,
const unsigned char *  packet 
)

Algorithm of list decompression.

Parameters:
decompThe list decompressor
packetThe ROHC packet to decompress
Returns:
the size of the compressed list

References decode_type_0(), decode_type_1(), decode_type_2(), decode_type_3(), GET_BIT_0_3, GET_BIT_4, GET_BIT_6_7, GET_REAL, list_decomp::list_decomp, m, and rohc_debugf.

Referenced by d_generic_detect_ir_dyn_size(), and d_generic_detect_ir_size().

void* d_generic_create ( void  )
int d_generic_decode ( struct rohc_decomp decomp,
struct d_context context,
unsigned char *  packet,
int  size,
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
packetThe ROHC packet to decode
sizeThe 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)
destThe 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_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,
unsigned char *  packet,
int  plen,
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
packetThe ROHC packet to decode
plenThe 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::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_algo_list_decompress(), 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, 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 d_algo_list_decompress(), 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_type_0 ( struct list_decomp decomp,
const unsigned char *  packet,
int  gen_id,
int  ps,
int  m 
)

Decode an extension list type 0.

Parameters:
decompThe list decompressor
packetThe ROHC packet to decompress
gen_idThe id of the current list
psThe ps field
mThe m fiel
Returns:
the size of the compressed list

References list_decomp::based_table, check_id(), list_decomp::counter, list_decomp::counter_list, list_decomp::create_item, empty_list(), c_list::first_elt, c_list::gen_id, GET_BIT_0_2, GET_BIT_0_6, GET_BIT_3, GET_BIT_4_6, GET_BIT_7, list_decomp::get_ext_size, insert_elt(), d_translation::known, L, LIST_COMP_WINDOW, list_decomp::list_table, m, list_decomp::ref_list, list_decomp::ref_ok, rohc_debugf, and list_decomp::trans_table.

Referenced by d_algo_list_decompress().

int decode_type_1 ( struct list_decomp decomp,
const unsigned char *  packet,
int  gen_id,
int  ps,
int  m,
int  ref_id 
)

Decode an extension list type 1.

Parameters:
decompThe list decompressor
packetThe ROHC packet to decompress
gen_idThe id of the current list
psThe ps field
mThe m fiel
ref_idThe id of the reference list
Returns:
the size of the compressed list

References list_decomp::based_table, check_id(), list_decomp::check_index, list_decomp::counter, list_decomp::counter_list, list_decomp::create_item, empty_list(), c_list::first_elt, c_list::gen_id, GET_BIT_0_2, GET_BIT_0_6, GET_BIT_3, GET_BIT_4_6, GET_BIT_7, get_bit_index(), get_elt(), list_decomp::get_ext_size, list_elt::index_table, insert_elt(), list_elt::item, d_translation::known, L, LIST_COMP_WINDOW, list_decomp::list_table, list_decomp::ref_list, list_decomp::ref_ok, rohc_debugf, size_list(), and list_decomp::trans_table.

Referenced by d_algo_list_decompress().

int decode_type_2 ( struct list_decomp decomp,
const unsigned char *  packet,
int  gen_id,
int  ps,
int  ref_id 
)

Decode an extension list type 2.

Parameters:
decompThe list decompressor
packetThe ROHC packet to decompress
gen_idThe id of the current list
psThe ps field
ref_idThe id of the reference list
Returns:
the size of the compressed list

References check_id(), list_decomp::counter, list_decomp::counter_list, empty_list(), c_list::first_elt, c_list::gen_id, get_bit_index(), get_elt(), list_elt::index_table, insert_elt(), list_elt::item, L, LIST_COMP_WINDOW, list_decomp::list_table, MIN, list_decomp::ref_list, list_decomp::ref_ok, rohc_debugf, and size_list().

Referenced by d_algo_list_decompress().

int decode_type_3 ( struct list_decomp decomp,
const unsigned char *  packet,
int  gen_id,
int  ps,
int  m,
int  ref_id 
)
int find_packet_type ( struct rohc_decomp decomp,
struct d_context context,
const unsigned char *  packet,
int  second_byte 
)

Find out of which type is the ROHC packet.

Parameters:
decompThe ROHC decompressor
contextThe decompression context
packetThe ROHC packet
second_byteThe offset for the second byte of the ROHC packet (depends on the CID encoding and the packet type)
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_PROFILE_RTP, and d_context::specific.

Referenced by d_generic_decode(), and d_udp_lite_decode().