ROHC compression/decompression library
Classes | Defines | Enumerations | Functions
ip.h File Reference

IP-agnostic packet. More...

#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <string.h>
Include dependency graph for ip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ip_packet
 Defines an IP-agnostic packet that can handle an IPv4 or IPv6 packet. More...
struct  ip6_ahhdr

Defines

#define IPV6_EXT_HOP_BY_HOP   0
#define IPV6_EXT_DESTINATION   60
#define IPV6_EXT_ROUTING   43
#define IPV6_EXT_AUTH   51
#define IP_GET_16_SUBFIELD(field, bitmask, offset)   ((ntohs(field) & (bitmask)) >> (offset))
 Get a subpart of a 16-bit IP field.
#define IP_GET_32_SUBFIELD(field, bitmask, offset)   ((ntohl(field) & (bitmask)) >> (offset))
 Get a subpart of a 32-bit IP field.
#define IP_SET_16_SUBFIELD(field, bitmask, offset, value)   (field) = (((field) & htons(~(bitmask))) | htons(((value) << (offset)) & (bitmask)))
 Set a subpart of a 16-bit IP field.
#define IP_SET_32_SUBFIELD(field, bitmask, offset, value)   (field) = (((field) & htonl(~(bitmask))) | htonl(((value) << (offset)) & (bitmask)))
 Set a subpart of a 32-bit IP field.
#define IPV4_DF_OFFSET   14
 The offset for the DF flag in an iphdr->frag_off variable.
#define IPV4_GET_DF(ip4)   IP_GET_16_SUBFIELD((ip4).frag_off, IP_DF, IPV4_DF_OFFSET)
 Get the IPv4 Don't Fragment (DF) bit from an iphdr object.
#define IPV4_SET_DF(ip4, value)   IP_SET_16_SUBFIELD((ip4)->frag_off, IP_DF, IPV4_DF_OFFSET, (value))
 Set the IPv4 Don't Fragment (DF) bit in an iphdr object.
#define IPV6_VERSION_MASK   0xf0000000
 The bitmask for the Version field in an ip6_hdr->ip6_flow variable.
#define IPV6_VERSION_OFFSET   28
 The offset for the Version field in an ip6_hdr->ip6_flow variable.
#define IPV6_TC_MASK   0x0ff00000
 The bitmask for the Traffic Class (TC) field in an ip6_hdr->ip6_flow variable.
#define IPV6_TC_OFFSET   20
 The offset for the Traffic Class (TC) field in an ip6_hdr->ip6_flow variable.
#define IPV6_FLOW_LABEL_MASK   0x000fffff
 The bitmask for the FLow Label field in an ip6_hdr->ip6_flow variable.
#define IPV6_GET_VERSION(ip6)   IP_GET_32_SUBFIELD((ip6).ip6_flow, IPV6_VERSION_MASK, IPV6_VERSION_OFFSET)
 Get the IPv6 Version 4-bit field from ip6_hdr object.
#define IPV6_SET_VERSION(ip6, value)   IP_SET_32_SUBFIELD((ip6)->ip6_flow, IPV6_VERSION_MASK, IPV6_VERSION_OFFSET, (value))
 Set the IPv6 Version 4-bit field in an ip6_hdr object.
#define IPV6_GET_TC(ip6)   IP_GET_32_SUBFIELD((ip6).ip6_flow, IPV6_TC_MASK, IPV6_TC_OFFSET)
 Get the IPv6 Traffic Class (TC) byte from an ip6_hdr object.
#define IPV6_SET_TC(ip6, value)   IP_SET_32_SUBFIELD((ip6)->ip6_flow, IPV6_TC_MASK, IPV6_TC_OFFSET, (value))
 Set the IPv6 Traffic Class (TC) byte in an ip6_hdr object.
#define IPV6_GET_FLOW_LABEL(ip6)   IP_GET_32_SUBFIELD((ip6).ip6_flow, IPV6_FLOW_LABEL_MASK, 0)
 Get the IPv6 Flow Label 20-bit field from an ip6_hdr object.
