ROHC compression/decompression library
|
Data Structures | |
struct | rohc_comp_last_packet_info2_t |
Some information about the last compressed packet. More... | |
struct | rohc_comp_general_info_t |
Some general information about the compressor. More... | |
Typedefs | |
typedef bool(* | rohc_rtp_detection_callback_t) (const unsigned char *const ip, const unsigned char *const udp, const unsigned char *const payload, const unsigned int payload_size, void *const rtp_private) |
The prototype of the RTP detection callback. More... | |
typedef int(* | rohc_comp_random_cb_t) (const struct rohc_comp *const comp, void *const user_context) |
The prototype of the callback for random numbers. More... | |
Enumerations | |
enum | rohc_comp_state_t { ROHC_COMP_STATE_UNKNOWN = 0, ROHC_COMP_STATE_IR = 1, ROHC_COMP_STATE_FO = 2, ROHC_COMP_STATE_SO = 3, ROHC_COMP_STATE_CR = 4 } |
The different ROHC compressor states. More... | |
enum | rohc_comp_features_t { ROHC_COMP_FEATURE_NONE = 0, ROHC_COMP_FEATURE_COMPAT_1_6_x = (1 << 0), ROHC_COMP_FEATURE_NO_IP_CHECKSUMS = (1 << 2), ROHC_COMP_FEATURE_DUMP_PACKETS = (1 << 3), ROHC_COMP_FEATURE_TIME_BASED_REFRESHES = (1 << 4) } |
The different features of the ROHC compressor. More... | |
Functions | |
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. More... | |
void | rohc_comp_free (struct rohc_comp *const comp) |
Destroy the given ROHC compressor. More... | |
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. More... | |
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. More... | |
rohc_status_t | rohc_comp_pad (struct rohc_comp *const comp, struct rohc_buf *const rohc_pkt, const size_t min_pkt_len) |
Pad the given ROHC compressed packet. More... | |
rohc_status_t | rohc_comp_get_segment2 (struct rohc_comp *const comp, struct rohc_buf *const segment) |
Get the next ROHC segment if any. More... | |
bool | rohc_comp_force_contexts_reinit (struct rohc_comp *const comp) |
Force the compressor to re-initialize all its contexts. More... | |
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. More... | |
bool | rohc_comp_set_periodic_refreshes (struct rohc_comp *const comp, const size_t ir_timeout, const size_t fo_timeout) |
Set the timeouts in packets for IR and FO periodic refreshes. More... | |
bool | rohc_comp_set_periodic_refreshes_time (struct rohc_comp *const comp, const uint64_t ir_timeout, const uint64_t fo_timeout) |
Set the timeouts in ms for IR and FO periodic refreshes. More... | |
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. More... | |
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. More... | |
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? More... | |
bool | rohc_comp_enable_profile (struct rohc_comp *const comp, const rohc_profile_t profile) |
Enable a compression profile for a compressor. More... | |
bool | rohc_comp_disable_profile (struct rohc_comp *const comp, const rohc_profile_t profile) |
Disable a compression profile for a compressor. More... | |
bool | rohc_comp_enable_profiles (struct rohc_comp *const comp,...) |
Enable several compression profiles for a compressor. More... | |
bool | rohc_comp_disable_profiles (struct rohc_comp *const comp,...) |
Disable several compression profiles for a compressor. More... | |
bool | rohc_comp_set_mrru (struct rohc_comp *const comp, const size_t mrru) |
Set the Maximum Reconstructed Reception Unit (MRRU). More... | |
bool | rohc_comp_get_mrru (const struct rohc_comp *const comp, size_t *const mrru) |
Get the Maximum Reconstructed Reception Unit (MRRU). More... | |
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. More... | |
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. More... | |
bool | rohc_comp_set_features (struct rohc_comp *const comp, const rohc_comp_features_t features) |
Enable/disable features for ROHC compressor. More... | |
bool | rohc_comp_deliver_feedback2 (struct rohc_comp *const comp, const struct rohc_buf feedback) |
Deliver a feedback packet to the compressor. More... | |
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. More... | |
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. More... | |
const char * | rohc_comp_get_state_descr (const rohc_comp_state_t state) |
Give a description for the given ROHC compression context state. More... | |
The compression API of the ROHC library allows a program to compress the protocol headers of some uncompressed packets into ROHC packets.
The program shall first create a compressor context and configure it. It then may compress as many packets as needed. When done, the ROHC compressor context shall be destroyed.
typedef int(* rohc_comp_random_cb_t) (const struct rohc_comp *const comp, void *const user_context) |
The prototype of the callback for random numbers.
User-defined function that is called when the ROHC library requires a random number. Currently, the ROHC library uses it when initializing the Sequence Number (SN) of contexts using the IP-only, IP/UDP, and IP/UDP-Lite profiles.
The user-defined function is set by calling the function rohc_comp_new2
comp | The ROHC compressor |
user_context | The context given by the user when he/she called the rohc_comp_new2 function, may be NULL. |
typedef bool(* rohc_rtp_detection_callback_t) (const unsigned char *const ip, const unsigned char *const udp, const unsigned char *const payload, const unsigned int payload_size, void *const rtp_private) |
The prototype of the RTP detection callback.
User-defined function that is called by the ROHC library for every UDP packet to determine whether the UDP packet transports RTP data. If the function returns true, the RTP profile is used to compress the packet. Otherwise the UDP profile is used.
The user-defined function is set by calling the function rohc_comp_set_rtp_detection_cb
ip | The innermost IP packet |
udp | The UDP header of the packet |
payload | The UDP payload of the packet |
payload_size | The size of the UDP payload (in bytes) |
rtp_private | A pointer to a memory area to be used by the callback function, may be NULL. |
enum rohc_comp_features_t |
The different features of the ROHC compressor.
Features for the ROHC compressor control whether mechanisms defined as optional by RFCs are enabled or not. They can be set or unset with the function rohc_comp_set_features.
enum rohc_comp_state_t |
The different ROHC compressor states.
The different ROHC operation states at compressor as defined in section 4.3.1 of RFC 3095. The CR operation state is defined in RFC 4164.
If you add a new compressor state, please also add the corresponding textual description in rohc_comp_get_state_descr.
Deliver a feedback packet to the compressor.
When feedback data is received by a decompressor, this function may be called to deliver the feedback data to the corresponding profile/context on the same-side associated compressor.
comp | The ROHC compressor |
feedback | The feedback data |
bool rohc_comp_disable_profile | ( | struct rohc_comp *const | comp, |
const rohc_profile_t | profile | ||
) |
Disable a compression profile for a compressor.
Disable a compression profile for a compressor.
The ROHC compressor does not use the compression profiles that were disabled. Thus disabling a profile might affect compression performances. Compression will fail if no profile at all is enabled.
If the profile is already disabled, nothing is performed and success is reported.
comp | The ROHC compressor |
profile | The profile to disable |
bool rohc_comp_disable_profiles | ( | struct rohc_comp *const | comp, |
... | |||
) |
Disable several compression profiles for a compressor.
Disable several compression profiles for a compressor. The list of profiles to disable shall stop with -1.
The ROHC compressor does not use the compression profiles that were disabled. Thus disabling a profile might affect compression performances. Compression will fail if no profile at all is enabled.
If one or more of the profiles are already disabled, nothing is performed and success is reported.
comp | The ROHC compressor |
... | The sequence of compression profiles to disable, the sequence shall be terminated by -1 |
bool rohc_comp_enable_profile | ( | struct rohc_comp *const | comp, |
const rohc_profile_t | profile | ||
) |
Enable a compression profile for a compressor.
Enable a compression profiles for a compressor.
The ROHC compressor does not use the compression profiles that are not enabled. Thus not enabling a profile might affect compression performances. Compression will fail if no profile at all is enabled.
If the profile is already enabled, nothing is performed and success is reported.
comp | The ROHC compressor |
profile | The profile to enable |
bool rohc_comp_enable_profiles | ( | struct rohc_comp *const | comp, |
... | |||
) |
Enable several compression profiles for a compressor.
Enable several compression profiles for a compressor. The list of profiles to enable shall stop with -1.
The ROHC compressor does not use the compression profiles that are not enabled. Thus not enabling a profile might affect compression performances. Compression will fail if no profile at all is enabled.
If one or more of the profiles are already enabled, nothing is performed and success is reported.
comp | The ROHC compressor |
... | The sequence of compression profiles to enable, the sequence shall be terminated by -1 |
bool rohc_comp_force_contexts_reinit | ( | struct rohc_comp *const | comp | ) |
Force the compressor to re-initialize all its contexts.
Make all contexts restart their initialization with decompressor, ie. they go in the lowest compression state. This function can be used once the ROHC channel is established again after an interruption.
The function implements the CONTEXT_REINITIALIZATION signal described by RFC 3095 at ยง6.3.1 as:
CONTEXT_REINITIALIZATION -- signal This parameter triggers a reinitialization of the entire context at the decompressor, both the static and the dynamic part. The compressor MUST, when CONTEXT_REINITIALIZATION is triggered, back off to the IR state and fully reinitialize the context by sending IR packets with both the static and dynamic chains covering the entire uncompressed headers until it is reasonably confident that the decompressor contexts are reinitialized. The context reinitialization MUST be done for all contexts at the compressor. This parameter may for instance be used to do context relocation at, e.g., a cellular handover that results in a change of compression point in the radio access network.
comp | The ROHC compressor |
void rohc_comp_free | ( | struct rohc_comp *const | comp | ) |
Destroy the given ROHC compressor.
Destroy a ROHC compressor that was successfully created with rohc_comp_new2
comp | The ROHC compressor to destroy |
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.
Get the CID type that the compressor currently uses.
comp | The ROHC compressor | |
[out] | cid_type | The current CID type among ROHC_SMALL_CID and ROHC_LARGE_CID |
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.
Get some general information about the compressor.
To use the function, call it with a pointer on a pre-allocated rohc_comp_general_info_t structure with the version_major and version_minor fields set to one of the following supported versions:
See the rohc_comp_general_info_t structure for details about fields that are supported in the above versions.
comp | The ROHC compressor to get information from | |
[in,out] | info | The structure where information will be stored |
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.
Get some information about the last compressed packet.
To use the function, call it with a pointer on a pre-allocated rohc_comp_last_packet_info2_t structure with the version_major and version_minor fields set to one of the following supported versions:
See the rohc_comp_last_packet_info2_t structure for details about fields that are supported in the above versions.
comp | The ROHC compressor to get information from | |
[in,out] | info | The structure where information will be stored |
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.
Get the maximal CID value the compressor uses, ie. the MAX_CID parameter defined in RFC 3095.
comp | The ROHC compressor | |
[out] | max_cid | The current maximal CID value |
bool rohc_comp_get_mrru | ( | const struct rohc_comp *const | comp, |
size_t *const | mrru | ||
) |
Get the Maximum Reconstructed Reception Unit (MRRU).
Get the current Maximum Reconstructed Reception Unit (MRRU).
The MRRU is the largest cumulative length (in bytes) of the ROHC segments that are parts of the same ROHC packet. In short, the ROHC decompressor does not expect to reassemble ROHC segments whose total length is larger than MRRU. So, the ROHC compressor shall not segment ROHC packets greater than the MRRU.
The MRRU value must be in range [0 ; ROHC_MAX_MRRU]. Remember that the MRRU includes the 32-bit CRC that protects it. If MRRU value is 0, segmentation is disabled.
If segmentation is enabled and used by the compressor, the function rohc_comp_get_segment2 can be used to retrieve ROHC segments.
comp | The ROHC compressor | |
[out] | mrru | The current MRRU value (in bytes) |
rohc_status_t rohc_comp_get_segment2 | ( | struct rohc_comp *const | comp, |
struct rohc_buf *const | segment | ||
) |
Get the next ROHC segment if any.
Get the next ROHC segment if any.
To get all the segments of one ROHC packet, call this function until ROHC_STATUS_OK or ROHC_STATUS_ERROR is returned.
comp | The ROHC compressor | |
[out] | segment | The buffer where to store the ROHC segment |
const char* rohc_comp_get_state_descr | ( | const rohc_comp_state_t | state | ) |
Give a description for the given ROHC compression context state.
Give a description for the given ROHC compression context state.
The descriptions are not part of the API. They may change between releases without any warning. Do NOT use them for other means that providing to users a textual description of compression context states used by the library. If unsure, ask on the mailing list.
state | The compression context state to get a description for |
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.
Create a new ROHC compressor with the given type of CIDs and MAX_CID.
The user-defined callback for random numbers is called by the ROHC library every time a new random number is required. It currently happens only to initiate the Sequence Number (SN) of new IP-only, IP/UDP, or IP/UDP-Lite streams to a random value as defined by RFC 3095.
cid_type | The type of Context IDs (CID) that the ROHC compressor shall operate with. Accepted values are:
|
max_cid | The maximum value that the ROHC compressor should use for context IDs (CID). As CIDs starts with value 0, the number of contexts is max_cid + 1. Accepted values are:
|
rand_cb | The random callback to set |
rand_priv | Private data that will be given to the callback, may be used as a context by user |
rohc_status_t rohc_comp_pad | ( | struct rohc_comp *const | comp, |
struct rohc_buf *const | rohc_pkt, | ||
const size_t | min_pkt_len | ||
) |
Pad the given ROHC compressed packet.
Add as many padding bytes as required to get a ROHC packet of the given length.
comp | The ROHC compressor | |
[in,out] | rohc_pkt | The compressed ROHC packet to pad up to min_pkt_len |
min_pkt_len | The minimum length of the ROHC packet |
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?
Is the given compression profile enabled or disabled for a compressor?
comp | The ROHC compressor |
profile | The profile to ask status for |
bool rohc_comp_set_features | ( | struct rohc_comp *const | comp, |
const rohc_comp_features_t | features | ||
) |
Enable/disable features for ROHC compressor.
Enable/disable features for ROHC compressor. Features control whether mechanisms defined as optional by RFCs are enabled or not.
Available features are listed by rohc_comp_features_t. They may be combined by XOR'ing them together.
comp | The ROHC compressor |
features | The feature set to enable/disable |
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.
Set the number of transmissions required for list compression. This matches the L parameter described in RFC 3095 and 4815. The compressor sends the list items uncompressed L times before compressing them. The compressor also sends the list structure L times before compressing it out.
The L parameter is set to ROHC_LIST_DEFAULT_L by default.
comp | The ROHC compressor |
list_trans_nr | The number of times the list items or the list itself are sent uncompressed before being sent compressed |
bool rohc_comp_set_mrru | ( | struct rohc_comp *const | comp, |
const size_t | mrru | ||
) |
Set the Maximum Reconstructed Reception Unit (MRRU).
Set the Maximum Reconstructed Reception Unit (MRRU).
The MRRU is the largest cumulative length (in bytes) of the ROHC segments that are parts of the same ROHC packet. In short, the ROHC decompressor does not expect to reassemble ROHC segments whose total length is larger than MRRU. So, the ROHC compressor shall not segment ROHC packets greater than the MRRU.
The MRRU value must be in range [0 ; ROHC_MAX_MRRU]. Remember that the MRRU includes the 32-bit CRC that protects it. If set to 0, segmentation is disabled as no segment headers are allowed on the channel. No segment will be generated.
If segmentation is enabled and used by the compressor, the function rohc_comp_get_segment2 can be used to retrieve ROHC segments.
comp | The ROHC compressor |
mrru | The new MRRU value (in bytes) |
bool rohc_comp_set_periodic_refreshes | ( | struct rohc_comp *const | comp, |
const size_t | ir_timeout, | ||
const size_t | fo_timeout | ||
) |
Set the timeouts in packets for IR and FO periodic refreshes.
Set the timeout values for IR and FO periodic refreshes. The IR timeout shall be greater than the FO timeout. Both timeouts are expressed in number of compressed packets.
The IR timeout is set to CHANGE_TO_IR_COUNT by default. The FO timeout is set to CHANGE_TO_FO_COUNT by default.
comp | The ROHC compressor |
ir_timeout | The number of packets to compress before going back to IR state to force a context refresh |
fo_timeout | The number of packets to compress before going back to FO state to force a context refresh |
bool rohc_comp_set_periodic_refreshes_time | ( | struct rohc_comp *const | comp, |
const uint64_t | ir_timeout, | ||
const uint64_t | fo_timeout | ||
) |
Set the timeouts in ms for IR and FO periodic refreshes.
Set the timeout values for IR and FO periodic refreshes. The IR timeout shall be greater than the FO timeout. Both timeouts are expressed in milliseconds.
The IR timeout is set to CHANGE_TO_IR_TIME by default. The FO timeout is set to CHANGE_TO_FO_TIME by default.
comp | The ROHC compressor |
ir_timeout | The delay (in ms) before going back to IR state to force a context refresh |
fo_timeout | The delay (in ms) before going back to FO state to force a context refresh |
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.
Set or replace the callback function that the ROHC library will call to detect RTP streams among other UDP streams.
The function is called once per UDP packet to compress, with the IP and UDP headers and the UDP payload. If the callback function returns true, the RTP profile is used for compression, otherwise the IP/UDP profile is used instead.
Special value NULL may be used to disable the detection of RTP streams with the callback method. The detection will then be based on a list of UDP ports dedicated for RTP streams.
comp | The ROHC compressor |
callback | The callback function used to detect RTP packets The callback is deactivated if NULL is given as parameter |
rtp_private | A pointer to an external memory area provided and used by the callback user |
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.
Set the user-defined callback function used to manage traces in the compressor.
The function will be called by the ROHC library every time it wants to print something related to compression, from errors to debug. User may thus decide what traces are interesting (filter on level, source entity, or profile) and what to do with them (print on console, storage in file, syslog...).
comp | The ROHC compressor |
callback | Two possible cases:
|
priv_ctxt | An optional private context, may be NULL |
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.
Set the window width for the Window-based Least Significant Bits (W-LSB) encoding. See section 4.5.2 of RFC 3095 for more details about the encoding scheme.
The width of the W-LSB window is set to 4 by default.
comp | The ROHC compressor |
width | The width of the W-LSB sliding window |
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.
Compress the given uncompressed packet into a ROHC packet. The compression may succeed into two different ways:
Notes:
comp | The ROHC compressor | |
uncomp_packet | The uncompressed packet to compress | |
[out] | rohc_packet | The resulting compressed ROHC packet |