ROHC compression/decompression library
Macros | Functions
comp_list.c File Reference

ROHC generic list compression. More...

#include "schemes/comp_list.h"
#include "rohc_comp_internals.h"
#include <string.h>
Include dependency graph for comp_list.c:

Macros

#define rohc_comp_list_warn(list_ctxt, format, ...)
 

Functions

static bool build_ipv6_ext_pkt_list (struct list_comp *const comp, const struct ip_packet *const ip, struct rohc_list *const pkt_list)
 Compute the list of extension headers for the current packet. More...
 
static unsigned int rohc_list_get_nearest_list (const struct list_comp *const comp, const struct rohc_list *const pkt_list, bool *const is_new_list)
 Search the nearest list for the packet list. More...
 
static int rohc_list_decide_type (struct list_comp *const comp)
 Decide the encoding type for compression list. More...
 
static int rohc_list_encode_type_0 (struct list_comp *const comp, uint8_t *const dest, int counter)
 Build encoding type 0 for list compression. More...
 
static int rohc_list_encode_type_1 (struct list_comp *const comp, uint8_t *const dest, int counter)
 Build encoding type 1 for list compression. More...
 
static int rohc_list_encode_type_2 (struct list_comp *const comp, uint8_t *const dest, int counter)
 Build encoding type 2 for list compression. More...
 
static int rohc_list_encode_type_3 (struct list_comp *const comp, uint8_t *const dest, int counter)
 Build encoding type 3 for list compression. More...
 
static size_t rohc_list_compute_ins_mask (const struct list_comp *const comp, const struct rohc_list *const ref_list, const struct rohc_list *const cur_list, const uint8_t rem_mask[ROHC_LIST_ITEMS_MAX], uint8_t ins_mask[ROHC_LIST_ITEMS_MAX], uint8_t *const rohc_data, const size_t rohc_max_len)
 Determine the insertion bit mask. More...
 
static size_t rohc_list_compute_rem_mask (const struct list_comp *const comp, const struct rohc_list *const ref_list, const struct rohc_list *const cur_list, uint8_t rem_mask[ROHC_LIST_ITEMS_MAX], uint8_t *const rohc_data, const size_t rohc_max_len)
 Determine the removal bit mask. More...
 
static uint8_t rohc_list_compute_ps (const struct list_comp *const comp, const struct rohc_list *const list, const uint8_t mask[ROHC_LIST_ITEMS_MAX], const size_t m)
 Determine whether we should use 4-bit or 8-bit indexes. More...
 
static int rohc_list_build_XIs (const struct list_comp *const comp, const struct rohc_list *const list, const uint8_t mask[ROHC_LIST_ITEMS_MAX], const size_t ps, uint8_t *const rohc_data, const size_t rohc_max_len, uint8_t *const first_4b_xi)
 Build the list of indexes (XI) More...
 
static int rohc_list_build_XIs_8 (const struct list_comp *const comp, const struct rohc_list *const list, const uint8_t mask[ROHC_LIST_ITEMS_MAX], uint8_t *const rohc_data, const size_t rohc_max_len)
 Build the list of 8-bit indexes (XI) More...
 
static int rohc_list_build_XIs_4 (const struct list_comp *const comp, const struct rohc_list *const list, const uint8_t mask[ROHC_LIST_ITEMS_MAX], uint8_t *const rohc_data, const size_t rohc_max_len, uint8_t *const first_4b_xi)
 Build the list of 4-bit indexes (XI) More...
 
bool detect_ipv6_ext_changes (struct list_comp *const comp, const struct ip_packet *const ip, bool *const list_struct_changed, bool *const list_content_changed)
 Detect changes within the list of IPv6 extension headers. More...
 
int rohc_list_encode (struct list_comp *const comp, uint8_t *const dest, int counter)
 Generic encoding of compressed list. More...
 
void rohc_list_update_context (struct list_comp *const comp)
 Update the list compression context. More...
 

Detailed Description

ROHC generic list compression.

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

Macro Definition Documentation

