ROHC compression/decompression library
Functions | Variables
rfc4996.c File Reference

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

#include "rfc4996.h"
#include "rohc_bit_ops.h"
#include "rohc_traces_internal.h"
#include "rohc_decomp_internals.h"
#include "rohc_debug.h"
#include "rohc_utils.h"
#include "crc.h"
#include "protocols/tcp.h"
#include "rohc_packets.h"
#include "rohc_decomp.h"
#include <string.h>
#include <assert.h>
Include dependency graph for decomp/schemes/rfc4996.c:

Functions

uint32_t d_lsb (const struct rohc_decomp_ctxt *const context, int num_lsbs_param, int offset_param, unsigned int context_value, unsigned int value)
 Decompress the lower bits from the given value and the context value.
int d_static_or_irreg8 (const uint8_t *rohc_data, const uint8_t context_value, const int indicator, uint8_t *const decoded_value)
 Decompress the 8-bit given value, according to the indicator.
int d_static_or_irreg16 (const uint8_t *rohc_data, const uint16_t context_value, const int indicator, uint16_t *const decoded_value)
 Decompress the 16-bit given value, according to the indicator.
int variable_length_32_dec (const struct rohc_lsb_decode *const lsb, const struct rohc_decomp_ctxt *const context, const uint8_t *rohc_data, const int indicator, uint32_t *const decoded_value)
 Decode the 32 bits value, according to the indicator.
int d_optional32 (const int flag, const uint8_t *const data, const size_t data_len, uint32_t context_value, uint32_t *const decoded_value)
 Decode the 32 bits value, according to the indicator.
uint32_t d_field_scaling (const uint32_t scaling_factor, const uint32_t scaled_value, const uint32_t residue_field)
 Calculate the value from the scaling factor, scaled value and residue.
unsigned int rsf_index_dec (unsigned int rsf_index)
 Calculate the rsf flags from the rsf index.
static uint32_t d_c_lsb (const struct rohc_decomp_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.
uint16_t d_ip_id_lsb (const struct rohc_decomp_ctxt *const context, const int behavior, const unsigned int k, const unsigned int p, const uint16_t context_ip_id, const uint16_t value, const uint16_t msn)
 Decompress the lower bits of IP-ID.
int d_optional_ip_id_lsb (const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_data, const int behavior, const int indicator, const uint16_t context_ip_id, uint16_t *const ip_id, const uint16_t msn)
 Decompress the IP-ID.
int dscp_decode (const uint8_t *const rohc_data, const uint8_t context_value, const int indicator, uint8_t *const decoded_value)
 Decode the DSCP field.

Variables

static unsigned int lsb_masks []
 Table of the mask for lsb()
unsigned int lsb_xor_masks []
 Table of the mask for lsb()
unsigned int variable_length_32_size [4]
 Table of the size of the variable_length_32 encode value.

Detailed Description

Library of decoding methods from RFC4997 and RFC4996.

Author:
FWX <rohc_team@dialine.fr>
Didier Barvaux <didier@barvaux.org>

Function Documentation

static uint32_t d_c_lsb ( const struct rohc_decomp_ctxt *const  context,
int  num_lsbs_param,
unsigned int  offset_param,
unsigned int  context_value,
unsigned int  original_value 
) [static]

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
Todo:
TODO: duplicated code from rfc4996_encoding.c
uint32_t d_field_scaling ( const uint32_t  scaling_factor,
const uint32_t  scaled_value,
const uint32_t  residue_field 
)

Calculate the value from the scaling factor, scaled value and residue.

See RFC4996 page 49

Parameters:
scaling_factorThe scaling factor
scaled_valueThe scaled value
residue_fieldThe residue value
Returns:
The unscaled value
uint16_t d_ip_id_lsb ( const struct rohc_decomp_ctxt *const  context,
const int  behavior,
const unsigned int  k,
const unsigned int  p,
const uint16_t  context_ip_id,
const uint16_t  value,
const uint16_t  msn 
)

Decompress the lower bits of IP-ID.

See RFC4996 page 75

Parameters:
contextThe decompression context
behaviorThe IP-ID behavior
kThe num_lsbs_param parameter for d_lsb()
pThe offset parameter for d_lsb()
context_ip_idThe context IP-ID value
valueThe value to decompress
msnThe Master Sequence Number
Returns:
The IP-ID
uint32_t d_lsb ( const struct rohc_decomp_ctxt *const  context,
int  num_lsbs_param,
int  offset_param,
unsigned int  context_value,
unsigned int  value 
)

Decompress the lower bits from the given value and the context value.

See RFC4997 page 27

Parameters:
contextThe decompression context
num_lsbs_paramThe number of bits
offset_paramThe offset
context_valueThe value of the context
valueThe compressed value
Returns:
The uncompressed value
int d_optional32 ( const int  flag,
const uint8_t *const  data,
const size_t  data_len,
uint32_t  context_value,
uint32_t *const  decoded_value 
)

Decode the 32 bits value, according to the indicator.

See RFC4996 page 47

Parameters:
flagFlag of compression
dataThe remaining part of the ROHC packet
data_lenThe length of the remaining part of the packet
context_valueThe context value
[out]decoded_valueThe uncompressed value
Returns:
The number of ROHC bytes parsed, -1 if packet is malformed
int d_optional_ip_id_lsb ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  rohc_data,
const int  behavior,
const int  indicator,
const uint16_t  context_ip_id,
uint16_t *const  ip_id,
const uint16_t  msn 
)