#define IPV6_SET_FLOW_LABEL(ip6, value)   IP_SET_32_SUBFIELD((ip6)->ip6_flow, IPV6_FLOW_LABEL_MASK, 0, (value))
 Set the IPv6 Flow Label 20-bit field in an ip6_hdr variable.
#define IPV6_ADDR_FORMAT   "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x"
 The format to print an IPv6 address.
#define IPV6_ADDR(x)
 The data to print an IPv6 address in (struct in6_addr *) format.
#define IPV6_ADDR_CMP(x, y)
 Compare two IPv6 addresses in (struct in6_addr *) format.

Enumerations

enum  ip_version { IPV4 = 4, IPV6 = 6, IP_UNKNOWN }
 IP version. More...

Functions

int ip_create (struct ip_packet *ip, unsigned char *packet, unsigned int size)
 Create an IP packet from raw data.
int ip_get_inner_packet (struct ip_packet outer, struct ip_packet *inner)
 Get the inner IP packet (IP in IP)
void ip_new (struct ip_packet *ip, ip_version version)
 Create an empty IP packet.
unsigned char * ip_get_raw_data (struct ip_packet ip)
 Get the IP raw data (header + payload)
unsigned char * ip_get_next_header (const struct ip_packet *ip, uint8_t *type)
 Get the IP next header.
unsigned char * ip_get_next_layer (const struct ip_packet *ip)
 Get the next header (but skip IP extensions)
unsigned char * ip_get_next_ext_header_from_ip (const struct ip_packet *ip, uint8_t *type)
 Get the next extension header of IPv6 packets from an IPv6 header.
unsigned char * ip_get_next_ext_header_from_ext (const unsigned char *ext, uint8_t *type)
 Get the next extension header of IPv6 packets from another extension.
unsigned int ip_get_totlen (struct ip_packet ip)
 Get the total length of an IP packet.
unsigned int ip_get_hdrlen (struct ip_packet ip)
 Get the length of an IP header.
unsigned int ip_get_plen (struct ip_packet ip)
 Get the length of an IP payload.
int ip_is_fragment (struct ip_packet ip)
 Whether the IP packet is an IP fragment or not.
ip_version ip_get_version (struct ip_packet ip)
 Get the IP version of an IP packet.
unsigned int ip_get_protocol (struct ip_packet ip)
 Get the protocol transported by an IP packet.
unsigned int ext_get_protocol (unsigned char *ext)
 Get the protocol transported by the last IPv6 extension.
unsigned int ip_get_tos (struct ip_packet ip)
 Get the IPv4 Type Of Service (TOS) or IPv6 Traffic Class (TC) of an IP packet.
unsigned int ip_get_ttl (struct ip_packet ip)
 Get the IPv4 Time To Live (TTL) or IPv6 Hop Limit (HL) of an IP packet.
void ip_set_protocol (struct ip_packet *ip, uint8_t value)
 Set the protocol transported by an IP packet.
void ip_set_tos (struct ip_packet *ip, uint8_t value)
 Set the IPv4 Type Of Service (TOS) or IPv6 Traffic Class (TC) of an IP packet.
void ip_set_ttl (struct ip_packet *ip, uint8_t value)
 Set the IPv4 Time To Live (TTL) or IPv6 Hop Limit (HL) of an IP packet.
void ip_set_saddr (struct ip_packet *ip, const unsigned char *value)
 Set the Source Address of an IP packet.
void ip_set_daddr (struct ip_packet *ip, const unsigned char *value)
 Set the Destination Address of an IP packet.
struct iphdr * ipv4_get_header (const struct ip_packet *const ip)
 Get the IPv4 header.
int ipv4_get_id (struct ip_packet ip)
 Get the IP-ID of an IPv4 packet.