#define rohc_comp_list_warn (   list_ctxt,
  format,
  ... 
)
Value:
rohc_warning(list_ctxt, ROHC_TRACE_COMP, (list_ctxt)->profile_id, \
format, ##__VA_ARGS__)
Definition: rohc_traces.h:83
#define rohc_warning(entity_struct, entity, profile, format,...)
Definition: rohc_traces_internal.h:71

Print a warning trace for the given list compression context

Function Documentation

static bool build_ipv6_ext_pkt_list ( struct list_comp *const  comp,
const struct ip_packet *const  ip,
struct rohc_list *const  pkt_list 
)
static

Compute the list of extension headers for the current packet.

Parse all extension headers:

  • update the related entries in the translation table,
  • create the list for the packet
Parameters
compThe list compressor
ipThe IP packet to compress
[out]pkt_listThe list of extension headers for the current packet
Returns
true if no error occurred, false if one error occurred
bool detect_ipv6_ext_changes ( struct list_comp *const  comp,
const struct ip_packet *const  ip,
bool *const  list_struct_changed,
bool *const  list_content_changed 
)

Detect changes within the list of IPv6 extension headers.

Parameters
compThe list compressor
ipThe IP packet to compress
[out]list_struct_changedWhether the structure of the list changed
[out]list_content_changedWhether the content of the list changed
Returns
true if no error occurred, false if one error occurred
static int rohc_list_build_XIs ( const struct list_comp *const  comp,
const struct rohc_list *const  list,
const uint8_t  mask[ROHC_LIST_ITEMS_MAX],
const size_t  ps,
uint8_t *const  rohc_data,
const size_t  rohc_max_len,
uint8_t *const  first_4b_xi 
)
static

Build the list of indexes (XI)

Parameters
compThe list compressor
listThe current list to get the indexes size for
maskThe insertion mask for the current list
psThe size of the indexes: 1 for 8-bit XI, 0 for 4-bit XI
rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
first_4b_xiThe first 4-bit XI item
Returns
The length of the XI items in case of success, -1 in case of failure
static int rohc_list_build_XIs_4 ( const struct list_comp *const  comp,
const struct rohc_list *const  list,
const uint8_t  mask[ROHC_LIST_ITEMS_MAX],
uint8_t *const  rohc_data,
const size_t  rohc_max_len,
uint8_t *const  first_4b_xi 
)
static

Build the list of 4-bit indexes (XI)

Parameters
compThe list compressor
listThe current list to get the indexes size for
maskThe insertion mask for the current list
rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
first_4b_xiThe first 4-bit XI item
Returns
The length of the XI items in case of success, -1 in case of failure
static int rohc_list_build_XIs_8 ( const struct list_comp *const  comp,
const struct rohc_list *const  list,
const uint8_t  mask[ROHC_LIST_ITEMS_MAX],
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Build the list of 8-bit indexes (XI)

Parameters
compThe list compressor
listThe current list to get the indexes size for
maskThe insertion mask for the current list
rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length of the XI items in case of success, -1 in case of failure
static size_t rohc_list_compute_ins_mask ( const struct list_comp *const  comp,
const struct rohc_list *const  ref_list,
const struct rohc_list *const  cur_list,
const uint8_t  rem_mask[ROHC_LIST_ITEMS_MAX],
uint8_t  ins_mask[ROHC_LIST_ITEMS_MAX],
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Determine the insertion bit mask.

Parameters
compThe list compressor
ref_listThe reference list
cur_listThe current list to create the insertion mask for
rem_maskThe removal mask for the list
[out]ins_maskThe insertion mask for the list
rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length of the insertion mask in case of success, 0 in case of failure
static uint8_t rohc_list_compute_ps ( const struct list_comp *const  comp,
const struct rohc_list *const  list,
const uint8_t  mask[ROHC_LIST_ITEMS_MAX],
const size_t  m 
)
static

Determine whether we should use 4-bit or 8-bit indexes.

Parameters
compThe list compressor
listThe list to get the indexes size for
maskThe insertion mask for the list
mThe number of elements in current list
Returns
0 for 4-bit indexes, 1 for 8-bit indexes, 2 for error
static size_t rohc_list_compute_rem_mask ( const struct list_comp *const  comp,
const struct rohc_list *const  ref_list,
const struct rohc_list *const  cur_list,
uint8_t  rem_mask[ROHC_LIST_ITEMS_MAX],
uint8_t *const  rohc_data,
const size_t  rohc_max_len 
)
static

Determine the removal bit mask.

Parameters
compThe list compressor
ref_listThe reference list
cur_listThe current list to create the removal mask for
[out]rem_maskThe removal mask for the list
rohc_dataThe ROHC packet being built
rohc_max_lenThe max remaining length in the ROHC buffer
Returns
The length of the removal mask in case of success, 0 in case of failure
static int rohc_list_decide_type ( struct list_comp *const  comp)
static

Decide the encoding type for compression list.

Parameters
compThe list compressor
Returns
the encoding type among [0-3]
int rohc_list_encode ( struct list_comp *const  comp,
uint8_t *const  dest,
int  counter 
)

Generic encoding of compressed list.

Parameters
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer, -1 in case of error
static int rohc_list_encode_type_0 ( struct list_comp *const  comp,
uint8_t *const  dest,
int  counter 
)
static

Build encoding type 0 for list compression.

 Encoding type 0 (5.8.6.1):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  | ET = 0| GP| PS|   CC = m      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
    |       XI 1, ..., XI m         | m octets, or m * 4 bits
 3  /               --- --- --- --- /
    |               :    Padding    : if PS = 0 and m is odd
    +---+---+---+---+---+---+---+---+
    |                               |
 4  /      item 1, ..., item n      / variable length
    |                               |
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is zero.

 GP: Indicates presence of gen_id field.

 PS: Indicates size of XI fields:
     PS = 0 indicates 4-bit XI fields;
     PS = 1 indicates 8-bit XI fields.

 CC: CSRC counter from original RTP header.

 gen_id: Identifier for a sequence of identical lists.  It is
     present in U/O-mode when the compressor decides that it may use
     this list as a future reference list.

 XI 1, ..., XI m: m XI items. The format of an XI item is as
     follows:

              +---+---+---+---+
     PS = 0:  | X |   Index   |
              +---+---+---+---+

                0   1   2   3   4   5   6   7
              +---+---+---+---+---+---+---+---+
     PS = 1:  | X |           Index           |
              +---+---+---+---+---+---+---+---+

     X = 1 indicates that the item corresponding to the Index
           is sent in the item 0, ..., item n list.
     X = 0 indicates that the item corresponding to the Index is
               not sent.

     When 4-bit XI items are used and m > 1, the XI items are placed in
     octets in the following manner:

          0   1   2   3   4   5   6   7
        +---+---+---+---+---+---+---+---+
        |     XI k      |    XI k + 1   |
        +---+---+---+---+---+---+---+---+

 Padding: A 4-bit padding field is present when PS = 0 and m is
     odd.  The Padding field is set to zero when sending and ignored
     when receiving.

 Item 1, ..., item n:
     Each item corresponds to an XI with X = 1 in XI 1, ..., XI m.
Parameters
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer, -1 in case of error
static int rohc_list_encode_type_1 ( struct list_comp *const  comp,
uint8_t *const  dest,
int  counter 
)
static

Build encoding type 1 for list compression.

 Encoding type 1 (5.8.6.2):

      0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  | ET = 1| GP| PS|     XI 1      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
 3  |            ref_id             |
    +---+---+---+---+---+---+---+---+
 4  /       insertion bit mask      / 1-2 octets
    +---+---+---+---+---+---+---+---+
    |           XI list             | k octets, or (k - 1) * 4 bits
 5  /               --- --- --- --- /
    |               :    Padding    : if PS = 0 and k is even
    +---+---+---+---+---+---+---+---+
    |                               |
 6  /      item 1, ..., item n      / variable
    |                               |
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is one (1).

 GP: Indicates presence of gen_id field.

 PS: Indicates size of XI fields:
     PS = 0 indicates 4-bit XI fields;
     PS = 1 indicates 8-bit XI fields.

 XI 1: When PS = 0, the first 4-bit XI item is placed here.
       When PS = 1, the field is set to zero when sending, and
       ignored when receiving.

 ref_id: The identifier of the reference CSRC list used when the
       list was compressed.  It is the 8 least significant bits of
       the RTP Sequence Number in R-mode and gen_id (see section
       5.8.2) in U/O-mode.

 insertion bit mask: Bit mask indicating the positions where new
           items are to be inserted.  See Insertion Only scheme in
           section 5.8.3.  The bit mask can have either of the
           following two formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

 XI list: XI fields for items to be inserted.  When the insertion
    bit mask has k ones, the total number of XI fields is k.  When
    PS = 1, all XI fields are in the XI list.  When PS = 0, the
    first XI field is in the XI 1 field, and the remaining k - 1
    XI fields are in the XI list.

 Padding: Present when PS = 0 and k is even.

 item 1, ..., item n: One item for each XI field with the X bit set.
Parameters
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer, -1 in case of error
static int rohc_list_encode_type_2 ( struct list_comp *const  comp,
uint8_t *const  dest,
int  counter 
)
static

Build encoding type 2 for list compression.

 Encoding type 2 (5.8.6.3):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 1  | ET = 2| GP|res|    Count      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
 3  |            ref_id             |
    +---+---+---+---+---+---+---+---+
 4  /        removal bit mask       / 1-2 octets
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is 2.

 GP: Indicates presence of gen_id field.

 res: Reserved.  Set to zero when sending, ignored when
      received.

 Count: Number of elements in ref_list.

 removal bit mask: Indicates the elements in ref_list to be
    removed in order to obtain the current list.  See section
    5.8.3.  The bit mask can have either of the following two
    formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+
Parameters
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer, -1 in case of error
static int rohc_list_encode_type_3 ( struct list_comp *const  comp,
uint8_t *const  dest,
int  counter 
)
static

Build encoding type 3 for list compression.

 Encoding type 3 (5.8.6.4):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 1  | ET=3  |GP |PS |     XI 1      |
    +---+---+---+---+---+---+---+---+
 2  :            gen_id             : 1 octet, if GP = 1
    +---+---+---+---+---+---+---+---+
 3  |            ref_id             |
    +---+---+---+---+---+---+---+---+
 4  /        removal bit mask       / 1-2 octets
    +---+---+---+---+---+---+---+---+
 5  /       insertion bit mask      / 1-2 octets
    +---+---+---+---+---+---+---+---+
    |           XI list             | k octets, or (k - 1) * 4 bits
 6  /               --- --- --- --- /
    |               :    Padding    : if PS = 0 and k is even
    +---+---+---+---+---+---+---+---+
    |                               |
 7  /      item 1, ..., item n      / variable
    |                               |
    +---+---+---+---+---+---+---+---+

 ET: Encoding type is 3.

 GP: Indicates presence of gen_id field.

 PS: Indicates size of XI fields:
     PS = 0 indicates 4-bit XI fields;
     PS = 1 indicates 8-bit XI fields.

 gen_id: Identifier for a sequence of identical lists.  It is
     present in U/O-mode when the compressor decides that it may use
     this list as a future reference list.

 ref_id: The identifier of the reference CSRC list used when the
       list was compressed.  It is the 8 least significant bits of
       the RTP Sequence Number in R-mode and gen_id (see section
       5.8.2) in U/O-mode.

 removal bit mask: Indicates the elements in ref_list to be
    removed in order to obtain the current list.  See section
    5.8.3.  The bit mask can have either of the following two
    formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

 insertion bit mask: Bit mask indicating the positions where new
           items are to be inserted.  See Insertion Only scheme in
           section 5.8.3.  The bit mask can have either of the
           following two formats:

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 0 |        7-bit mask         |  bit 1 is the first bit
    +---+---+---+---+---+---+---+---+

    +---+---+---+---+---+---+---+---+
    | 1 |                           |  bit 1 is the first bit
    +---+      15-bit mask          +
    |                               |  bit 7 is the last bit
    +---+---+---+---+---+---+---+---+

 XI list: XI fields for items to be inserted.  When the insertion
    bit mask has k ones, the total number of XI fields is k.  When
    PS = 1, all XI fields are in the XI list.  When PS = 0, the
    first XI field is in the XI 1 field, and the remaining k - 1
    XI fields are in the XI list.

 Padding: Present when PS = 0 and k is even.

 item 1, ..., item n: One item for each XI field with the X bit set.
Parameters
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer, -1 in case of error
static unsigned int rohc_list_get_nearest_list ( const struct list_comp *const  comp,
const struct rohc_list *const  pkt_list,
bool *const  is_new_list 
)
static

Search the nearest list for the packet list.

Search for a context list with the same structure:

  • check the reference list first as it is probably the correct one,
  • then check the other identified lists,
  • finally, use an anonymous list or promote the repeated anonymous list to an identified list.
Parameters
compThe list compressor
pkt_listThe list of extension headers for the current packet
[out]is_new_listWhether the list is new or not
Returns
The list to use as a base to transmit the packet list
void rohc_list_update_context ( struct list_comp *const  comp)

Update the list compression context.

Update the counter of the current list. Update the counters of the items of the current list. Update the reference list with the current list if possible.

Parameters
compThe list compressor