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

ROHC compression context for the UDP 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.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
Include dependency graph for c_udp.c:

Data Structures

struct  udp_tmp_vars
 
struct  sc_udp_context
 Define the UDP part of the profile decompression context. More...
 

Functions

static bool c_udp_create (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
 Create a new UDP context and initialize it thanks to the given IP/UDP packet. More...
 
static rohc_packet_t c_udp_decide_FO_packet (const struct rohc_comp_ctxt *const context)
 Decide which packet to send when in First Order (FO) state. More...
 
static rohc_packet_t c_udp_decide_SO_packet (const struct rohc_comp_ctxt *const context)
 Decide which packet to send when in Second Order (SO) state. More...
 
static int c_udp_encode (struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type)
 Encode an IP/UDP packet according to a pattern decided by several different factors. More...
 
static size_t udp_code_dynamic_udp_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 header. More...
 
static void udp_detect_udp_changes (const struct rohc_comp_ctxt *const context, const struct udphdr *const udp, struct udp_tmp_vars *const tmp)
 Detect changes in the UDP header. More...
 
size_t udp_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-related fields in the tail of the UO packets. More...
 
size_t udp_code_static_udp_part (const struct rohc_comp_ctxt *const context, const uint8_t *const next_header, uint8_t *const dest, const size_t counter)
 Build the static part of the UDP header. More...
 

Variables

const struct rohc_comp_profile c_udp_profile
 Define the compression part of the UDP profile as described in the RFC 3095. More...
 

Detailed Description

ROHC compression context for the UDP 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

Function Documentation

◆ c_udp_create()

static bool c_udp_create ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs 
)
static

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

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

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers to initialize the new context
Returns
true if successful, false otherwise

◆ c_udp_decide_FO_packet()

static rohc_packet_t c_udp_decide_FO_packet ( const struct rohc_comp_ctxt *const  context)
static

Decide which packet to send when in First Order (FO) state.

Packets that can be used are the IR-DYN and UO-2 packets.

See also
decide_packet
Parameters
contextThe compression context
Returns
The packet type among ROHC_PACKET_IR_DYN and ROHC_PACKET_UOR_2

◆ c_udp_decide_SO_packet()

static rohc_packet_t c_udp_decide_SO_packet ( const struct rohc_comp_ctxt *const  context)
static

Decide which packet to send when in Second Order (SO) state.

Packets that can be used are the UO-0, UO-1 and UO-2 (with or without extensions) packets.

See also
decide_packet
Parameters
contextThe compression context
Returns
The packet type among ROHC_PACKET_UO_0, ROHC_PACKET_UO_1 and ROHC_PACKET_UOR_2

◆ c_udp_encode()

static int c_udp_encode ( struct rohc_comp_ctxt *const  context,
const struct rohc_pkt_hdrs *const  uncomp_pkt_hdrs,
uint8_t *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type 
)
static

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

Parameters
contextThe compression context
uncomp_pkt_hdrsThe uncompressed headers 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
Returns
The length of the ROHC packet if successful, -1 otherwise

◆ udp_code_dynamic_udp_part()

static size_t udp_code_dynamic_udp_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 header.

 Dynamic part of UDP header (5.7.7.5):

    +---+---+---+---+---+---+---+---+
 1  /           Checksum            /   2 octets
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
next_headerThe UDP 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

◆ udp_code_static_udp_part()

size_t udp_code_static_udp_part ( const struct rohc_comp_ctxt *const  context,
const uint8_t *const  next_header,
uint8_t *const  dest,
const size_t  counter 
)

Build the static part of the UDP header.

 Static part of UDP header (5.7.7.5):

    +---+---+---+---+---+---+---+---+
 1  /          Source Port          /   2 octets
    +---+---+---+---+---+---+---+---+
 2  /       Destination Port        /   2 octets
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
next_headerThe UDP 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

◆ udp_code_uo_remainder()

size_t udp_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-related fields in the tail of the UO packets.

     --- --- --- --- --- --- --- ---
    :                               :
 13 +         UDP Checksum          +  2 octets,
    :                               :  if context(UDP Checksum) != 0
     --- --- --- --- --- --- --- ---
Parameters
contextThe compression context
next_headerThe UDP 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

◆ udp_detect_udp_changes()

static void udp_detect_udp_changes ( const struct rohc_comp_ctxt *const  context,
const struct udphdr *const  udp,
struct udp_tmp_vars *const  tmp 
)
static

Detect changes in the UDP header.

Parameters
contextThe compression context
udpThe UDP header
[out]tmpThe changes detected in the UDP header

Variable Documentation

◆ c_udp_profile

const struct rohc_comp_profile c_udp_profile
Initial value:
=
{
.create = c_udp_create,
.encode = c_udp_encode,
}
void rohc_comp_rfc3095_destroy(struct rohc_comp_ctxt *const context)
Destroy the context.
Definition: rohc_comp_rfc3095.c:649
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:756
static int c_udp_encode(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type)
Encode an IP/UDP packet according to a pattern decided by several different factors.
Definition: c_udp.c:189
static bool c_udp_create(struct rohc_comp_ctxt *const context, const struct rohc_pkt_hdrs *const uncomp_pkt_hdrs)
Create a new UDP context and initialize it thanks to the given IP/UDP packet.
Definition: c_udp.c:118
Definition: rohc_profiles.h:87

Define the compression part of the UDP profile as described in the RFC 3095.