ROHC compression/decompression library
Functions
ip.c File Reference

IP-agnostic packet. More...

#include "ip.h"
#include "rohc_utils.h"
#include "protocols/ip_numbers.h"
#include "protocols/ip.h"
#include "protocols/ipv4.h"
#include "protocols/ipv6.h"
#include <string.h>
#include <assert.h>
Include dependency graph for ip.c:

Functions

void ip_set_version (struct ip_packet *const ip, const ip_version value)
 Set the IP version of an IP packet. More...
 
uint8_t ip_get_protocol (const struct ip_packet *const ip)
 Get the protocol transported by an IP packet. More...
 
void ip_set_protocol (struct ip_packet *const ip, const uint8_t value)
 Set the protocol transported by an IP packet. More...
 
unsigned int ip_get_tos (const struct ip_packet *const ip)
 Get the IPv4 Type Of Service (TOS) or IPv6 Traffic Class (TC) of an IP packet. More...
 
void ip_set_tos (struct ip_packet *const ip, const uint8_t value)
 Set the IPv4 Type Of Service (TOS) or IPv6 Traffic Class (TC) of an IP packet. More...
 
unsigned int ip_get_ttl (const struct ip_packet *const ip)
 Get the IPv4 Time To Live (TTL) or IPv6 Hop Limit (HL) of an IP packet. More...
 
void ip_set_ttl (struct ip_packet *const ip, const uint8_t value)
 Set the IPv4 Time To Live (TTL) or IPv6 Hop Limit (HL) of an IP packet. More...
 
void ip_set_saddr (struct ip_packet *const ip, const uint8_t *value)
 Set the Source Address of an IP packet. More...
 
void ip_set_daddr (struct ip_packet *const ip, const uint8_t *value)
 Set the Destination Address of an IP packet. More...
 

Detailed Description

IP-agnostic packet.

Author
Didier Barvaux didie.nosp@m.r.ba.nosp@m.rvaux.nosp@m.@tou.nosp@m.louse.nosp@m..viv.nosp@m.eris..nosp@m.com
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org

Function Documentation

◆ ip_get_protocol()

uint8_t ip_get_protocol ( const struct ip_packet *const  ip)

Get the protocol transported by an IP packet.

The protocol returned is the one transported by the last known IP extension header if any is found.

The function handles ip_packet whose ip_packet::version is IP_UNKNOWN. It always returns the special value 0.

Parameters
ipThe IP packet to analyze
Returns
The protocol number that identify the protocol transported by the given IP packet, 0 if the packet is not IPv4 nor IPv6

◆ ip_get_tos()

unsigned int ip_get_tos ( const struct ip_packet *const  ip)

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

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to analyze
Returns
The TOS or TC value if successful, 0 otherwise

◆ ip_get_ttl()

unsigned int ip_get_ttl ( const struct ip_packet *const  ip)

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

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to analyze
Returns
The TTL or HL value if successful, 0 otherwise

◆ ip_set_daddr()

void ip_set_daddr ( struct ip_packet *const  ip,
const uint8_t *  value 
)

Set the Destination Address of an IP packet.

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to modify
valueThe IP address value

◆ ip_set_protocol()

void ip_set_protocol ( struct ip_packet *const  ip,
const uint8_t  value 
)

Set the protocol transported by an IP packet.

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to modify
valueThe protocol value

◆ ip_set_saddr()

void ip_set_saddr ( struct ip_packet *const  ip,
const uint8_t *  value 
)

Set the Source Address of an IP packet.

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to modify
valueThe IP address value

◆ ip_set_tos()

void ip_set_tos ( struct ip_packet *const  ip,
const uint8_t  value 
)

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

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to modify
valueThe TOS/TC value

◆ ip_set_ttl()

void ip_set_ttl ( struct ip_packet *const  ip,
const uint8_t  value 
)

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

The function does not handle ip_packet whose ip_packet::version is IP_UNKNOWN.

Parameters
ipThe IP packet to modify
valueThe TTL/HL value

◆ ip_set_version()

void ip_set_version ( struct ip_packet *const  ip,
const ip_version  value 
)

Set the IP version of an IP packet.

Parameters
ipThe IP packet to modify
valueThe version value