ROHC compression/decompression library
|
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>
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. |
ROHC generic compression context for IP-only, UDP and UDP Lite profiles.
#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.
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.
context | The compression context |
sn_shift | The shift parameter (p) to use for encoding SN with W-LSB |
ip | The IP packet given to initialize the new context |
References c_create_wlsb(), c_generic_destroy(), c_init_header_info(), c_init_tmp_variables(), c_generic_context::code_dynamic_part, c_generic_context::code_static_part, c_generic_context::code_UO_packet_head, c_generic_context::code_uo_remainder, c_context::compressor, c_generic_context::compute_crc_dynamic, compute_crc_dynamic(), compute_crc_static(), c_generic_context::compute_crc_static, c_generic_context::decide_extension, c_generic_context::decide_FO_packet, c_generic_context::decide_SO_packet, c_generic_context::decide_state, decide_state(), c_generic_context::fo_count, c_generic_context::get_next_sn, c_generic_context::go_back_fo_count, c_generic_context::go_back_ir_count, c_generic_context::init_at_IR, c_generic_context::ip_flags, ip_get_inner_packet(), ip_get_protocol(), c_generic_context::ir_count, c_generic_context::is_ip2_initialized, c_generic_context::next_header_len, c_generic_context::next_header_proto, rohc_debugf, ROHC_IPPROTO_IPIP, ROHC_IPPROTO_IPV6, c_generic_context::sn_window, c_generic_context::so_count, c_context::specific, c_generic_context::specific, c_generic_context::tmp, and rohc_comp::wlsb_window_width.
Referenced by c_rtp_create(), c_udp_create(), and c_udp_lite_create().
void c_generic_destroy | ( | struct c_context *const | context | ) |
Destroy the context.
This function is one of the functions that must exist in one profile for the framework to work.
context | The compression context |
References c_destroy_wlsb(), list_comp::curr_list, ipv6_header_info::ext_comp, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, ipv4_header_info::ip_id_window, IPV4, IPV6, c_generic_context::is_ip2_initialized, list_destroy(), list_comp::ref_list, c_generic_context::sn_window, c_context::specific, c_generic_context::specific, ip_header_info::v4, ip_header_info::v6, ip_header_info::version, and zfree.
Referenced by c_generic_create(), c_rtp_create(), c_rtp_destroy(), c_udp_create(), and c_udp_lite_create().
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.
context | The compression context |
ip | The IP packet to encode |
packet_size | The length of the IP packet to encode |
dest | The rohc-packet-under-build buffer |
dest_size | The length of the rohc-packet-under-build buffer |
packet_type | OUT: The type of ROHC packet that is created |
payload_offset | The offset for the payload in the IP packet |
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 | ||
) |
Update the profile when feedback arrives.
This function is one of the functions that must exist in one profile for the framework to work.
context | The compression context |
feedback | The feedback information including the whole feedback packet |
References c_feedback::acktype, c_ack_sn_wlsb(), change_mode(), change_state(), c_context::compressor, crc_calculate(), CRC_INIT_8, rohc_comp::crc_table_8, c_feedback::data, FO, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, ipv4_header_info::ip_id_window, IPV4, IR, c_generic_context::is_ip2_initialized, ROHC_CRC_TYPE_8, rohc_debugf, c_feedback::size, sn, c_generic_context::sn_window, SO, c_context::specific, c_feedback::specific_offset, c_feedback::specific_size, c_context::state, c_feedback::type, ip_header_info::v4, and ip_header_info::version.
void change_mode | ( | struct c_context *const | context, |
const rohc_mode | new_mode | ||
) |
Change the mode of the context.
context | The compression context |
new_mode | The 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.
context | The compression context |
new_state | The 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.
context | The compression context |
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:
context | The 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.
context | The compression context |
nr_innermost_bits | OUT: the maximum number of IP-ID bits for the innermost IPv4 header |
nr_outermost_bits | OUT: 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().