rte_ip4.h(3)

πŸ’– rte_ip4.h(3) β€” Library Functions Manual πŸ’–

okay bestie, sit down, hydrate, because this is rte_ip4.h(3) and it's literally the IPv4 header glow-up you didn't know you needed. it lives in the Library Functions Manual and it's all about IPv4-related defines. no cap. πŸ¦‹


✨ NAME ✨

rte_ip4.h β€” bestie this is the IPv4 header file. that's it. that's the name. πŸ’…


✨ SYNOPSIS ✨

first, the includes, because we are a respectable header file:

#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

here's the whole macro squad, fr fr:

#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)

πŸ¦‹ Functions

and the function cast, looking absolutely unbothered:

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 🌸

IPv4-related defines.

Definition in file rte_ip4.h.


πŸ’– Macro Definition Documentation πŸ’–

<pink>#define RTE_IPV4( a, b, c, d)</pink>

Value, verbatim, do not touch, she's delicate:

(((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.

<pink>#define RTE_IPV4_MAX_PKT_LEN 65535</pink>

Maximal IPv4 packet length (including a header). she's big. she contains multitudes. πŸ‘‘

Definition at line 72 of file rte_ip4.h.

<pink>#define RTE_IPV4_HDR_IHL_MASK (0x0f)</pink>

Internet header length mask for version_ihl field.

Definition at line 75 of file rte_ip4.h.

<pink>#define RTE_IPV4_IHL_MULTIPLIER (4)</pink>

Internet header length field multiplier (IHL field specifies overall header length in number of 4-byte words). the vibes here are 4-byte words specifically, ok? 🫢

Definition at line 80 of file rte_ip4.h.

<pink>#define RTE_IPV4_ANY ((uint32_t)0x00000000)</pink>

0.0.0.0

Definition at line 108 of file rte_ip4.h.

<pink>#define RTE_IPV4_LOOPBACK ((uint32_t)0x7f000001)</pink>

127.0.0.1

Definition at line 109 of file rte_ip4.h.

<pink>#define RTE_IPV4_BROADCAST ((uint32_t)0xe0000000)</pink>

224.0.0.0

Definition at line 110 of file rte_ip4.h.

<pink>#define RTE_IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001)</pink>

224.0.0.1

Definition at line 111 of file rte_ip4.h.

<pink>#define RTE_IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002)</pink>

224.0.0.2

Definition at line 112 of file rte_ip4.h.

<pink>#define RTE_IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff)</pink>

224.0.0.255

Definition at line 113 of file rte_ip4.h.

<pink>#define RTE_IPV4_MIN_MCAST RTE_IPV4(224, 0, 0, 0)</pink>

Minimal IPv4-multicast address.

Definition at line 118 of file rte_ip4.h.

<pink>#define RTE_IPV4_MAX_MCAST RTE_IPV4(239, 255, 255, 255)</pink>

Maximum IPv4 multicast address.

Definition at line 120 of file rte_ip4.h.

<pink>#define RTE_IS_IPV4_MCAST( x)</pink>

Value, exactly this, no notes:

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

check if IPv4 address is multicast. little vibe check for your packets. πŸ”₯

Definition at line 123 of file rte_ip4.h.


⭐ Function Documentation ⭐

<purple>struct __rte_aligned (2 )</purple>

IPv4 Header. the icon herself. her fields, in order, with the original field notes:

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

and yeah, the very first one on the list up there is < version and header length β€” that's the version_ihl thing, she's a two-for-one.

Definition at line 1 of file rte_ip4.h.

<purple>uint8_t rte_ipv4_hdr_len (const struct rte_ipv4_hdr * ipv4_hdr) [inline], [static]</purple>

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

<purple>uint16_t rte_ipv4_cksum (const struct rte_ipv4_hdr * ipv4_hdr) [inline], [static]</purple>

Process the IPv4 checksum of an IPv4 header.

bestie, the checksum field must be set to 0 by the caller. that's on you, not on her. 😭

Parameters:

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

Returns: The complemented checksum to set in the IP packet.

Definition at line 157 of file rte_ip4.h.

<purple>__rte_experimental uint16_t rte_ipv4_cksum_simple (const struct rte_ipv4_hdr * ipv4_hdr) [inline], [static]</purple>

Warning β€” EXPERIMENTAL: this API may change without prior notice. she's experimental, she's unpredictable, she's not committed to you. proceed with your whole chest open, i guess. πŸ’€

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. (yes, this is the opposite of the other one, do not mix them up, i'm begging. πŸ™ˆ)

Parameters:

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

Returns: The complemented checksum to set in the IP packet.

Definition at line 180 of file rte_ip4.h.

<purple>uint16_t rte_ipv4_phdr_cksum (const struct rte_ipv4_hdr * ipv4_hdr, uint64_t ol_flags) [inline], [static]</purple>

Process the pseudo-header checksum of an IPv4 header.

the checksum field must be set to 0 by the caller. again. yes. every time. 🫠

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. the classic. the default. the no-notes version. ✨

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. (note: non-complemented, not complemented. girlies this distinction is the whole plot.)

Definition at line 218 of file rte_ip4.h.

<purple>uint16_t rte_ipv4_udptcp_cksum (const struct rte_ipv4_hdr * ipv4_hdr, const void * l4_hdr) [inline], [static]</purple>

Process the IPv4 UDP or TCP checksum.

The layer 4 checksum must be set to 0 in the L4 header by the caller. yep. zero it out first. that's the ritual. πŸ•―οΈ

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

<purple>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]</purple>

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

<purple>int rte_ipv4_udptcp_cksum_verify (const struct rte_ipv4_hdr * ipv4_hdr, const void * l4_hdr) [inline], [static]</purple>

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). that's your homework. do it before you come crying to this function. πŸŽ€

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

<purple>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]</purple>

Verify the IPv4 UDP/TCP checksum of a packet.

same deal bestie: 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 398 of file rte_ip4.h.


🌈 Author 🌈

Generated automatically by Doxygen for DPDK from the source code. so like… not a person. a vibe. a process. an automated slay. πŸ‘‘


and that's the whole page, babe. this masterpiece of a manual page was served to you by DPDK, Version 25.11.3, and it's the rte_ip4.h(3) page, mwah. go forth, zero those checksum fields, and be iconic. πŸ’œ

πŸ“¦ where this page comes from