ROHC compression/decompression library
Classes | Functions
c_udp.h File Reference

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

#include <netinet/ip.h>
#include <netinet/udp.h>
#include "c_generic.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.

Classes

struct  udp_tmp_variables
 Define the UDP-specific temporary variables in the profile compression context. More...
struct  sc_udp_context
 Define the UDP part of the profile decompression context. More...

Functions

int c_udp_create (struct c_context *context, const struct ip_packet ip)
 Create a new UDP context and initialize it thanks to the given IP/UDP packet.
int c_udp_check_context (struct c_context *context, const struct ip_packet ip)
 Check if the IP/UDP packet belongs to the context.
int c_udp_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/UDP packet according to a pattern decided by several different factors.
void udp_decide_state (struct c_context *context)
 Decide the state that should be used for the next packet compressed with the ROHC UDP profile.
int udp_code_UO_packet_tail (struct c_context *context, const unsigned char *next_header, unsigned char *dest, int counter)
 Build UDP-related fields in the tail of the UO packets.
int udp_code_static_udp_part (struct c_context *context, const unsigned char *next_header, unsigned char *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

int c_udp_check_context ( struct c_context context,
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:
1 if the IP/UDP packet belongs to the context, 0 if it does not belong to the context and -1 if the profile cannot compress it or an error occurs

References ip_header_info::info, c_generic_context::ip2_flags, c_generic_context::ip_flags, ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), ip_get_version(), ip_is_fragment(), 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, rohc_debugf, c_context::specific, c_generic_context::specific, ip_header_info::v4, ip_header_info::v6, version, and ip_header_info::version.

Referenced by c_rtp_check_context().

int c_udp_create ( struct c_context context,
const struct ip_packet  ip 
)
int c_udp_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/UDP packet according to a pattern decided by several different factors.

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 or -1 in case of failure

References c_generic_encode(), ip_get_inner_packet(), ip_get_next_layer(), ip_get_protocol(), sc_udp_context::old_udp, PACKET_IR, PACKET_IR_DYN, generic_tmp_variables::packet_type, rohc_debugf, udp_tmp_variables::send_udp_dynamic, c_context::specific, c_generic_context::specific, sc_udp_context::tmp_variables, c_generic_context::tmp_variables, and udp_changed_udp_dynamic().

int udp_code_static_udp_part ( struct c_context context,
const unsigned char *  next_header,
unsigned char *  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 rohc_debugf.

Referenced by c_udp_create(), c_udp_lite_create(), and rtp_code_static_rtp_part().

int udp_code_UO_packet_tail ( struct c_context context,
const unsigned char *  next_header,
unsigned char *  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 rohc_debugf.

Referenced by c_rtp_create(), and c_udp_create().

void udp_decide_state ( struct c_context context)

Decide the state that should be used for the next packet compressed with the ROHC UDP profile.

The three states are:

  • Initialization and Refresh (IR),
  • First Order (FO),
  • Second Order (SO).
Parameters:
contextThe compression context

References change_state(), decide_state(), IR, rohc_debugf, udp_tmp_variables::send_udp_dynamic, c_context::specific, c_generic_context::specific, and sc_udp_context::tmp_variables.

Referenced by c_udp_create().