ROHC compression/decompression library
Data Structures | Macros | Functions | Variables
c_udp_lite.c File Reference

ROHC compression context for the UDP-Lite profile. More...

#include "c_udp.h"
#include "c_ip.h"
#include "rohc_traces_internal.h"
#include "rohc_packets.h"
#include "rohc_utils.h"
#include "crc.h"
#include "rohc_comp_rfc3095.h"
#include "protocols/udp_lite.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
Include dependency graph for c_udp_lite.c:

Data Structures

struct  udp_lite_tmp_vars
 Define the UDP-Lite-specific temporary variables in the profile compression context. More...
 
struct  sc_udp_lite_context
 Define the UDP-Lite part of the profile compression context. More...
 

Macros

#define MAX_LITE_COUNT   2
 The maximal number of times the checksum coverage dit not change or may be inferred. More...
 

Functions

static bool c_udp_lite_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Create a new UDP-Lite context and initialize it thanks to the given IP/UDP-Lite packet. More...
 
static bool c_udp_lite_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to the UDP-Lite profile. More...
 
static bool c_udp_lite_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Check if the IP/UDP-Lite packet belongs to the context. More...
 
static int c_udp_lite_encode (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset)
 Encode an IP/UDP-lite packet according to a pattern decided by several different factors. More...
 
static size_t udp_lite_code_dynamic_udplite_part (const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
 Build the dynamic part of the UDP-Lite header. More...
 
static size_t udp_lite_build_cce_packet (const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter, size_t *const first_position)
 Build the Checksum Coverage Extension (CCE) packet. More...
 
static bool udp_lite_send_cce_packet (const struct rohc_comp_ctxt *const context, const struct udphdr *const udp_lite)
 Check whether a Checksum Coverage Extension (CCE) packet must be sent or not in order to compress the given UDP-Lite header. More...
 
static size_t udp_lite_code_uo_remainder (const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
 Build UDP-Lite-related fields in the tail of the UO packets. More...
 
static void udp_lite_init_cc (struct rohc_comp_ctxt *const context, const uint8_t *const next_header)
 Initialize checksum coverage in the compression context with the given UDP-Lite header. More...
 

Variables

const struct rohc_comp_profile c_udp_lite_profile
 Define the compression part of the UDP-Lite profile as described in the RFC 4019. More...
 

Detailed Description

ROHC compression context for the UDP-Lite profile.

Author
Didier Barvaux didie.nosp@m.r.ba.nosp@m.rvaux.nosp@m.@tou.nosp@m.louse.nosp@m..viv.nosp@m.eris..nosp@m.com
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org

Macro Definition Documentation

#define MAX_LITE_COUNT   2

The maximal number of times the checksum coverage dit not change or may be inferred.

Function Documentation

static bool c_udp_lite_check_context ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
)
static

Check if the IP/UDP-Lite packet belongs to the context.

Conditions are:

  • the number of IP headers must be the same as in context
  • IP version of the two IP headers must be the same as in context
  • IP packets must not be fragmented
  • the source and destination addresses of the two IP headers must match the ones in the context
  • the transport protocol must be UDP-Lite
  • the source and destination ports of the UDP-Lite header must match the ones in the context
  • IPv6 only: the Flow Label of the two IP headers must match the ones the context

This function is one of the functions that must exist in one profile for the framework to work.

Parameters
contextThe compression context
packetThe IP/UDP-Lite packet to check
Returns
true if the IP/UDP-Lite packet belongs to the context, false if it does not belong to the context
static bool c_udp_lite_check_profile ( const struct rohc_comp *const  comp,
const struct net_pkt *const  packet 
)
static

Check if the given packet corresponds to the UDP-Lite profile.

Conditions are:

  • the transport protocol is UDP-Lite
  • the version of the outer IP header is 4 or 6
  • the outer IP header is not an IP fragment
  • if there are at least 2 IP headers, the version of the inner IP header is 4 or 6
  • if there are at least 2 IP headers, the inner IP header is not an IP fragment
See also
rohc_comp_rfc3095_check_profile

This function is one of the functions that must exist in one profile for the framework to work.

Parameters
compThe ROHC compressor
packetThe packet to check
Returns
Whether the IP packet corresponds to the profile:
  • true if the IP packet corresponds to the profile,
  • false if the IP packet does not correspond to the profile
static bool c_udp_lite_create ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
)
static

Create a new UDP-Lite context and initialize it thanks to the given IP/UDP-Lite packet.

This function is one of the functions that must exist in one profile for the framework to work.

Parameters
contextThe compression context
packetThe IP/UDP-Lite packet given to initialize the new context
Returns
true if successful, false otherwise
static int c_udp_lite_encode ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type,
size_t *const  payload_offset 
)
static

Encode an IP/UDP-lite packet according to a pattern decided by several different factors.

Parameters
contextThe compression context
uncomp_pktThe uncompressed packet to encode
rohc_pktOUT: The ROHC packet
rohc_pkt_max_lenThe maximum length of the ROHC packet
packet_typeOUT: The type of ROHC packet that is created
payload_offsetOUT: The offset for the payload in the IP packet
Returns
The length of the ROHC packet if successful, -1 otherwise
static size_t udp_lite_build_cce_packet ( const struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header,
uint8_t *const  dest,
const size_t  counter,
size_t *const  first_position 
)
static