int ipv4_get_id_nbo (struct ip_packet ip, unsigned int nbo)
 Get the IP-ID of an IPv4 packet in Network Byte Order.
int ipv4_get_df (struct ip_packet ip)
 Get the Don't Fragment (DF) bit of an IPv4 packet.
uint32_t ipv4_get_saddr (struct ip_packet ip)
 Get the source address of an IPv4 packet.
uint32_t ipv4_get_daddr (struct ip_packet ip)
 Get the destination address of an IPv4 packet.
void ipv4_set_id (struct ip_packet *ip, int value)
 Set the IP-ID of an IPv4 packet.
void ipv4_set_df (struct ip_packet *ip, int value)
 Set the Don't Fragment (DF) bit of an IPv4 packet.
struct ip6_hdr * ipv6_get_header (const struct ip_packet *const ip)
 Get the IPv6 header.
uint32_t ipv6_get_flow_label (struct ip_packet ip)
 Get the flow label of an IPv6 packet.
struct in6_addr * ipv6_get_saddr (struct ip_packet *ip)
 Get the source address of an IPv6 packet.
struct in6_addr * ipv6_get_daddr (struct ip_packet *ip)
 Get the destination address of an IPv6 packet.
void ipv6_set_flow_label (struct ip_packet *ip, uint32_t value)
 Set the flow label of an IPv6 packet.
unsigned short ip_get_extension_size (unsigned char *ext)
 Get the size of an IPv6 extension.
unsigned short ip_get_total_extension_size (struct ip_packet ip)
 Get the size of the extension list.
int get_ip_version (const unsigned char *packet, unsigned int size, ip_version *version)

Detailed Description

IP-agnostic packet.

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

Define Documentation

#define IP_GET_16_SUBFIELD (   field,
  bitmask,
  offset 
)    ((ntohs(field) & (bitmask)) >> (offset))

Get a subpart of a 16-bit IP field.

#define IP_GET_32_SUBFIELD (   field,
  bitmask,
  offset 
)    ((ntohl(field) & (bitmask)) >> (offset))

Get a subpart of a 32-bit IP field.

#define IP_SET_16_SUBFIELD (   field,
  bitmask,
  offset,
  value 
)    (field) = (((field) & htons(~(bitmask))) | htons(((value) << (offset)) & (bitmask)))

Set a subpart of a 16-bit IP field.

#define IP_SET_32_SUBFIELD (   field,
  bitmask,
  offset,
  value 
)    (field) = (((field) & htonl(~(bitmask))) | htonl(((value) << (offset)) & (bitmask)))

Set a subpart of a 32-bit IP field.

#define IPV4_DF_OFFSET   14

The offset for the DF flag in an iphdr->frag_off variable.

#define IPV4_GET_DF (   ip4)    IP_GET_16_SUBFIELD((ip4).frag_off, IP_DF, IPV4_DF_OFFSET)

Get the IPv4 Don't Fragment (DF) bit from an iphdr object.

Referenced by changed_dynamic_one_hdr(), and ipv4_get_df().

#define IPV4_SET_DF (   ip4,
  value 
)    IP_SET_16_SUBFIELD((ip4)->frag_off, IP_DF, IPV4_DF_OFFSET, (value))

Set the IPv4 Don't Fragment (DF) bit in an iphdr object.

Referenced by ipv4_set_df().

#define IPV6_ADDR (   x)
Value:
(x)->s6_addr[0], (x)->s6_addr[1], (x)->s6_addr[2], (x)->s6_addr[3], \
        (x)->s6_addr[4], (x)->s6_addr[5], (x)->s6_addr[6], (x)->s6_addr[7], \
        (x)->s6_addr[8], (x)->s6_addr[9], (x)->s6_addr[10], (x)->s6_addr[11], \
        (x)->s6_addr[12], (x)->s6_addr[13], (x)->s6_addr[14], (x)->s6_addr[15]

The data to print an IPv6 address in (struct in6_addr *) format.

Referenced by code_ipv6_static_part(), and d_decode_static_ip6().

