rte_ether.h(3)

πŸ’– rte_ether.h πŸ’– β€” from the Library Functions Manual

okay bestie, sit down, hydrate, because this is the Ethernet helpers header from DPDK and it is a lot in the best way. Every MAC address, every ethertype, every little VLAN byte β€” it's all here. no cap. πŸ¦‹


✨ NAME ✨

rte_ether.h β€” literally the whole Ethernet toolbox, living in a header file πŸ’…


✨ SYNOPSIS ✨

#include <assert.h>
#include <stdalign.h>
#include <stdint.h>
#include <stdio.h>
#include <rte_random.h>
#include <rte_mbuf.h>
#include <rte_byteorder.h>

πŸŽ€ Data Structures

  • struct rte_ether_hdr
  • struct rte_vlan_hdr

πŸŽ€ Macros

#define RTE_ETHER_ADDR_LEN   6
#define RTE_ETHER_TYPE_LEN   2
#define RTE_ETHER_CRC_LEN   4
#define RTE_ETHER_HDR_LEN
#define RTE_ETHER_MIN_LEN   64
#define RTE_ETHER_MAX_LEN   1518
#define RTE_ETHER_MTU
#define RTE_VLAN_HLEN   4
#define RTE_ETHER_MAX_VLAN_FRAME_LEN       (RTE_ETHER_MAX_LEN +
    RTE_VLAN_HLEN)
#define RTE_ETHER_MAX_JUMBO_FRAME_LEN       0x3F00
#define RTE_ETHER_MAX_VLAN_ID   4095
#define RTE_ETHER_MIN_MTU   68
#define RTE_ETHER_LOCAL_ADMIN_ADDR   0x02
#define RTE_ETHER_GROUP_ADDR   0x01
#define RTE_ETHER_ADDR_PRT_FMT   '%02X:%02X:%02X:%02X:%02X:%02X'
#define RTE_ETHER_ADDR_BYTES(mac_addrs)
#define RTE_ETHER_TYPE_IPV4   0x0800
#define RTE_ETHER_TYPE_IPV6   0x86DD
#define RTE_ETHER_TYPE_ARP   0x0806
#define RTE_ETHER_TYPE_RARP   0x8035
#define RTE_ETHER_TYPE_VLAN   0x8100
#define RTE_ETHER_TYPE_QINQ   0x88A8
#define RTE_ETHER_TYPE_QINQ1   0x9100
#define RTE_ETHER_TYPE_QINQ2   0x9200
#define RTE_ETHER_TYPE_QINQ3   0x9300
#define RTE_ETHER_TYPE_PPPOE_DISCOVERY   0x8863
#define RTE_ETHER_TYPE_PPPOE_SESSION   0x8864
#define RTE_ETHER_TYPE_ETAG   0x893F
#define RTE_ETHER_TYPE_1588   0x88F7
#define RTE_ETHER_TYPE_SLOW   0x8809
#define RTE_ETHER_TYPE_TEB   0x6558
#define RTE_ETHER_TYPE_LLDP   0x88CC
#define RTE_ETHER_TYPE_MPLS   0x8847
#define RTE_ETHER_TYPE_MPLSM   0x8848
#define RTE_ETHER_TYPE_ECPRI   0xAEFE

πŸŽ€ Functions

struct __rte_aligned (2) rte_ether_addr
static int rte_is_same_ether_addr (const struct rte_ether_addr *ea1,
    const struct rte_ether_addr *ea2)
static int rte_is_zero_ether_addr (const struct rte_ether_addr *ea)
static int rte_is_unicast_ether_addr (const struct rte_ether_addr *ea)
static int rte_is_multicast_ether_addr (const struct rte_ether_addr *ea)
static int rte_is_broadcast_ether_addr (const struct rte_ether_addr *ea)
static int rte_is_universal_ether_addr (const struct rte_ether_addr *ea)
static int rte_is_local_admin_ether_addr (const struct rte_ether_addr
    *ea)
static int rte_is_valid_assigned_ether_addr (const struct rte_ether_addr
    *ea)
void rte_eth_random_addr (uint8_t *addr)
static void rte_ether_addr_copy (const struct rte_ether_addr *__restrict
    ea_from, struct rte_ether_addr *__restrict ea_to)
void rte_ether_format_addr (char *buf, uint16_t size, const struct
    rte_ether_addr *eth_addr)
