ROHC compression/decompression library
Functions | Variables
rohc_comp.c File Reference

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.h"
#include "rohc_debug.h"
#include "rohc_utils.h"
#include "sdvl.h"
#include "decode.h"
#include "ip.h"
#include "crc.h"
#include "protocols/udp.h"
#include "protocols/ip_numbers.h"
#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for rohc_comp.c:

Functions

static void nonnull (4)))
struct rohc_comprohc_alloc_compressor (int max_cid, int jam_use, int adapt_size, int encap_size)
 Create one ROHC compressor.
void rohc_free_compressor (struct rohc_comp *comp)
 Destroy one ROHC compressor.
bool rohc_comp_set_traces_cb (struct rohc_comp *const comp, rohc_trace_callback_t callback)
 Set the callback function used to manage traces in compressor.
bool rohc_comp_set_random_cb (struct rohc_comp *const comp, rohc_comp_random_cb_t callback, void *const user_context)
 Set the user-defined callback for random numbers.
int rohc_compress (struct rohc_comp *comp, unsigned char *ibuf, int isize, unsigned char *obuf, int osize)
 Compress a ROHC packet.
int rohc_compress2 (struct rohc_comp *const comp, const unsigned char *const uncomp_packet, const size_t uncomp_packet_len, unsigned char *const rohc_packet, const size_t rohc_packet_max_len, size_t *const rohc_packet_len)
 Compress a ROHC packet.
int rohc_comp_get_segment (struct rohc_comp *const comp, unsigned char *const segment, const size_t max_len, size_t *const len)
 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 algorithm.
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_rtp_detection_cb (struct rohc_comp *const comp, rohc_rtp_detection_callback_t callback, void *const rtp_private)
 Set the RTP detection callback function.
void rohc_activate_profile (struct rohc_comp *comp, int profile)
 Activate a profile for a compressor.
int rohc_c_using_small_cid (struct rohc_comp *comp)
 Whether the compressor uses small CID or not.
void rohc_c_set_header (struct rohc_comp *comp, int header)
 Set the maximal header size. The maximal header size is ignored for the moment.
void rohc_c_set_mrru (struct rohc_comp *comp, int value)
 Set the Maximum Reconstructed Reception Unit (MRRU).
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).
void rohc_c_set_max_cid (struct rohc_comp *comp, int value)
 Set the maximal CID value the compressor should use.
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.
void rohc_c_set_large_cid (struct rohc_comp *comp, int large_cid)
 Tell the compressor to use large CIDs.
bool rohc_comp_get_cid_type (const struct rohc_comp *const comp, rohc_cid_type_t *const cid_type)
 Get the CID type the compressor uses.
bool rohc_comp_add_rtp_port (struct rohc_comp *const comp, const unsigned int port)
 Add a port to the list of UDP ports dedicated for RTP traffic.
bool rohc_comp_remove_rtp_port (struct rohc_comp *const comp, const unsigned int port)
 Remove a port from the list of UDP ports dedicated to RTP traffic.
bool rohc_comp_reset_rtp_ports (struct rohc_comp *const comp)
 Reset the list of dedicated RTP ports.
void rohc_c_set_enable (struct rohc_comp *comp, int enable)
 Enable the ROHC compressor.
int rohc_c_is_enabled (struct rohc_comp *comp)
 Whether the ROHC compressor is enabled or not.
int rohc_c_info (char *buffer)
 Get information about available compression profiles.
int rohc_c_statistics (struct rohc_comp *comp, unsigned int indent, char *buffer)
 Get information about a ROHC compressor.
int rohc_c_context (struct rohc_comp *comp, int cid, unsigned int indent, char *buffer)
 Get information about a compression context.
void c_piggyback_feedback (struct rohc_comp *comp, unsigned char *feedback, int size)
 Add a feedback packet to the next outgoing ROHC packet (piggybacking)
bool rohc_comp_piggyback_feedback (struct rohc_comp *const comp, const unsigned char *const feedback, const size_t size)
 Add a feedback packet to the next outgoing ROHC packet (piggybacking)
void c_deliver_feedback (struct rohc_comp *comp, unsigned char *packet, int size)
 Callback called by a decompressor to deliver a feedback packet to the compressor.
int rohc_feedback_flush (struct rohc_comp *comp, unsigned char *obuf, int osize)
 Send as much feedback data as possible.
