rte_ip4.h(3)

πŸ“¦
version 24.11.8 Β· 3 versions
, in debian trixie

πŸ’– rte_ip4.h β€” like, the IPv4 era of DPDK, bestie πŸ’–

okay so welcome to rte_ip4.h(3), a Library Functions Manual situation, and it's giving networking. everything IPv4-flavored in DPDK lives here and honestly? she's iconic. let's go πŸ¦‹


✨ NAME ✨

rte_ip4.h β€” that's her. that's the whole name. short, sweet, slays.


✨ SYNOPSIS ✨

first things first, you gotta invite the whole friend group in:

#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_IPV4_MIN_IHL (0x5)

🌸 Functions

struct __rte_aligned (2) 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 β€” that's it, that's the vibe. everything IPv4-coded lives right here.

Definition in file rte_ip4.h.

✨ Macro Definition Documentation ✨

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

the Value is:

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

Create IPv4 address β€” yes bestie, you feed it four octets and it hands you back a whole uint32_t. main character energy fr.

Definition at line 68 of file rte_ip4.h.

🌈 #define RTE_IPV4_MAX_PKT_LEN 65535

Maximal IPv4 packet length (including a header) β€” the absolute biggest she can be, header and all.

Definition at line 74 of file rte_ip4.h.

🌈 #define RTE_IPV4_HDR_IHL_MASK (0x0f)

Internet header length mask for version_ihl field β€” this is the lil mask that pulls the IHL out of the version_ihl field.

Definition at line 77 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) β€” so the IHL field counts in 4-byte words, and this is the number you multiply by to get actual bytes. math is mathing πŸ’…

Definition at line 82 of file rte_ip4.h.

🌈 #define RTE_IPV4_ANY ((uint32_t)0x00000000)

0.0.0.0 β€” the classic "anywhere, nowhere, whatever" address.

Definition at line 110 of file rte_ip4.h.

🌈 #define RTE_IPV4_LOOPBACK ((uint32_t)0x7f000001)

127.0.0.1 β€” it's giving home. the address that always knows you back.

Definition at line 111 of file rte_ip4.h.

🌈 #define RTE_IPV4_BROADCAST ((uint32_t)0xe0000000)

224.0.0.0 β€” loud and proud.

Definition at line 112 of file rte_ip4.h.

🌈 #define RTE_IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001)

224.0.0.1 β€” every host in the group, we're all here bestie.

Definition at line 113 of file rte_ip4.h.

🌈 #define RTE_IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002)

224.0.0.2 β€” all the routers, roll call 🫢

Definition at line 114 of file rte_ip4.h.

🌈 #define RTE_IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff)

224.0.0.255 β€” the last of the local-scope groupies.

Definition at line 115 of file rte_ip4.h.

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

Minimal IPv4-multicast address β€” the smallest multicast address that exists.

Definition at line 121 of file rte_ip4.h.

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

Maximum IPv4 multicast address β€” and the biggest one. maxed out, no cap 🌈

Definition at line 123 of file rte_ip4.h.

🌈 #define RTE_IPV4_MIN_IHL (0x5)

< check if IPv4 address is multicast β€” yeah the comment in the source really does just start with a <, we don't make the rules, we just document them. anyway: it's the minimum IHL value.

Definition at line 130 of file rte_ip4.h.

✨ Function Documentation ✨

πŸŽ€ struct __rte_aligned (2)

the IPv4 Header, and her little field annotations, in order:

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

πŸŽ€ 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.

πŸŽ€ 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. like, you GOTTA zero it out first, that's the deal.

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.

πŸŽ€ 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. πŸ’€ bestie do NOT build your whole personality on this one, she may shapeshift.

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

and here's the glow-up: the checksum field does NOT have to be set by the caller, the field is skipped by the calculation. so much easier, obsessed.

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.

πŸŽ€ 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. (again! zero it!)

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. so like, context matters, iykyk.

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.

πŸŽ€ 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. yes king, zero that field first.

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.

πŸŽ€ 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.

πŸŽ€ 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). don't skip that step bestie, it's important 🫢

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.

πŸŽ€ 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). same energy as above, same required check.

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. β€” so like, nobody hand-wrote this, the robot did it, and honestly the robot ate πŸ”₯


and that's the whole page bestie!! we did it πŸŽ€ this one came from DPDK, Version 24.11.8, and it's the rte_ip4.h(3) page, mwah, drink some water πŸ’–βœ¨

πŸ“¦ where this page comes from