ROHC compression/decompression library
|
ROHC compression context for the ROHCv2 IP-only profile. More...
#include "rohc_comp_internals.h"
#include "rohc_traces.h"
#include "rohc_traces_internal.h"
#include "rohc_debug.h"
#include "rohc_bit_ops.h"
#include "protocols/ip_numbers.h"
#include "protocols/ip.h"
#include "protocols/rfc5225.h"
#include "schemes/cid.h"
#include "schemes/ipv6_exts.h"
#include "schemes/ip_ctxt.h"
#include "schemes/comp_wlsb.h"
#include "schemes/ip_id_offset.h"
#include "schemes/rfc4996.h"
#include "crc.h"
#include <assert.h>
Data Structures | |
struct | comp_rfc5225_tmp_variables |
Define the RFC5225-specific temporary variables in the profile compression context. More... | |
struct | rohc_comp_rfc5225_ip_ctxt |
Functions | |
static bool | rohc_comp_rfc5225_ip_create (struct rohc_comp_ctxt *const context, const struct net_pkt *const packet) |
Create a new ROHCv2 IP-only context and initialize it thanks to the given uncompressed packet. More... | |
static void | rohc_comp_rfc5225_ip_destroy (struct rohc_comp_ctxt *const context) |
Destroy the ROHCv2 IP-only context. More... | |
static bool | rohc_comp_rfc5225_ip_check_profile (const struct rohc_comp *const comp, const struct net_pkt *const packet) |
Check if the given packet corresponds to the ROHCv2 IP-only profile. More... | |
static bool | rohc_comp_rfc5225_ip_check_context (const struct rohc_comp_ctxt *const context, const struct net_pkt *const packet, size_t *const cr_score) |
Check if the IP packet belongs to the given ROHCv2 IP-only context. More... | |
static int | rohc_comp_rfc5225_ip_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 uncompressed packet according to a pattern decided by several different factors. More... | |
static bool | rohc_comp_rfc5225_ip_detect_changes (struct rohc_comp_ctxt *const context, const struct net_pkt *const uncomp_pkt, size_t *const payload_offset) |
Detect changes between packet and context. More... | |
static int | rohc_comp_rfc5225_ip_detect_changes_ipv4 (struct rohc_comp_ctxt *const ctxt, ip_context_t *const ip_ctxt, const struct ip_hdr *const ip_hdr, const bool is_innermost) |
Detect changes for the given IPv4 header between packet and context. More... | |
static int | rohc_comp_rfc5225_ip_detect_changes_ipv6 (struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ip_hdr *const ip_hdr, const bool is_innermost) |
Detect changes for the given IPv6 header between packet and context. More... | |
static int | rohc_comp_rfc5225_ip_code_IR_pkt (const struct rohc_comp_ctxt *context, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len) |
Encode an IP packet as IR packet. More... | |
static int | rohc_comp_rfc5225_ip_code_co_repair_pkt (const struct rohc_comp_ctxt *context, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const size_t payload_offset) |
Encode an IP packet as co_repair packet. More... | |
static int | rohc_comp_rfc5225_ip_code_CO_pkt (const struct rohc_comp_ctxt *const context, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len, const rohc_packet_t packet_type, const size_t payload_offset) |
Encode an IP packet as CO packet. More... | |
static int | rohc_comp_rfc5225_ip_build_pt_0_crc3_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build a ROHCv2 pt_0_crc3 packet. More... | |
static int | rohc_comp_rfc5225_ip_build_pt_0_crc7_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build a ROHCv2 pt_0_crc7 packet. More... | |
static int | rohc_comp_rfc5225_ip_build_pt_1_seq_id_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build a ROHCv2 pt_1_seq_id packet. More... | |
static int | rohc_comp_rfc5225_ip_build_pt_2_seq_id_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build a ROHCv2 pt_2_seq_id packet. More... | |
static int | rohc_comp_rfc5225_ip_build_co_common_pkt (const struct rohc_comp_ctxt *const context, const uint8_t crc, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build a ROHCv2 co_common packet. More... | |
static int | rohc_comp_rfc5225_ip_static_chain (const struct rohc_comp_ctxt *const ctxt, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len) |
Code the static chain of an ROHCv2 IP-only IR packet. More... | |
static int | rohc_comp_rfc5225_ip_static_ipv4_part (const struct rohc_comp_ctxt *const ctxt, const struct ipv4_hdr *const ipv4, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build the static part of the IPv4 header. More... | |
static int | rohc_comp_rfc5225_ip_static_ipv6_part (const struct rohc_comp_ctxt *const ctxt, const struct ipv6_hdr *const ipv6, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build the static part of the IPv6 header. More... | |
static int | rohc_comp_rfc5225_ip_dyn_chain (const struct rohc_comp_ctxt *const ctxt, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len) |
Code the dynamic chain of a ROHCv2 IP-only IR packet. More... | |
static int | rohc_comp_rfc5225_ip_dyn_ipv4_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv4_hdr *const ipv4, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build the dynamic part of the IPv4 header. More... | |
static int | rohc_comp_rfc5225_ip_dyn_ipv6_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv6_hdr *const ipv6, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build the dynamic part of the IPv6 header. More... | |
static int | rohc_comp_rfc5225_ip_irreg_chain (const struct rohc_comp_ctxt *const ctxt, const struct ip_packet *const ip, uint8_t *const rohc_pkt, const size_t rohc_pkt_max_len) |
Code the irregular chain of a ROHCv2 IP-only IR packet. More... | |
static int | rohc_comp_rfc5225_ip_irreg_ipv4_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv4_hdr *const ipv4, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build the irregular part of the IPv4 header. More... | |
static int | rohc_comp_rfc5225_ip_irreg_ipv6_part (const struct rohc_comp_ctxt *const ctxt, const ip_context_t *const ip_ctxt, const struct ipv6_hdr *const ipv6, const bool is_innermost, uint8_t *const rohc_data, const size_t rohc_max_len) |
Build the irregular part of the IPv6 header. More... | |
static bool | rohc_comp_rfc5225_ip_feedback (struct rohc_comp_ctxt *const ctxt, 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. More... | |
static bool | rohc_comp_rfc5225_ip_feedback_2 (struct rohc_comp_ctxt *const ctxt, 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-2 is received. More... | |
static void | rohc_comp_rfc5225_ip_feedback_ack (struct rohc_comp_ctxt *const ctxt, const uint32_t sn_bits, const size_t sn_bits_nr, const bool sn_not_valid) |
Perform the required actions after the reception of a positive ACK. More... | |
static void | rohc_comp_rfc5225_ip_decide_state (struct rohc_comp_ctxt *const context, const struct rohc_ts pkt_time) |
Decide the state that should be used for the next packet. More... | |
static rohc_packet_t | rohc_comp_rfc5225_ip_decide_pkt (struct rohc_comp_ctxt *const context) |
Decide which packet to send when in the different states. More... | |
static rohc_packet_t | rohc_comp_rfc5225_ip_decide_FO_pkt (const struct rohc_comp_ctxt *const ctxt) |
Decide which packet to send when in FO state. More... | |
static rohc_packet_t | rohc_comp_rfc5225_ip_decide_SO_pkt (const struct rohc_comp_ctxt *const ctxt) |
Decide which packet to send when in SO state. More... | |
static rohc_packet_t | rohc_comp_rfc5225_ip_decide_FO_SO_pkt (const struct rohc_comp_ctxt *const ctxt, const bool crc7_at_least) |
Decide which packet to send when in FO or SO state. More... | |
static bool | rohc_comp_rfc5225_is_msn_lsb_possible (const struct c_wlsb *const wlsb, const uint16_t value, const rohc_reordering_offset_t reorder_ratio, const size_t k) |
Define according to computed shift parameter if msn_lsb() is possible. More... | |
static bool | rohc_comp_rfc5225_is_ipid_sequential (const rohc_ip_id_behavior_t behavior) |
Whether the given IP-ID is sequential (swapped or not) More... | |
static bool | rohc_comp_rfc5225_is_seq_ipid_inferred (const ip_context_t *const ip_ctxt, const uint16_t new_ip_id) |
Whether the given IP-ID is inferred from SN. More... | |
Variables | |
const struct rohc_comp_profile | rohc_comp_rfc5225_ip_profile |
Define the compression part of the ROHCv2 IP-only profile as described in the RFC 5225. More... | |
ROHC compression context for the ROHCv2 IP-only profile.
|
static |
Build a ROHCv2 co_common packet.
context | The compression context | |
crc | The CRC on the uncompressed headers | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build a ROHCv2 pt_0_crc3 packet.
context | The compression context | |
crc | The CRC on the uncompressed headers | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build a ROHCv2 pt_0_crc7 packet.
context | The compression context | |
crc | The CRC on the uncompressed headers | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build a ROHCv2 pt_1_seq_id packet.
context | The compression context | |
crc | The CRC on the uncompressed headers | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build a ROHCv2 pt_2_seq_id packet.
context | The compression context | |
crc | The CRC on the uncompressed headers | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Check if the IP packet belongs to the given ROHCv2 IP-only context.
Conditions are:
This function is one of the functions that must exist in one profile for the framework to work.
context | The compression context | |
packet | The IP packet to check | |
[out] | cr_score | The score of the context for Context Replication (CR) |
|
static |
Check if the given packet corresponds to the ROHCv2 IP-only profile.
Conditions are:
This function is one of the functions that must exist in one profile for the framework to work.
comp | The ROHC compressor |
packet | The packet to check |
|
static |
Encode an IP packet as CO packet.
context | The compression context |
ip | The outer IP header |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
packet_type | The type of ROHC packet to create |
payload_offset | The offset for the payload in the IP packet |
|
static |
Encode an IP packet as co_repair packet.
0 1 2 3 4 5 6 7 --- --- --- --- --- --- --- --- : Add-CID octet : if for small CIDs and CID 1-15 +---+---+---+---+---+---+---+---+ | 1 1 1 1 1 0 1 1 | discriminator +---+---+---+---+---+---+---+---+ : : / 0, 1, or 2 octets of CID / 1-2 octets if large CIDs : : +---+---+---+---+---+---+---+---+ |r1 | CRC-7 | +---+---+---+---+---+---+---+---+ | r2 | CRC-3 | +---+---+---+---+---+---+---+---+ | | / Dynamic chain / variable length | | - - - - - - - - - - - - - - - -
context | The compression context |
ip | The outer IP header |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
payload_offset | The offset for the payload in the IP packet |
|
static |
Encode an IP packet as IR packet.
context | The compression context |
ip | The outer IP header |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
|
static |
Create a new ROHCv2 IP-only context and initialize it thanks to the given uncompressed packet.
This function is one of the functions that must exist in one profile for the framework to work.
context | The compression context |
packet | The packet given to initialize the new context |
|
static |
Decide which packet to send when in FO state.
ctxt | The compression context |
|
static |
Decide which packet to send when in FO or SO state.
ctxt | The compression context |
crc7_at_least | Whether packet types with CRC strictly smaller than 7 bits are allowed or not |
|
static |
Decide which packet to send when in the different states.
context | The compression context |
|
static |
Decide which packet to send when in SO state.
ctxt | The compression context |
|
static |
Decide the state that should be used for the next packet.
context | The compression context |
pkt_time | The time of packet arrival |
|
static |
Destroy the ROHCv2 IP-only context.
This function is one of the functions that must exist in one profile for the framework to work.
context | The ROHCv2 IP-only compression context to destroy |
|
static |
Detect changes between packet and context.
context | The compression context to compare | |
uncomp_pkt | The uncompressed packet to compare | |
[out] | payload_offset | The offset for the payload in the uncompressed packet |
|
static |
Detect changes for the given IPv4 header between packet and context.
ctxt | The compression context |
ip_ctxt | The IPv4 context to compare |
ip_hdr | The IPv4 header to compare |
is_innermost | Whether the IPv4 header is the innermost of all IP headers |
|
static |
Detect changes for the given IPv6 header between packet and context.
ctxt | The compression context |
ip_ctxt | The IPv6 context to compare |
ip_hdr | The IPv6 header to compare |
is_innermost | Whether the IPv6 header is the innermost of all IP headers |
|
static |
Code the dynamic chain of a ROHCv2 IP-only IR packet.
ctxt | The compression context |
ip | The outer IP header |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
|
static |
Build the dynamic part of the IPv4 header.
ctxt | The compression context | |
ip_ctxt | The specific IP compression context | |
ipv4 | The IPv4 header | |
is_innermost | true if the IP header is the innermost of the packet, false otherwise | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the dynamic part of the IPv6 header.
ctxt | The compression context | |
ip_ctxt | The specific IP compression context | |
ipv6 | The IPv6 header | |
is_innermost | true if the IP header is the innermost of the packet, false otherwise | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Encode an uncompressed packet according to a pattern decided by several different factors.
context | The compression context |
uncomp_pkt | The uncompressed packet to encode |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
packet_type | OUT: The type of ROHC packet that is created |
payload_offset | OUT: The offset for the payload in the uncompressed packet |
|
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.
ctxt | The compression context |
feedback_type | The feedback type among ROHC_FEEDBACK_1 and ROHC_FEEDBACK_2 |
packet | The whole feedback packet with CID bits |
packet_len | The length of the whole feedback packet with CID bits |
feedback_data | The feedback data without the CID bits |
feedback_data_len | The length of the feedback data without the CID bits |
|
static |
Update the profile when FEEDBACK-2 is received.
ctxt | The compression context |
packet | The whole feedback packet with CID bits |
packet_len | The length of the whole feedback packet with CID bits |
feedback_data | The feedback data without the CID bits |
feedback_data_len | The length of the feedback data without the CID bits |
|
static |
Perform the required actions after the reception of a positive ACK.
ctxt | The compression context that received a positive ACK |
sn_bits | The LSB bits of the acknowledged SN |
sn_bits_nr | The number of LSB bits of the acknowledged SN |
sn_not_valid | Whether the received SN may be considered as valid or not |
|
static |
Code the irregular chain of a ROHCv2 IP-only IR packet.
ctxt | The compression context |
ip | The outer IP header |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
|
static |
Build the irregular part of the IPv4 header.
ctxt | The compression context | |
ip_ctxt | The specific IP compression context | |
ipv4 | The IPv4 header | |
is_innermost | true if the IP header is the innermost of the packet, false otherwise | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the irregular part of the IPv6 header.
ctxt | The compression context | |
ip_ctxt | The specific IP compression context | |
ipv6 | The IPv6 header | |
is_innermost | true if the IP header is the innermost of the packet, false otherwise | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Code the static chain of an ROHCv2 IP-only IR packet.
ctxt | The compression context |
ip | The outer IP header |
rohc_pkt | OUT: The ROHC packet |
rohc_pkt_max_len | The maximum length of the ROHC packet |
|
static |
Build the static part of the IPv4 header.
ctxt | The compression context | |
ipv4 | The IPv4 header | |
is_innermost | Whether the IPv4 header is the innermost IP header | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Build the static part of the IPv6 header.
ctxt | The compression context | |
ipv6 | The IPv6 header | |
is_innermost | Whether the IPv6 header is the innermost IP header | |
[out] | rohc_data | The ROHC packet being built |
rohc_max_len | The max remaining length in the ROHC buffer |
|
static |
Whether the given IP-ID is sequential (swapped or not)
behavior | The IP-ID behavior |
|
static |
Define according to computed shift parameter if msn_lsb() is possible.
wlsb | The W-LSB object |
value | The value to encode using the LSB algorithm |
reorder_ratio | The reordering ratio |
k | The number of bits for encoding |
|
static |
Whether the given IP-ID is inferred from SN.
The given IP-ID is inferred from SN if:
For the IP-only profile, the MSN is generated by the compressor, so the MSN delta is always 1.
ip_ctxt | The context for the given IP header |
new_ip_id | The new value of the IP-ID |
const struct rohc_comp_profile rohc_comp_rfc5225_ip_profile |
Define the compression part of the ROHCv2 IP-only profile as described in the RFC 5225.