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

ROHC ESP compression profile. More...

#include "rohc_comp_rfc3095.h"
#include "c_ip.h"
#include "rohc_traces_internal.h"
#include "crc.h"
#include "protocols/esp.h"
#include "rohc_utils.h"
#include <stdbool.h>
#include <string.h>
#include <assert.h>
Include dependency graph for c_esp.c:

Data Structures

struct  sc_esp_context
 Define the ESP part of the profile decompression context. More...
 

Functions

static bool c_esp_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Create a new ESP context and initialize it thanks to the given IP/ESP packet. More...
 
static bool c_esp_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to the ESP profile. More...
 
static bool c_esp_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const cr_score)
 Check if the IP/ESP packet belongs to the context. More...
 
static int c_esp_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/ESP packet according to a pattern decided by several different factors. More...
 
static uint32_t c_esp_get_next_sn (const struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt)
 Determine the SN value for the next packet. More...
 
static size_t esp_code_static_esp_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 ESP header. More...
 
static size_t esp_code_dynamic_esp_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 ESP header. More...
 

Variables

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

Detailed Description

ROHC ESP compression profile.

Author
FWX rohc_.nosp@m.team.nosp@m.@dial.nosp@m.ine..nosp@m.fr
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org

Function Documentation

◆ c_esp_check_context()

static bool c_esp_check_context ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet,
size_t *const  cr_score 
)
static

Check if the IP/ESP 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 ESP
  • the security parameters index of the ESP header must match the one 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/ESP packet to check
[out]cr_scoreThe score of the context for Context Replication (CR)
Returns
true if the packet belongs to the context, false if it does not belong to the context

◆ c_esp_check_profile()

static bool c_esp_check_profile ( const struct rohc_comp *const  comp,
const struct net_pkt *const  packet 
)
static

Check if the given packet corresponds to the ESP profile.

Conditions are:

  • the transport protocol is ESP
  • 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

◆ c_esp_create()

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

Create a new ESP context and initialize it thanks to the given IP/ESP 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/ESP packet given to initialize the new context
Returns
true if successful, false otherwise

◆ c_esp_encode()

static int c_esp_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/ESP 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

◆ c_esp_get_next_sn()

static uint32_t c_esp_get_next_sn ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt 
)
static

Determine the SN value for the next packet.

Profile SN is the ESP SN.

Parameters
contextThe compression context
uncomp_pktThe uncompressed packet to encode
Returns
The SN

◆ esp_code_dynamic_esp_part()

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

 Dynamic part of ESP header (5.7.7.7):

    +---+---+---+---+---+---+---+---+
 1  /       Sequence Number         /   4 octets
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
next_headerThe ESP 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

◆ esp_code_static_esp_part()

static size_t esp_code_static_esp_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 static part of the ESP header.

 Static part of ESP header (5.7.7.7):

    +---+---+---+---+---+---+---+---+
 1  /              SPI              /   4 octets
    +---+---+---+---+---+---+---+---+

 SPI = Security Parameters Index
Parameters
contextThe compression context
next_headerThe ESP 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

Variable Documentation

◆ c_esp_profile

const struct rohc_comp_profile c_esp_profile
Initial value:
=
{
.protocol = ROHC_IPPROTO_ESP,
.create = c_esp_create,
.check_profile = c_esp_check_profile,
.check_context = c_esp_check_context,
.encode = c_esp_encode,
.reinit_context = rohc_comp_reinit_context,
}
static bool c_esp_check_profile(const struct rohc_comp *const comp, const struct net_pkt *const packet)
Check if the given packet corresponds to the ESP profile.
Definition: c_esp.c:208
static int c_esp_encode(struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, 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/ESP packet according to a pattern decided by several different factors.
Definition: c_esp.c:310
static bool c_esp_create(struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
Create a new ESP context and initialize it thanks to the given IP/ESP packet.
Definition: c_esp.c:116
void rohc_comp_rfc3095_destroy(struct rohc_comp_ctxt *const context)
Destroy the context.
Definition: rohc_comp_rfc3095.c:620
Definition: ip_numbers.h:68
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:881
bool rohc_comp_reinit_context(struct rohc_comp_ctxt *const context)
Re-initialize the given context.
Definition: rohc_comp.c:2986
static bool c_esp_check_context(const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const ctxt_replication_score)
Check if the IP/ESP packet belongs to the context.
Definition: c_esp.c:268
Definition: rohc.h:219

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