#define IPV6_ADDR_CMP (   x,
 
)
Value:
((x)->s6_addr32[0] == (y)->s6_addr32[0] && \
         (x)->s6_addr32[1] == (y)->s6_addr32[1] && \
         (x)->s6_addr32[2] == (y)->s6_addr32[2] && \
         (x)->s6_addr32[3] == (y)->s6_addr32[3])

Compare two IPv6 addresses in (struct in6_addr *) format.

Referenced by c_ip_check_context(), c_udp_check_context(), and c_udp_lite_check_context().

#define IPV6_ADDR_FORMAT   "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x"

The format to print an IPv6 address.

Referenced by code_ipv6_static_part(), and d_decode_static_ip6().

#define IPV6_EXT_AUTH   51
#define IPV6_EXT_DESTINATION   60
#define IPV6_EXT_HOP_BY_HOP   0
#define IPV6_EXT_ROUTING   43
#define IPV6_FLOW_LABEL_MASK   0x000fffff

The bitmask for the FLow Label field in an ip6_hdr->ip6_flow variable.

#define IPV6_GET_FLOW_LABEL (   ip6)    IP_GET_32_SUBFIELD((ip6).ip6_flow, IPV6_FLOW_LABEL_MASK, 0)

Get the IPv6 Flow Label 20-bit field from an ip6_hdr object.

Referenced by c_ip_check_context(), c_udp_check_context(), c_udp_lite_check_context(), and ipv6_get_flow_label().

#define IPV6_GET_TC (   ip6)    IP_GET_32_SUBFIELD((ip6).ip6_flow, IPV6_TC_MASK, IPV6_TC_OFFSET)

Get the IPv6 Traffic Class (TC) byte from an ip6_hdr object.

Referenced by changed_fields(), and ip_get_tos().

#define IPV6_GET_VERSION (   ip6)    IP_GET_32_SUBFIELD((ip6).ip6_flow, IPV6_VERSION_MASK, IPV6_VERSION_OFFSET)

Get the IPv6 Version 4-bit field from ip6_hdr object.

#define IPV6_SET_FLOW_LABEL (   ip6,
  value 
)    IP_SET_32_SUBFIELD((ip6)->ip6_flow, IPV6_FLOW_LABEL_MASK, 0, (value))

Set the IPv6 Flow Label 20-bit field in an ip6_hdr variable.

Referenced by ipv6_set_flow_label().

#define IPV6_SET_TC (   ip6,
  value 
)    IP_SET_32_SUBFIELD((ip6)->ip6_flow, IPV6_TC_MASK, IPV6_TC_OFFSET, (value))

Set the IPv6 Traffic Class (TC) byte in an ip6_hdr object.

Referenced by ip_set_tos().

#define IPV6_SET_VERSION (   ip6,
  value 
)    IP_SET_32_SUBFIELD((ip6)->ip6_flow, IPV6_VERSION_MASK, IPV6_VERSION_OFFSET, (value))

Set the IPv6 Version 4-bit field in an ip6_hdr object.

Referenced by ip_new().

#define IPV6_TC_MASK   0x0ff00000

The bitmask for the Traffic Class (TC) field in an ip6_hdr->ip6_flow variable.

#define IPV6_TC_OFFSET   20

The offset for the Traffic Class (TC) field in an ip6_hdr->ip6_flow variable.

#define IPV6_VERSION_MASK   0xf0000000

The bitmask for the Version field in an ip6_hdr->ip6_flow variable.

#define IPV6_VERSION_OFFSET   28

The offset for the Version field in an ip6_hdr->ip6_flow variable.


Enumeration Type Documentation

enum ip_version

IP version.

Enumerator:
IPV4 

IP version 4.

IPV6 

IP version 6.

IP_UNKNOWN 

not IP


Function Documentation

unsigned int ext_get_protocol ( unsigned char *  ext)

Get the protocol transported by the last IPv6 extension.

