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

ROHC compression context for the uncompressed profile. More...

#include "rohc_comp_internals.h"
#include "rohc_traces.h"
#include "rohc_traces_internal.h"
#include "rohc_debug.h"
#include "schemes/cid.h"
#include "crc.h"
#include <assert.h>
Include dependency graph for c_uncompressed.c:

Data Structures

struct  sc_uncompressed_context
 The Uncompressed context. More...

Functions

static bool c_uncompressed_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Create a new Uncompressed context and initialize it thanks to the given IP packet.
static void c_uncompressed_destroy (struct rohc_comp_ctxt *const context)
 Destroy the Uncompressed context.
static bool c_uncompressed_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet)
 Check if the given packet corresponds to the Uncompressed profile.
bool c_uncompressed_use_udp_port (const struct rohc_comp_ctxt *const context, const unsigned int port)
 Whether the profile uses the given UDP port.
static bool c_uncompressed_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet)
 Check if an IP packet belongs to the Uncompressed context.
static int c_uncompressed_encode (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, unsigned char *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.
static int uncompressed_code_packet (const struct rohc_comp_ctxt *context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, rohc_packet_t *const packet_type, size_t *const payload_offset)
 Build the ROHC packet to send.
static int uncompressed_code_IR_packet (const struct rohc_comp_ctxt *context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, size_t *const payload_offset)
 Build the IR packet.
static int uncompressed_code_normal_packet (const struct rohc_comp_ctxt *context, const struct net_pkt *const uncomp_pkt, unsigned char *const rohc_pkt, const size_t rohc_pkt_max_len, size_t *const payload_offset)
 Build the Normal packet.
static bool c_uncompressed_reinit_context (struct rohc_comp_ctxt *const context)
 Re-initialize a given context.
static bool uncomp_feedback (struct rohc_comp_ctxt *const context, const struct c_feedback *const feedback)
 Update the profile when feedback is received.
static bool uncomp_feedback_2 (struct rohc_comp_ctxt *const context, const struct c_feedback *const feedback)
 Update the profile when a FEEDBACK-2 is received.
static void uncompressed_decide_state (struct rohc_comp_ctxt *const context)
 Decide the state that should be used for the next packet.
static void uncompressed_periodic_down_transition (struct rohc_comp_ctxt *const context)
 Periodically change the context state after a certain number of packets.
static void uncompressed_change_mode (struct rohc_comp_ctxt *const context, const rohc_mode_t new_mode)
 Change the mode of the context.
static void uncompressed_change_state (struct rohc_comp_ctxt *const context, const rohc_comp_state_t new_state)
 Change the state of the context.

Variables

struct rohc_comp_profile c_uncompressed_profile
 Define the compression part of the Uncompressed profile as described in the RFC 3095.

Detailed Description

ROHC compression context for the uncompressed profile.

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

Function Documentation

static bool c_uncompressed_check_context ( const struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
) [static]

Check if an IP packet belongs to the Uncompressed context.

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

Parameters:
contextThe compression context
packetThe packet to check
Returns:
Always return true to tell that the packet belongs to the context
static bool c_uncompressed_check_profile ( const struct rohc_comp *const  comp,
const struct net_pkt *const  packet 
) [static]

Check if the given packet corresponds to the Uncompressed profile.

There are no condition. If this function is called, the packet always matches the Uncompressed 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 packet corresponds to the profile:
  • true if the packet corresponds to the profile,
  • false if the packet does not correspond to the profile
static bool c_uncompressed_create ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  packet 
) [static]

Create a new Uncompressed 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 packet given to initialize the new context
Returns:
true if successful, false otherwise
static void c_uncompressed_destroy ( struct rohc_comp_ctxt *const  context) [static]

