#include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <rte_byteorder.h>
#include <rte_mbuf.h>
Go to the source code of this file.
|
static uint8_t | rte_ipv4_hdr_len (const struct rte_ipv4_hdr *ipv4_hdr) |
|
static uint16_t | rte_raw_cksum (const void *buf, size_t len) |
|
static int | rte_raw_cksum_mbuf (const struct rte_mbuf *m, uint32_t off, uint32_t len, uint16_t *cksum) |
|
static uint16_t | rte_ipv4_cksum (const struct rte_ipv4_hdr *ipv4_hdr) |
|
static uint16_t | rte_ipv4_phdr_cksum (const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags) |
|
static uint16_t | rte_ipv4_udptcp_cksum (const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) |
|
static __rte_experimental int | rte_ipv4_udptcp_cksum_verify (const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) |
|
static uint16_t | rte_ipv6_phdr_cksum (const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags) |
|
static uint16_t | rte_ipv6_udptcp_cksum (const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) |
|
static __rte_experimental int | rte_ipv6_udptcp_cksum_verify (const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) |
|
static __rte_experimental int | rte_ipv6_get_next_ext (const uint8_t *p, int proto, size_t *ext_len) |
|
IP-related defines
Definition in file rte_ip.h.
◆ RTE_IPV4
#define RTE_IPV4 |
( |
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
d |
|
) |
| |
◆ RTE_IPV4_MAX_PKT_LEN
#define RTE_IPV4_MAX_PKT_LEN 65535 |
◆ RTE_IPV4_HDR_IHL_MASK
#define RTE_IPV4_HDR_IHL_MASK (0x0f) |
◆ RTE_IPV4_IHL_MULTIPLIER
#define RTE_IPV4_IHL_MULTIPLIER (4) |
◆ RTE_IPV4_ANY
#define RTE_IPV4_ANY ((uint32_t)0x00000000) |
◆ RTE_IPV4_LOOPBACK
#define RTE_IPV4_LOOPBACK ((uint32_t)0x7f000001) |
◆ RTE_IPV4_BROADCAST
#define RTE_IPV4_BROADCAST ((uint32_t)0xe0000000) |
◆ RTE_IPV4_ALLHOSTS_GROUP
#define RTE_IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001) |
◆ RTE_IPV4_ALLRTRS_GROUP
#define RTE_IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002) |
◆ RTE_IPV4_MAX_LOCAL_GROUP
#define RTE_IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff) |
◆ RTE_IPV4_MIN_MCAST
#define RTE_IPV4_MIN_MCAST RTE_IPV4(224, 0, 0, 0) |
Minimal IPv4-multicast address
Definition at line 114 of file rte_ip.h.
◆ RTE_IPV4_MAX_MCAST
#define RTE_IPV4_MAX_MCAST RTE_IPV4(239, 255, 255, 255) |
Maximum IPv4 multicast address
Definition at line 116 of file rte_ip.h.
◆ RTE_IS_IPV4_MCAST
◆ RTE_IPV6_MIN_MTU
#define RTE_IPV6_MIN_MTU 1280 |
Minimum MTU for IPv6, see RFC 8200.
Definition at line 455 of file rte_ip.h.
◆ RTE_IPV6_EHDR_MF_SHIFT
#define RTE_IPV6_EHDR_MF_SHIFT 0 |
IPv6 fragment extension header.
Definition at line 574 of file rte_ip.h.
◆ rte_ipv4_hdr_len()
static uint8_t rte_ipv4_hdr_len |
( |
const struct rte_ipv4_hdr * |
ipv4_hdr | ) |
|
|
inlinestatic |
Get the length of an IPv4 header.
- Parameters
-
ipv4_hdr | Pointer to the IPv4 header. |
- Returns
- The length of the IPv4 header (with options if present) in bytes.
- Examples
- examples/l3fwd/l3fwd_em.c.
Definition at line 137 of file rte_ip.h.
◆ rte_raw_cksum()
static uint16_t rte_raw_cksum |
( |
const void * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
Process the non-complemented checksum of a buffer.
- Parameters
-
buf | Pointer to the buffer. |
len | Length of the buffer. |
- Returns
- The non-complemented checksum.
Definition at line 208 of file rte_ip.h.
◆ rte_raw_cksum_mbuf()
static int rte_raw_cksum_mbuf |
( |
const struct rte_mbuf * |
m, |
|
|
uint32_t |
off, |
|
|
uint32_t |
len, |
|
|
uint16_t * |
cksum |
|
) |
| |
|
inlinestatic |
Compute the raw (non complemented) checksum of a packet.
- Parameters
-
m | The pointer to the mbuf. |
off | The offset in bytes to start the checksum. |
len | The length in bytes of the data to checksum. |
cksum | A pointer to the checksum, filled on success. |
- Returns
- 0 on success, -1 on error (bad length or offset).
Definition at line 231 of file rte_ip.h.
◆ rte_ipv4_cksum()
static uint16_t rte_ipv4_cksum |
( |
const struct rte_ipv4_hdr * |
ipv4_hdr | ) |
|
|
inlinestatic |
◆ rte_ipv4_phdr_cksum()
static uint16_t rte_ipv4_phdr_cksum |
( |
const struct rte_ipv4_hdr * |
ipv4_hdr, |
|
|
uint64_t |
ol_flags |
|
) |
| |
|
inlinestatic |
Process the pseudo-header checksum of an IPv4 header.
The checksum field must be set to 0 by the caller.
Depending on the ol_flags, the pseudo-header checksum expected by the drivers is not the same. For instance, when TSO is enabled, the IP payload length must not be included in the packet.
When ol_flags is 0, it computes the standard pseudo-header checksum.
- Parameters
-
ipv4_hdr | The pointer to the contiguous IPv4 header. |
ol_flags | The ol_flags of the associated mbuf. |
- Returns
- The non-complemented checksum to set in the L4 header.
- Examples
- examples/vhost/main.c.
Definition at line 327 of file rte_ip.h.
◆ rte_ipv4_udptcp_cksum()
static uint16_t rte_ipv4_udptcp_cksum |
( |
const struct rte_ipv4_hdr * |
ipv4_hdr, |
|
|
const void * |
l4_hdr |
|
) |
| |
|
inlinestatic |
Process the IPv4 UDP or TCP checksum.
The layer 4 checksum must be set to 0 in the L4 header by the caller.
- Parameters
-
ipv4_hdr | The pointer to the contiguous IPv4 header. |
l4_hdr | The pointer to the beginning of the L4 header. |
- Returns
- The complemented checksum to set in the L4 header.
Definition at line 391 of file rte_ip.h.
◆ rte_ipv4_udptcp_cksum_verify()
static __rte_experimental int rte_ipv4_udptcp_cksum_verify |
( |
const struct rte_ipv4_hdr * |
ipv4_hdr, |
|
|
const void * |
l4_hdr |
|
) |
| |
|
inlinestatic |
Validate the IPv4 UDP or TCP checksum.
In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0 (i.e. no checksum).
- Parameters
-
ipv4_hdr | The pointer to the contiguous IPv4 header. |
l4_hdr | The pointer to the beginning of the L4 header. |
- Returns
- Return 0 if the checksum is correct, else -1.
Definition at line 423 of file rte_ip.h.
◆ rte_ipv6_phdr_cksum()
static uint16_t rte_ipv6_phdr_cksum |
( |
const struct rte_ipv6_hdr * |
ipv6_hdr, |
|
|
uint64_t |
ol_flags |
|
) |
| |
|
inlinestatic |
Process the pseudo-header checksum of an IPv6 header.
Depending on the ol_flags, the pseudo-header checksum expected by the drivers is not the same. For instance, when TSO is enabled, the IPv6 payload length must not be included in the packet.
When ol_flags is 0, it computes the standard pseudo-header checksum.
- Parameters
-
ipv6_hdr | The pointer to the contiguous IPv6 header. |
ol_flags | The ol_flags of the associated mbuf. |
- Returns
- The non-complemented checksum to set in the L4 header.
- Examples
- examples/vhost/main.c.
Definition at line 474 of file rte_ip.h.
◆ rte_ipv6_udptcp_cksum()
static uint16_t rte_ipv6_udptcp_cksum |
( |
const struct rte_ipv6_hdr * |
ipv6_hdr, |
|
|
const void * |
l4_hdr |
|
) |
| |
|
inlinestatic |
Process the IPv6 UDP or TCP checksum.
The IPv6 header must not be followed by extension headers. The layer 4 checksum must be set to 0 in the L4 header by the caller.
- Parameters
-
ipv6_hdr | The pointer to the contiguous IPv6 header. |
l4_hdr | The pointer to the beginning of the L4 header. |
- Returns
- The complemented checksum to set in the L4 header.
Definition at line 529 of file rte_ip.h.
◆ rte_ipv6_udptcp_cksum_verify()
static __rte_experimental int rte_ipv6_udptcp_cksum_verify |
( |
const struct rte_ipv6_hdr * |
ipv6_hdr, |
|
|
const void * |
l4_hdr |
|
) |
| |
|
inlinestatic |
Validate the IPv6 UDP or TCP checksum.
In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0: this is either invalid or means no checksum in some situations. See 8.1 (Upper-Layer Checksums) in RFC 8200.
- Parameters
-
ipv6_hdr | The pointer to the contiguous IPv6 header. |
l4_hdr | The pointer to the beginning of the L4 header. |
- Returns
- Return 0 if the checksum is correct, else -1.
Definition at line 562 of file rte_ip.h.
◆ rte_ipv6_get_next_ext()
static __rte_experimental int rte_ipv6_get_next_ext |
( |
const uint8_t * |
p, |
|
|
int |
proto, |
|
|
size_t * |
ext_len |
|
) |
| |
|
inlinestatic |
Parse next IPv6 header extension
This function checks if proto number is an IPv6 extensions and parses its data if so, providing information on next header and extension length.
- Parameters
-
p | Pointer to an extension raw data. |
proto | Protocol number extracted from the "next header" field from the IPv6 header or the previous extension. |
ext_len | Extension data length. |
- Returns
- next protocol number if proto is an IPv6 extension, -EINVAL otherwise
- Examples
- examples/ipsec-secgw/ipsec-secgw.c.
Definition at line 616 of file rte_ip.h.