ROHC compression/decompression library
Functions
c_udp.h File Reference

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

#include "rohc_comp_internals.h"
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for c_udp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool c_udp_check_profile (const struct rohc_comp *const comp, const struct ip_packet *const outer_ip, const struct ip_packet *const inner_ip, const uint8_t protocol, rohc_ctxt_key_t *const ctxt_key)
 Check if the given packet corresponds to the UDP profile.
bool c_udp_check_context (const struct c_context *context, const struct ip_packet *ip)
 Check if the IP/UDP packet belongs to the context.
int udp_code_uo_remainder (const struct c_context *context, const unsigned char *next_header, unsigned char *const dest, int counter)
 Build UDP-related fields in the tail of the UO packets.
int udp_code_static_udp_part (const struct c_context *context, const unsigned char *next_header, unsigned char *const dest, int counter)
 Build the static part of the UDP header.

Detailed Description

ROHC compression context for the UDP profile.

Author:
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
The hackers from ROHC for Linux

Function Documentation

bool c_udp_check_context ( const struct c_context context,
const struct ip_packet ip 
)

Check if the IP/UDP 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 UDP
  • the source and destination ports of the UDP header must match the ones 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
ipThe IP/UDP packet to check
Returns:
true if the IP/UDP packet belongs to the context false if it does not belong to the context

References c_context::compressor, ipv4_hdr::daddr, udphdr::dest, c_profile::id, ip_header_info::info, c_generic_context::ip2_flags, ipv6_hdr::ip6_dst, ipv6_hdr::ip6_src, c_generic_context::ip_flags, ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), ip_get_version(), IPV4, ipv4_get_daddr(), ipv4_get_saddr(), IPV6, IPV6_ADDR_CMP, ipv6_get_daddr(), IPV6_GET_FLOW_LABEL, ipv6_get_flow_label(), ipv6_get_saddr(), c_generic_context::is_ip2_initialized, ipv4_header_info::old_ip, ipv6_header_info::old_ip, sc_udp_context::old_udp, c_context::profile, ROHC_IPPROTO_IPIP, ROHC_IPPROTO_IPV6, ROHC_IPPROTO_UDP, ROHC_TRACE_COMP, rohc_warning, ipv4_hdr::saddr, udphdr::source, c_generic_context::specific, c_context::specific, ip_header_info::v4, ip_header_info::v6, version, and ip_header_info::version.

bool c_udp_check_profile ( const struct rohc_comp *const  comp,
const struct ip_packet *const  outer_ip,
const struct ip_packet *const  inner_ip,
const uint8_t  protocol,
rohc_ctxt_key_t *const  ctxt_key 
)

Check if the given packet corresponds to the UDP profile.

Conditions are:

  • the transport protocol is UDP
  • 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
  • the inner IP payload is at least 8-byte long for UDP header
  • the UDP Length field and the UDP payload match
See also:
c_generic_check_profile

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

Parameters:
compThe ROHC compressor
outer_ipThe outer IP header of the IP packet to check
inner_ip
  • The inner IP header of the IP packet to check if the IP packet contains at least 2 IP headers,
  • NULL if the IP packet to check contains only one IP header
protocolThe transport protocol carried by the IP packet:
  • the protocol carried by the outer IP header if there is only one IP header,
  • the protocol carried by the inner IP header if there are at least two IP headers.
ctxt_keyThe key to help finding the context associated with packet
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

References c_generic_check_profile(), udphdr::dest, ip_get_next_layer(), ip_get_plen(), udphdr::len, ROHC_IPPROTO_UDP, rohc_ntoh16(), and udphdr::source.

int udp_code_static_udp_part ( const struct c_context context,
const unsigned char *  next_header,
unsigned char *const  dest,
int  counter 
)

Build the static part of the UDP header.


 Static part of UDP header (5.7.7.5):

    +---+---+---+---+---+---+---+---+
 1  /          Source Port          /   2 octets
    +---+---+---+---+---+---+---+---+
 2  /       Destination Port        /   2 octets
    +---+---+---+---+---+---+---+---+

Parameters:
contextThe compression context
next_headerThe UDP 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

References udphdr::dest, rohc_comp_debug, and udphdr::source.

int udp_code_uo_remainder ( const struct c_context context,
const unsigned char *  next_header,
unsigned char *const  dest,
int  counter 
)

Build UDP-related fields in the tail of the UO packets.


     --- --- --- --- --- --- --- ---
    :                               :
 13 +         UDP Checksum          +  2 octets,
    :                               :  if context(UDP Checksum) != 0
     --- --- --- --- --- --- --- ---

Parameters:
contextThe compression context
next_headerThe UDP 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

References udphdr::check, and rohc_comp_debug.