Destroy the Uncompressed 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 c_uncompressed_encode ( struct rohc_comp_ctxt *const  context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *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 packet according to a pattern decided by several different factors.

1. Decide state
2. Code packet

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

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 bool c_uncompressed_reinit_context ( struct rohc_comp_ctxt *const  context) [static]

Re-initialize a given context.

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

Parameters:
contextThe compression context
Returns:
true in case of success, false otherwise
bool c_uncompressed_use_udp_port ( const struct rohc_comp_ctxt *const  context,
const unsigned int  port 
)

Whether the profile uses the given UDP port.

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

Parameters:
contextThe compression context
portThe port number to check
Returns:
Always return false because the Uncompressed profile does not use UDP port
static bool uncomp_feedback ( struct rohc_comp_ctxt *const  context,
const struct c_feedback *const  feedback 
) [static]

Update the profile when feedback is received.

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

Parameters:
contextThe compression context
feedbackThe feedback information
Returns:
true if the feedback was successfully handled, false if the feedback could not be taken into account
static bool uncomp_feedback_2 ( struct rohc_comp_ctxt *const  context,
const struct c_feedback *const  feedback 
) [static]

Update the profile when a FEEDBACK-2 is received.

Parameters:
contextThe compression context
feedbackThe feedback information
Returns:
true if the feedback was successfully handled, false if the feedback could not be taken into account
static void uncompressed_change_mode ( struct rohc_comp_ctxt *const  context,
const rohc_mode_t  new_mode 
) [static]

Change the mode of the context.

Parameters:
contextThe compression context
new_modeThe new mode the context must enter in
static void uncompressed_change_state ( struct rohc_comp_ctxt *const  context,
const rohc_comp_state_t  new_state 
) [static]

Change the state of the context.

Parameters:
contextThe compression context
new_stateThe new state the context must enter in
static int uncompressed_code_IR_packet ( const struct rohc_comp_ctxt context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
size_t *const  payload_offset 
) [static]

Build the IR packet.


 IR packet (5.10.1)

     0   1   2   3   4   5   6   7
    --- --- --- --- --- --- --- ---
 1 :         Add-CID octet         : if for small CIDs and (CID != 0)
   +---+---+---+---+---+---+---+---+
 2 | 1   1   1   1   1   1   0 |res|
   +---+---+---+---+---+---+---+---+
   :                               :
 3 /    0-2 octets of CID info     / 1-2 octets if for large CIDs
   :                               :
   +---+---+---+---+---+---+---+---+
 4 |          Profile = 0          | 1 octet
   +---+---+---+---+---+---+---+---+
 5 |              CRC              | 1 octet
   +---+---+---+---+---+---+---+---+
   :                               : (optional)
 6 /           IP packet           / variable length
   :                               :
    --- --- --- --- --- --- --- ---

Part 6 is not managed by this function.

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
payload_offsetOUT: the offset of the payload in the buffer
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int uncompressed_code_normal_packet ( const struct rohc_comp_ctxt context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
size_t *const  payload_offset 
) [static]

Build the Normal packet.


 Normal packet (5.10.2)

     0   1   2   3   4   5   6   7
    --- --- --- --- --- --- --- ---
 1 :         Add-CID octet         : if for small CIDs and (CID != 0)
   +---+---+---+---+---+---+---+---+
 2 |   first octet of IP packet    |
   +---+---+---+---+---+---+---+---+
   :                               :
 3 /    0-2 octets of CID info     / 1-2 octets if for large CIDs
   :                               :
   +---+---+---+---+---+---+---+---+
   |                               |
 4 /      rest of IP packet        / variable length
   |                               |
   +---+---+---+---+---+---+---+---+

Part 4 is not managed by this function.

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
payload_offsetOUT: the offset of the payload in the buffer
Returns:
The length of the ROHC packet if successful, -1 otherwise
static int uncompressed_code_packet ( const struct rohc_comp_ctxt context,
const struct net_pkt *const  uncomp_pkt,
unsigned char *const  rohc_pkt,
const size_t  rohc_pkt_max_len,
rohc_packet_t *const  packet_type,
size_t *const  payload_offset 
) [static]

Build the ROHC packet to send.

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 of the payload in the buffer
Returns:
The length of the ROHC packet if successful, -1 otherwise
static void uncompressed_decide_state ( struct rohc_comp_ctxt *const  context) [static]

Decide the state that should be used for the next packet.

Parameters:
contextThe compression context
static void uncompressed_periodic_down_transition ( struct rohc_comp_ctxt *const  context) [static]

Periodically change the context state after a certain number of packets.

Parameters:
contextThe compression context

Variable Documentation

Initial value:
{
        .id             = ROHC_PROFILE_UNCOMPRESSED, 
        .protocol       = 0,                         
        .create         = c_uncompressed_create,     
        .destroy        = c_uncompressed_destroy,
        .check_profile  = c_uncompressed_check_profile,
        .check_context  = c_uncompressed_check_context,
        .encode         = c_uncompressed_encode,
        .reinit_context = c_uncompressed_reinit_context,
        .feedback       = uncomp_feedback,
        .use_udp_port   = c_uncompressed_use_udp_port,
}

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