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

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

#include "rohc_comp_internals.h"
#include "rohc_packets.h"
#include "comp_list.h"
#include "ip.h"
#include "crc.h"
#include <stdlib.h>
Include dependency graph for c_generic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ipv4_header_info
 Store information about an IPv4 header between the different compressions of IP packets. More...
struct  ipv6_header_info
 Store information about an IPv6 header between the different compressions of IP packets. More...
struct  ip_header_info
 Store information about an IP (IPv4 or IPv6) header between the different compressions of IP packets. More...
struct  generic_tmp_vars
 Structure that contains variables that are used during one single compression of packet. More...
struct  c_generic_context
 The generic compression context. More...
struct  list_comp
 The list compressor. More...

Defines

#define MAX_ITEM   15
 The number of compression list items.
#define L   5

Functions

int c_generic_create (struct c_context *const context, const rohc_lsb_shift_t sn_shift, 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.
rohc_ext_t decide_extension (const struct c_context *context)
 Decide what extension shall be used in the UO-1/UO-2 packet.
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.
void c_generic_feedback (struct c_context *const context, const struct c_feedback *feedback)
 Update the profile when feedback arrives.
void decide_state (struct c_context *const context)
 Decide the state that should be used for the next packet.
void rohc_get_ipid_bits (const struct c_context *context, size_t *const nr_innermost_bits, size_t *const nr_outermost_bits)
 Get the number of non-random outer/inner IP-ID bits.

Detailed Description

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

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

Define Documentation

#define L   5

The number of compressed list to send to make the reference list L is the name specified in the RFC

#define MAX_ITEM   15

The number of compression list items.


Function Documentation

int c_generic_create ( struct c_context *const  context,
const rohc_lsb_shift_t  sn_shift,
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_init_header_info(), changed_dynamic_both_hdr(), generic_tmp_vars::changed_fields, changed_fields(), generic_tmp_vars::changed_fields2, changed_static_both_hdr(), code_packet(), c_context::compressor, c_generic_context::decide_state, c_generic_context::encode_uncomp_fields, c_generic_context::get_next_sn, 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(), ip_header_info::is_first_header, c_generic_context::is_ip2_initialized, generic_tmp_vars::max_size, ipv4_header_info::nbo, c_generic_context::next_header_len, 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, ipv4_header_info::rnd, rohc_debugf, ROHC_IPPROTO_IPIP, ROHC_IPPROTO_IPV6, ROHC_OK, generic_tmp_vars::send_dynamic, generic_tmp_vars::send_static, ip_packet::size, c_generic_context::sn, c_context::specific, c_generic_context::tmp, ip_header_info::v4, ip_header_info::v6, and rohc_comp::wlsb_window_width.

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

rohc_ext_t decide_extension ( const struct c_context context)

Decide what extension shall be used in the UO-1/UO-2 packet.

Extensions 0, 1 & 2 are IPv4 only because of the IP-ID.

Parameters:
contextThe compression context
Returns:
The extension code among PACKET_NOEXT, PACKET_EXT_0, PACKET_EXT_1 and PACKET_EXT_3 if successful, PACKET_EXT_UNKNOWN otherwise

References generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, 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, rohc_assert, rohc_debugf, rohc_get_ipid_bits(), generic_tmp_vars::send_dynamic, generic_tmp_vars::send_static, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, and c_generic_context::tmp.

Referenced by c_udp_create(), and c_udp_lite_create().

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

void rohc_get_ipid_bits ( const struct c_context context,
size_t *const  nr_innermost_bits,
size_t *const  nr_outermost_bits 
)

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

Parameters:
contextThe compression context
nr_innermost_bitsOUT: the maximum number of IP-ID bits for the innermost IPv4 header
nr_outermost_bitsOUT: the maximum number of IP-ID bits for the outermost IP header

References ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, generic_tmp_vars::nr_ip_id_bits, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, ipv4_header_info::rnd, c_context::specific, c_generic_context::tmp, ip_header_info::v4, and ip_header_info::version.

Referenced by decide_extension().