ROHC compression/decompression library
Data Structures | Functions | Variables
rfc4996.h File Reference

Library of encoding methods from RFC4997 and RFC4996. More...

#include "protocols/tcp.h"
#include "schemes/wlsb.h"
#include <stdint.h>
#include "dllexport.h"
Include dependency graph for comp/schemes/rfc4996.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  multi_ptr_t
 Define union of different compressed datas pointers. More...

Functions

uint32_t ROHC_EXPORT c_lsb (const struct rohc_comp_ctxt *const context, int num_lsbs_param, unsigned int offset_param, unsigned int context_value, unsigned int original_value)
 Compress the lower bits of the given value.
int c_static_or_irreg8 (const uint8_t context_value, const uint8_t packet_value, uint8_t *const rohc_data, int *const indicator)
 Compress the 8 bits given, depending of the context value.
int c_static_or_irreg16 (const uint16_t context_value, const uint16_t packet_value, uint8_t *const rohc_data, int *const indicator)
 Compress the 16 bits given, depending of the context value.
int c_zero_or_irreg8 (const uint8_t packet_value, uint8_t *const rohc_data, int *const indicator)
 Compress the 8 bits value, regarding if null or not.
int c_zero_or_irreg16 (const uint16_t packet_value, uint8_t *const rohc_data, int *const indicator)
 Compress the 16 bits value, regarding if null or not.
int c_zero_or_irreg32 (const uint32_t packet_value, uint8_t *const rohc_data, int *const indicator)
 Compress the 32 bits value, regarding if null or not.
size_t ROHC_EXPORT 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, int *const indicator)
 Compress the given 32-bit value.
int c_optional32 (const int indicator, const uint32_t packet_value, uint8_t *const rohc_data)
 Compress a 32 bits value, regarding the context value.
int c_lsb_7_or_31 (const uint32_t context_value, const uint32_t packet_value, uint8_t *const rohc_data)
 Compress a 32 bits value to 7 or 31 bits.
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.
unsigned int rsf_index_enc (const struct rohc_comp_ctxt *const context, unsigned int rsf_flags)
 Calculate the rsf_index from the rsf flags.
uint16_t c_ip_id_lsb (const struct rohc_comp_ctxt *const context, const int behavior, const unsigned int k, const unsigned int p, const uint16_t context_ip_id, const uint16_t ip_id, const uint16_t msn)
 Compress the lower bits of IP-ID.
int c_optional_ip_id_lsb (const struct rohc_comp_ctxt *const context, const int behavior, const uint16_t context_ip_id, const uint16_t ip_id, const uint16_t msn, uint8_t *const rohc_data, int *const indicator)
 Compress or not the IP-ID.
unsigned int dscp_encode (multi_ptr_t *pmptr, const uint8_t context_value, const uint8_t value)
 Encode the DSCP field.

Variables

unsigned int ROHC_EXPORT lsb_xor_masks []
 Table of the mask for lsb()

Detailed Description

Library of encoding methods from RFC4997 and RFC4996.

Author:
FWX <rohc_team@dialine.fr>
Didier Barvaux <didier@barvaux.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
uint16_t c_ip_id_lsb ( const struct rohc_comp_ctxt *const  context,
const int  behavior,
const unsigned int  k,
const unsigned int  p,
const uint16_t  context_ip_id,
const uint16_t  ip_id,
const uint16_t  msn 
)

Compress the lower bits of IP-ID.

See RFC4996 page 75

Parameters:
contextThe compressor context
behaviorThe IP-ID behavior
kThe num_lsbs_param parameter for c_lsb()
pThe offset parameter for c_lsb()
context_ip_idThe context value of IP-ID
ip_idThe IP-ID value to compress
msnThe Master Sequence Number
Returns:
The lsb of offset between IP-ID and MSN
uint32_t ROHC_EXPORT c_lsb ( const struct rohc_comp_ctxt *const  context,
int  num_lsbs_param,
unsigned int  offset_param,
unsigned int  context_value,
unsigned int  original_value 
)

Compress the lower bits of the given value.

See RFC4997 page 27

Parameters:
contextThe compressor context
num_lsbs_paramThe number of bits
offset_paramThe offset
context_valueThe value of the context
original_valueThe value to compress
Returns:
The compressed value with num_lsbs_param bits
int c_lsb_7_or_31 ( const uint32_t  context_value,
const uint32_t  packet_value,
uint8_t *const  rohc_data 
)

Compress a 32 bits value to 7 or 31 bits.

See RFC4996 page 47

Parameters:
context_valueThe context value
packet_valueThe packet value
[out]rohc_dataThe compressed value
Returns:
The number of ROHC bytes written, -1 if a problem occurs
int c_optional32 ( const int  indicator,
const uint32_t  packet_value,
uint8_t *const  rohc_data 
)

Compress a 32 bits value, regarding the context value.

See RFC4996 page 47

Parameters:
indicatorThe indicator: 1 if present, 0 if not
packet_valueThe packet value
rohc_dataThe compressed value
Returns:
The number of ROHC bytes written, -1 if a problem occurs
int c_optional_ip_id_lsb ( const struct rohc_comp_ctxt *const  context,
const int  behavior,
const uint16_t  context_ip_id,
const uint16_t  ip_id,
const uint16_t  msn,
uint8_t *const  rohc_data,
int *const  indicator 
)

Compress or not the IP-ID.

See RFC4996 page 76

Parameters:
contextThe compressor context
behaviorThe IP-ID behavior
context_ip_idThe context value of IP-ID
ip_idThe IP-ID value to compress
msnThe Master Sequence Number
[out]rohc_dataThe compressed value
[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  context_value,
const uint16_t  packet_value,
uint8_t *const  rohc_data,
int *const  indicator 
)

Compress the 16 bits given, depending of the context value.

Parameters:
context_valueThe context value
packet_valueThe packet value
[out]rohc_dataThe compressed value
[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,
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
[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,
int *const  indicator 
)

Compress the 16 bits value, regarding if null or not.

Parameters:
packet_valueThe packet value
[out]rohc_dataThe compressed value
[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,
int *const  indicator 
)

Compress the 32 bits value, regarding if null or not.

Parameters:
packet_valueThe packet value
[out]rohc_dataThe compressed value
[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_irreg8 ( const uint8_t  packet_value,
uint8_t *const  rohc_data,
int *const  indicator 
)

Compress the 8 bits value, regarding if null or not.

Parameters:
packet_valueThe packet value
[out]rohc_dataThe compressed value
[out]indicatorThe indicator: 1 if present, 0 if not
Returns:
The number of ROHC bytes written, -1 if a problem occurs
unsigned int dscp_encode ( multi_ptr_t pmptr,
const uint8_t  context_value,
const uint8_t  packet_value 
)

Encode the DSCP field.

See RFC4996 page 75

Parameters:
pmptrThe destination for the compressed value
context_valueThe DSCP value in the compression context
packet_valueThe DSCP value in the packet to compress
Returns:
Indicator 1 if value compressed, 0 otherwise
unsigned int rsf_index_enc ( const struct rohc_comp_ctxt *const  context,
unsigned int  rsf_flags 
)

Calculate the rsf_index from the rsf flags.

See RFC4996 page 71

Parameters:
contextThe compressor context
rsf_flagsThe RSF flags
Returns:
The rsf index
size_t ROHC_EXPORT 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,
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
[out]indicatorThe indicator for the compressed value
Returns:
The number of ROHC bytes written

Variable Documentation

unsigned int ROHC_EXPORT lsb_xor_masks[]

Table of the mask for lsb()