ROHC compression/decompression library
|
ROHC compression context for the UDP-Lite profile. More...
#include "c_udp_lite.h"
#include "c_udp.h"
#include "c_ip.h"
#include "rohc_traces.h"
#include "rohc_packets.h"
#include "crc.h"
#include "protocols/udp_lite.h"
#include <stdlib.h>
#include <string.h>
Functions | |
int | udp_lite_code_dynamic_udp_lite_part (const struct c_context *context, const unsigned char *next_header, unsigned char *const dest, int counter) |
Build the dynamic part of the UDP-Lite header. | |
int | udp_lite_build_cce_packet (const struct c_context *context, const unsigned char *next_header, unsigned char *const dest, int counter, int *const first_position) |
Build the Checksum Coverage Extension (CCE) packet. | |
int | udp_lite_send_cce_packet (struct sc_udp_lite_context *const udp_lite_context, const struct udphdr *udp_lite) |
Check whether a Checksum Coverage Extension (CCE) packet must be sent or not in order to compress the given UDP-Lite header. | |
int | udp_lite_code_uo_remainder (const struct c_context *context, const unsigned char *next_header, unsigned char *const dest, int counter) |
Build UDP-Lite-related fields in the tail of the UO packets. | |
void | udp_lite_init_cc (const struct c_context *context, const unsigned char *next_header) |
Initialize checksum coverage in the compression context with the given UDP-Lite header. | |
int | c_udp_lite_create (struct c_context *const context, const struct ip_packet *ip) |
Create a new UDP-Lite context and initialize it thanks to the given IP/UDP-Lite packet. | |
int | c_udp_lite_check_context (const struct c_context *context, const struct ip_packet *ip) |
Check if the IP/UDP-Lite packet belongs to the context. | |
int | c_udp_lite_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/UDP-lite packet according to a pattern decided by several different factors. | |
Variables | |
struct c_profile | c_udp_lite_profile |
Define the compression part of the UDP-Lite profile as described in the RFC 4019. |
ROHC compression context for the UDP-Lite profile.
int c_udp_lite_check_context | ( | const struct c_context * | context, |
const struct ip_packet * | ip | ||
) |
Check if the IP/UDP-Lite packet belongs to the context.
Conditions are:
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/UDP-Lite packet to check |
References ipv4_hdr::daddr, udphdr::dest, ip_header_info::info, c_generic_context::ip2_flags, ipv6_hdr::ip6_dst, ipv6_hdr::ip6_src, c_generic_context::ip_flags, ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), ip_get_version(), IPV4, ipv4_get_daddr(), ipv4_get_saddr(), IPV6, IPV6_ADDR_CMP, ipv6_get_daddr(), IPV6_GET_FLOW_LABEL, ipv6_get_flow_label(), ipv6_get_saddr(), c_generic_context::is_ip2_initialized, ipv4_header_info::old_ip, ipv6_header_info::old_ip, sc_udp_lite_context::old_udp_lite, rohc_debugf, ROHC_IPPROTO_IPIP, ROHC_IPPROTO_IPV6, ROHC_IPPROTO_UDPLITE, ipv4_hdr::saddr, udphdr::source, c_context::specific, c_generic_context::specific, ip_header_info::v4, ip_header_info::v6, version, and ip_header_info::version.
int c_udp_lite_create | ( | struct c_context *const | context, |
const struct ip_packet * | ip | ||
) |
Create a new UDP-Lite context and initialize it thanks to the given IP/UDP-Lite 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/UDP-Lite packet given to initialize the new context |
References c_generic_create(), c_generic_destroy(), c_ip_code_ir_remainder(), c_ip_decide_FO_packet(), c_ip_decide_SO_packet(), c_ip_get_next_sn(), sc_udp_lite_context::cfi, sc_udp_lite_context::cfp, c_generic_context::code_dynamic_part, c_generic_context::code_ir_remainder, 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, c_generic_context::compute_crc_static, sc_udp_lite_context::coverage_equal_count, sc_udp_lite_context::coverage_inferred_count, c_generic_context::decide_extension, decide_extension(), c_generic_context::decide_FO_packet, c_generic_context::decide_SO_packet, c_generic_context::decide_state, decide_state(), sc_udp_lite_context::FK, c_generic_context::get_next_sn, c_generic_context::init_at_IR, ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), MAX_IR_COUNT, c_generic_context::next_header_len, c_generic_context::next_header_proto, sc_udp_lite_context::old_udp_lite, rohc_comp::random_cb, rohc_comp::random_cb_ctxt, rohc_debugf, ROHC_IPPROTO_IPIP, ROHC_IPPROTO_IPV6, ROHC_IPPROTO_UDPLITE, ROHC_LSB_SHIFT_SN, sc_udp_lite_context::sent_cce_off_count, sc_udp_lite_context::sent_cce_on_count, sc_udp_lite_context::sent_cce_only_count, c_generic_context::sn, c_context::specific, c_generic_context::specific, sc_udp_lite_context::tmp, udp_code_static_udp_part(), udp_compute_crc_dynamic(), udp_compute_crc_static(), udp_lite_build_cce_packet(), udp_lite_code_dynamic_udp_lite_part(), udp_lite_code_uo_remainder(), udp_lite_init_cc(), and udp_lite_tmp_vars::udp_size.
int c_udp_lite_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/UDP-lite packet according to a pattern decided by several different factors.
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_generic_encode(), ip_get_hdrlen(), ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), sc_udp_lite_context::old_udp_lite, PACKET_IR, PACKET_IR_DYN, generic_tmp_vars::packet_type, rohc_debugf, ROHC_IPPROTO_IPIP, ROHC_IPPROTO_IPV6, ROHC_IPPROTO_UDPLITE, c_context::specific, c_generic_context::specific, sc_udp_lite_context::tmp, c_generic_context::tmp, and udp_lite_tmp_vars::udp_size.
int udp_lite_build_cce_packet | ( | const struct c_context * | context, |
const unsigned char * | next_header, | ||
unsigned char *const | dest, | ||
int | counter, | ||
int *const | first_position | ||
) |
Build the Checksum Coverage Extension (CCE) packet.
The Checksum Coverage Extension is located at the very start of the UO packet (part 2 in the following figure).
0 1 2 3 4 5 6 7 --- --- --- --- --- --- --- --- 1 : Add-CID octet : If for small CIDs and CID 1 - 15 +---+---+---+---+---+---+---+---+ 2 | 1 1 1 1 1 0 F | K | Outer packet type identifier +---+---+---+---+---+---+---+---+ : : 3 / 0, 1, or 2 octets of CID / 1 - 2 octets if large CIDs : : +---+---+---+---+---+---+---+---+ : : 4 / UO-0, UO-1 or UO-2 packet / : : +---+---+---+---+---+---+---+---+
Parts 1, 3 and 4 are coded by the generic code_UO0_packet, code_UO1_packet and code_UO2_packet functions. These functions call the code_UO_packet_head function which in case of UDP-Lite profile is the udp_lite_build_cce_packet function.
When the udp_lite_build_cce_packet is called, the parameter first_position points on the part 2 and the parameter counter points on the beginning of the part 4.
context | The compression context |
next_header | The UDP header |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
first_position | The position to place the first byte of packet |
References sc_udp_lite_context::FK, rohc_debugf, c_context::specific, c_generic_context::specific, and udp_lite_send_cce_packet().
Referenced by c_udp_lite_create().
int udp_lite_code_dynamic_udp_lite_part | ( | const struct c_context * | context, |
const unsigned char * | next_header, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build the dynamic part of the UDP-Lite header.
Dynamic part of UDP-Lite header (5.2.1 of RFC 4019): +---+---+---+---+---+---+---+---+ 1 / Checksum Coverage / 2 octets +---+---+---+---+---+---+---+---+ 2 / Checksum / 2 octets +---+---+---+---+---+---+---+---+
context | The compression context |
next_header | The UDP-Lite header |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References udphdr::check, udphdr::len, and rohc_debugf.
Referenced by c_udp_lite_create().
int udp_lite_code_uo_remainder | ( | const struct c_context * | context, |
const unsigned char * | next_header, | ||
unsigned char *const | dest, | ||
int | counter | ||
) |
Build UDP-Lite-related fields in the tail of the UO packets.
--- --- --- --- --- --- --- --- : : 2 octets, 1 + UDP-Lite Checksum Coverage + if context(CFP) = 1 or : : if packet type = CCE --- --- --- --- --- --- --- --- : : 2 + UDP-Lite Checksum + 2 octets : : --- --- --- --- --- --- --- ---
context | The compression context |
next_header | The UDP-Lite header |
dest | The rohc-packet-under-build buffer |
counter | The current position in the rohc-packet-under-build buffer |
References sc_udp_lite_context::cfp, udphdr::check, udphdr::len, rohc_debugf, c_context::specific, c_generic_context::specific, and udp_lite_send_cce_packet().
Referenced by c_udp_lite_create().
void udp_lite_init_cc | ( | const struct c_context * | context, |
const unsigned char * | next_header | ||
) |
Initialize checksum coverage in the compression context with the given UDP-Lite header.
context | The compression context |
next_header | The UDP-Lite header |
References sc_udp_lite_context::cfi, sc_udp_lite_context::cfp, c_generic_context::ir_count, udphdr::len, sc_udp_lite_context::old_udp_lite, rohc_debugf, c_context::specific, c_generic_context::specific, sc_udp_lite_context::tmp, sc_udp_lite_context::tmp_coverage, and udp_lite_tmp_vars::udp_size.
Referenced by c_udp_lite_create().
int udp_lite_send_cce_packet | ( | struct sc_udp_lite_context *const | udp_lite_context, |
const struct udphdr * | udp_lite | ||
) |
Check whether a Checksum Coverage Extension (CCE) packet must be sent or not in order to compress the given UDP-Lite header.
The function also updates the FK variable stored in the UDP-Lite context.
udp_lite_context | The compression context |
udp_lite | The UDP-Lite header |
References sc_udp_lite_context::cfi, sc_udp_lite_context::cfp, sc_udp_lite_context::coverage_equal_count, sc_udp_lite_context::coverage_inferred_count, sc_udp_lite_context::FK, udphdr::len, MAX_IR_COUNT, MAX_LITE_COUNT, sc_udp_lite_context::old_udp_lite, rohc_debugf, sc_udp_lite_context::sent_cce_off_count, sc_udp_lite_context::sent_cce_on_count, sc_udp_lite_context::sent_cce_only_count, sc_udp_lite_context::tmp, sc_udp_lite_context::tmp_coverage, and udp_lite_tmp_vars::udp_size.
Referenced by udp_lite_build_cce_packet(), and udp_lite_code_uo_remainder().
struct c_profile c_udp_lite_profile |
{ ROHC_IPPROTO_UDPLITE, NULL, ROHC_PROFILE_UDPLITE, "UDP-Lite / Compressor", c_udp_lite_create, c_generic_destroy, c_udp_lite_check_context, c_udp_lite_encode, c_generic_feedback, }
Define the compression part of the UDP-Lite profile as described in the RFC 4019.