ROHC compression/decompression library
Functions
comp/schemes/rfc4996.c File Reference

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>
Include dependency graph for comp/schemes/rfc4996.c:

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...
 

Detailed Description

Library of encoding methods from RFC4997 and RFC4996.

Author
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org

Function Documentation

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

Parameters
scaled_valueTODO
residue_fieldTODO
scaling_factorTODO
unscaled_valueTODO
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

Parameters
behaviorThe IP-ID behavior
ip_id_nboThe IP-ID value to compress (in NBO)
ip_id_offsetThe IP-ID offset value to compress (in HBO)
nr_bits_wlsbThe number of IP-ID offset bits required for W-LSB
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator: 0 if short, 1 if long
Returns
The number of ROHC bytes written, -1 if a problem occurs
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.

Parameters
packet_valueThe packet value
is_staticWhether the value is static or not
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator: 1 if present, 0 if not
Returns
The number of ROHC bytes written, -1 if a problem occurs
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

Parameters
context_valueThe context value
packet_valueThe packet value
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator: 1 if present, 0 if not
Returns
The number of ROHC bytes written, -1 if a problem occurs
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.

Parameters
packet_valueThe packet value
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator: 1 if present, 0 if not
Returns
The number of ROHC bytes written, -1 if a problem occurs
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.

Parameters
packet_valueThe packet value
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator: 1 if present, 0 if not
Returns
The number of ROHC bytes written, -1 if a problem occurs
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

Parameters
context_valueThe DSCP value in the compression context
packet_valueThe DSCP value in the packet to compress
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator: 1 if present, 1 if not
Returns
The number of ROHC bytes written, -1 if a problem occurs
unsigned int rsf_index_enc ( const uint8_t  rsf_flags)

Calculate the rsf_index from the rsf flags.

See RFC4996 page 71

Parameters
rsf_flagsThe RSF flags
Returns
The rsf index
bool rsf_index_enc_possible ( const uint8_t  rsf_flags)

Is is possible to use the rsf_index_enc encoding?

See RFC4996 page 71

Parameters
rsf_flagsThe RSF flags
Returns
true if the rsf_index_enc may be used, false if it cannot
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.

Parameters
old_valueThe previous 32-bit value
new_valueThe 32-bit value to compress
nr_bits_63The number of bits required for W-LSB encoding with p = 63
nr_bits_16383The number of bits required for W-LSB encoding with p = 16383
[out]rohc_dataThe compressed value
rohc_max_lenThe max remaining length in the ROHC buffer
[out]indicatorThe indicator for the compressed value
Returns
The number of ROHC bytes written in case of success, -1 in case of error