Parameters:
extThe first extension
Returns:
The protocol number that identify the protocol transported by the given IP extension

References ext_get_protocol(), IPV6_EXT_AUTH, IPV6_EXT_DESTINATION, IPV6_EXT_HOP_BY_HOP, and IPV6_EXT_ROUTING.

Referenced by ext_get_protocol(), and ip_get_protocol().

int get_ip_version ( const unsigned char *  packet,
unsigned int  size,
ip_version version 
)

Private functions used by the IP module: (please do not use directly)

References IP_UNKNOWN, IPV4, and IPV6.

Referenced by compute_crc_dynamic(), compute_crc_static(), and ip_create().

int ip_create ( struct ip_packet ip,
unsigned char *  packet,
unsigned int  size 
)

Create an IP packet from raw data.

Parameters:
ipOUT: The IP packet to create
packetThe IP packet data
sizeThe length of the IP packet data
Returns:
Whether the IP packet was successfully created or not

References ip_packet::data, get_ip_version(), ip_packet::header, ip_get_hdrlen(), ip_get_totlen(), IP_UNKNOWN, IPV4, IPV6, rohc_debugf, ip_packet::size, ip_packet::v4, ip_packet::v6, version, and ip_packet::version.

Referenced by ip_get_inner_packet(), and rohc_compress().

unsigned short ip_get_extension_size ( unsigned char *  ext)

Get the size of an IPv6 extension.

Parameters:
extThe extension
Returns:
The size of the extension

Referenced by ip_get_total_extension_size(), ipv6_ext_compute_crc_dynamic(), and ipv6_ext_compute_crc_static().

unsigned int ip_get_hdrlen ( struct ip_packet  ip)

Get the length of an IP header.

Parameters:
ipThe IP packet to analyze
Returns:
The length of the IP header

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by c_generic_encode(), c_get_profile_from_packet(), c_udp_lite_encode(), d_generic_decode_ir(), decode_irdyn(), do_decode_uo0_and_uo1(), do_decode_uor2(), and ip_create().

int ip_get_inner_packet ( struct ip_packet  outer,
struct ip_packet inner 
)

Get the inner IP packet (IP in IP)

Parameters:
outerThe outer IP packet to analyze
innerThe inner IP packet to create
Returns:
Whether the inner IP header is successfully created or not

References ip_create(), ip_get_next_layer(), ip_get_plen(), and rohc_debugf.

Referenced by c_generic_create(), c_generic_encode(), c_ip_check_context(), c_rtp_check_context(), c_rtp_create(), c_rtp_encode(), c_udp_check_context(), c_udp_create(), c_udp_encode(), c_udp_lite_check_context(), c_udp_lite_create(), c_udp_lite_encode(), and rohc_compress().

unsigned char* ip_get_next_ext_header_from_ext ( const unsigned char *  ext,
uint8_t *  type 
)

Get the next extension header of IPv6 packets from another extension.

Parameters:
extThe extension to analyse
typeOUT: The type of the next header If there is no next header the value must be ignored
Returns:
The next extension header, NULL if there is no more extension

References IPV6_EXT_AUTH, IPV6_EXT_DESTINATION, IPV6_EXT_HOP_BY_HOP, and IPV6_EXT_ROUTING.

Referenced by get_index_ipv6_table(), get_ipv6_extension(), ip_get_total_extension_size(), ipv6_ext_compute_crc_dynamic(), and ipv6_ext_compute_crc_static().

unsigned char* ip_get_next_ext_header_from_ip ( const struct ip_packet ip,
uint8_t *  type 
)

Get the next extension header of IPv6 packets from an IPv6 header.

Parameters:
ipThe IP packet to analyze
typeOUT: The type of the next header If there is no next header the value must be ignored
Returns:
The next extension header, NULL if there is no extension

References ip_get_next_header(), IPV6, IPV6_EXT_AUTH, IPV6_EXT_DESTINATION, IPV6_EXT_HOP_BY_HOP, IPV6_EXT_ROUTING, and ip_packet::version.

