Sponsor:

Your company here, and a link to your site. Click to find out more.

rte_ether.h - Man Page

Synopsis

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

Data Structures

struct rte_ether_addr
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

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)

Variables

uint8_t addr_bytes [RTE_ETHER_ADDR_LEN]
struct rte_ether_addr dst_addr
struct rte_ether_addr src_addr
rte_be16_t ether_type

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 25 of file rte_ether.h.

#define RTE_ETHER_TYPE_LEN   2

Length of Ethernet type field.

Definition at line 26 of file rte_ether.h.

#define RTE_ETHER_CRC_LEN   4

Length of Ethernet CRC.

Definition at line 27 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 28 of file rte_ether.h.

#define RTE_ETHER_MIN_LEN   64

Minimum frame len, including CRC.

Definition at line 31 of file rte_ether.h.

#define RTE_ETHER_MAX_LEN   1518

Maximum frame len, including CRC.

Definition at line 32 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 33 of file rte_ether.h.

#define RTE_VLAN_HLEN   4

VLAN (IEEE 802.1Q) header length.

Definition at line 37 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 39 of file rte_ether.h.

#define RTE_ETHER_MAX_JUMBO_FRAME_LEN   0x3F00

Maximum Jumbo frame length, including CRC.

Definition at line 42 of file rte_ether.h.

#define RTE_ETHER_MAX_VLAN_ID   4095

Maximum VLAN ID.

Definition at line 45 of file rte_ether.h.

#define RTE_ETHER_MIN_MTU   68

Minimum MTU for IPv4 packets, see RFC 791.

Definition at line 47 of file rte_ether.h.

#define RTE_ETHER_LOCAL_ADMIN_ADDR   0x02

Locally assigned Eth. address.

Definition at line 64 of file rte_ether.h.

#define RTE_ETHER_GROUP_ADDR   0x01

Multicast or broadcast Eth. address.

Definition at line 65 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 227 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 231 of file rte_ether.h.

#define RTE_ETHER_TYPE_IPV4   0x0800

IPv4 Protocol.

Definition at line 298 of file rte_ether.h.

#define RTE_ETHER_TYPE_IPV6   0x86DD

IPv6 Protocol.

Definition at line 299 of file rte_ether.h.

#define RTE_ETHER_TYPE_ARP   0x0806

Arp Protocol.

Definition at line 300 of file rte_ether.h.

#define RTE_ETHER_TYPE_RARP   0x8035

Reverse Arp Protocol.

Definition at line 301 of file rte_ether.h.

#define RTE_ETHER_TYPE_VLAN   0x8100

IEEE 802.1Q VLAN tagging.

Definition at line 302 of file rte_ether.h.

#define RTE_ETHER_TYPE_QINQ   0x88A8

IEEE 802.1ad QinQ tagging.

Definition at line 303 of file rte_ether.h.

#define RTE_ETHER_TYPE_QINQ1   0x9100

Deprecated QinQ VLAN.

Definition at line 304 of file rte_ether.h.

#define RTE_ETHER_TYPE_QINQ2   0x9200

Deprecated QinQ VLAN.

Definition at line 305 of file rte_ether.h.

#define RTE_ETHER_TYPE_QINQ3   0x9300

Deprecated QinQ VLAN.

Definition at line 306 of file rte_ether.h.

#define RTE_ETHER_TYPE_PPPOE_DISCOVERY   0x8863

PPPoE Discovery Stage.

Definition at line 307 of file rte_ether.h.

#define RTE_ETHER_TYPE_PPPOE_SESSION   0x8864

PPPoE Session Stage.

Definition at line 308 of file rte_ether.h.

#define RTE_ETHER_TYPE_ETAG   0x893F

IEEE 802.1BR E-Tag.

Definition at line 309 of file rte_ether.h.

#define RTE_ETHER_TYPE_1588   0x88F7

IEEE 802.1AS 1588 Precise Time Protocol.

Definition at line 310 of file rte_ether.h.

#define RTE_ETHER_TYPE_SLOW   0x8809

Slow protocols (LACP and Marker).