Build the Checksum Coverage Extension (CCE) packet.

The Checksum Coverage Extension is located at the very start of the UO packet (part 2 in the following figure).

     0   1   2   3   4   5   6   7
     --- --- --- --- --- --- --- ---
 1  :         Add-CID octet         :  If for small CIDs and CID 1 - 15
    +---+---+---+---+---+---+---+---+
 2  | 1   1   1   1   1   0   F | K |  Outer packet type identifier
    +---+---+---+---+---+---+---+---+
    :                               :
 3  /   0, 1, or 2 octets of CID    /  1 - 2 octets if large CIDs
    :                               :
    +---+---+---+---+---+---+---+---+
    :                               :
 4  /   UO-0, UO-1 or UO-2 packet   /
    :                               :
    +---+---+---+---+---+---+---+---+

Parts 1, 3 and 4 are coded by the generic code_UO0_packet, code_UO1_packet and code_UO2_packet functions. These functions call the code_UO_packet_head function which in case of UDP-Lite profile is the udp_lite_build_cce_packet function.

When the udp_lite_build_cce_packet is called, the parameter first_position points on the part 2 and the parameter counter points on the beginning of the part 4.

Parameters
contextThe compression context
next_headerThe UDP header
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
first_positionThe position to place the first byte of packet
Returns
The new position in the rohc-packet-under-build buffer
static size_t udp_lite_code_dynamic_udplite_part ( const struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header,
uint8_t *const  dest,
const size_t  counter 
)
static

Build the dynamic part of the UDP-Lite header.

 Dynamic part of UDP-Lite header (5.2.1 of RFC 4019):

    +---+---+---+---+---+---+---+---+
 1  /       Checksum Coverage       /   2 octets
    +---+---+---+---+---+---+---+---+
 2  /           Checksum            /   2 octets
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
next_headerThe UDP-Lite header
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer
static size_t udp_lite_code_uo_remainder ( const struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header,
uint8_t *const  dest,
const size_t  counter 
)
static

Build UDP-Lite-related fields in the tail of the UO packets.

     --- --- --- --- --- --- --- ---
    :                               :  2 octets,
 1  +  UDP-Lite Checksum Coverage   +  if context(CFP) = 1 or
    :                               :  if packet type = CCE
     --- --- --- --- --- --- --- ---
    :                               :
 2  +       UDP-Lite Checksum       +  2 octets
    :                               :
     --- --- --- --- --- --- --- ---
Parameters
contextThe compression context
next_headerThe UDP-Lite header
destThe rohc-packet-under-build buffer
counterThe current position in the rohc-packet-under-build buffer
Returns
The new position in the rohc-packet-under-build buffer
static void udp_lite_init_cc ( struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header 
)
static

Initialize checksum coverage in the compression context with the given UDP-Lite header.

Parameters
contextThe compression context
next_headerThe UDP-Lite header
static bool udp_lite_send_cce_packet ( const struct rohc_comp_ctxt *const  context,
const struct udphdr *const  udp_lite 
)
static

Check whether a Checksum Coverage Extension (CCE) packet must be sent or not in order to compress the given UDP-Lite header.

The function also updates the FK variable stored in the UDP-Lite context.

Parameters
contextThe compression context
udp_liteThe UDP-Lite header
Returns
true if a CCE packet must be sent, false if not

Variable Documentation

const struct rohc_comp_profile c_udp_lite_profile
Initial value:
=
{
.protocol = ROHC_IPPROTO_UDPLITE,
.create = c_udp_lite_create,
.check_profile = c_udp_lite_check_profile,
.check_context = c_udp_lite_check_context,
.encode = c_udp_lite_encode,
.reinit_context = rohc_comp_reinit_context,
}
static bool c_udp_lite_check_context(const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
Check if the IP/UDP-Lite packet belongs to the context.
Definition: c_udp_lite.c:328
void rohc_comp_rfc3095_destroy(struct rohc_comp_ctxt *const context)
Destroy the context.
Definition: rohc_comp_rfc3095.c:652
static int c_udp_lite_encode(struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset)
Encode an IP/UDP-lite packet according to a pattern decided by several different factors.
Definition: c_udp_lite.c:370
static bool c_udp_lite_create(struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
Create a new UDP-Lite context and initialize it thanks to the given IP/UDP-Lite packet.
Definition: c_udp_lite.c:170
static bool c_udp_lite_check_profile(const struct rohc_comp *const comp, const struct net_pkt *const packet)
Check if the given packet corresponds to the UDP-Lite profile.
Definition: c_udp_lite.c:269
bool rohc_comp_rfc3095_feedback(struct rohc_comp_ctxt *const context, const enum rohc_feedback_type feedback_type, const uint8_t *const packet, const size_t packet_len, const uint8_t *const feedback_data, const size_t feedback_data_len)
Update the profile when feedback is received.
Definition: rohc_comp_rfc3095.c:908
Definition: rohc.h:232
bool rohc_comp_reinit_context(struct rohc_comp_ctxt *const context)
Re-initialize the given context.
Definition: rohc_comp.c:2694
Definition: ip_numbers.h:82

Define the compression part of the UDP-Lite profile as described in the RFC 4019.