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... | |
Macros | |
#define | ROHC_ETHERTYPE 0x22f1 |
The Ethertype assigned to the ROHC protocol by the IEEE. More... | |
#define | ROHC_LARGE_CID_MAX ((1U << 14) - 1) /* 2^14 - 1 = 16383 */ |
The maximum value for large CIDs. More... | |
#define | ROHC_SMALL_CID_MAX 15U |
The maximum value for small CIDs. More... | |
#define | rohc_buf_init_empty(__data, __max_len) |
Initialize the given network buffer with no data. More... | |
#define | rohc_buf_init_full(__data, __len, __time) |
Initialize the given network buffer with all its data. More... | |
#define | rohc_buf_byte_at(__buf, __offset) ((__buf).data)[(__buf).offset + (__offset)] |
Get the byte at the given offset in the given network buffer. More... | |
#define | rohc_buf_byte(__buf) rohc_buf_byte_at((__buf), 0) |
Get the next byte in the given network buffer. More... | |
#define | ROHC_PROFILE_GENERAL 0xffff |
A general profile number used for traces not related to a specific profile. More... | |
Typedefs | |
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. More... | |
Functions | |
static bool | rohc_buf_is_malformed (const struct rohc_buf buf) |
Is the given network buffer malformed? More... | |
static bool | rohc_buf_is_empty (const struct rohc_buf buf) |
Is the given network buffer empty? More... | |
static void | rohc_buf_pull (struct rohc_buf *const buf, const size_t offset) |
Pull the beginning of the given network buffer. More... | |
static void | rohc_buf_push (struct rohc_buf *const buf, const size_t offset) |
Push the beginning of the given network buffer. More... | |
static size_t | rohc_buf_avail_len (const struct rohc_buf buf) |
How many bytes the given network buffer may contain? More... | |
static uint8_t * | rohc_buf_data (const struct rohc_buf buf) |
Get the bytes in the given network buffer. More... | |
static 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. More... | |
static 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. More... | |
static 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. More... | |
static 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. More... | |
static void | rohc_buf_reset (struct rohc_buf *const buf) |
Reset the given network buffer. More... | |
char * | rohc_version (void) |
Get the version of the ROHC library. More... | |
const char * | rohc_strerror (const rohc_status_t status) |
Give a description for the given ROHC status code. More... | |
const char * | rohc_get_mode_descr (const rohc_mode_t mode) |
Give a description for the given ROHC mode. More... | |
const char * | rohc_get_packet_descr (const rohc_packet_t packet_type) |
Give a description for the given type of ROHC packet. More... | |
const char * | rohc_get_ext_descr (const rohc_ext_t ext_type) |
Give a description for the given type of ROHC extension. More... | |
rohc_packet_t | rohc_get_packet_type (const char *const packet_id) |
Get the packet type from a packet identifier. More... | |
const char * | rohc_get_profile_descr (const rohc_profile_t profile) |
Give a description for the given ROHC profile. More... | |
bool | rohc_profile_is_rohcv1 (const rohc_profile_t profile) |
Is the given profile one ROHCv1 profile? More... | |
bool | rohc_profile_is_rohcv2 (const rohc_profile_t profile) |
Is the given profile one ROHCv2 profile? More... | |
rohc_profile_t | rohc_profile_get_other_version (const rohc_profile_t profile) |
Get the other version of the given profile. More... | |
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 | |||
) |
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 rohc_buf_init_full | ( | __data, | |
__len, | |||
__time | |||
) |
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 ROHC_ETHERTYPE 0x22f1 |
The Ethertype assigned to the ROHC protocol by the IEEE.
#define ROHC_LARGE_CID_MAX ((1U << 14) - 1) /* 2^14 - 1 = 16383 */ |
The maximum value for large CIDs.
#define ROHC_PROFILE_GENERAL 0xffff |
A general profile number used for traces not related to a specific profile.
#define ROHC_SMALL_CID_MAX 15U |
The maximum value for small CIDs.
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 |
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.
Enumerator | |
---|---|
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_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.
The ROHC profiles numbers are allocated by the IANA:
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_callback2_t user-defined callback.
Enumerator | |
---|---|
ROHC_TRACE_COMP | Compressor traces |
ROHC_TRACE_DECOMP | Decompressor traces |
ROHC_TRACE_ENTITY_MAX | The maximum number of trace entities |
enum rohc_trace_level_t |
The different levels of the traces.
Used for the level parameter of the rohc_trace_callback2_t user-defined callback.
|
inlinestatic |
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 |
|
inlinestatic |
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 |
|
inlinestatic |
How many bytes the given network buffer may contain?
buf | The network buffer to check |
|
inlinestatic |
Get the bytes in the given network buffer.
This function is a shortcut for:
buf | The network buffer to get bytes from |
|
inlinestatic |
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 |
|
inlinestatic |
Is the given network buffer empty?
Empty means no data at all.
buf | The network buffer to check for |
|
inlinestatic |
Is the given network buffer malformed?
buf | The network buffer to check for |
|
inlinestatic |
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 |
|
inlinestatic |
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 |
|
inlinestatic |
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 |
|
inlinestatic |
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 |
rohc_packet_t rohc_get_packet_type | ( | const char *const | packet_id | ) |
Get the packet type from a packet identifier.
packet_id | The identifier of packet (NULL-terminated string) |
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 |
rohc_profile_t rohc_profile_get_other_version | ( | const rohc_profile_t | profile | ) |
Get the other version of the given profile.
profile | The profile ID for which to get the other version |
bool rohc_profile_is_rohcv1 | ( | const rohc_profile_t | profile | ) |
Is the given profile one ROHCv1 profile?
profile | The profile ID to check for |
bool rohc_profile_is_rohcv2 | ( | const rohc_profile_t | profile | ) |
Is the given profile one ROHCv2 profile?
profile | The profile ID to check 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