---
name: "rte_ether.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_ether.h"
---

# rte\_ether.h(3)

## NAME

rte\_ether.h

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

Length of Ethernet address.

Definition at line **27** of file **rte\_ether.h**.

### #define RTE\_ETHER\_TYPE\_LEN 2

Length of Ethernet type field.

Definition at line **28** of file **rte\_ether.h**.

### #define RTE\_ETHER\_CRC\_LEN 4

Length of Ethernet CRC.

Definition at line **29** of file **rte\_ether.h**.

### #define RTE\_ETHER\_HDR\_LEN

**Value:**.PP

```
    (RTE_ETHER_ADDR_LEN * 2 + \
        RTE_ETHER_TYPE_LEN)
```

Length of Ethernet header.

Definition at line **32** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MIN\_LEN 64

Minimum frame len, including CRC.

Definition at line **33** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MAX\_LEN 1518

Maximum frame len, including CRC.

Definition at line **34** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MTU

**Value:**.PP

```
    (RTE_ETHER_MAX_LEN - RTE_ETHER_HDR_LEN - \
        RTE_ETHER_CRC_LEN)
```

Ethernet MTU.

Definition at line **37** of file **rte\_ether.h**.

### #define RTE\_VLAN\_HLEN 4

VLAN (IEEE 802.1Q) header length.

Definition at line **39** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MAX\_VLAN\_FRAME\_LEN (RTE\_ETHER\_MAX\_LEN + RTE\_VLAN\_HLEN)

Maximum VLAN frame length (excluding QinQ), including CRC.

Definition at line **41** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MAX\_JUMBO\_FRAME\_LEN 0x3F00

Maximum Jumbo frame length, including CRC.

Definition at line **45** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MAX\_VLAN\_ID 4095

Maximum VLAN ID.

Definition at line **47** of file **rte\_ether.h**.

### #define RTE\_ETHER\_MIN\_MTU 68

Minimum MTU for IPv4 packets, see RFC 791.

Definition at line **49** of file **rte\_ether.h**.

### #define RTE\_ETHER\_LOCAL\_ADMIN\_ADDR 0x02

Locally assigned Eth. address.

Definition at line **85** of file **rte\_ether.h**.

### #define RTE\_ETHER\_GROUP\_ADDR 0x01

Multicast or broadcast Eth. address.

Definition at line **86** of file **rte\_ether.h**.

### #define RTE\_ETHER\_ADDR\_PRT\_FMT '%02X:%02X:%02X:%02X:%02X:%02X'

Macro to print six-bytes of MAC address in hex format

Definition at line **248** of file **rte\_ether.h**.

### #define RTE\_ETHER\_ADDR\_BYTES(mac\_addrs)

**Value:**.PP

```
                     ((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])
```

Macro to extract the MAC address bytes from rte\_ether\_addr struct

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.

Definition at line **335** of file **rte\_ether.h**.

### #define RTE\_ETHER\_TYPE\_QINQ2 0x9200

Deprecated QinQ VLAN.

Definition at line **336** of file **rte\_ether.h**.

### #define RTE\_ETHER\_TYPE\_QINQ3 0x9300

Deprecated QinQ VLAN.

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.

Definition at line **342** of file **rte\_ether.h**.

### #define RTE\_ETHER\_TYPE\_SLOW 0x8809

Slow protocols (LACP and Marker).

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 (.1Q supported).

Definition at line **348** of file **rte\_ether.h**.

## Function Documentation

### struct \_\_rte\_aligned (2)

Ethernet address: A universally administered address is uniquely assigned to a device by its manufacturer. The first three octets (in transmission order) contain the Organizationally Unique Identifier (OUI). The following three (MAC-48 and EUI-48) octets are assigned by that organization with the only constraint of uniqueness. A locally administered address is assigned to a device by a network administrator and does not contain OUIs. See http://standards.ieee.org/regauth/groupmac/tutorial.html \< Addr bytes in tx order

Definition at line **1** of file **rte\_ether.h**.

### static int rte\_is\_same\_ether\_addr (const struct rte\_ether\_addr \* ea1, const struct rte\_ether\_addr \* ea2)` [inline]`, ` [static]`

Check if two Ethernet addresses are the same.

**Parameters**

*ea1* A pointer to the first ether\_addr structure containing the ethernet address. \
 *ea2* A pointer to the second ether\_addr structure containing the ethernet address.

**Returns**

True (1) if the given two ethernet address are the same; False (0) otherwise.

Definition at line **102** of file **rte\_ether.h**.

### static int rte\_is\_zero\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is filled with zeros.

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

### static int rte\_is\_unicast\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is 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**.

### static int rte\_is\_multicast\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is a multicast 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 multicast address; false (0) otherwise.

Definition at line **153** of file **rte\_ether.h**.

### static int rte\_is\_broadcast\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is a broadcast 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 broadcast address; false (0) otherwise.

Definition at line **168** of file **rte\_ether.h**.

### static int rte\_is\_universal\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is a universally assigned 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 universally assigned address; false (0) otherwise.

Definition at line **185** of file **rte\_ether.h**.

### static int rte\_is\_local\_admin\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is a locally assigned 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 locally assigned address; false (0) otherwise.

Definition at line **200** of file **rte\_ether.h**.

### static int rte\_is\_valid\_assigned\_ether\_addr (const struct rte\_ether\_addr \* ea)` [inline]`, ` [static]`

Check if an Ethernet address is a valid address. Checks that the address is a unicast address and is not filled with zeros.

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

Generate a random Ethernet address that is locally administered and not multicast.

**Parameters**

*addr* A pointer to Ethernet address.

### static void rte\_ether\_addr\_copy (const struct rte\_ether\_addr \*\_\_restrict ea\_from, struct rte\_ether\_addr \*\_\_restrict ea\_to)` [inline]`, ` [static]`

Copy an Ethernet address.

**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 to copy the Ethernet address.

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 48bits Ethernet address in pattern xx:xx:xx:xx:xx:xx.

**Parameters**

*buf* A pointer to buffer contains 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)

Convert string with Ethernet address to an ether\_addr.

**Parameters**

*str* A pointer to buffer contains the formatted MAC address. Accepts either byte or word format separated by colon, hyphen or 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. 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 invalid string

### static int rte\_vlan\_strip (struct rte\_mbuf \* m)` [inline]`, ` [static]`

Extract VLAN tag information into mbuf

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

### static int rte\_vlan\_insert (struct rte\_mbuf \*\* m)` [inline]`, ` [static]`

Insert VLAN tag into mbuf.

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.
