ROHC compression/decompression library
Defines | Functions
list.c File Reference

ROHC generic list compression. More...

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

Defines

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

Functions

static int rohc_list_decide_type (struct list_comp *const comp)
 Decide the encoding type for compression list.
static int rohc_list_encode_type_0 (struct list_comp *const comp, unsigned char *const dest, int counter)
 Build encoding type 0 for list compression.
static int rohc_list_encode_type_1 (struct list_comp *const comp, unsigned char *const dest, int counter)
 Build encoding type 1 for list compression.
static int rohc_list_encode_type_2 (struct list_comp *const comp, unsigned char *const dest, int counter)
 Build encoding type 2 for list compression.
static int rohc_list_encode_type_3 (struct list_comp *const comp, unsigned char *const dest, int counter)
 Build encoding type 3 for list compression.
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 withint the list of IPv6 extension headers.
int rohc_list_encode (struct list_comp *const comp, unsigned char *const dest, int counter, const int size)
 Generic encoding of compressed list.
void rohc_list_update_context (struct list_comp *const comp)
 Update the list compression context.

Detailed Description

ROHC generic list compression.

Author:
Didier Barvaux <didier@barvaux.org>

Define Documentation

#define rohc_comp_list_warn (   list_ctxt,
  format,
  ... 
)
Value:
rohc_warning(list_ctxt, ROHC_TRACE_COMP, (list_ctxt)->profile_id, \
                     format, ##__VA_ARGS__)

Print a warning trace for the given list compression context


Function Documentation

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 withint 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_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,
unsigned char *const  dest,
int  counter,
const int  size 
)

Generic encoding of compressed list.

Parameters:
compThe list compressor
destThe ROHC packet under build
counterThe current position in the rohc-packet-under-build buffer
sizeThe number of element in current list
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,
unsigned char *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
static int rohc_list_encode_type_1 ( struct list_comp *const  comp,
unsigned char *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
static int rohc_list_encode_type_2 ( struct list_comp *const  comp,
unsigned char *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
static int rohc_list_encode_type_3 ( struct list_comp *const  comp,
unsigned char *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
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