Definition at line 312 of file rte_ether.h.

#define RTE_ETHER_TYPE_TEB   0x6558

Transparent Ethernet Bridging.

Definition at line 313 of file rte_ether.h.

#define RTE_ETHER_TYPE_LLDP   0x88CC

LLDP Protocol.

Definition at line 314 of file rte_ether.h.

#define RTE_ETHER_TYPE_MPLS   0x8847

MPLS ethertype.

Definition at line 315 of file rte_ether.h.

#define RTE_ETHER_TYPE_MPLSM   0x8848

MPLS multicast ethertype.

Definition at line 316 of file rte_ether.h.

#define RTE_ETHER_TYPE_ECPRI   0xAEFE

eCPRI ethertype (.1Q supported).

Definition at line 317 of file rte_ether.h.

Function Documentation

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 81 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 100 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 117 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 132 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 147 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 164 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 179 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 195 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 218 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 330 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 362 of file rte_ether.h.

Variable Documentation

uint8_t addr_bytes[RTE_ETHER_ADDR_LEN]

Addr bytes in tx order

Definition at line 0 of file rte_ether.h.

struct rte_ether_addr dst_addr

Destination address.

Definition at line 0 of file rte_ether.h.

struct rte_ether_addr src_addr

Source address.

Definition at line 1 of file rte_ether.h.

rte_be16_t ether_type

Frame type.

Definition at line 2 of file rte_ether.h.

Author

Generated automatically by Doxygen for DPDK from the source code.

Referenced By

The man pages RTE_ETHER_ADDR_BYTES(3), rte_ether_addr_copy(3), RTE_ETHER_ADDR_LEN(3), RTE_ETHER_ADDR_PRT_FMT(3), RTE_ETHER_CRC_LEN(3), rte_ether_format_addr(3), RTE_ETHER_GROUP_ADDR(3), RTE_ETHER_HDR_LEN(3), RTE_ETHER_LOCAL_ADMIN_ADDR(3), RTE_ETHER_MAX_JUMBO_FRAME_LEN(3), RTE_ETHER_MAX_LEN(3), RTE_ETHER_MAX_VLAN_FRAME_LEN(3), RTE_ETHER_MAX_VLAN_ID(3), RTE_ETHER_MIN_LEN(3), RTE_ETHER_MIN_MTU(3), RTE_ETHER_MTU(3), RTE_ETHER_TYPE_1588(3), RTE_ETHER_TYPE_ARP(3), RTE_ETHER_TYPE_ECPRI(3), RTE_ETHER_TYPE_ETAG(3), RTE_ETHER_TYPE_IPV4(3), RTE_ETHER_TYPE_IPV6(3), RTE_ETHER_TYPE_LEN(3), RTE_ETHER_TYPE_LLDP(3), RTE_ETHER_TYPE_MPLS(3), RTE_ETHER_TYPE_MPLSM(3), RTE_ETHER_TYPE_PPPOE_DISCOVERY(3), RTE_ETHER_TYPE_PPPOE_SESSION(3), RTE_ETHER_TYPE_QINQ(3), RTE_ETHER_TYPE_QINQ1(3), RTE_ETHER_TYPE_QINQ2(3), RTE_ETHER_TYPE_QINQ3(3), RTE_ETHER_TYPE_RARP(3), RTE_ETHER_TYPE_SLOW(3), RTE_ETHER_TYPE_TEB(3), RTE_ETHER_TYPE_VLAN(3), rte_ether_unformat_addr(3), rte_eth_random_addr(3), rte_is_broadcast_ether_addr(3), rte_is_local_admin_ether_addr(3), rte_is_multicast_ether_addr(3), rte_is_same_ether_addr(3), rte_is_unicast_ether_addr(3), rte_is_universal_ether_addr(3), rte_is_valid_assigned_ether_addr(3), rte_is_zero_ether_addr(3), RTE_VLAN_HLEN(3), rte_vlan_insert(3) and rte_vlan_strip(3) are aliases of rte_ether.h(3).

Version 23.11.0 DPDK