int rte_ether_unformat_addr (const char *str, struct rte_ether_addr
    *eth_addr)
static int rte_vlan_strip (struct rte_mbuf *m)
static int rte_vlan_insert (struct rte_mbuf **m)

✨ Detailed Description ✨

Ethernet Helpers in RTE 🫢

Definition in file rte_ether.h.


✨ Macro Definition Documentation ✨

🌸 #define RTE_ETHER_ADDR_LEN 6

How long an Ethernet address is. that's it, that's the number. six bytes of pure identity πŸ’«

Definition at line 27 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_LEN 2

How long the Ethernet type field is. two bytes, tiny but mighty.

Definition at line 28 of file rte_ether.h.

🌸 #define RTE_ETHER_CRC_LEN 4

How long the Ethernet CRC is. four bytes of "did this survive the trip" energy πŸ”₯

Definition at line 29 of file rte_ether.h.

🌸 #define RTE_ETHER_HDR_LEN

Value:

(RTE_ETHER_ADDR_LEN * 2 + \
    RTE_ETHER_TYPE_LEN)

How long the Ethernet header is β€” both addresses plus the type field, added up for you so you never have to do math at 3am πŸŒ™

Definition at line 30 of file rte_ether.h.

🌸 #define RTE_ETHER_MIN_LEN 64

Smallest frame length out there, CRC included. baby frame. so small. iconic.

Definition at line 33 of file rte_ether.h.

🌸 #define RTE_ETHER_MAX_LEN 1518

Biggest frame length, CRC included. she's large and in charge πŸ‘‘

Definition at line 34 of file rte_ether.h.

🌸 #define RTE_ETHER_MTU

Value:

(RTE_ETHER_MAX_LEN - RTE_ETHER_HDR_LEN - \
    RTE_ETHER_CRC_LEN)

The Ethernet MTU, which is just the max length minus the header minus the CRC. subtraction slay ✨

Definition at line 35 of file rte_ether.h.

🌸 #define RTE_VLAN_HLEN 4

How long a VLAN (IEEE 802.1Q) header is. four bytes of tagging, iykyk 🏷️

Definition at line 39 of file rte_ether.h.

🌸 #define RTE_ETHER_MAX_VLAN_FRAME_LEN (RTE_ETHER_MAX_LEN + RTE_VLAN_HLEN)

Biggest VLAN frame length (and no, QinQ does not count here), CRC included.

Definition at line 41 of file rte_ether.h.

🌸 #define RTE_ETHER_MAX_JUMBO_FRAME_LEN 0x3F00

Biggest Jumbo frame length, CRC included. jumbo. enormous. the main character of frames 🐘

Definition at line 44 of file rte_ether.h.

🌸 #define RTE_ETHER_MAX_VLAN_ID 4095

The highest VLAN ID you can have. that's the ceiling, bestie.

Definition at line 47 of file rte_ether.h.

🌸 #define RTE_ETHER_MIN_MTU 68

Smallest MTU for IPv4 packets β€” and yes, this one comes straight from RFC 791, we do not make the rules πŸ“œ

Definition at line 49 of file rte_ether.h.

🌸 #define RTE_ETHER_LOCAL_ADMIN_ADDR 0x02

An address that's locally assigned. homegrown. artisanal. πŸŽ€

Definition at line 85 of file rte_ether.h.

🌸 #define RTE_ETHER_GROUP_ADDR 0x01

A multicast or broadcast Ethernet address β€” she's talking to everyone, not just you πŸ’Œ

Definition at line 86 of file rte_ether.h.

🌸 #define RTE_ETHER_ADDR_PRT_FMT '%02X:%02X:%02X:%02X:%02X:%02X'

A macro for printing all six bytes of a MAC address in hex format. you want the pretty AA:BB:CC:DD:EE:FF look? this is her πŸ’…

Definition at line 248 of file rte_ether.h.

🌸 #define RTE_ETHER_ADDR_BYTES( mac_addrs)

Value:

                     ((mac_addrs)->addr_bytes[0]), \
                     ((mac_addrs)->addr_bytes[1]), \
                     ((mac_addrs)->addr_bytes[2]), \
                     ((mac_addrs)->addr_bytes[3]), \
                     ((mac_addrs)->addr_bytes[4]), \
                     ((mac_addrs)->addr_bytes[5])

A macro that yoinks the MAC address bytes right out of a rte_ether_addr struct, so you can hand them to a printf and go 🎀

