ROHC compression/decompression library
|
ROHC generic compression context for IP-only, UDP, UDP-Lite, ESP, and RTP profiles. More...
#include "c_generic.h"
#include "c_rtp.h"
#include "rohc_traces.h"
#include "rohc_debug.h"
#include "rohc_packets.h"
#include "rohc_utils.h"
#include "cid.h"
#include "sdvl.h"
#include "crc.h"
#include "config.h"
#include <string.h>
#include <assert.h>
Defines | |
#define | MOD_TOS 0x0001 |
#define | MOD_TTL 0x0010 |
#define | MOD_PROTOCOL 0x0020 |
Functions | |
int | code_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest) |
Build the ROHC packet to send. | |
int | code_IR_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest) |
Build the IR packet. | |
int | code_IR_DYN_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest) |
Build the IR-DYN packet. | |
int | code_generic_static_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter) |
Build the static part of the IR and IR-DYN packets. | |
int | code_ipv4_static_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter) |
Build the IPv4 static part of the IR and IR-DYN packets. | |
int | code_ipv6_static_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter) |
Build the IPv6 static part of the IR and IR-DYN packets. | |
int | code_generic_dynamic_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter) |
int | code_ipv4_dynamic_part (const struct c_context *const context, struct ip_header_info *header_info, const struct ip_packet *ip, unsigned char *const dest, int counter) |
Build the IPv4 dynamic part of the IR and IR-DYN packets. | |
int | code_ipv6_dynamic_part (const struct c_context *context, struct ip_header_info *const header_info, const struct ip_packet *ip, unsigned char *const dest, int counter) |
Build the IPv6 dynamic part of the IR and IR-DYN packets. | |
int | code_uo_remainder (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest, int counter) |
Build the tail of the UO packet. | |
int | code_UO0_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest) |
Build the UO-0 packet. | |
int | code_UO1_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest) |
Build the UO-1 packet. | |
int | code_UO2_packet (struct c_context *const context, const struct ip_packet *ip, const struct ip_packet *ip2, const unsigned char *next_header, unsigned char *const dest) |
Build the UO-2 packet. | |
int | code_UOR2_bytes (const struct c_context *context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte) |
Code some fields of the UOR-2 packet. | |
int | code_UOR2_RTP_bytes (const struct c_context *context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte) |
Code some fields of the UOR-2-RTP packet. | |
int | code_UOR2_TS_bytes (const struct c_context *context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte) |
Code some fields of the UOR-2-TS packet. | |
int | code_UOR2_ID_bytes (const struct c_context *context, const rohc_ext_t extension, unsigned char *const f_byte, unsigned char *const s_byte, unsigned char *const t_byte) |
Code some fields of the UOR-2-ID packet. | |
int | code_EXT0_packet (const struct c_context *context, unsigned char *const dest, int counter) |
Build the extension 0 of the UO-2 packet. | |
int | code_EXT1_packet (const struct c_context *context, unsigned char *const dest, int counter) |
Build the extension 1 of the UO-2 packet. | |
int | code_EXT2_packet (const struct c_context *context, unsigned char *const dest, int counter) |
Build the extension 2 of the UO-2 packet. | |
int | code_EXT3_packet (const struct c_context *context, const struct ip_packet *ip, const struct ip_packet *ip2, unsigned char *const dest, int counter) |
Build the extension 3 of the UO-2 packet. | |
int | rtp_header_flags_and_fields (const struct c_context *context, const unsigned short changed_f, const struct ip_packet *ip, unsigned char *const dest, int counter) |
int | header_flags (const struct c_context *context, struct ip_header_info *const header_info, const unsigned short changed_f, const struct ip_packet *ip, const int ip2_or_I2, const size_t nr_ip_id_bits, unsigned char *const dest, int counter) |
Build inner or outer IP header flags. | |
int | header_fields (const struct c_context *context, struct ip_header_info *const header_info, const unsigned short changed_f, const struct ip_packet *ip, const int I, const ip_header_pos_t ip_hdr_pos, unsigned char *const dest, int counter) |
Build inner or outer IP header fields. | |
int | changed_static_both_hdr (const struct c_context *context, const struct ip_packet *ip, const struct ip_packet *ip2) |
Check if the static parts of the context changed in any of the two IP headers. | |
int | changed_static_one_hdr (const struct c_context *const context, const unsigned short changed_fields, struct ip_header_info *const header_info, const struct ip_packet *ip) |
Check if the static part of the context changed in the new IP packet. | |
int | changed_dynamic_both_hdr (const struct c_context *context, const struct ip_packet *ip, const struct ip_packet *ip2) |
Check if the dynamic parts of the context changed in any of the two IP headers. | |
int | changed_dynamic_one_hdr (const struct c_context *const context, const unsigned short changed_fields, struct ip_header_info *const header_info, const struct ip_packet *ip) |
Check if the dynamic part of the context changed in the IP packet. | |
unsigned short | changed_fields (const struct ip_header_info *header_info, const struct ip_packet *ip) |
Find the IP fields that changed between the profile and a new IP packet. | |
int | is_changed (const unsigned short changed_fields, const unsigned short check_field) |
Check if a specified IP field has changed. | |
int | c_init_header_info (struct ip_header_info *header_info, const struct ip_packet *ip, const size_t wlsb_window_width) |
Initialize the inner or outer IP header info stored in the context. | |
void | c_init_tmp_variables (struct generic_tmp_vars *tmp_vars) |
Initialize all temporary variables stored in the context. | |
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. | |
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 | periodic_down_transition (struct c_context *context) |
Periodically change the context state after a certain number of packets. | |
void | decide_state (struct c_context *const context) |
Decide the state that should be used for the next packet. | |
int | code_generic_dynamic_part (const struct c_context *context, struct ip_header_info *const header_info, const const struct ip_packet *ip, unsigned char *const dest, int counter) |
Build the dynamic part of the IR and IR-DYN packets. | |
rohc_ext_t | decide_extension (const struct c_context *context) |
Decide what extension shall be used in the UO-1/UO-2 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, UDP-Lite, ESP, and RTP profiles.
#define MOD_PROTOCOL 0x0020 |
A flag to indicate that the IPv4 Protocol field changed in IP header
Referenced by changed_fields(), changed_static_one_hdr(), header_fields(), and header_flags().
#define MOD_TOS 0x0001 |
A flag to indicate that IPv4 Type Of Service field changed in IP header
Referenced by changed_dynamic_one_hdr(), changed_fields(), header_fields(), and header_flags().
#define MOD_TTL 0x0010 |
A flag to indicate that IPv4 Time To Live field changed in IP header
Referenced by changed_dynamic_one_hdr(), changed_fields(), header_fields(), and header_flags().
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.
int c_init_header_info | ( | struct ip_header_info * | header_info, |
const struct ip_packet * | ip, | ||
const size_t | wlsb_window_width | ||
) |
Initialize the inner or outer IP header info stored in the context.
header_info | The inner or outer IP header info to initialize |
ip | The inner or outer IP header |
wlsb_window_width | The width of the W-LSB sliding window for IPv4 IP-ID (must be > 0) |
References c_create_wlsb(), list_comp::changed, list_comp::compare, list_comp::counter, list_comp::create_item, list_comp::curr_list, ipv4_header_info::df_count, ipv6_header_info::ext_comp, c_list::first_elt, list_comp::free_table, c_list::gen_id, list_comp::get_extension, list_comp::get_index_table, list_comp::get_size, ip_header_info::info, ip_get_extension_size(), ip_get_version(), ipv4_header_info::ip_id_window, IPV4, ip_header_info::is_first_header, MAX_FO_COUNT, ipv4_header_info::nbo_count, ip_header_info::protocol_count, list_comp::ref_list, ipv4_header_info::rnd_count, rohc_debugf, ROHC_LSB_SHIFT_IP_ID, ip_header_info::tos_count, ip_header_info::ttl_count, ip_header_info::v4, ip_header_info::v6, and ip_header_info::version.
Referenced by c_generic_create(), and c_generic_encode().
void c_init_tmp_variables | ( | struct generic_tmp_vars * | tmp_vars | ) |
Initialize all temporary variables stored in the context.
tmp_vars | The temporary variables to initialize |
References generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, generic_tmp_vars::max_size, generic_tmp_vars::nr_ip_id_bits, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, generic_tmp_vars::packet_type, PACKET_UNKNOWN, generic_tmp_vars::send_dynamic, and generic_tmp_vars::send_static.
Referenced by c_generic_create().
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().
int changed_dynamic_both_hdr | ( | const struct c_context * | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2 | ||
) |
Check if the dynamic parts of the context changed in any of the two IP headers.
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
References changed_dynamic_one_hdr(), generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, c_generic_context::ip2_flags, c_generic_context::ip_flags, generic_tmp_vars::nr_of_ip_hdr, rohc_debugf, c_context::specific, and c_generic_context::tmp.
Referenced by c_generic_encode().
int changed_dynamic_one_hdr | ( | const struct c_context *const | context, |
const unsigned short | changed_fields, | ||
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip | ||
) |
Check if the dynamic part of the context changed in the IP packet.
The fields classified as CHANGING by RFC need to be checked for change. The fields are:
The IP-ID changes are managed outside of this function.
Althought classified as STATIC, the IPv4 Don't Fragment flag is not part of the static initialization, but of the dynamic initialization. It needs to be checked for change.
Other flags are checked for change for IPv4. There are IP-ID related flags:
context | The compression context |
changed_fields | The fields that changed, created by the function changed_fields |
header_info | The header info stored in the profile |
ip | The header of the new IP packet |
References ipv4_header_info::df_count, c_generic_context::fo_count, ip_header_info::info, ip_get_version(), IPV4, IPV4_GET_DF, ipv4_get_df(), is_changed(), MAX_FO_COUNT, MOD_TOS, MOD_TTL, ipv4_header_info::nbo, ipv4_header_info::nbo_count, ipv4_header_info::old_ip, ipv4_header_info::old_nbo, ipv4_header_info::old_rnd, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, c_context::specific, ip_header_info::tos_count, ip_header_info::ttl_count, and ip_header_info::v4.
Referenced by changed_dynamic_both_hdr(), and code_EXT3_packet().
unsigned short changed_fields | ( | const struct ip_header_info * | header_info, |
const struct ip_packet * | ip | ||
) |
Find the IP fields that changed between the profile and a new IP packet.
Only some fields are checked for change in the compression process, so only check these ones to avoid useless work. The fields to check are: TOS/TC, TTL/HL and Protocol/Next Header.
header_info | The header info stored in the profile |
ip | The header of the new IP packet |
References ip_header_info::info, ip_get_protocol(), ip_get_tos(), ip_get_ttl(), ip_get_version(), IPV4, IPV6_GET_TC, MOD_PROTOCOL, MOD_TOS, MOD_TTL, ipv4_header_info::old_ip, ipv6_header_info::old_ip, ipv4_hdr::protocol, rohc_debugf, ipv4_hdr::tos, ipv4_hdr::ttl, ip_header_info::v4, and ip_header_info::v6.
Referenced by c_generic_encode().
int changed_static_both_hdr | ( | const struct c_context * | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2 | ||
) |
Check if the static parts of the context changed in any of the two IP headers.
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
References generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, changed_static_one_hdr(), c_generic_context::ip2_flags, c_generic_context::ip_flags, generic_tmp_vars::nr_of_ip_hdr, c_context::specific, and c_generic_context::tmp.
Referenced by c_generic_encode().
int changed_static_one_hdr | ( | const struct c_context *const | context, |
const unsigned short | changed_fields, | ||
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip | ||
) |
Check if the static part of the context changed in the new IP packet.
The fields classified as STATIC-DEF by RFC do not need to be checked for change. These fields are constant for all packets in a stream (ie. a profile context). So, the Source Address and Destination Address fields are not checked for change for both IPv4 and IPv6. The Flow Label is not checked for IPv6.
Althought not classified as STATIC-DEF, the Version field is the same for all packets in a stream (ie. a profile context) and therefore does not need to be checked for change neither for IPv4 nor IPv6.
Althought classified as STATIC, the IPv4 Don't Fragment flag is not part of the static initialization, but of the dynamic initialization.
Summary:
context | The compression context |
changed_fields | The fields that changed, created by the function changed_fields |
header_info | The header info stored in the profile |
ip | The header of the new IP packet |
References c_generic_context::fo_count, is_changed(), MAX_FO_COUNT, MOD_PROTOCOL, ip_header_info::protocol_count, rohc_debugf, and c_context::specific.
Referenced by changed_static_both_hdr(), and code_EXT3_packet().
int code_EXT0_packet | ( | const struct c_context * | context, |
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the extension 0 of the UO-2 packet.
Extension 0 for non-RTP profiles (5.11.4): +---+---+---+---+---+---+---+---+ 1 | 0 0 | SN | IP-ID | +---+---+---+---+---+---+---+---+ Extension 0 for RTP profile (5.7.5): +---+---+---+---+---+---+---+---+ 1 | 0 0 | SN | +T | +---+---+---+---+---+---+---+---+ if T = 0 -> +T = IP-ID -> -T = TS if T = 1 -> +T = TS -> -T = IP-ID no T bit -> +T = -T = TS
context | The compression context |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, rohc_assert, ROHC_IP_HDR_NONE, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, and rtp_tmp_vars::ts_send.
Referenced by code_UO2_packet().
int code_EXT1_packet | ( | const struct c_context * | context, |
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the extension 1 of the UO-2 packet.
Extension 1 for non-RTP profiles (5.11.4): +---+---+---+---+---+---+---+---+ 1 | 0 1 | SN | IP-ID | +---+---+---+---+---+---+---+---+ 2 | IP-ID | +---+---+---+---+---+---+---+---+ Extension 1 for RTP profile (5.7.5): +---+---+---+---+---+---+---+---+ 1 | 0 1 | SN | +T | +---+---+---+---+---+---+---+---+ 2 | -T | +---+---+---+---+---+---+---+---+ if T = 0 -> +T = IP-ID -> -T = TS if T = 1 -> +T = TS -> -T = IP-ID no T bit -> +T = -T = TS
context | The compression context |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, rohc_assert, ROHC_IP_HDR_NONE, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, and rtp_tmp_vars::ts_send.
Referenced by code_UO2_packet().
int code_EXT2_packet | ( | const struct c_context * | context, |
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the extension 2 of the UO-2 packet.
Extension 2 for non-RTP profiles (5.11.4): +---+---+---+---+---+---+---+---+ 1 | 1 0 | SN | IP-ID2 | +---+---+---+---+---+---+---+---+ 2 | IP-ID2 | +---+---+---+---+---+---+---+---+ 3 | IP-ID | +---+---+---+---+---+---+---+---+ IP-ID2 is for outer IP-ID field Extension 2 for RTP profile (5.7.5): +---+---+---+---+---+---+---+---+ 1 | 1 0 | SN | +T | +---+---+---+---+---+---+---+---+ 2 | +T | +---+---+---+---+---+---+---+---+ 3 | -T | +---+---+---+---+---+---+---+---+ if T = 0 -> +T = IP-ID -> -T = TS if T = 1 -> +T = TS -> -T = IP-ID no T bit -> +T = -T = TS
context | The compression context |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References ipv4_header_info::id_delta, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, c_generic_context::is_ip2_initialized, generic_tmp_vars::packet_type, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, ipv4_header_info::rnd, rohc_assert, rohc_debugf, ROHC_IP_HDR_NONE, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.
Referenced by code_UO2_packet().
int code_EXT3_packet | ( | const struct c_context * | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the extension 3 of the UO-2 packet.
Extension 3 for non-RTP profiles (5.7.5 & 5.11.4): 0 1 2 3 4 5 6 7 +-----+-----+-----+-----+-----+-----+-----+-----+ 1 | 1 1 | S | Mode | I | ip | ip2 | +-----+-----+-----+-----+-----+-----+-----+-----+ 2 | Inner IP header flags | | if ip = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ 3 | Outer IP header flags | if ip2 = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ 4 | SN | if S = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ | | 5 / Inner IP header fields / variable, | | if ip = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ 6 | IP-ID | 2 octets, if I = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ | | 7 / Outer IP header fields / variable, | | if ip2 = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ Extension 3 for RTP profile (5.7.5): 0 1 2 3 4 5 6 7 +-----+-----+-----+-----+-----+-----+-----+-----+ 1 | 1 1 | S |R-TS | Tsc | I | ip | rtp | +-----+-----+-----+-----+-----+-----+-----+-----+ 2 | Inner IP header flags | ip2 | if ip = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ 3 | Outer IP header flags | if ip2 = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ 4 | SN | if S = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ | | 4.1 / TS / 1-4octets, if R-TS = 1 | | +-----+-----+-----+-----+-----+-----+-----+-----+ | | 5 / Inner IP header fields / variable, | | if ip = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ 6 | IP-ID | 2 octets, if I = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ | | 7 / Outer IP header fields / variable, | | if ip2 = 1 +-----+-----+-----+-----+-----+-----+-----+-----+ | | variable, 8 / RTP Header flags and fields / if rtp = 1 | | +-----+-----+-----+-----+-----+-----+-----+-----+
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References c_bytesSdvl(), c_encodeSdvl(), changed_dynamic_one_hdr(), generic_tmp_vars::changed_fields, generic_tmp_vars::changed_fields2, changed_static_one_hdr(), header_fields(), header_flags(), c_profile::id, ipv4_header_info::id_delta, ip_header_info::info, INIT_STRIDE, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_version(), IPV4, MAX_FO_COUNT, c_context::mode, generic_tmp_vars::nr_ip_id_bits, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, generic_tmp_vars::packet_type, PACKET_UO_1_ID, PACKET_UOR_2, PACKET_UOR_2_ID, PACKET_UOR_2_RTP, PACKET_UOR_2_TS, c_context::profile, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_assert, rohc_debugf, ROHC_IP_HDR_FIRST, ROHC_IP_HDR_NONE, ROHC_IP_HDR_SECOND, ROHC_PROFILE_RTP, rtp_header_flags_and_fields(), sc_rtp_context::rtp_pt_change_count, rtp_tmp_vars::rtp_pt_changed, SEND_SCALED, c_generic_context::sn, c_context::specific, c_generic_context::specific, ts_sc_comp::state, sc_rtp_context::tmp, c_generic_context::tmp, sc_rtp_context::ts_sc, rtp_tmp_vars::ts_send, and ip_header_info::v4.
Referenced by code_UO2_packet().
int code_generic_dynamic_part | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Referenced by code_IR_DYN_packet(), and code_IR_packet().
int code_generic_dynamic_part | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the dynamic part of the IR and IR-DYN packets.
context | The compression context |
header_info | The IP header info stored in the profile |
ip | The IP header the dynamic part is built for |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References code_ipv4_dynamic_part(), code_ipv6_dynamic_part(), ip_get_version(), and IPV4.
int code_generic_static_part | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the static part of the IR and IR-DYN packets.
context | The compression context |
header_info | The IP header info stored in the profile |
ip | The IP header the static part is built for |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References code_ipv4_static_part(), code_ipv6_static_part(), ip_get_version(), and IPV4.
Referenced by code_IR_packet().
int code_ipv4_dynamic_part | ( | const struct c_context *const | context, |
struct ip_header_info * | header_info, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the IPv4 dynamic part of the IR and IR-DYN packets.
Dynamic part IPv4 (5.7.7.4): +---+---+---+---+---+---+---+---+ 1 | Type of Service | +---+---+---+---+---+---+---+---+ 2 | Time to Live | +---+---+---+---+---+---+---+---+ 3 / Identification / 2 octets +---+---+---+---+---+---+---+---+ 4 | DF|RND|NBO| 0 | +---+---+---+---+---+---+---+---+ 5 / Generic extension header list / variable length +---+---+---+---+---+---+---+---+
context | The compression context |
header_info | The IP header info stored in the profile |
ip | The IPv4 header the dynamic part is built for |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References ipv4_header_info::df_count, ip_header_info::info, ip_get_tos(), ip_get_ttl(), ipv4_get_df(), ipv4_get_id_nbo(), ipv4_header_info::nbo, ipv4_header_info::nbo_count, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, ip_header_info::tos_count, ip_header_info::ttl_count, and ip_header_info::v4.
Referenced by code_generic_dynamic_part().
int code_ipv4_static_part | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the IPv4 static part of the IR and IR-DYN packets.
Static part IPv4 (5.7.7.4): +---+---+---+---+---+---+---+---+ 1 | Version = 4 | 0 | +---+---+---+---+---+---+---+---+ 2 | Protocol | +---+---+---+---+---+---+---+---+ 3 / Source Address / 4 octets +---+---+---+---+---+---+---+---+ 4 / Destination Address / 4 octets +---+---+---+---+---+---+---+---+
context | The compression context |
header_info | The IP header info stored in the profile |
ip | The IPv4 header the static part is built for |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References ip_get_protocol(), IPV4_ADDR_FORMAT, IPV4_ADDR_RAW, ipv4_get_daddr(), ipv4_get_saddr(), ip_header_info::protocol_count, and rohc_debugf.
Referenced by code_generic_static_part().
int code_ipv6_dynamic_part | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the IPv6 dynamic part of the IR and IR-DYN packets.
Dynamic part IPv6 (5.7.7.3): +---+---+---+---+---+---+---+---+ 1 | Traffic Class | 1 octet +---+---+---+---+---+---+---+---+ 2 | Hop Limit | 1 octet +---+---+---+---+---+---+---+---+ 3 / Generic extension header list / variable length +---+---+---+---+---+---+---+---+
context | The compression context |
header_info | The IP header info stored in the profile |
ip | The IPv6 header the dynamic part is built for |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References list_comp::changed, list_comp::curr_list, ipv6_header_info::ext_comp, ip_header_info::info, ip_get_tos(), ip_get_ttl(), list_comp::is_present, list_get_size(), list_comp::ref_list, rohc_debugf, ip_header_info::tos_count, ip_header_info::ttl_count, and ip_header_info::v6.
Referenced by code_generic_dynamic_part().
int code_ipv6_static_part | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the IPv6 static part of the IR and IR-DYN packets.
Static part IPv6 (5.7.7.3): +---+---+---+---+---+---+---+---+ 1 | Version = 6 |Flow Label(msb)| 1 octet +---+---+---+---+---+---+---+---+ 2 / Flow Label (lsb) / 2 octets +---+---+---+---+---+---+---+---+ 3 | Next Header | 1 octet +---+---+---+---+---+---+---+---+ 4 / Source Address / 16 octets +---+---+---+---+---+---+---+---+ 5 / Destination Address / 16 octets +---+---+---+---+---+---+---+---+
context | The compression context |
header_info | The IP header info stored in the profile |
ip | The IPv6 header the static part is built for |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References ip_get_protocol(), IPV6_ADDR_FORMAT, IPV6_ADDR_IN6, ipv6_get_daddr(), ipv6_get_flow_label(), ipv6_get_saddr(), ip_header_info::protocol_count, and rohc_debugf.
Referenced by code_generic_static_part().
int code_IR_DYN_packet | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest | ||
) |
Build the IR-DYN packet.
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 nor ESP +---+---+---+---+---+---+---+---+ : : / Payload / variable length : : - - - - - - - - - - - - - - - -
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header data used to code the dynamic part of the next header for some profiles such as UDP, UDP-Lite, etc. |
dest | The rohc-packet-under-build buffer |
References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_dynamic_part, code_generic_dynamic_part(), c_generic_context::code_ir_remainder, c_context::compressor, crc_calculate(), CRC_INIT_8, rohc_comp::crc_table_8, c_profile::id, c_generic_context::init_at_IR, c_generic_context::ip2_flags, c_generic_context::ip_flags, generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, c_context::profile, ROHC_CRC_TYPE_8, rohc_debugf, c_context::specific, and c_generic_context::tmp.
Referenced by code_packet().
int code_IR_packet | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest | ||
) |
Build the IR packet.
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 nor ESP +---+---+---+---+---+---+---+---+ | | | Payload | variable length | | - - - - - - - - - - - - - - - -
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header data used to code the static and dynamic parts of the next header for some profiles such as UDP, UDP-Lite, and so on. |
dest | The rohc-packet-under-build buffer |
References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_dynamic_part, code_generic_dynamic_part(), code_generic_static_part(), c_generic_context::code_ir_remainder, c_generic_context::code_static_part, c_context::compressor, crc_calculate(), CRC_INIT_8, rohc_comp::crc_table_8, c_profile::id, c_generic_context::init_at_IR, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_version(), IPV4, generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_ip_id_bits, generic_tmp_vars::nr_ip_id_bits2, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, c_context::profile, ROHC_CRC_TYPE_8, rohc_debugf, c_context::specific, and c_generic_context::tmp.
Referenced by code_packet().
int code_packet | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest | ||
) |
Build the ROHC packet to send.
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header such as UDP or UDP-Lite |
dest | The rohc-packet-under-build buffer |
References code_IR_DYN_packet(), code_IR_packet(), code_UO0_packet(), code_UO1_packet(), code_UO2_packet(), PACKET_IR, PACKET_IR_DYN, generic_tmp_vars::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, rohc_debugf, c_context::specific, and c_generic_context::tmp.
Referenced by c_generic_encode().
int code_UO0_packet | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest | ||
) |
Build the UO-0 packet.
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 / : : +---+---+---+---+---+---+---+---+ UO-0 (5.7.1) 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 0 | SN | CRC | +===+===+===+===+===+===+===+===+
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header such as UDP or UDP-Lite |
dest | The rohc-packet-under-build buffer |
References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_UO_packet_head, code_uo_remainder(), c_context::compressor, c_generic_context::compute_crc_dynamic, c_generic_context::compute_crc_static, CRC_INIT_3, rohc_comp::crc_table_3, ip_packet::data, ip_get_raw_data(), generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, ROHC_CRC_TYPE_3, rohc_debugf, c_generic_context::sn, c_context::specific, and c_generic_context::tmp.
Referenced by code_packet().
int code_UO1_packet | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest | ||
) |
Build the UO-1 packet.
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.
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 / : : +---+---+---+---+---+---+---+---+ 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.
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header such as UDP or UDP-Lite |
dest | The rohc-packet-under-build buffer |
References c_context::cid, medium::cid_type, code_cid_values(), c_generic_context::code_UO_packet_head, code_uo_remainder(), c_context::compressor, c_generic_context::compute_crc_dynamic, c_generic_context::compute_crc_static, CRC_INIT_3, rohc_comp::crc_table_3, ip_packet::data, c_profile::id, ipv4_header_info::id_delta, ip_header_info::info, c_generic_context::ip_flags, ip_get_raw_data(), IPV4, rtp_tmp_vars::m_set, generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::packet_type, PACKET_UO_1, PACKET_UO_1_ID, PACKET_UO_1_RTP, PACKET_UO_1_TS, c_context::profile, rohc_assert, ROHC_CRC_TYPE_3, rohc_debugf, ROHC_PROFILE_RTP, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.
Referenced by code_packet().
int code_UO2_packet | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest | ||
) |
Build the UO-2 packet.
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 / : : +---+---+---+---+---+---+---+---+ UOR-2 (5.11.3): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | SN | +===+===+===+===+===+===+===+===+ 5 | X | CRC | +---+---+---+---+---+---+---+---+ UOR-2-RTP (5.7.4): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | TS | +===+===+===+===+===+===+===+===+ 4 | TS| M | SN | +---+---+---+---+---+---+---+---+ 5 | X | CRC | +---+---+---+---+---+---+---+---+ UOR-2-TS (5.7.4): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | TS | +===+===+===+===+===+===+===+===+ 4 |T=1| M | SN | +---+---+---+---+---+---+---+---+ 5 | X | CRC | +---+---+---+---+---+---+---+---+ UOR-2-ID (5.7.4): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | IP-ID | +===+===+===+===+===+===+===+===+ 4 |T=0| M | SN | +---+---+---+---+---+---+---+---+ 5 | X | CRC | +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+ : : 6 / Extension / : : --- --- --- --- --- --- --- --- X: X = 0 indicates that no extension is present; X = 1 indicates that an extension is present. T: T = 0 indicates format UOR-2-ID; T = 1 indicates format UOR-2-TS.
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header such as UDP or UDP-Lite |
dest | The rohc-packet-under-build buffer |
References c_context::cid, medium::cid_type, code_cid_values(), code_EXT0_packet(), code_EXT1_packet(), code_EXT2_packet(), code_EXT3_packet(), c_generic_context::code_UO_packet_head, code_uo_remainder(), code_UOR2_bytes(), code_UOR2_ID_bytes(), code_UOR2_RTP_bytes(), code_UOR2_TS_bytes(), c_context::compressor, c_generic_context::compute_crc_dynamic, c_generic_context::compute_crc_static, CRC_INIT_6, CRC_INIT_7, rohc_comp::crc_table_6, rohc_comp::crc_table_7, ip_packet::data, c_generic_context::decide_extension, extension, c_profile::id, ip_get_raw_data(), generic_tmp_vars::max_size, rohc_comp::medium, generic_tmp_vars::nr_of_ip_hdr, 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, c_context::profile, rohc_assert, ROHC_CRC_TYPE_6, ROHC_CRC_TYPE_7, rohc_debugf, rohc_get_ext_descr(), ROHC_PROFILE_RTP, c_context::specific, and c_generic_context::tmp.
Referenced by code_packet().
int code_uo_remainder | ( | struct c_context *const | context, |
const struct ip_packet * | ip, | ||
const struct ip_packet * | ip2, | ||
const unsigned char * | next_header, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the tail of the UO packet.
The general format for the UO packets is: 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 / | : : | +---+---+---+---+---+---+---+---+ | 4 / remainder of base header / | +---+---+---+---+---+---+---+---+ | : : | 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 --- --- --- --- --- --- --- ---
Parts 7, 8, 10, 11 and 12 are not supported. Parts 1, 2, 3, 4 and 5 are built in packet-specific functions. Parts 6 and 9 are built in this function. Part 13 is built in profile-specific function.
context | The compression context |
ip | The outer IP header |
ip2 | The inner IP header |
next_header | The next header such as UDP or UDP-Lite |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References c_generic_context::code_uo_remainder, ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_version(), IPV4, ipv4_get_id(), generic_tmp_vars::nr_of_ip_hdr, ipv4_header_info::rnd, rohc_debugf, c_context::specific, c_generic_context::tmp, and ip_header_info::v4.
Referenced by code_UO0_packet(), code_UO1_packet(), and code_UO2_packet().
int code_UOR2_bytes | ( | const struct c_context * | context, |
const rohc_ext_t | extension, | ||
unsigned char *const | f_byte, | ||
unsigned char *const | s_byte, | ||
unsigned char *const | t_byte | ||
) |
Code some fields of the UOR-2 packet.
This function is called by code_UO2_packet. It should not be called directly.
UOR-2 (5.11.3): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | SN | +===+===+===+===+===+===+===+===+ 5 | X | CRC | +---+---+---+---+---+---+---+---+
context | The compression context |
extension | The extension that will be appended to the packet |
f_byte | IN/OUT: The first byte of the UOR-2 packet |
s_byte | IN/OUT: Not used by the UOR-2 packet |
t_byte | IN/OUT: The second byte of the UOR-2 packet |
References generic_tmp_vars::nr_sn_bits, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, rohc_debugf, c_generic_context::sn, c_context::specific, and c_generic_context::tmp.
Referenced by code_UO2_packet().
int code_UOR2_ID_bytes | ( | const struct c_context * | context, |
const rohc_ext_t | extension, | ||
unsigned char *const | f_byte, | ||
unsigned char *const | s_byte, | ||
unsigned char *const | t_byte | ||
) |
Code some fields of the UOR-2-ID packet.
This function is called by code_UO2_packet. It should not be called directly.
UOR-2-ID (5.7.4): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | IP-ID | +===+===+===+===+===+===+===+===+ 4 |T=0| M | SN | +---+---+---+---+---+---+---+---+ 5 | X | CRC | +---+---+---+---+---+---+---+---+
context | The compression context |
extension | The extension that will be appended to the packet |
f_byte | IN/OUT: The first byte of the UOR-2-ID packet |
s_byte | IN/OUT: The second byte of the UOR-2-ID packet |
t_byte | IN/OUT: The third byte of the UOR-2-ID packet |
References rtp_tmp_vars::m_set, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, rohc_assert, rohc_debugf, ROHC_IP_HDR_NONE, sdvl_get_min_len(), c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, and rtp_tmp_vars::ts_send.
Referenced by code_UO2_packet().
int code_UOR2_RTP_bytes | ( | const struct c_context * | context, |
const rohc_ext_t | extension, | ||
unsigned char *const | f_byte, | ||
unsigned char *const | s_byte, | ||
unsigned char *const | t_byte | ||
) |
Code some fields of the UOR-2-RTP packet.
This function is called by code_UO2_packet. It should not be called directly.
UOR-2-RTP (5.7.4): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | TS | +===+===+===+===+===+===+===+===+ 4 | TS| M | SN | +---+---+---+---+---+---+---+---+ 5 | X | CRC | +---+---+---+---+---+---+---+---+
context | The compression context |
extension | The extension that will be appended to the packet |
f_byte | IN/OUT: The first byte of the UOR-2-RTP packet |
s_byte | IN/OUT: The second byte of the UOR-2-RTP packet |
t_byte | IN/OUT: The third byte of the UOR-2-RTP packet |
References ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, rtp_tmp_vars::m_set, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, ipv4_header_info::rnd, rohc_assert, rohc_debugf, sdvl_get_min_len(), c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.
Referenced by code_UO2_packet().
int code_UOR2_TS_bytes | ( | const struct c_context * | context, |
const rohc_ext_t | extension, | ||
unsigned char *const | f_byte, | ||
unsigned char *const | s_byte, | ||
unsigned char *const | t_byte | ||
) |
Code some fields of the UOR-2-TS packet.
This function is called by code_UO2_packet. It should not be called directly.
UOR-2-TS (5.7.4): 0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ 2 | 1 1 0 | TS | +===+===+===+===+===+===+===+===+ 4 |T=1| M | SN | +---+---+---+---+---+---+---+---+ 5 | X | CRC | +---+---+---+---+---+---+---+---+
context | The compression context |
extension | The extension that will be appended to the packet |
f_byte | IN/OUT: The first byte of the UOR-2-TS packet |
s_byte | IN/OUT: The second byte of the UOR-2-TS packet |
t_byte | IN/OUT: The third byte of the UOR-2-TS packet |
References ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, IPV4, rtp_tmp_vars::m_set, generic_tmp_vars::nr_of_ip_hdr, generic_tmp_vars::nr_sn_bits, rtp_tmp_vars::nr_ts_bits, rtp_tmp_vars::nr_ts_bits_ext3, PACKET_EXT_0, PACKET_EXT_1, PACKET_EXT_2, PACKET_EXT_3, PACKET_NOEXT, ipv4_header_info::rnd, rohc_assert, rohc_debugf, rohc_min, sdvl_get_min_len(), c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_rtp_context::tmp, c_generic_context::tmp, rtp_tmp_vars::ts_send, ip_header_info::v4, and ip_header_info::version.
Referenced by code_UO2_packet().
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().
int header_fields | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const unsigned short | changed_f, | ||
const struct ip_packet * | ip, | ||
const int | I, | ||
const ip_header_pos_t | ip_hdr_pos, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build inner or outer IP header fields.
This function is used to code the IP header fields of the extension 3 of the UO-2 packet. The function is called twice (one for inner IP header and one for outer IP header) with different arguments.
+-----+-----+-----+-----+-----+-----+-----+-----+ 1 | Type of Service/Traffic Class | if TOS = 1 ..... ..... ..... ..... ..... ..... ..... ..... 2 | Time to Live/Hop Limit | if TTL = 1 ..... ..... ..... ..... ..... ..... ..... ..... 3 | Protocol/Next Header | if PR = 1 ..... ..... ..... ..... ..... ..... ..... ..... 4 / IP extension headers / variable, if IPX = 1 ..... ..... ..... ..... ..... ..... ..... ..... For outer IP-ID: ..... ..... ..... ..... ..... ..... ..... ..... 5 | IP-ID | 2 octets, ..... ..... ..... ..... ..... ..... ..... ..... if I2 = 1
Part 4 is not supported.
context | The compression context |
header_info | The header info stored in the profile |
changed_f | The fields that changed, created by the function changed_fields |
ip | One inner or outer IP header |
I | The I flag of the IP header |
ip_hdr_pos | The position of the IP header |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References ipv4_header_info::id_delta, ip_header_info::info, ip_get_protocol(), ip_get_tos(), ip_get_ttl(), is_changed(), MAX_FO_COUNT, MOD_PROTOCOL, MOD_TOS, MOD_TTL, ip_header_info::protocol_count, rohc_debugf, ROHC_IP_HDR_FIRST, ip_header_info::tos_count, ip_header_info::ttl_count, and ip_header_info::v4.
Referenced by code_EXT3_packet().
int header_flags | ( | const struct c_context * | context, |
struct ip_header_info *const | header_info, | ||
const unsigned short | changed_f, | ||
const struct ip_packet * | ip, | ||
const int | ip2_or_I2, | ||
const size_t | nr_ip_id_bits, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build inner or outer IP header flags.
This function is used to code the IP header fields of the extension 3 of the UO-2 packet. The function is called twice (one for inner IP header and one for outer IP header) with different arguments.
Header flags for IP and UDP profiles (5.11.4): For inner flags: +-----+-----+-----+-----+-----+-----+-----+-----+ 1 | Inner IP header flags | | if ip = 1 | TOS | TTL | DF | PR | IPX | NBO | RND | ip2 | ip2 = 0 if non-RTP +-----+-----+-----+-----+-----+-----+-----+-----+ or for outer flags: +-----+-----+-----+-----+-----+-----+-----+-----+ 2 | Outer IP header flags | | TOS2| TTL2| DF2 | PR2 |IPX2 |NBO2 |RND2 | I2 | if ip2 = 1 +-----+-----+-----+-----+-----+-----+-----+-----+
context | The compression context |
header_info | The header info stored in the profile |
changed_f | The fields that changed, created by the function changed_fields |
ip | One inner or outer IP header |
ip2_or_I2 | Whether the ip2 (inner, RTP only) or I2 (outer) flag is set or not |
nr_ip_id_bits | The number of bits needed to transmit the IP-ID field |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References ipv4_header_info::df_count, ip_header_info::info, IPV4, ipv4_get_df(), is_changed(), MAX_FO_COUNT, MOD_PROTOCOL, MOD_TOS, MOD_TTL, ipv4_header_info::nbo, ipv4_header_info::nbo_count, ip_header_info::protocol_count, ipv4_header_info::rnd, ipv4_header_info::rnd_count, rohc_debugf, ip_header_info::tos_count, ip_header_info::ttl_count, ip_header_info::v4, and ip_header_info::version.
Referenced by code_EXT3_packet().
int is_changed | ( | const unsigned short | changed_fields, |
const unsigned short | check_field | ||
) |
Check if a specified IP field has changed.
changed_fields | The fields that changed, created by the function changed_fields |
check_field | The field for which to check a change |
Referenced by changed_dynamic_one_hdr(), changed_static_one_hdr(), header_fields(), and header_flags().
void periodic_down_transition | ( | struct c_context * | context | ) |
Periodically change the context state after a certain number of packets.
context | The compression context |
References change_state(), c_context::compressor, FO, c_generic_context::go_back_fo_count, c_generic_context::go_back_ir_count, IR, rohc_comp::periodic_refreshes_fo_timeout, rohc_comp::periodic_refreshes_ir_timeout, rohc_debugf, SO, c_context::specific, and c_context::state.
Referenced by 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().
int rtp_header_flags_and_fields | ( | const struct c_context * | context, |
const unsigned short | changed_f, | ||
const struct ip_packet * | ip, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
References c_bytesSdvl(), c_encodeSdvl(), rtphdr::extension, get_ts_stride(), INIT_STRIDE, ip_get_next_layer(), rtphdr::m, MAX_IR_COUNT, c_context::mode, ts_sc_comp::nr_init_stride_packets, rtphdr::padding, rtphdr::pt, rohc_debugf, ROHC_INIT_TS_STRIDE_MIN, sc_rtp_context::rtp_pt_change_count, rtp_tmp_vars::rtp_pt_changed, SEND_SCALED, c_context::specific, c_generic_context::specific, ts_sc_comp::state, sc_rtp_context::tmp, and sc_rtp_context::ts_sc.
Referenced by code_EXT3_packet().