Decompress the IP-ID.

See RFC4996 page 76

Parameters:
contextThe decompression context
rohc_dataThe compressed value
behaviorThe IP-ID behavior
indicatorThe compression indicator
context_ip_idThe context IP-ID value
ip_idPointer to the uncompressed IP-ID
msnThe Master Sequence Number
Returns:
The length (in bytes) of the compressed value, -1 if ROHC data is malformed
int d_static_or_irreg16 ( const uint8_t *  rohc_data,
const uint16_t  context_value,
const int  indicator,
uint16_t *const  decoded_value 
)

Decompress the 16-bit given value, according to the indicator.

Parameters:
rohc_dataThe packet value
context_valueThe context value
indicatorThe indicator of compression
[out]decoded_valueThe decoded value
Returns:
The length (in bytes) of the compressed value, -1 if ROHC data is malformed
int d_static_or_irreg8 ( const uint8_t *  rohc_data,
const uint8_t  context_value,
const int  indicator,
uint8_t *const  decoded_value 
)

Decompress the 8-bit given value, according to the indicator.

Parameters:
rohc_dataThe packet value
context_valueThe context value
indicatorThe indicator of compression
[out]decoded_valueThe decoded value
Returns:
The length (in bytes) of the compressed value, -1 if ROHC data is malformed
int dscp_decode ( const uint8_t *const  rohc_data,
const uint8_t  context_value,
const int  indicator,
uint8_t *const  decoded_value 
)

Decode the DSCP field.

Parameters:
rohc_dataThe compressed value
context_valueThe context DSCP value
indicatorThe indicator of the compression
[out]decoded_valueThe decoded value
Returns:
The length (in bytes) of the compressed value, -1 if ROHC data is malformed
unsigned int rsf_index_dec ( unsigned int  rsf_index)

Calculate the rsf flags from the rsf index.

See RFC4996 page 71

Parameters:
rsf_indexThe rsf index
Returns:
The rsf flags
int variable_length_32_dec ( const struct rohc_lsb_decode *const  lsb,
const struct rohc_decomp_ctxt *const  context,
const uint8_t *  rohc_data,
const int  indicator,
uint32_t *const  decoded_value 
)

Decode the 32 bits value, according to the indicator.

See RFC4996 page 46

Parameters:
lsbThe WLSB decoding context
contextThe decompression context
rohc_dataThe compressed value
indicatorThe indicator of compression
[out]decoded_valueThe decoded value (in NBO)
Returns:
The length (in bytes) of the compressed value, -1 if ROHC data is malformed

Variable Documentation

unsigned int lsb_masks[] [static]
Initial value:
{
        0x00000,
        0x00001, 0x00003, 0x00007, 0x0000F,
        0x0001F, 0x0003F, 0x0007F, 0x000FF,
        0x001FF, 0x003FF, 0x007FF, 0x00FFF,
        0x01FFF, 0x03FFF, 0x07FFF, 0x0FFFF,
        0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF
}

Table of the mask for lsb()

unsigned int lsb_xor_masks[]
Initial value:
{
        0xFFFFFFFF,
        0xFFFFFFFE, 0xFFFFFFFC, 0xFFFFFFF8, 0xFFFFFFF0,
        0xFFFFFFE0, 0xFFFFFFC0, 0xFFFFFF80, 0xFFFFFF00,
        0xFFFFFE00, 0xFFFFFC00, 0xFFFFF800, 0xFFFFF000,
        0xFFFFE000, 0xFFFFC000, 0xFFFF8000, 0xFFFF0000,
        0xFFFE0000, 0xFFFC0000, 0xFFF80000, 0xFFF00000
}

Table of the mask for lsb()

unsigned int variable_length_32_size[4]
Initial value:
{
        0,1,2,4
}

Table of the size of the variable_length_32 encode value.