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

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

#include "d_ip.h"
#include "d_udp.h"
#include "d_generic.h"
#include "rohc_bit_ops.h"
#include "rohc_traces_internal.h"
#include "rohc_debug.h"
#include "rohc_utils.h"
#include "rohc_packets.h"
#include "crc.h"
#include "protocols/udp_lite.h"
#include <string.h>
Include dependency graph for d_udp_lite.c:

Data Structures

struct  d_udp_lite_context
 Define the UDP-Lite part of the decompression profile context. More...

Functions

static void d_udp_lite_destroy (void *const context)
 Destroy the context.
static rohc_packet_t udp_lite_detect_packet_type (const struct rohc_decomp_ctxt *const context, const uint8_t *const rohc_packet, const size_t rohc_length, const size_t large_cid_len)
 Detect the type of ROHC packet for the UDP-Lite profile.
static int udp_lite_parse_dynamic_udp (const struct rohc_decomp_ctxt *const context, const uint8_t *packet, const size_t length, struct rohc_extr_bits *const bits)
 Parse the UDP-Lite dynamic part of the ROHC packet.
static int udp_lite_parse_uo_remainder (const struct rohc_decomp_ctxt *const context, const unsigned char *packet, unsigned int length, struct rohc_extr_bits *const bits)
 Parse the UDP-Lite remainder of the UO* ROHC packets.
static bool udp_lite_decode_values_from_bits (const struct rohc_decomp_ctxt *context, const struct rohc_extr_bits bits, struct rohc_decoded_values *const decoded)
 Decode UDP-Lite values from extracted bits.
static int udp_lite_build_uncomp_udp (const struct rohc_decomp_ctxt *const context, const struct rohc_decoded_values decoded, unsigned char *dest, const unsigned int payload_len)
 Build an uncompressed UDP-Lite header.
void * d_udp_lite_create (const struct rohc_decomp_ctxt *const context)
 Create the UDP-Lite decompression context.
static rohc_status_t d_udp_lite_decode (struct rohc_decomp *const decomp, struct rohc_decomp_ctxt *const context, const struct rohc_buf rohc_packet, const size_t add_cid_len, const size_t large_cid_len, struct rohc_buf *const uncomp_packet, rohc_packet_t *const packet_type)
 Decode one IR, IR-DYN or UO* packet for UDP-Lite profile.

Variables

struct rohc_decomp_profile d_udplite_profile
 Define the decompression part of the UDP-Lite profile as described in the RFC 4019.

Detailed Description

ROHC decompression context for the UDP-Lite profile.

Author:
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
Didier Barvaux <didier@barvaux.org>

Function Documentation

void* d_udp_lite_create ( const struct rohc_decomp_ctxt *const  context)

Create the UDP-Lite decompression context.

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

Parameters:
contextThe decompression context
Returns:
The newly-created UDP-Lite decompression context
static rohc_status_t d_udp_lite_decode ( struct rohc_decomp *const  decomp,
struct rohc_decomp_ctxt *const  context,
const struct rohc_buf  rohc_packet,
const size_t  add_cid_len,
const size_t  large_cid_len,
struct rohc_buf *const  uncomp_packet,
rohc_packet_t *const  packet_type 
) [static]

Decode one IR, IR-DYN or UO* packet for UDP-Lite profile.

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

Parameters:
decompThe ROHC decompressor
contextThe decompression context
rohc_packetThe ROHC packet to decode
add_cid_lenThe length of the optional Add-CID field
large_cid_lenThe length of the optional large CID field
[out]uncomp_packetThe uncompressed packet
packet_typeIN: The type of the ROHC packet to parse OUT: The type of the parsed ROHC packet
Returns:
ROHC_STATUS_OK if packet is successfully decoded, ROHC_STATUS_MALFORMED if packet is malformed, ROHC_STATUS_BAD_CRC if a CRC error occurs, ROHC_STATUS_ERROR if an error occurs
static void d_udp_lite_destroy ( void *const  context) [static]

Destroy the context.

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

Parameters:
contextThe compression context
static int udp_lite_build_uncomp_udp ( const struct rohc_decomp_ctxt *const  context,
const struct rohc_decoded_values  decoded,
unsigned char *  dest,
const unsigned int  payload_len 
) [static]

Build an uncompressed UDP-Lite header.

Todo:
check for dest size before writing into it
Parameters:
contextThe decompression context
decodedThe values decoded from the ROHC header
destThe buffer to store the UDP-Lite header
payload_lenThe length of the UDP-Lite payload
Returns:
The length of the next header (ie. the UDP-Lite header), -1 in case of error
static bool udp_lite_decode_values_from_bits ( const struct rohc_decomp_ctxt context,
const struct rohc_extr_bits  bits,
struct rohc_decoded_values *const  decoded 
) [static]

Decode UDP-Lite values from extracted bits.

The following values are decoded:

  • UDP-Lite source port
  • UDP-Lite destination port
  • UDP-Lite checksum
  • UDP-Lite Checksum Coverage (CC)
Parameters:
contextThe decompression context
bitsThe extracted bits
decodedOUT: The corresponding decoded values
Returns:
true if decoding is successful, false otherwise
static rohc_packet_t udp_lite_detect_packet_type ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *const  rohc_packet,
const size_t  rohc_length,
const size_t  large_cid_len 
) [static]

Detect the type of ROHC packet for the UDP-Lite profile.

Parse optional CCE packet type, then normal packet type.

Parameters:
contextThe decompression context
rohc_packetThe ROHC packet
rohc_lengthThe length of the ROHC packet
large_cid_lenThe length of the optional large CID field
Returns:
The packet type
static int udp_lite_parse_dynamic_udp ( const struct rohc_decomp_ctxt *const  context,
const uint8_t *  packet,
const size_t  length,
struct rohc_extr_bits *const  bits 
) [static]

Parse the UDP-Lite dynamic part of the ROHC packet.

Parameters:
contextThe decompression context
packetThe ROHC packet to parse
lengthThe length of the ROHC packet
bitsOUT: The bits extracted from the ROHC header
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure
static int udp_lite_parse_uo_remainder ( const struct rohc_decomp_ctxt *const  context,
const unsigned char *  packet,
unsigned int  length,
struct rohc_extr_bits *const  bits 
) [static]

Parse the UDP-Lite remainder of the UO* ROHC packets.

Parameters:
contextThe decompression context
packetThe ROHC packet to parse
lengthThe length of the ROHC packet
bitsOUT: The bits extracted from the ROHC header
Returns:
The number of bytes read in the ROHC packet, -1 in case of failure

Variable Documentation

Initial value:
{
        .id              = ROHC_PROFILE_UDPLITE, 
        .new_context     = d_udp_lite_create,
        .free_context    = d_udp_lite_destroy,
        .decode          = d_udp_lite_decode,
        .detect_pkt_type = udp_lite_detect_packet_type,
        .get_sn          = d_generic_get_sn,
}

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