int rohc_comp_get_last_packet_info (const struct rohc_comp *const comp, rohc_comp_last_packet_info_t *const info)
 Get some information about the last compressed packet.
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 generak information about the compressor.
const char * rohc_comp_get_state_descr (const rohc_c_state state)
 Give a description for the given ROHC compression context state.
bool rohc_feedback_remove_locked (struct rohc_comp *const comp)
 Remove all feedbacks locked during the packet build.
bool rohc_feedback_unlock (struct rohc_comp *const comp)
 Unlock all feedbacks locked during the packet build.

Variables

struct c_profile c_rtp_profile
c_udp_profile
c_udp_lite_profile
c_esp_profile c_ip_profile 
c_uncompressed_profile
 Define the compression part of the Uncompressed profile as described in the RFC 3095.
struct c_profilec_profiles [C_NUM_PROFILES]
 The compression parts of the ROHC profiles.
static struct c_context warn_unused_result

Detailed Description

ROHC compression routines.

Author:
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
Didier Barvaux <didier@barvaux.org>
The hackers from ROHC for Linux
David Moreau from TAS

Function Documentation

void c_deliver_feedback ( struct rohc_comp comp,
unsigned char *  packet,
int  size 
)

Callback called by a decompressor to 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.

Parameters:
compThe ROHC compressor
packetThe feedback data
sizeThe length of the feedback packet

References c_feedback::acktype, c_feedback::cid, medium::cid_type, d_decode_add_cid(), d_is_add_cid(), c_feedback::data, c_profile::feedback, rohc_comp::medium, c_context::num_recv_feedbacks, c_context::profile, rohc_debug, rohc_error, ROHC_LARGE_CID, ROHC_PROFILE_GENERAL, ROHC_TRACE_COMP, rohc_warning, sdvl_decode(), c_feedback::size, c_feedback::specific_offset, c_feedback::specific_size, c_feedback::type, and zfree.

void c_piggyback_feedback ( struct rohc_comp comp,
unsigned char *  feedback,
int  size 
)

Add a feedback packet to the next outgoing ROHC packet (piggybacking)

Deprecated:
do not use this function anymore, use rohc_comp_piggyback_feedback() instead
Parameters:
compThe ROHC compressor
feedbackThe feedback data
sizeThe length of the feedback packet

References __attribute__, and rohc_comp_piggyback_feedback().

static void nonnull ( )
int rohc_c_context ( struct rohc_comp comp,
int  cid,
unsigned int  indent,
char *  buffer 
)

Get information about a compression context.

This function outputs XML.

Deprecated:
do not use this function anymore, use rohc_comp_get_general_info() instead
Parameters:
compThe ROHC compressor
cidThe CID of the compressor context to output information about
indentThe indent level to beautify the XML output
bufferThe buffer where to store the information
Returns:
The length of the data stored in the buffer if successful, -2 if the given CID is too large, -1 if the given CID is unused or an error occurs
bool rohc_comp_piggyback_feedback ( struct rohc_comp *const  comp,
const unsigned char *const  feedback,
const size_t  size 
)

Add a feedback packet to the next outgoing ROHC packet (piggybacking)

Parameters:
compThe ROHC compressor
feedbackThe feedback data
sizeThe length of the feedback packet
Returns:
true in case of success, false otherwise

References rohc_feedback::data, FEEDBACK_RING_SIZE, rohc_comp::feedbacks, rohc_comp::feedbacks_first, rohc_comp::feedbacks_next, rohc_feedback::is_locked, rohc_feedback::length, rohc_debug, rohc_error, ROHC_PROFILE_GENERAL, and ROHC_TRACE_COMP.

Referenced by c_piggyback_feedback(), d_change_mode_feedback(), d_optimistic_feedback(), and main().

bool rohc_comp_set_traces_cb ( struct rohc_comp *const  comp,
rohc_trace_callback_t  callback 
)

Set the callback function used to manage traces in compressor.

Warning:
The callback can not be modified after library initialization
Parameters:
compThe ROHC compressor
callback
  • The callback function used to manage traces
  • NULL to remove the previous callback
Returns:
true on success, false otherwise

References rohc_comp::num_packets, rohc_error, ROHC_PROFILE_GENERAL, ROHC_TRACE_COMP, and rohc_comp::trace_callback.

Referenced by main().


Variable Documentation

Initial value:

The compression parts of the ROHC profiles.

Define the compression part of the Uncompressed profile as described in the RFC 3095.