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

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

#include "c_uncompressed.h"
#include "rohc_traces.h"
#include <assert.h>
Include dependency graph for c_uncompressed.c:

Functions

int c_uncompressed_create (struct c_context *context, const struct ip_packet ip)
 Create a new Uncompressed context and initialize it thanks to the given IP packet.
void c_uncompressed_destroy (struct c_context *context)
 Destroy the Uncompressed context.
int c_uncompressed_check_context (struct c_context *context, const struct ip_packet ip)
 Check if an IP packet belongs to the Uncompressed context.
int c_uncompressed_encode (struct c_context *context, const struct ip_packet ip, int packet_size, unsigned char *dest, int dest_size, int *payload_offset)
 Encode an IP packet according to a pattern decided by several different factors.
void c_uncompressed_feedback (struct c_context *context, struct c_feedback *feedback)
 Update the profile when feedback arrives.
void uncompressed_decide_state (struct c_context *context)
 Decide the state that should be used for the next packet.
void uncompressed_periodic_down_transition (struct c_context *context)
 Periodically change the context state after a certain number of packets.
void uncompressed_change_mode (struct c_context *context, rohc_mode new_mode)
 Change the mode of the context.
void uncompressed_change_state (struct c_context *context, rohc_c_state new_state)
 Change the state of the context.
int uncompressed_code_packet (struct c_context *context, const struct ip_packet ip, unsigned char *dest, int *payload_offset, int dest_size)
 Build the ROHC packet to send.
int uncompressed_code_IR_packet (struct c_context *context, const struct ip_packet ip, unsigned char *dest, int *payload_offset, int dest_size)
 Build the IR packet.
int uncompressed_code_normal_packet (struct c_context *context, const struct ip_packet ip, unsigned char *dest, int *payload_offset, int dest_size)
 Build the Normal packet.

Variables

struct c_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>
The hackers from ROHC for Linux

Function Documentation

int c_uncompressed_check_context ( struct c_context context,
const struct ip_packet  ip 
)

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
ipThe IP packet to check
Returns:
Always return 1 to tell that the IP packet belongs to the context
int c_uncompressed_create ( struct c_context context,
const struct ip_packet  ip 
)

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
ipThe IP packet given to initialize the new context
Returns:
1 if successful, 0 otherwise

References sc_uncompressed_context::go_back_ir_count, sc_uncompressed_context::ir_count, sc_uncompressed_context::normal_count, rohc_debugf, and c_context::specific.

void c_uncompressed_destroy ( struct c_context context)

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

References c_context::specific, and zfree.

int c_uncompressed_encode ( struct c_context context,
const struct ip_packet  ip,
int  packet_size,
unsigned char *  dest,
int  dest_size,
int *  payload_offset 
)

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
ipThe IP packet to encode
packet_sizeThe length of the IP packet to encode
destThe rohc-packet-under-build buffer
dest_sizeThe length of the rohc-packet-under-build buffer
payload_offsetThe offset for the payload in the IP packet
Returns:
The length of the created ROHC packet

References uncompressed_code_packet(), and uncompressed_decide_state().

void c_uncompressed_feedback ( struct c_context context,
struct c_feedback feedback 
)

Update the profile when feedback arrives.

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 including the whole feedback packet

References c_feedback::acktype, crc_calculate(), CRC_INIT_8, CRC_TYPE_8, c_feedback::data, IR, rohc_debugf, c_feedback::size, c_feedback::specific_offset, c_feedback::specific_size, c_feedback::type, uncompressed_change_mode(), and uncompressed_change_state().

void uncompressed_change_mode ( struct c_context context,
rohc_mode  new_mode 
)

Change the mode of the context.

Parameters:
contextThe compression context
new_modeThe new mode the context must enter in

References IR, c_context::mode, and uncompressed_change_state().

Referenced by c_uncompressed_feedback().

void uncompressed_change_state ( struct c_context context,
rohc_c_state  new_state 
)

Change the state of the context.

Parameters:
contextThe compression context
new_stateThe new state the context must enter in

References sc_uncompressed_context::ir_count, sc_uncompressed_context::normal_count, c_context::specific, and c_context::state.

Referenced by c_uncompressed_feedback(), uncompressed_change_mode(), uncompressed_decide_state(), and uncompressed_periodic_down_transition().

int uncompressed_code_IR_packet ( struct c_context context,
const struct ip_packet  ip,
unsigned char *  dest,
int *  payload_offset,
int  dest_size 
)

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
ipThe IP header
destThe rohc-packet-under-build buffer
payload_offsetOUT: the offset of the payload in the buffer
dest_sizeThe maximal size of the ROHC packet
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References c_context::cid, code_cid_values(), crc_calculate(), CRC_INIT_8, CRC_TYPE_8, rohc_debugf, and ROHC_PROFILE_UNCOMPRESSED.

Referenced by uncompressed_code_packet().

int uncompressed_code_normal_packet ( struct c_context context,
const struct ip_packet  ip,
unsigned char *  dest,
int *  payload_offset,
int  dest_size 
)

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
ipThe IP header
destThe rohc-packet-under-build buffer
payload_offsetOUT: the offset of the payload in the buffer
dest_sizeThe maximal size of the ROHC packet
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References c_context::cid, code_cid_values(), ip_get_raw_data(), and rohc_debugf.

Referenced by uncompressed_code_packet().

int uncompressed_code_packet ( struct c_context context,
const struct ip_packet  ip,
unsigned char *  dest,
int *  payload_offset,
int  dest_size 
)

Build the ROHC packet to send.

Parameters:
contextThe compression context
ipThe IP header
destThe rohc-packet-under-build buffer
payload_offsetOUT: the offset of the payload in the buffer
dest_sizeThe maximal size of the ROHC packet
Returns:
The position in the rohc-packet-under-build buffer if successful, -1 otherwise

References code_packet(), FO, ip_get_version(), IPV4, IPV6, IR, sc_uncompressed_context::ir_count, sc_uncompressed_context::normal_count, PACKET_IR, PACKET_NORMAL, PACKET_UNKNOWN, rohc_debugf, c_context::specific, c_context::state, uncompressed_code_IR_packet(), and uncompressed_code_normal_packet().

Referenced by c_uncompressed_encode().

void uncompressed_decide_state ( struct c_context context)

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

Parameters:
contextThe compression context

References FO, IR, sc_uncompressed_context::ir_count, MAX_IR_COUNT, c_context::mode, c_context::specific, c_context::state, U_MODE, uncompressed_change_state(), and uncompressed_periodic_down_transition().

Referenced by c_uncompressed_encode().

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

Parameters:
contextThe compression context

References CHANGE_TO_IR_COUNT, FO, sc_uncompressed_context::go_back_ir_count, IR, c_context::specific, c_context::state, and uncompressed_change_state().

Referenced by uncompressed_decide_state().


Variable Documentation

Initial value:

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