ROHC compression/decompression library
|
Data Structures | |
struct | rohc_buf |
A network buffer for the ROHC library. More... | |
struct | rohc_ts |
A timestamp for the ROHC library. More... | |
Defines | |
#define | ROHC_ETHERTYPE 0x22f1 |
The Ethertype assigned to the ROHC protocol by the IEEE. | |
#define | ROHC_OK 1 |
Return code: the action was performed without problem. | |
#define | ROHC_ERROR_NO_CONTEXT -1 |
Return code: the action failed because no context is defined. | |
#define | ROHC_ERROR_PACKET_FAILED -2 |
Return code: the action failed due to an unattended or malformed packet. | |
#define | ROHC_FEEDBACK_ONLY -3 |
Return code: the action failed because the packet only contains feedback info. | |
#define | ROHC_ERROR_CRC -4 |
Return code: the action failed due to a CRC failure. | |
#define | ROHC_ERROR -5 |
Return code: the action encountered a problem. | |
#define | ROHC_NEED_REPARSE -6 |
Return code: the packet needs to be parsed again. | |
#define | ROHC_NEED_SEGMENT -7 |
Return code: the action succeeded but packet needs to be segmented. | |
#define | ROHC_NON_FINAL_SEGMENT -8 |
Return code: the action succeeded but packet is a non-final segment. | |
#define | ROHC_LARGE_CID_MAX ((1 << 14) - 1) /* 2^14 - 1 = 16383 */ |
The maximum value for large CIDs. | |
#define | ROHC_SMALL_CID_MAX 15 |
The maximum value for small CIDs. | |
#define | rohc_buf_init_empty(__data, __max_len) |
Initialize the given network buffer with no data. | |
#define | rohc_buf_init_full(__data, __len, __time) |
Initialize the given network buffer with all its data. | |
#define | rohc_buf_byte_at(__buf, __offset) ((__buf).data)[(__buf).offset + (__offset)] |
Get the byte at the given offset in the given network buffer. | |
#define | rohc_buf_byte(__buf) rohc_buf_byte_at((__buf), 0) |
Get the next byte in the given network buffer. | |
#define | ROHC_PROFILE_GENERAL 0xffff |
A general profile number used for traces not related to a specific profile. | |
Typedefs | |
typedef void(* | rohc_trace_callback_t )(const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...) |
The function prototype for the trace callback. | |
typedef void(* | rohc_trace_callback2_t )(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...) |
The function prototype for the trace callback. | |
Enumerations | |
enum | rohc_status_t { ROHC_STATUS_OK = 0, ROHC_STATUS_SEGMENT = 1, ROHC_STATUS_MALFORMED = 2, ROHC_STATUS_NO_CONTEXT = 3, ROHC_STATUS_BAD_CRC = 4, ROHC_STATUS_OUTPUT_TOO_SMALL = 5, ROHC_STATUS_ERROR = 6 } |
The status code of several functions in the library API. More... | |
enum | rohc_mode { U_MODE = 1, O_MODE = 2, R_MODE = 3 } |
ROHC operation modes (see 4.4 in the RFC 3095) More... | |
enum | rohc_mode_t { ROHC_U_MODE = 1, ROHC_O_MODE = 2, ROHC_R_MODE = 3 } |
ROHC operation modes. More... | |
enum | rohc_cid_type_t { ROHC_LARGE_CID, ROHC_SMALL_CID } |
The different types of Context IDs (CID) More... | |
enum | rohc_profile_t { ROHC_PROFILE_UNCOMPRESSED = 0x0000, ROHC_PROFILE_RTP = 0x0001, ROHC_PROFILE_UDP = 0x0002, ROHC_PROFILE_ESP = 0x0003, ROHC_PROFILE_IP = 0x0004, ROHC_PROFILE_TCP = 0x0006, ROHC_PROFILE_UDPLITE = 0x0008 } |
The different ROHC compression/decompression profiles. More... | |
enum | rohc_trace_level_t { ROHC_TRACE_DEBUG = 0, ROHC_TRACE_INFO = 1, ROHC_TRACE_WARNING = 2, ROHC_TRACE_ERROR = 3, ROHC_TRACE_LEVEL_MAX } |
The different levels of the traces. More... | |
enum | rohc_trace_entity_t { ROHC_TRACE_COMP = 0, ROHC_TRACE_DECOMP = 1, ROHC_TRACE_ENTITY_MAX } |
The different entities concerned by the traces. More... | |
Functions | |
int | crc_get_polynom (int type) |
Get the polynom for the given CRC type. | |
void | crc_init_table (unsigned char *table, unsigned char poly) |
Initialize a CRC table given a 256-byte table and the polynom to use. | |
bool | rohc_buf_is_malformed (const struct rohc_buf buf) |
Is the given network buffer malformed? | |
bool | rohc_buf_is_empty (const struct rohc_buf buf) |
Is the given network buffer empty? | |
void | rohc_buf_pull (struct rohc_buf *const buf, const size_t offset) |
Pull the beginning of the given network buffer. | |
void | rohc_buf_push (struct rohc_buf *const buf, const size_t offset) |
Push the beginning of the given network buffer. | |
size_t | rohc_buf_avail_len (const struct rohc_buf buf) |
How many bytes the given network buffer may contain? | |
uint8_t * | rohc_buf_data (const struct rohc_buf buf) |
Get the bytes in the given network buffer. | |
uint8_t * | rohc_buf_data_at (const struct rohc_buf buf, const size_t offset) |
Get the bytes at the given offset in the given network buffer. | |
void | rohc_buf_prepend (struct rohc_buf *const buf, const uint8_t *const data, const size_t len) |
Add data at the beginning of the given network buffer. | |
void | rohc_buf_append (struct rohc_buf *const buf, const uint8_t *const data, const size_t len) |
Add data at the end of the given network buffer. | |
void | rohc_buf_append_buf (struct rohc_buf *const dst, const struct rohc_buf src) |
Add a network buffer at the end of the given network buffer. | |
void | rohc_buf_reset (struct rohc_buf *const buf) |
Reset the given network buffer. | |
char * | rohc_version (void) |
Get the version of the ROHC library. | |
const char * | rohc_strerror (const rohc_status_t status) |
Give a description for the given ROHC status code. | |
const char * | rohc_get_mode_descr (const rohc_mode_t mode) |
Give a description for the given ROHC mode. | |
const char * | rohc_get_profile_descr (const rohc_profile_t profile) |
Give a description for the given ROHC profile. | |
const char * | rohc_get_packet_descr (const rohc_packet_t packet_type) |
Give a description for the given type of ROHC packet. | |
const char * | rohc_get_ext_descr (const rohc_ext_t ext_type) |
Give a description for the given type of ROHC extension. |
The common API of the ROHC library allows a program to print the version of the ROHC library, or retrieve the description of ROHC modes and packets. No initialization is required.
#define rohc_buf_byte | ( | __buf | ) | rohc_buf_byte_at((__buf), 0) |
Get the next byte in the given network buffer.
__buf | The network buffer to get the next byte from |
#define rohc_buf_byte_at | ( | __buf, | |
__offset | |||
) | ((__buf).data)[(__buf).offset + (__offset)] |
Get the byte at the given offset in the given network buffer.
__buf | The network buffer to get a byte from |
__offset | The offset to get bytes at |
#define rohc_buf_init_empty | ( | __data, | |
__max_len | |||
) |
{ \ .time = { .sec = 0, .nsec = 0, }, \ .data = (__data), \ .max_len = (__max_len), \ .offset = 0, \ .len = 0, \ }
Initialize the given network buffer with no data.
This method is used to initialize an empty network buffer that will be used to create a packet. For example, the ROHC packet for a compression operation, or the uncompressed packet for a decompression operation.
__data | The packet data to point to |
__max_len | The maxmimum length (in bytes) of the packet data |
#define PKT_DATA_LEN 145U uint8_t pkt_data[PKT_DATA_LEN]; struct rohc_buf packet = rohc_buf_init_empty(pkt_data, PKT_DATA_LEN);
#define rohc_buf_init_full | ( | __data, | |
__len, | |||
__time | |||
) |
{ \ .time = (__time), \ .data = (__data), \ .max_len = (__len), \ .offset = 0, \ .len = (__len), \ }
Initialize the given network buffer with all its data.
This method is used to initialize a network buffer that will be used for parsing only. For example, the uncompressed packet for a compression operation, or the ROHC packet for a decompression operation.
__data | The packet data to point to |
__len | The maxmimum length (in bytes) of the packet data |
__time | The timestamp at which the packet was received/handled |
#define PKT_DATA_LEN 145U const uint8_t pkt_data[PKT_DATA_LEN]; const struct rohc_ts arrival_time = { .sec = 1399745625, .nsec = 42 }; const struct rohc_buf packet = rohc_buf_init_full(pkt_data, PKT_DATA_LEN, arrival_time);
#define ROHC_ERROR -5 |
Return code: the action encountered a problem.
#define ROHC_ERROR_CRC -4 |
Return code: the action failed due to a CRC failure.
#define ROHC_ERROR_NO_CONTEXT -1 |
Return code: the action failed because no context is defined.
#define ROHC_ERROR_PACKET_FAILED -2 |
Return code: the action failed due to an unattended or malformed packet.
#define ROHC_ETHERTYPE 0x22f1 |
The Ethertype assigned to the ROHC protocol by the IEEE.
#define ROHC_FEEDBACK_ONLY -3 |
Return code: the action failed because the packet only contains feedback info.
#define ROHC_LARGE_CID_MAX ((1 << 14) - 1) /* 2^14 - 1 = 16383 */ |
The maximum value for large CIDs.
#define ROHC_NEED_REPARSE -6 |
Return code: the packet needs to be parsed again.
#define ROHC_NEED_SEGMENT -7 |
Return code: the action succeeded but packet needs to be segmented.
#define ROHC_NON_FINAL_SEGMENT -8 |
Return code: the action succeeded but packet is a non-final segment.
#define ROHC_OK 1 |
Return code: the action was performed without problem.
#define ROHC_PROFILE_GENERAL 0xffff |
A general profile number used for traces not related to a specific profile.
#define ROHC_SMALL_CID_MAX 15 |
The maximum value for small CIDs.
struct rohc_comp *compressor; /* the ROHC compressor */
compressor = rohc_comp_new2(ROHC_SMALL_CID, ROHC_SMALL_CID_MAX, gen_random_num, NULL); if(compressor == NULL) { fprintf(stderr, "failed create the ROHC compressor\n"); goto error; }
typedef void(* rohc_trace_callback2_t)(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...) |
The function prototype for the trace callback.
User-defined function that is called by the ROHC library every time it wants to print something, 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...).
The user-defined function is set by calling:
Both functions accept the NULL value to fully disable tracing.
priv_ctxt | An optional private context, may be NULL |
level | The level of the message, |
entity | The entity concerned by the traces |
profile | The number of the profile concerned by the message |
format | The format string for the trace message |
typedef void(* rohc_trace_callback_t)(const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...) |
The function prototype for the trace callback.
User-defined function that is called by the ROHC library every time it wants to print something, 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...).
The user-defined function is set by calling:
Both functions accept the NULL value to fully disable tracing.
level | The level of the message, |
entity | The entity concerned by the traces, |
profile | The number of the profile concerned by the message |
format | The format string for the trace message |
enum rohc_cid_type_t |
The different types of Context IDs (CID)
The different types of Context IDs (CID) a ROHC compressor or a ROHC decompressor may use.
Possible values are:
In short, you choose the CID type in function of the number of simultaneous streams you have to compress efficiently.
ROHC_LARGE_CID |
The context uses large CID. CID values shall be in the range [0, ROHC_LARGE_CID_MAX]. |
ROHC_SMALL_CID |
The context uses small CID. CID value shall be in the range [0, ROHC_SMALL_CID_MAX]. |
enum rohc_mode |
ROHC operation modes (see 4.4 in the RFC 3095)
If you add a new operation mode, please also add the corresponding textual description in rohc_get_mode_descr.
enum rohc_mode_t |
ROHC operation modes.
The different ROHC operation modes as defined in section 4.4 of RFC 3095.
If you add a new operation mode, please also add the corresponding textual description in rohc_get_mode_descr.
enum rohc_profile_t |
The different ROHC compression/decompression profiles.
If you add a new compression/decompression profile, please also add the corresponding textual description in rohc_get_profile_descr.
enum rohc_status_t |
The status code of several functions in the library API.
enum rohc_trace_entity_t |
The different entities concerned by the traces.
Used for the source entity parameter of the rohc_trace_callback_t user-defined callback.
enum rohc_trace_level_t |
The different levels of the traces.
Used for the level parameter of the rohc_trace_callback_t user-defined callback.
int crc_get_polynom | ( | int | type | ) |
Get the polynom for the given CRC type.
Public functions
type | The CRC type |
void crc_init_table | ( | unsigned char * | table, |
unsigned char | poly | ||
) |
Initialize a CRC table given a 256-byte table and the polynom to use.
table | The 256-byte table |
poly | The polynom |
void rohc_buf_append | ( | struct rohc_buf *const | buf, |
const uint8_t *const | data, | ||
const size_t | len | ||
) |
Add data at the end of the given network buffer.
buf | The network buffer to append data to |
data | The data to append |
len | The length (in bytes) of the data to append |
void rohc_buf_append_buf | ( | struct rohc_buf *const | dst, |
const struct rohc_buf | src | ||
) |
Add a network buffer at the end of the given network buffer.
dst | The network buffer to append data to |
src | The network buffer to append data from |
size_t rohc_buf_avail_len | ( | const struct rohc_buf | buf | ) |
How many bytes the given network buffer may contain?
buf | The network buffer to check |
uint8_t* rohc_buf_data | ( | const struct rohc_buf | buf | ) |
Get the bytes in the given network buffer.
This function is a shortcut for:
rohc_buf_data_at(buf, 0);
buf | The network buffer to get bytes from |
uint8_t* rohc_buf_data_at | ( | const struct rohc_buf | buf, |
const size_t | offset | ||
) |
Get the bytes at the given offset in the given network buffer.
buf | The network buffer to get bytes from |
offset | The offset to get bytes at |
bool rohc_buf_is_empty | ( | const struct rohc_buf | buf | ) |
Is the given network buffer empty?
Empty means no data at all.
buf | The network buffer to check for |
bool rohc_buf_is_malformed | ( | const struct rohc_buf | buf | ) |
Is the given network buffer malformed?
buf | The network buffer to check for |
void rohc_buf_prepend | ( | struct rohc_buf *const | buf, |
const uint8_t *const | data, | ||
const size_t | len | ||
) |
Add data at the beginning of the given network buffer.
buf | The network buffer to prepend data to |
data | The data to prepend |
len | The length (in bytes) of the data to prepend |
void rohc_buf_pull | ( | struct rohc_buf *const | buf, |
const size_t | offset | ||
) |
Pull the beginning of the given network buffer.
Pulling the beginning of the buffer increases the space at the beginning of the buffer. This is useful when parsing a network packet (once bytes are read, pull them) for example.
buf | The network buffer to check for |
offset | The offset to pull the beginning of the buffer of |
void rohc_buf_push | ( | struct rohc_buf *const | buf, |
const size_t | offset | ||
) |
Push the beginning of the given network buffer.
Pushing the beginning of the buffer decreases the space at the beginning of the buffer. This is useful to prepend a network header before the network buffer.
buf | The network buffer to check for |
offset | The offset to push the beginning of the buffer of |
void rohc_buf_reset | ( | struct rohc_buf *const | buf | ) |
Reset the given network buffer.
buf | The network buffer to remove all data from |
const char* rohc_get_ext_descr | ( | const rohc_ext_t | ext_type | ) |
Give a description for the given type of ROHC extension.
Give a description for the given type of ROHC extension.
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 the extensions used by the library. If unsure, ask on the mailing list.
ext_type | The type of extension to get a description for |
const char* rohc_get_mode_descr | ( | const rohc_mode_t | mode | ) |
Give a description for the given ROHC mode.
Give a description for the given ROHC mode.
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 modes used by the library. If unsure, ask on the mailing list.
mode | The ROHC mode to get a description for |
const char* rohc_get_packet_descr | ( | const rohc_packet_t | packet_type | ) |
Give a description for the given type of ROHC packet.
Give a description for the given type of ROHC packet.
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 the packets used by the library. If unsure, ask on the mailing list.
packet_type | The type of packet to get a description for |
const char* rohc_get_profile_descr | ( | const rohc_profile_t | profile | ) |
Give a description for the given ROHC profile.
Give a description for the given ROHC compression/decompression profile.
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 profiles used by the library. If unsure, ask on the mailing list.
profile | The ROHC profile to get a description for |
const char* rohc_strerror | ( | const rohc_status_t | status | ) |
Give a description for the given ROHC status code.
Give a description for the given ROHC status code.
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 status codes returned by the library. If unsure, ask on the mailing list.
status | The ROHC status code to get a description for |
char* rohc_version | ( | void | ) |
Get the version of the ROHC library.
Get the version of the ROHC library
const char *version; version = rohc_version(); printf("ROHC version %s\n", version);