Definition at line 252 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_IPV4 0x0800

IPv4 Protocol.

Definition at line 329 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_IPV6 0x86DD

IPv6 Protocol.

Definition at line 330 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_ARP 0x0806

Arp Protocol.

Definition at line 331 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_RARP 0x8035

Reverse Arp Protocol.

Definition at line 332 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_VLAN 0x8100

IEEE 802.1Q VLAN tagging.

Definition at line 333 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_QINQ 0x88A8

IEEE 802.1ad QinQ tagging.

Definition at line 334 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_QINQ1 0x9100

Deprecated QinQ VLAN. she's retired, show some respect 🫑

Definition at line 335 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_QINQ2 0x9200

Deprecated QinQ VLAN. also retired. also respected.

Definition at line 336 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_QINQ3 0x9300

Deprecated QinQ VLAN. the third one. yes, all three are deprecated.

Definition at line 337 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_PPPOE_DISCOVERY 0x8863

PPPoE Discovery Stage.

Definition at line 338 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_PPPOE_SESSION 0x8864

PPPoE Session Stage.

Definition at line 339 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_ETAG 0x893F

IEEE 802.1BR E-Tag.

Definition at line 340 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_1588 0x88F7

IEEE 802.1AS 1588 Precise Time Protocol. precision. clock. timing. πŸ’«

Definition at line 341 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_SLOW 0x8809

Slow protocols β€” LACP and Marker, to be exact. no rush, bestie 🐒

Definition at line 343 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_TEB 0x6558

Transparent Ethernet Bridging.

Definition at line 344 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_LLDP 0x88CC

LLDP Protocol.

Definition at line 345 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_MPLS 0x8847

MPLS ethertype.

Definition at line 346 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_MPLSM 0x8848

MPLS multicast ethertype.

Definition at line 347 of file rte_ether.h.

🌸 #define RTE_ETHER_TYPE_ECPRI 0xAEFE

eCPRI ethertype (and yes, .1Q is supported β€” she plays nice with her neighbors) πŸ’…

Definition at line 348 of file rte_ether.h.


okay don't go anywhere, there's more πŸ‘€

🌸 struct __rte_aligned(2) β€” the ethernet address vibe, unpacked

Okay bestie, listen. A universally administered address is one that a device just has, assigned to it by whoever manufactured it. Periodt. The first three octets (in transmission order!) hold the Organizationally Unique Identifier (OUI), and then the following three octets β€” for MAC-48 and EUI-48 β€” get handed out by that same organization with literally one rule: they gotta be unique. That's the whole constraint. πŸ¦‹

A locally administered address hits different though β€” a network administrator assigns that one to a device, and it does not contain an OUI.

Wanna know more? See http://standards.ieee.org/regauth/groupmac/tutorial.html (the address bytes are listed in tx order πŸ’…).

Definition at line 1 of file rte_ether.h.


✨ int rte_is_same_ether_addr(const struct rte_ether_addr * ea1, const struct rte_ether_addr * ea2) β€” [inline], [static]

Are these two ethernet addresses the same address? Let's find out, bestie. πŸ‘―

Parameters

  • ea1 β€” a pointer to the first ether_addr structure holding the ethernet address.
  • ea2 β€” a pointer to the second ether_addr structure holding the ethernet address.

Returns

True (1) if the two ethernet addresses are the same; False (0) otherwise. ✨

Definition at line 102 of file rte_ether.h.


πŸ’€ int rte_is_zero_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Is this ethernet address just... all zeros? Not a single bit of personality? 😭 Let's check.

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is filled with zeros; false (0) otherwise.

Definition at line 121 of file rte_ether.h.


πŸŽ€ int rte_is_unicast_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Vibe check: is this ethernet address a unicast address? πŸ‘‘

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is a unicast address; false (0) otherwise.

Definition at line 138 of file rte_ether.h.


🌈 int rte_is_multicast_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Now the other direction β€” is this ethernet address a multicast address? Everybody's invited energy. 🫢

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is a multicast address; false (0) otherwise.

Definition at line 153 of file rte_ether.h.


πŸ“’ int rte_is_broadcast_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Is it shouting to everybody? Is this ethernet address a broadcast address? Let's see.

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is a broadcast address; false (0) otherwise.

Definition at line 168 of file rte_ether.h.


🌍 int rte_is_universal_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Is this ethernet address a universally assigned address β€” like, straight from the manufacturer, no notes? πŸ’…

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is a universally assigned address; false (0) otherwise.

