ROHC compression routines. More...
#include "rohc_comp.h"#include "rohc_comp_internals.h"#include "rohc_packets.h"#include "rohc_traces.h"#include "rohc_traces_internal.h"#include "rohc_time_internal.h"#include "rohc_debug.h"#include "rohc_utils.h"#include "sdvl.h"#include "rohc_add_cid.h"#include "rohc_bit_ops.h"#include "ip.h"#include "crc.h"#include "protocols/udp.h"#include "protocols/ip_numbers.h"#include "feedback_parse.h"#include "config.h"#include <string.h>#include <stdlib.h>#include <stdbool.h>#include <assert.h>#include <stdarg.h>
Functions | |
| static struct rohc_comp_profile * | rohc_get_profile_from_id (const struct rohc_comp *comp, const rohc_profile_t profile_id) |
| Find out a ROHC profile given a profile ID. | |
| static struct rohc_comp_profile * | c_get_profile_from_packet (const struct rohc_comp *const comp, const struct net_pkt *const packet) |
| Find out a ROHC profile given an IP protocol ID. | |
| static bool | c_create_contexts (struct rohc_comp *const comp) |
| Create the array of compression contexts. | |
| static void | c_destroy_contexts (struct rohc_comp *const comp) |
| Destroy all the compression contexts in the context array. | |
| static struct rohc_comp_ctxt * | c_create_context (struct rohc_comp *const comp, const struct rohc_comp_profile *const profile, const struct net_pkt *const packet, const struct rohc_ts arrival_time) |
| Create a compression context. | |
| static struct rohc_comp_ctxt * | rohc_comp_find_ctxt (struct rohc_comp *const comp, const struct net_pkt *const packet, const int profile_id_hint, const struct rohc_ts arrival_time) |
| Find a compression context given an IP packet. | |
| static struct rohc_comp_ctxt * | c_get_context (struct rohc_comp *const comp, const rohc_cid_t cid) |
| Find out a context given its CID. | |
| static bool | __rohc_comp_deliver_feedback (struct rohc_comp *const comp, const uint8_t *const packet, const size_t size) |
| Deliver a feedback packet to the compressor. | |
| static bool | rohc_comp_feedback_parse_cid (const struct rohc_comp *const comp, const uint8_t *const feedback, const size_t feedback_len, rohc_cid_t *const cid, size_t *const cid_len) |
| Parse ROHC feedback CID. | |
| static bool | rohc_comp_feedback_parse_opt_sn (const struct rohc_comp_ctxt *const context, const uint8_t *const feedback_data, const size_t feedback_data_len, uint32_t *const sn_bits, size_t *const sn_bits_nr) |
| Parse the FEEDBACK-2 SN option. | |
| static bool | rohc_comp_feedback_check_opts (const struct rohc_comp_ctxt *const context, const size_t opts_present[ROHC_FEEDBACK_OPT_MAX]) |
| Check FEEDBACK-2 options. | |
| struct rohc_comp * | rohc_comp_new2 (const rohc_cid_type_t cid_type, const rohc_cid_t max_cid, const rohc_comp_random_cb_t rand_cb, void *const rand_priv) |
| Create a new ROHC compressor. | |
| void | rohc_comp_free (struct rohc_comp *const comp) |
| Destroy the given ROHC compressor. | |
| bool | rohc_comp_set_traces_cb2 (struct rohc_comp *const comp, rohc_trace_callback2_t callback, void *const priv_ctxt) |
| Set the callback function used to manage traces in compressor. | |
| rohc_status_t | rohc_compress4 (struct rohc_comp *const comp, const struct rohc_buf uncomp_packet, struct rohc_buf *const rohc_packet) |
| Compress the given uncompressed packet into a ROHC packet. | |
| rohc_status_t | rohc_comp_get_segment2 (struct rohc_comp *const comp, struct rohc_buf *const segment) |
| Get the next ROHC segment if any. | |
| bool | rohc_comp_force_contexts_reinit (struct rohc_comp *const comp) |
| Force the compressor to re-initialize all its contexts. | |
| bool | rohc_comp_set_wlsb_window_width (struct rohc_comp *const comp, const size_t width) |
| Set the window width for the W-LSB encoding scheme. | |
| bool | rohc_comp_set_periodic_refreshes (struct rohc_comp *const comp, const size_t ir_timeout, const size_t fo_timeout) |
| Set the timeout values for IR and FO periodic refreshes. | |
| bool | rohc_comp_set_list_trans_nr (struct rohc_comp *const comp, const size_t list_trans_nr) |
| Set the number of uncompressed transmissions for list compression. | |
| bool | rohc_comp_set_rtp_detection_cb (struct rohc_comp *const comp, rohc_rtp_detection_callback_t callback, void *const rtp_private) |
| Set the RTP detection callback function. | |
| bool | rohc_comp_profile_enabled (const struct rohc_comp *const comp, const rohc_profile_t profile) |
| Is the given compression profile enabled for a compressor? | |
| bool | rohc_comp_enable_profile (struct rohc_comp *const comp, const rohc_profile_t profile) |
| Enable a compression profile for a compressor. | |
| bool | rohc_comp_disable_profile (struct rohc_comp *const comp, const rohc_profile_t profile) |
| Disable a compression profile for a compressor. | |
| bool | rohc_comp_enable_profiles (struct rohc_comp *const comp,...) |
| Enable several compression profiles for a compressor. | |
| bool | rohc_comp_disable_profiles (struct rohc_comp *const comp,...) |
| Disable several compression profiles for a compressor. | |
| bool | rohc_comp_set_mrru (struct rohc_comp *const comp, const size_t mrru) |
| Set the Maximum Reconstructed Reception Unit (MRRU). | |
| bool | rohc_comp_get_mrru (const struct rohc_comp *const comp, size_t *const mrru) |
| Get the Maximum Reconstructed Reception Unit (MRRU). | |
| bool | rohc_comp_get_max_cid (const struct rohc_comp *const comp, size_t *const max_cid) |
| Get the maximal CID value the compressor uses. | |
| bool | rohc_comp_get_cid_type (const struct rohc_comp *const comp, rohc_cid_type_t *const cid_type) |
| Get the CID type that the compressor uses. | |
| bool | rohc_comp_set_features (struct rohc_comp *const comp, const rohc_comp_features_t features) |
| Enable/disable features for ROHC compressor. | |
| bool | rohc_comp_deliver_feedback2 (struct rohc_comp *const comp, const struct rohc_buf feedback) |
| Deliver a feedback packet to the compressor. | |
| bool | rohc_comp_get_last_packet_info2 (const struct rohc_comp *const comp, rohc_comp_last_packet_info2_t *const info) |
| Get some information about the last compressed packet. | |
| bool | rohc_comp_get_general_info (const struct rohc_comp *const comp, rohc_comp_general_info_t *const info) |
| Get some general information about the compressor. | |
| const char * | rohc_comp_get_state_descr (const rohc_comp_state_t state) |
| Give a description for the given ROHC compression context state. | |
| void | rohc_comp_change_mode (struct rohc_comp_ctxt *const context, const rohc_mode_t new_mode) |
| Change the mode of the context. | |
| void | rohc_comp_change_state (struct rohc_comp_ctxt *const context, const rohc_comp_state_t new_state) |
| Change the state of the context. | |
| void | rohc_comp_periodic_down_transition (struct rohc_comp_ctxt *const context) |
| Periodically change the context state after a certain number of packets. | |
| bool | rohc_comp_reinit_context (struct rohc_comp_ctxt *const context) |
| Re-initialize the given context. | |
| bool | rohc_comp_feedback_parse_opts (const struct rohc_comp_ctxt *const context, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len, size_t opts_present[ROHC_FEEDBACK_OPT_MAX], uint32_t *const sn_bits, size_t *const sn_bits_nr, uint8_t crc_in_packet, size_t crc_pos_from_end) |
| Parse FEEDBACK-2 options. | |
Variables | |
| struct rohc_comp_profile c_rtp_profile c_udp_profile c_udp_lite_profile c_esp_profile c_tcp_profile c_ip_profile | c_uncompressed_profile |
| Define the compression part of the Uncompressed profile as described in the RFC 3095. | |
| static struct rohc_comp_profile *const | rohc_comp_profiles [C_NUM_PROFILES] |
| The compression parts of the ROHC profiles. | |
ROHC compression routines.
| static bool __rohc_comp_deliver_feedback | ( | struct rohc_comp *const | comp, | |
| const uint8_t *const | packet, | |||
| const size_t | size | |||
| ) | [static] |
Deliver a feedback packet to the compressor.
When feedback is received by the decompressor, this function is called and delivers the feedback to the right profile/context of the compressor.
| comp | The ROHC compressor | |
| packet | The feedback data | |
| size | The length of the feedback packet |
| static struct rohc_comp_ctxt * c_create_context | ( | struct rohc_comp *const | comp, | |
| const struct rohc_comp_profile *const | profile, | |||
| const struct net_pkt *const | packet, | |||
| const struct rohc_ts | arrival_time | |||
| ) | [static, read] |
Create a compression context.
| comp | The ROHC compressor | |
| profile | The profile to associate the context with | |
| packet | The packet to create a compression context for | |
| arrival_time | The time at which packet was received (0 if unknown, or to disable time-related features in ROHC protocol) |
| static bool c_create_contexts | ( | struct rohc_comp *const | comp | ) | [static] |
Create the array of compression contexts.
| comp | The ROHC compressor |
| static void c_destroy_contexts | ( | struct rohc_comp *const | comp | ) | [static] |
Destroy all the compression contexts in the context array.
The profile-specific contexts are also destroyed.
| comp | The ROHC compressor |
| static struct rohc_comp_ctxt * c_get_context | ( | struct rohc_comp *const | comp, | |
| const rohc_cid_t | cid | |||
| ) | [static, read] |
Find out a context given its CID.
| comp | The ROHC compressor | |
| cid | The CID of the context to find |
| static struct rohc_comp_profile * c_get_profile_from_packet | ( | const struct rohc_comp *const | comp, | |
| const struct net_pkt *const | packet | |||
| ) | [static, read] |
Find out a ROHC profile given an IP protocol ID.
| comp | The ROHC compressor | |
| packet | The packet to find a compression profile for |
| void rohc_comp_change_mode | ( | struct rohc_comp_ctxt *const | context, | |
| const rohc_mode_t | new_mode | |||
| ) |
Change the mode of the context.
| context | The compression context | |
| new_mode | The new mode the context must enter in |
| void rohc_comp_change_state | ( | struct rohc_comp_ctxt *const | context, | |
| const rohc_comp_state_t | new_state | |||
| ) |
Change the state of the context.
| context | The compression context | |
| new_state | The new state the context must enter in |
| static bool rohc_comp_feedback_check_opts | ( | const struct rohc_comp_ctxt *const | context, | |
| const size_t | opts_present[ROHC_FEEDBACK_OPT_MAX] | |||
| ) | [static] |
Check FEEDBACK-2 options.
sanity checks:
| context | The ROHC decompression context | |
| opts_present | Whether options are present or not |
| static bool rohc_comp_feedback_parse_cid | ( | const struct rohc_comp *const | comp, | |
| const uint8_t *const | feedback, | |||
| const size_t | feedback_len, | |||
| rohc_cid_t *const | cid, | |||
| size_t *const | cid_len | |||
| ) | [static] |
Parse ROHC feedback CID.
| comp | The ROHC compressor | |
| feedback | The ROHC feedback data to parse | |
| feedback_len | The length of the ROHC feedback data | |
| [out] | cid | The CID of the ROHC feedback |
| [out] | cid_len | The length of the CID of the ROHC feedback |
| static bool rohc_comp_feedback_parse_opt_sn | ( | const struct rohc_comp_ctxt *const | context, | |
| const uint8_t *const | feedback_data, | |||
| const size_t | feedback_data_len, | |||
| uint32_t *const | sn_bits, | |||
| size_t *const | sn_bits_nr | |||
| ) | [static] |
Parse the FEEDBACK-2 SN option.
| context | The ROHC decompression context | |
| feedback_data | The feedback data without the CID bits | |
| feedback_data_len | The length of the feedback data without the CID bits | |
| [out] | sn_bits | in: the SN bits collected in base header out: the SN bits collected in base header and options |
| [out] | sn_bits_nr | in: the number of SN bits collected in base header out: the number of SN bits collected in base header and options |
| bool rohc_comp_feedback_parse_opts | ( | const struct rohc_comp_ctxt *const | context, | |
| const uint8_t *const | packet, | |||
| const size_t | packet_len, | |||
| const uint8_t *const | feedback_data, | |||
| const size_t | feedback_data_len, | |||
| size_t | opts_present[ROHC_FEEDBACK_OPT_MAX], | |||
| uint32_t *const | sn_bits, | |||
| size_t *const | sn_bits_nr, | |||
| uint8_t | crc_in_packet, | |||
| size_t | crc_pos_from_end | |||
| ) |
Parse FEEDBACK-2 options.
| context | The ROHC decompression context | |
| packet | The whole feedback packet with CID bits | |
| packet_len | The length of the whole feedback packet with CID bits | |
| feedback_data | The feedback data without the CID bits | |
| feedback_data_len | The length of the feedback data without the CID bits | |
| [out] | opts_present | Whether options are present or not |
| [out] | sn_bits | in: the SN bits collected in base header out: the SN bits collected in base header and options |
| [out] | sn_bits_nr | in: the number of SN bits collected in base header out: the number of SN bits collected in base header and options |
| crc_in_packet | The CRC of the feedback packet | |
| crc_pos_from_end | The position of the CRC byte from the end of the feedback packet |
| static struct rohc_comp_ctxt * rohc_comp_find_ctxt | ( | struct rohc_comp *const | comp, | |
| const struct net_pkt *const | packet, | |||
| const int | profile_id_hint, | |||
| const struct rohc_ts | arrival_time | |||
| ) | [static, read] |
Find a compression context given an IP packet.
| comp | The ROHC compressor | |
| packet | The packet to find a compression context for | |
| profile_id_hint | If positive, indicate the profile to use | |
| arrival_time | The time at which packet was received (0 if unknown, or to disable time-related features in the ROHC protocol) |
| void rohc_comp_periodic_down_transition | ( | struct rohc_comp_ctxt *const | context | ) |
Periodically change the context state after a certain number of packets.
| context | The compression context |
| bool rohc_comp_reinit_context | ( | struct rohc_comp_ctxt *const | context | ) |
Re-initialize the given context.
Make the context restart its initialization with decompressor, ie. it goes in the lowest compression state.
| context | The compression context to re-initialize |
| static struct rohc_comp_profile * rohc_get_profile_from_id | ( | const struct rohc_comp * | comp, | |
| const rohc_profile_t | profile_id | |||
| ) | [static, read] |
Find out a ROHC profile given a profile ID.
| comp | The ROHC compressor | |
| profile_id | The ID of the ROHC profile to find out |
| struct rohc_comp_profile c_rtp_profile c_udp_profile c_udp_lite_profile c_esp_profile c_tcp_profile c_ip_profile c_uncompressed_profile |
Define the compression part of the Uncompressed profile as described in the RFC 3095.
struct rohc_comp_profile* const rohc_comp_profiles[C_NUM_PROFILES] [static] |
{
&c_rtp_profile,
&c_udp_profile,
&c_udp_lite_profile,
&c_esp_profile,
&c_tcp_profile,
&c_ip_profile,
&c_uncompressed_profile,
}
The compression parts of the ROHC profiles.
The order of profiles declaration is important: they are evaluated in that order. The RTP profile shall be declared before the UDP one for example.
1.6.1