ROHC compression/decompression library
|
Library of encoding methods from RFC4997 and RFC4996. More...
#include "rfc4996.h"
#include "rohc_utils.h"
#include "protocols/tcp.h"
#include <string.h>
#include <assert.h>
Functions | |
int | c_static_or_irreg8 (const uint8_t context_value, const uint8_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Compress the 8 bits given, depending of the context value. More... | |
int | c_static_or_irreg16 (const uint16_t packet_value, const bool is_static, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Compress the 16 bits given, depending of the context value. More... | |
int | c_zero_or_irreg16 (const uint16_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Compress the 16 bits value, regarding if null or not. More... | |
int | c_zero_or_irreg32 (const uint32_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Compress the 32 bits value, regarding if null or not. More... | |
int | variable_length_32_enc (const uint32_t old_value, const uint32_t new_value, const size_t nr_bits_63, const size_t nr_bits_16383, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Compress the given 32-bit value. More... | |
void | c_field_scaling (uint32_t *const scaled_value, uint32_t *const residue_field, const uint32_t scaling_factor, const uint32_t unscaled_value) |
Calculate the scaled and residue values from unscaled value and scaling factor. More... | |
bool | rsf_index_enc_possible (const uint8_t rsf_flags) |
Is is possible to use the rsf_index_enc encoding? More... | |
unsigned int | rsf_index_enc (const uint8_t rsf_flags) |
Calculate the rsf_index from the rsf flags. More... | |
int | c_optional_ip_id_lsb (const int behavior, const uint16_t ip_id_nbo, const uint16_t ip_id_offset, const size_t nr_bits_wlsb, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Compress or not the IP-ID. More... | |
int | dscp_encode (const uint8_t context_value, const uint8_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator) |
Encode the DSCP field. More... | |
Library of encoding methods from RFC4997 and RFC4996.
void c_field_scaling | ( | uint32_t *const | scaled_value, |
uint32_t *const | residue_field, | ||
const uint32_t | scaling_factor, | ||
const uint32_t | unscaled_value | ||
) |
Calculate the scaled and residue values from unscaled value and scaling factor.
See RFC4996 page 49
scaled_value | TODO |
residue_field | TODO |
scaling_factor | TODO |
unscaled_value | TODO |
int c_optional_ip_id_lsb | ( | const int | behavior, |
const uint16_t | ip_id_nbo, | ||
const uint16_t | ip_id_offset, | ||
const size_t | nr_bits_wlsb, | ||
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Compress or not the IP-ID.
See RFC4996 page 76
behavior | The IP-ID behavior | |
ip_id_nbo | The IP-ID value to compress (in NBO) | |
ip_id_offset | The IP-ID offset value to compress (in HBO) | |
nr_bits_wlsb | The number of IP-ID offset bits required for W-LSB | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator: 0 if short, 1 if long |
int c_static_or_irreg16 | ( | const uint16_t | packet_value, |
const bool | is_static, | ||
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Compress the 16 bits given, depending of the context value.
packet_value | The packet value | |
is_static | Whether the value is static or not | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator: 1 if present, 0 if not |
int c_static_or_irreg8 | ( | const uint8_t | context_value, |
const uint8_t | packet_value, | ||
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Compress the 8 bits given, depending of the context value.
See RFC4996 page 46
context_value | The context value | |
packet_value | The packet value | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator: 1 if present, 0 if not |
int c_zero_or_irreg16 | ( | const uint16_t | packet_value, |
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Compress the 16 bits value, regarding if null or not.
packet_value | The packet value | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator: 1 if present, 0 if not |
int c_zero_or_irreg32 | ( | const uint32_t | packet_value, |
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Compress the 32 bits value, regarding if null or not.
packet_value | The packet value | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator: 1 if present, 0 if not |
int dscp_encode | ( | const uint8_t | context_value, |
const uint8_t | packet_value, | ||
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Encode the DSCP field.
See RFC4996 page 75
context_value | The DSCP value in the compression context | |
packet_value | The DSCP value in the packet to compress | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator: 1 if present, 1 if not |
unsigned int rsf_index_enc | ( | const uint8_t | rsf_flags | ) |
Calculate the rsf_index from the rsf flags.
See RFC4996 page 71
rsf_flags | The RSF flags |
bool rsf_index_enc_possible | ( | const uint8_t | rsf_flags | ) |
Is is possible to use the rsf_index_enc encoding?
See RFC4996 page 71
rsf_flags | The RSF flags |
int variable_length_32_enc | ( | const uint32_t | old_value, |
const uint32_t | new_value, | ||
const size_t | nr_bits_63, | ||
const size_t | nr_bits_16383, | ||
uint8_t *const | rohc_data, | ||
const size_t | rohc_max_len, | ||
int *const | indicator | ||
) |
Compress the given 32-bit value.
See variable_length_32_enc in RFC4996 page 46.
old_value | The previous 32-bit value | |
new_value | The 32-bit value to compress | |
nr_bits_63 | The number of bits required for W-LSB encoding with p = 63 | |
nr_bits_16383 | The number of bits required for W-LSB encoding with p = 16383 | |
[out] | rohc_data | The compressed value |
rohc_max_len | The max remaining length in the ROHC buffer | |
[out] | indicator | The indicator for the compressed value |