rohc_compress4

NAME
SYNOPSIS
DESCRIPTION
PARAMETERS
STRUCTURES
RETURN VALUE
EXAMPLE
SEE ALSO

NAME

rohc_compress4 − Compress the given uncompressed packet into a ROHC packet.

SYNOPSIS

#include <rohc/rohc_comp.h>

rohc_status_t rohc_compress4(
struct rohc_comp *const comp
,
const struct rohc_buf uncomp_packet
,
struct rohc_buf *const rohc_packet

);

DESCRIPTION

Compress the given uncompressed packet into a ROHC packet. The compression may succeed into two different ways:

• return ROHC_STATUS_OK and a full ROHC packet,

• return ROHC_STATUS_SEGMENT and no ROHC data if ROHC segmentation is required.

Notes:

• ROHC segmentation: The ROHC compressor has to use ROHC segmentation if the output buffer rohc_packet was too small for the compressed ROHC packet and if the Maximum Reconstructed Reception Unit (MRRU) configured with the function rohc_comp_set_mrru was not exceeded. If ROHC segmentation is used, one may use the rohc_comp_get_segment2 function to retrieve all the ROHC segments one by one.

• Time−related features in the ROHC protocol: Set the uncomp_packet.time parameter to 0 if arrival time of the uncompressed packet is unknown or to disable the time−related features in the ROHC protocol.

PARAMETERS

comp

The ROHC compressor

uncomp_packet

The uncompressed packet to compress

rohc_packet [output]

The resulting compressed ROHC packet

STRUCTURES

A network buffer for the ROHC library
May represent one uncompressed packet, one ROHC packet, or a ROHC feedback.

The network buffer does not contain the packet data itself. It only has a pointer on it. This is designed this way for performance reasons: no copy required to initialize a network buffer, the struct is small and may be passed as copy to function.

The network buffer is able to keep some free space at its beginning. The unused space at the beginning of the buffer may be used to prepend a network header at the very end of the packet handling.

The beginning of the network buffer may also be shifted forward with the rohc_buf_pull function or shifted backward with the rohc_buf_push function. This is useful when parsing a network packet (once bytes are read, shift them forward) for example.

The network buffer may be initialized manually (see below) or with the helper functions rohc_buf_init_empty or rohc_buf_init_full...

struct rohc_buf {
struct rohc_ts time; /* The timestamp associated to the data */
uint8_t *data; /* The buffer data */
size_t max_len; /* The maximum length of the buffer */
size_t offset; /* The offset for the beginning of the data */
size_t len; /* The data length (in bytes) */
};

RETURN VALUE

Possible return values:

ROHC_STATUS_OK if a ROHC packet is returned

ROHC_STATUS_SEGMENT if no ROHC data is returned and ROHC segments can be retrieved with successive calls to rohc_comp_get_segment2

ROHC_STATUS_OUTPUT_TOO_SMALL if the output buffer is too small for the compressed packet

ROHC_STATUS_ERROR if an error occurred

EXAMPLE

struct rohc_comp *compressor; /* the ROHC compressor */
/* the buffer that will contain the IPv4 packet to compress */
unsigned char ip_buffer[BUFFER_SIZE];
struct rohc_buf ip_packet = rohc_buf_init_empty(ip_buffer, BUFFER_SIZE);
/* the buffer that will contain the resulting ROHC packet */
unsigned char rohc_buffer[BUFFER_SIZE];
struct rohc_buf rohc_packet = rohc_buf_init_empty(rohc_buffer, BUFFER_SIZE);

status = rohc_compress4(compressor, ip_packet, &rohc_packet);
if(status == ROHC_STATUS_SEGMENT)
{
/* success: compression succeeded, but resulting ROHC packet was too
* large for the Maximum Reconstructed Reception Unit (MRRU) configured
* with rohc_comp_set_mrru, the rohc_packet buffer contains the
* first ROHC segment and rohc_comp_get_segment can be used to
* retrieve the next ones. */

}
else if(status == ROHC_STATUS_OK)
{
/* success: compression succeeded, and resulting ROHC packet fits the
* Maximum Reconstructed Reception Unit (MRRU) configured with
* rohc_comp_set_mrru, the rohc_packet buffer contains the
* rohc_packet_len bytes of the ROHC packet */

}
else
{
/* compressor failed to compress the IP packet */

}

SEE ALSO

rohc_comp.h(3), ROHC_STATUS_OK(3), ROHC_STATUS_SEGMENT(3), rohc_comp_set_mrru(3), rohc_comp_get_segment2(3), ROHC_STATUS_OUTPUT_TOO_SMALL(3), ROHC_STATUS_ERROR(3)