ROHC compression/decompression library
Functions | Variables
c_ip.c File Reference

ROHC compression context for the IP-only profile. More...

#include "c_ip.h"
#include "rohc_traces_internal.h"
#include "rohc_utils.h"
#include <string.h>
#include <assert.h>
Include dependency graph for c_ip.c:

Functions

static bool rohc_ip_ctxt_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Create a new context and initialize it thanks to the given IP packet. More...
 
bool c_ip_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const cr_score)
 Check if an IP packet belongs to the context. More...
 
rohc_packet_t c_ip_decide_FO_packet (const struct rohc_comp_ctxt *context)
 Decide which packet to send when in First Order (FO) state. More...
 
rohc_packet_t c_ip_decide_SO_packet (const struct rohc_comp_ctxt *context)
 Decide which packet to send when in Second Order (SO) state. More...
 
uint32_t c_ip_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...
 
int c_ip_code_ir_remainder (const struct rohc_comp_ctxt *const context, uint8_t *const dest, const size_t dest_max_len, const size_t counter)
 Code the remainder header for the IR or IR-DYN packets. More...
 

Variables

const struct rohc_comp_profile c_ip_profile
 Define the compression part of the IP-only profile as described in the RFC 3843. More...
 

Detailed Description

ROHC compression context for the IP-only 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_ip_check_context()

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

Check if an IP 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
  • IPv6 only: the Flow Label of the two IP headers must match the ones in the context
  • the transport protocol must match the one in 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 packet to check
[out]cr_scoreThe score of the context for Context Replication (CR)
Returns
true if the IP packet belongs to the context false if it does not belong to the context

◆ c_ip_code_ir_remainder()

int c_ip_code_ir_remainder ( const struct rohc_comp_ctxt *const  context,
uint8_t *const  dest,
const size_t  dest_max_len,
const size_t  counter 
)

Code the remainder header for the IR or IR-DYN packets.

 Remainder of IR/IR-DYN packet (5.7.7.1):

      0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
 1  |             SN                |  2 octets if not RTP
    +---+---+---+---+---+---+---+---+
Parameters
contextThe compression context
destThe ROHC packet being coded
dest_max_lenThe maximum length (in bytes) of the ROHC packet
counterThe current position in the ROHC buffer
Returns
The new position in ROHC buffer in case of success, -1 in case of failure

◆ c_ip_decide_FO_packet()

rohc_packet_t c_ip_decide_FO_packet ( const struct rohc_comp_ctxt context)

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_ip_decide_SO_packet()

rohc_packet_t c_ip_decide_SO_packet ( const struct rohc_comp_ctxt context)

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_ip_get_next_sn()

uint32_t c_ip_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.

Profile SN is an internal increasing 16-bit number.

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

◆ rohc_ip_ctxt_create()

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

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

Variable Documentation

◆ c_ip_profile

const struct rohc_comp_profile c_ip_profile
Initial value:
=
{
.protocol = 0,
.create = rohc_ip_ctxt_create,
.check_context = c_ip_check_context,
}
void rohc_comp_rfc3095_destroy(struct rohc_comp_ctxt *const context)
Destroy the context.
Definition: rohc_comp_rfc3095.c:628
int rohc_comp_rfc3095_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 packet according to a pattern decided by several different factors.
Definition: rohc_comp_rfc3095.c:798
static bool rohc_ip_ctxt_create(struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
Create a new context and initialize it thanks to the given IP packet.
Definition: c_ip.c:59
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:882
Definition: rohc_profiles.h:89
bool rohc_comp_rfc3095_check_profile(const struct rohc_comp *const comp, const struct net_pkt *const packet)
Check if the given packet corresponds to an IP-based profile.
Definition: rohc_comp_rfc3095.c:668
bool c_ip_check_context(const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const cr_score)
Check if an IP packet belongs to the context.
Definition: c_ip.c:114

Define the compression part of the IP-only profile as described in the RFC 3843.