Referenced by get_index_ipv6_table(), get_ipv6_extension(), and ip_get_total_extension_size().

unsigned char* ip_get_next_header ( const struct ip_packet ip,
uint8_t *  type 
)

Get the IP next header.

Parameters:
ipThe IP packet to analyze
typeOUT: The type of the next header
Returns:
The next header

References ip_packet::data, ip_packet::header, IPV4, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by ip_get_next_ext_header_from_ip(), and ip_get_next_layer().

unsigned char* ip_get_next_layer ( const struct ip_packet ip)
unsigned int ip_get_plen ( struct ip_packet  ip)

Get the length of an IP payload.

Parameters:
ipThe IP packet to analyze
Returns:
The length of the IP payload

References ip_packet::header, ip_get_total_extension_size(), IPV4, IPV6_EXT_AUTH, IPV6_EXT_DESTINATION, IPV6_EXT_HOP_BY_HOP, IPV6_EXT_ROUTING, size_list(), ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by c_get_profile_from_packet(), and ip_get_inner_packet().

unsigned int ip_get_protocol ( struct ip_packet  ip)
unsigned char* ip_get_raw_data ( struct ip_packet  ip)

Get the IP raw data (header + payload)

Parameters:
ipThe IP packet to analyze
Returns:
The IP raw data (header + payload)

References ip_packet::data.

Referenced by rohc_compress(), and uncompressed_code_normal_packet().

unsigned int ip_get_tos ( struct ip_packet  ip)

Get the IPv4 Type Of Service (TOS) or IPv6 Traffic Class (TC) of an IP packet.

Parameters:
ipThe IP packet to analyze
Returns:
The TOS or TC value

References ip_packet::header, IPV4, IPV6_GET_TC, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by changed_fields(), code_ipv4_dynamic_part(), code_ipv6_dynamic_part(), d_decode_dynamic_ip4(), d_decode_dynamic_ip6(), and header_fields().

unsigned short ip_get_total_extension_size ( struct ip_packet  ip)

Get the size of the extension list.

Parameters:
ipThe packet to analyse
Returns:
The size of extension list

References ip_get_extension_size(), ip_get_next_ext_header_from_ext(), and ip_get_next_ext_header_from_ip().

Referenced by c_generic_encode(), and ip_get_plen().

unsigned int ip_get_totlen ( struct ip_packet  ip)

Get the total length of an IP packet.

Parameters:
ipThe IP packet to analyze
Returns:
The total length of the IP packet

References ip_packet::header, IPV4, IPV6, ip_packet::v4, and ip_packet::version.

Referenced by ip_create(), and rohc_compress().

unsigned int ip_get_ttl ( struct ip_packet  ip)

Get the IPv4 Time To Live (TTL) or IPv6 Hop Limit (HL) of an IP packet.

Parameters:
ipThe IP packet to analyze
Returns:
The TTL or HL value

References ip_packet::header, IPV4, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by changed_fields(), code_ipv4_dynamic_part(), code_ipv6_dynamic_part(), d_decode_dynamic_ip4(), d_decode_dynamic_ip6(), and header_fields().

int ip_is_fragment ( struct ip_packet  ip)

Whether the IP packet is an IP fragment or not.

The IP packet is a fragment if the MF (More Fragments) bit is set or the Fragment Offset field is non-zero.

Parameters:
ipThe IP packet to analyze
Returns:
Whether the IP packet is an IP fragment or not

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by c_generic_encode(), c_get_profile_from_packet(), c_ip_check_context(), c_udp_check_context(), and c_udp_lite_check_context().

void ip_new ( struct ip_packet ip,
ip_version  version 
)

Create an empty IP packet.

Parameters:
ipOUT: The IP packet to create
versionThe version of the IP packet
Returns:
Whether the IP packet was successfully created or not

