IP-agnostic packet.
More...
#include "protocols/ipv4.h"
#include "protocols/ipv6.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
◆ ip_header_pos_t
The selected IP header
Enumerator |
---|
ROHC_IP_HDR_NONE | No IP header selected
|
ROHC_IP_HDR_FIRST | The first IP header is selected
|
ROHC_IP_HDR_SECOND | The second IP header is selected
|
◆ ip_version
IP version.
Enumerator |
---|
IPV4 | IP version 4.
|
IPV6 | IP version 6.
|
IP_UNKNOWN | not IP
|
IPV4_MALFORMED | IP version 4 (malformed)
|
IPV6_MALFORMED | IP version 6 (malformed)
|
◆ from32to16()
static uint16_t from32to16 |
( |
const uint32_t |
x | ) |
|
|
inlinestatic |
◆ ip_fast_csum()
static uint16_t ip_fast_csum |
( |
const uint8_t *const |
iph, |
|
|
const size_t |
ihl |
|
) |
| |
|
inlinestatic |
This is a version of ip_compute_csum() optimized for IP headers, which always checksum on 4 octet boundaries.
◆ 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
-
ip | The 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
-
ip | The 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
-
ip | The IP packet to analyze |
- Returns
- The TTL or HL value if successful, 0 otherwise
◆ ip_get_version()
◆ 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
-
ip | The IP packet to modify |
value | The 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
-
ip | The IP packet to modify |
value | The protocol value |
◆ ip_set_saddr()
void ip_set_saddr |
( |
struct ip_packet *const |
ip, |
|
|
const uint8_t * |
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
-
ip | The IP packet to modify |
value | The 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
-
ip | The IP packet to modify |
value | The TTL/HL value |
◆ ip_set_version()
Set the IP version of an IP packet.
- Parameters
-
ip | The IP packet to modify |
value | The version value |
◆ swab16()
static uint16_t swab16 |
( |
const uint16_t |
value | ) |
|
|
inlinestatic |
In-place change the byte order in a two-byte value.
- Parameters
-
value | The two-byte value to modify |
- Returns
- The same value with the byte order changed