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

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

#include "rohc_decomp.h"
#include "rohc_packets.h"
#include "comp_list.h"
#include "lsb.h"
#include "ip_id.h"
#include "ip.h"
#include <stddef.h>
#include <stdbool.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.

Data Structures

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, 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_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 *first_byte, unsigned int plen, unsigned int large_cid_len)
 Find the length of the IR-DYN header.
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 L   5
#define LIST_COMP_WINDOW   100

Referenced by d_generic_destroy().

#define MAX_ITEM   15

Function Documentation

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.

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