References ip_packet::header, IPV4, IPV6_SET_VERSION, ip_packet::v4, ip_packet::v6, ip_packet::version, and version.

Referenced by d_decode_static_ip().

void ip_set_daddr ( struct ip_packet ip,
const unsigned char *  value 
)

Set the Destination Address of an IP packet.

Parameters:
ipThe IP packet to modify
valueThe IP address value

References ip_packet::header, IPV4, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by d_decode_static_ip4(), and d_decode_static_ip6().

void ip_set_protocol ( struct ip_packet ip,
uint8_t  value 
)

Set the protocol transported by an IP packet.

Parameters:
ipThe IP packet to modify
valueThe protocol value

References ip_packet::header, IPV4, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by d_decode_static_ip4(), d_decode_static_ip6(), and decode_inner_header_flags().

void ip_set_saddr ( struct ip_packet ip,
const unsigned char *  value 
)

Set the Source Address of an IP packet.

Parameters:
ipThe IP packet to modify
valueThe IP address value

References ip_packet::header, IPV4, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by d_decode_static_ip4(), and d_decode_static_ip6().

void ip_set_tos ( struct ip_packet ip,
uint8_t  value 
)

Set the IPv4 Type Of Service (TOS) or IPv6 Traffic Class (TC) of an IP packet.

Parameters:
ipThe IP packet to modify
valueThe TOS/TC value

References ip_packet::header, IPV4, IPV6_SET_TC, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by d_decode_dynamic_ip4(), d_decode_dynamic_ip6(), and decode_inner_header_flags().

void ip_set_ttl ( struct ip_packet ip,
uint8_t  value 
)

Set the IPv4 Time To Live (TTL) or IPv6 Hop Limit (HL) of an IP packet.

Parameters:
ipThe IP packet to modify
valueThe TTL/HL value

References ip_packet::header, IPV4, ip_packet::v4, ip_packet::v6, and ip_packet::version.

Referenced by d_decode_dynamic_ip4(), d_decode_dynamic_ip6(), and decode_inner_header_flags().

uint32_t ipv4_get_daddr ( struct ip_packet  ip)

Get the destination address of an IPv4 packet.

Parameters:
ipThe IPv4 packet to analyze
Returns:
The source address of the given IPv4 packet

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by c_ip_check_context(), c_udp_check_context(), c_udp_lite_check_context(), code_ipv4_static_part(), and d_decode_static_ip4().

int ipv4_get_df ( struct ip_packet  ip)

Get the Don't Fragment (DF) bit of an IPv4 packet.

Parameters:
ipThe IP packet to analyze
Returns:
The DF bit of the IPv4 header if the given packet is IPv4, -1 otherwise

References ip_packet::header, IPV4, IPV4_GET_DF, ip_packet::v4, and ip_packet::version.

Referenced by changed_dynamic_one_hdr(), code_ipv4_dynamic_part(), d_decode_dynamic_ip4(), decode_inner_header_flags(), and header_flags().

struct iphdr* ipv4_get_header ( const struct ip_packet *const  ip) [read]

Get the IPv4 header.

Parameters:
ipThe IP packet to analyze
Returns:
The IP header if IPv4, NULL otherwise

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by c_generic_encode(), and c_init_header_info().

int ipv4_get_id ( struct ip_packet  ip)

Get the IP-ID of an IPv4 packet.

The IP-ID value is returned as-is (ie. not automatically converted to the host byte order).

Parameters:
ipThe IP packet to analyze
Returns:
The IP-ID if the given packet is IPv4, -1 otherwise

References ipv4_get_id_nbo().

Referenced by c_generic_encode(), check_ip_identification(), code_UO_packet_tail(), d_decode_dynamic_ip4(), decode_extension3(), decode_outer_header_flags(), do_decode_uo0_and_uo1(), do_decode_uor2(), ip_decode_dynamic_ip(), rtp_decode_dynamic_rtp(), and update_variables().

int ipv4_get_id_nbo ( struct ip_packet  ip,
unsigned int  nbo 
)