Definition at line 185 of file rte_ether.h.


🧚 int rte_is_local_admin_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Or is it a locally assigned address β€” the kind a network admin hand-picked? So specific, so curated.

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is a locally assigned address; false (0) otherwise.

Definition at line 200 of file rte_ether.h.


βœ… int rte_is_valid_assigned_ether_addr(const struct rte_ether_addr * ea) β€” [inline], [static]

Is this ethernet address actually valid? The tea: it checks that the address is a unicast address and is not filled with zeros. Both things, bestie, no skipping. πŸ‘€

Parameters

  • ea β€” a pointer to a ether_addr structure containing the ethernet address to check.

Returns

True (1) if the given ethernet address is valid; false (0) otherwise.

Definition at line 216 of file rte_ether.h.


🎲 void rte_eth_random_addr(uint8_t * addr)

Spin the wheel, babes β€” this generates a random Ethernet address that is locally administered and not multicast. The perfect middle-child address. 🌈

Parameters

  • addr β€” a pointer to the Ethernet address.

πŸ“‹ void rte_ether_addr_copy(const struct rte_ether_addr *__restrict ea_from, struct rte_ether_addr *__restrict ea_to) β€” [inline], [static]

Copying an Ethernet address, one to another. Dupe it, bestie, it's giving twins. πŸ‘―β€β™€οΈ

Parameters

  • ea_from β€” a pointer to a ether_addr structure holding the Ethernet address to copy.
  • ea_to β€” a pointer to a ether_addr structure where the Ethernet address gets copied to.

Definition at line 239 of file rte_ether.h.


πŸ–‹οΈ void rte_ether_format_addr(char * buf, uint16_t size, const struct rte_ether_addr * eth_addr)

Format a 48-bit Ethernet address all pretty in the pattern xx:xx:xx:xx:xx:xx. Gorgeous, iconic, exactly how you'd expect. πŸ’…

Parameters

  • buf β€” a pointer to a buffer that will contain the formatted MAC address.
  • size β€” the format buffer size.
  • eth_addr β€” a pointer to a ether_addr structure.

πŸ”„ int rte_ether_unformat_addr(const char * str, struct rte_ether_addr * eth_addr)

Turning a string with an Ethernet address back into an ether_addr. The glow-down, if you will. Reverse it. πŸ”

Parameters

  • str β€” a pointer to a buffer containing the formatted MAC address. It accepts either byte or word format, separated by a colon, a hyphen, or a period.

The example formats are:

  • XX:XX:XX:XX:XX:XX β€” Canonical form
  • XX-XX-XX-XX-XX-XX β€” Windows and IEEE 802
  • XXXX.XXXX.XXXX β€” Cisco

where XX is a hex digit: 0-9, a-f, or A-F. And heads up: in the byte format, leading zeros are optional. 🀫

Parameters

  • eth_addr β€” a pointer to a ether_addr structure.

Returns

0 if successful, -1 and sets rte_errno if the string is invalid. 😬


βœ‚οΈ int rte_vlan_strip(struct rte_mbuf * m) β€” [inline], [static]

Extract VLAN tag information into the mbuf. 🏷️

This is the software version of VLAN stripping.

Parameters

  • m β€” the packet mbuf.

Returns

  • 0: Success πŸŽ‰
  • 1: not a vlan packet πŸ™…

Definition at line 361 of file rte_ether.h.


πŸ”Œ int rte_vlan_insert(struct rte_mbuf ** m) β€” [inline], [static]

Insert that VLAN tag into the mbuf. Put it back where it belongs. πŸ’–

This is the software version of VLAN unstripping.

Parameters

  • m β€” the packet mbuf.

Returns

  • 0: On success
  • -EPERM: mbuf is shared, overwriting would be unsafe 😰
  • -ENOSPC: not enough headroom in mbuf πŸ’€

Definition at line 393 of file rte_ether.h.


πŸ‘‘ AUTHOR

Generated automatically by Doxygen for DPDK from the source code. So technically the author is a robot and honestly? It ate. Periodt. πŸ€–βœ¨


And that's the whole page, bestie β€” courtesy of DPDK, Version 25.11.3, for rte_ether.h(3). Slay, stay safe out there, and don't forget to check your broadcast address before you shout. πŸ’…πŸ’–πŸŽ€

πŸ“¦ where this page comes from