rte_ip4.h(3)

πŸ¦‹ rte_ip4.h(3)

Okay bestie, this is the DPDK manual page for rte_ip4.h β€” yes, the iconic IPv4 header header. It's giving "all the IPv4-related defines" and we're gonna walk through every macro, every function, every line number, no cap. πŸ’…βœ¨

NAME

rte_ip4.h

SYNOPSIS

First up, the include besties:

#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_cksum.h>
#include <rte_mbuf.h>

Macros

#define RTE_IPV4(a,  b,  c,  d)
#define RTE_IPV4_MAX_PKT_LEN   65535
#define RTE_IPV4_HDR_IHL_MASK   (0x0f)
#define RTE_IPV4_IHL_MULTIPLIER   (4)
#define RTE_IPV4_ANY   ((uint32_t)0x00000000)
#define RTE_IPV4_LOOPBACK   ((uint32_t)0x7f000001)
#define RTE_IPV4_BROADCAST   ((uint32_t)0xe0000000)
#define RTE_IPV4_ALLHOSTS_GROUP   ((uint32_t)0xe0000001)
#define RTE_IPV4_ALLRTRS_GROUP   ((uint32_t)0xe0000002)
#define RTE_IPV4_MAX_LOCAL_GROUP   ((uint32_t)0xe00000ff)
#define RTE_IPV4_MIN_MCAST    RTE_IPV4(224, 0, 0, 0)
#define RTE_IPV4_MAX_MCAST    RTE_IPV4(239, 255, 255, 255)
#define RTE_IS_IPV4_MCAST(x)       ((x) >= RTE_IPV4_MIN_MCAST && (x) <=
    RTE_IPV4_MAX_MCAST)

Functions

And here are the function signatures, copied exactly because we do not play with source code around here:

struct __rte_aligned (2) __rte_packed_begin rte_ipv4_hdr
static uint8_t rte_ipv4_hdr_len (const struct rte_ipv4_hdr *ipv4_hdr)
static uint16_t rte_ipv4_cksum (const struct rte_ipv4_hdr *ipv4_hdr)
static __rte_experimental uint16_t rte_ipv4_cksum_simple (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 uint16_t rte_ipv4_udptcp_cksum_mbuf (const struct rte_mbuf *m,
    const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off)
static int rte_ipv4_udptcp_cksum_verify (const struct rte_ipv4_hdr
    *ipv4_hdr, const void *l4_hdr)
static int rte_ipv4_udptcp_cksum_mbuf_verify (const struct rte_mbuf *m,
    const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off)

Detailed Description

It's all the IPv4-related defines, bestie.

Definition in file rte_ip4.h.


Macro Definition Documentation

#define RTE_IPV4(a, b, c, d)

Value:

(((uint32_t)((a) & 0xff) << 24) | ((uint32_t)((b) & 0xff) << 16) |     ((uint32_t)((c) & 0xff) << 8) | ((uint32_t)((d) & 0xff)))

Create IPv4 address.

Definition at line 68 of file rte_ip4.h.

#define RTE_IPV4_MAX_PKT_LEN 65535

Maximal IPv4 packet length (including a header).

Definition at line 72 of file rte_ip4.h.

#define RTE_IPV4_HDR_IHL_MASK (0x0f)

Internet header length mask for version_ihl field.

Definition at line 75 of file rte_ip4.h.

#define RTE_IPV4_IHL_MULTIPLIER (4)

Internet header length field multiplier (IHL field specifies overall header length in number of 4-byte words).

Definition at line 80 of file rte_ip4.h.

#define RTE_IPV4_ANY ((uint32_t)0x00000000)

0.0.0.0

Definition at line 108 of file rte_ip4.h.

#define RTE_IPV4_LOOPBACK ((uint32_t)0x7f000001)

127.0.0.1

Definition at line 109 of file rte_ip4.h.

#define RTE_IPV4_BROADCAST ((uint32_t)0xe0000000)

224.0.0.0

Definition at line 110 of file rte_ip4.h.

#define RTE_IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001)

224.0.0.1

Definition at line 111 of file rte_ip4.h.

#define RTE_IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002)

224.0.0.2

Definition at line 112 of file rte_ip4.h.

#define RTE_IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff)

224.0.0.255

Definition at line 113 of file rte_ip4.h.

#define RTE_IPV4_MIN_MCAST RTE_IPV4(224, 0, 0, 0)

Minimal IPv4-multicast address.

Definition at line 119 of file rte_ip4.h.

#define RTE_IPV4_MAX_MCAST RTE_IPV4(239, 255, 255, 255)

Maximum IPv4 multicast address.

Definition at line 121 of file rte_ip4.h.

#define RTE_IS_IPV4_MCAST(x)

((x) >= RTE_IPV4_MIN_MCAST && (x) <=
    RTE_IPV4_MAX_MCAST)

check if IPv4 address is multicast.

Definition at line 127 of file rte_ip4.h.


Function Documentation

struct __rte_aligned (2)

Here's the header struct moment: struct __rte_aligned (2) __rte_packed_begin rte_ipv4_hdr. The field lines are exactly these, bestie:

  • IPv4 Header < version and header length
  • < header length
  • < version
  • < type of service
  • < length of packet
  • < packet ID
  • < fragmentation offset
  • < time to live
  • < protocol ID
  • < header checksum
  • < source address
  • < destination address

Definition at line 1 of file rte_ip4.h.

rte_ipv4_hdr_len

static uint8_t rte_ipv4_hdr_len (const struct rte_ipv4_hdr * ipv4_hdr)

[inline], [static]

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.

Definition at line 142 of file rte_ip4.h.

rte_ipv4_cksum

static uint16_t rte_ipv4_cksum (const struct rte_ipv4_hdr * ipv4_hdr)

[inline], [static]

Process the IPv4 checksum of an IPv4 header.

The checksum field must be set to 0 by the caller.

Parameters:

  • ipv4_hdr β€” The pointer to the contiguous IPv4 header.

Returns:

The complemented checksum to set in the IP packet.

Definition at line 159 of file rte_ip4.h.

rte_ipv4_cksum_simple

static __rte_experimental uint16_t rte_ipv4_cksum_simple (const struct
    rte_ipv4_hdr * ipv4_hdr)

[inline], [static]

⚠️ Warning: EXPERIMENTAL: this API may change without prior notice.

Process the IPv4 checksum of an IPv4 header without any extensions.

The checksum field does NOT have to be set by the caller, the field is skipped by the calculation.

Parameters:

  • ipv4_hdr β€” The pointer to the contiguous IPv4 header.

Returns:

The complemented checksum to set in the IP packet.

Definition at line 182 of file rte_ip4.h.

rte_ipv4_phdr_cksum

static uint16_t rte_ipv4_phdr_cksum (const struct rte_ipv4_hdr * ipv4_hdr,
    uint64_t ol_flags)

[inline], [static]

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.

Definition at line 220 of file rte_ip4.h.

rte_ipv4_udptcp_cksum

static uint16_t rte_ipv4_udptcp_cksum (const struct rte_ipv4_hdr * ipv4_hdr,
    const void * l4_hdr)

[inline], [static]

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 284 of file rte_ip4.h.

rte_ipv4_udptcp_cksum_mbuf

static uint16_t rte_ipv4_udptcp_cksum_mbuf (const struct rte_mbuf * m, const
    struct rte_ipv4_hdr * ipv4_hdr, uint16_t l4_off)

[inline], [static]

Compute the IPv4 UDP/TCP checksum of a packet.

Parameters:

  • m β€” The pointer to the mbuf.
  • ipv4_hdr β€” The pointer to the contiguous IPv4 header.
  • l4_off β€” The offset in bytes to start L4 checksum.

Returns:

The complemented checksum to set in the L4 header.

Definition at line 341 of file rte_ip4.h.

rte_ipv4_udptcp_cksum_verify

static int rte_ipv4_udptcp_cksum_verify (const struct rte_ipv4_hdr *
    ipv4_hdr, const void * l4_hdr)

[inline], [static]

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 373 of file rte_ip4.h.

rte_ipv4_udptcp_cksum_mbuf_verify

static int rte_ipv4_udptcp_cksum_mbuf_verify (const struct rte_mbuf * m,
    const struct rte_ipv4_hdr * ipv4_hdr, uint16_t l4_off)

[inline], [static]

Verify the IPv4 UDP/TCP checksum of a packet.

In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0 (i.e. no checksum).

Parameters:

  • m β€” The pointer to the mbuf.
  • ipv4_hdr β€” The pointer to the contiguous IPv4 header.
  • l4_off β€” The offset in bytes to start L4 checksum.

Returns:

Return 0 if the checksum is correct, else -1.

Definition at line 400 of file rte_ip4.h.


Author

Generated automatically by Doxygen for DPDK from the source code.

πŸ’– That's the whole rte_ip4.h(3) source page, DPDK Version 25.11.0, dated Fri Jan 30 2026. Bye bestie, go make those checksums iconic! πŸ’…βœ¨

πŸ“¦ where this page comes from