Get the IP-ID of an IPv4 packet in Network Byte Order.

Parameters:
ipThe IP packet to analyze
nboThe NBO flag (if RND = 1, use NBO = 1)
Returns:
The IP-ID if the given packet is IPv4, -1 otherwise

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by code_EXT3_packet(), code_ipv4_dynamic_part(), header_fields(), and ipv4_get_id().

uint32_t ipv4_get_saddr ( struct ip_packet  ip)

Get the source address of an IPv4 packet.

Parameters:
ipThe IPv4 packet to analyze
Returns:
The source address of the given IPv4 packet

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by c_ip_check_context(), c_udp_check_context(), c_udp_lite_check_context(), code_ipv4_static_part(), and d_decode_static_ip4().

void ipv4_set_df ( struct ip_packet ip,
int  value 
)

Set the Don't Fragment (DF) bit of an IPv4 packet.

Parameters:
ipThe IP packet to modify
valueThe value of the DF bit

References ip_packet::header, IPV4, IPV4_SET_DF, ip_packet::v4, and ip_packet::version.

Referenced by d_decode_dynamic_ip4(), and decode_inner_header_flags().

void ipv4_set_id ( struct ip_packet ip,
int  value 
)

Set the IP-ID of an IPv4 packet.

The IP-ID value is set as-is (ie. not automatically converted to the host byte order).

Parameters:
ipThe IP packet to modify
valueThe IP-ID value

References ip_packet::header, IPV4, ip_packet::v4, and ip_packet::version.

Referenced by d_decode_dynamic_ip4(), decode_extension3(), decode_outer_header_flags(), do_decode_uo0_and_uo1(), and do_decode_uor2().

struct in6_addr* ipv6_get_daddr ( struct ip_packet ip) [read]

Get the destination address of an IPv6 packet.

Parameters:
ipThe IPv6 packet to analyze
Returns:
The source address of the given IPv6 packet

References ip_packet::header, IPV6, ip_packet::v6, and ip_packet::version.

Referenced by c_ip_check_context(), c_udp_check_context(), c_udp_lite_check_context(), code_ipv6_static_part(), and d_decode_static_ip6().

uint32_t ipv6_get_flow_label ( struct ip_packet  ip)

Get the flow label of an IPv6 packet.

Parameters:
ipThe IPv6 packet to analyze
Returns:
The flow label of the given IPv6 packet

References ip_packet::header, IPV6, IPV6_GET_FLOW_LABEL, ip_packet::v6, and ip_packet::version.

Referenced by c_ip_check_context(), c_udp_check_context(), c_udp_lite_check_context(), code_ipv6_static_part(), and d_decode_static_ip6().

struct ip6_hdr* ipv6_get_header ( const struct ip_packet *const  ip) [read]

Get the IPv6 header.

Parameters:
ipThe IP packet to analyze
Returns:
The IP header if IPv6, NULL otherwise

References ip_packet::header, IPV6, ip_packet::v6, and ip_packet::version.

Referenced by c_generic_encode(), and c_init_header_info().

struct in6_addr* ipv6_get_saddr ( struct ip_packet ip) [read]

Get the source address of an IPv6 packet.

Parameters:
ipThe IPv6 packet to analyze
Returns:
The source address of the given IPv6 packet

References ip_packet::header, IPV6, ip_packet::v6, and ip_packet::version.

Referenced by c_ip_check_context(), c_udp_check_context(), c_udp_lite_check_context(), code_ipv6_static_part(), and d_decode_static_ip6().

void ipv6_set_flow_label ( struct ip_packet ip,
uint32_t  value 
)

Set the flow label of an IPv6 packet.

Parameters:
ipThe IPv6 packet to modify
valueThe flow label value

References ip_packet::header, IPV6, IPV6_SET_FLOW_LABEL, ip_packet::v6, and ip_packet::version.

Referenced by d_decode_static_ip6().