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_hdrstruct 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 firstether_addrstructure holding the ethernet address.ea2β a pointer to the secondether_addrstructure 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 aether_addrstructure 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 aether_addrstructure 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 aether_addrstructure 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 aether_addrstructure 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 aether_addrstructure 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 aether_addrstructure 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 aether_addrstructure 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 aether_addrstructure holding the Ethernet address to copy.ea_toβ a pointer to aether_addrstructure 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 aether_addrstructure.
π 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 formXX-XX-XX-XX-XX-XXβ Windows and IEEE 802XXXX.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 aether_addrstructure.
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
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms