The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Enumerations
ethernet.h File Reference

Structures and functions for parsing ethernet headers. More...

#include <freeradius-devel/util/inet.h>
#include <stdint.h>
#include <stddef.h>
+ Include dependency graph for ethernet.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ethernet_header_t
 Structure of a DEC/Intel/Xerox or 802.3 Ethernet header. More...
 
struct  fr_ethernet_proto_ctx_t
 Src/dst link layer information. More...
 
struct  vlan_header_t
 A VLAN header. More...
 

Macros

#define ETHER_ADDR_LEN   6
 
#define VLAN_DEI_UNPACK(_vlan)   (((*(uint8_t const *)&(_vlan)->tag_control) & 0x10) >> 4)
 Unpack the Drop Eligible Indicator from the TCI. More...
 
#define VLAN_PCP_UNPACK(_vlan)   (((*(uint8_t const *)&(_vlan)->tag_control) & 0xe0) >> 5)
 Unpack the Priority Code Point from the TCI. More...
 
#define VLAN_TCI_PACK(_pcp, _dei, _vid)   htons((((uint16_t)(_pcp) & 0xe0) << 13) | (((uint16_t)(_dei) & 0x01) << 12) | ((_vid) & 0x0fff))
 Pack the PCP (Priority Code Point) DEI (Drop Eligible Indicator) and VID (VLAN ID) More...
 
#define VLAN_VID_UNPACK(_vlan)   ((htons((_vlan)->tag_control) & 0x0fff))
 Unpack the VLAN ID from the TCI. More...
 

Enumerations

enum  fr_ethernet_options_t {
  PROTO_OPT_ETHERNET_SVLAN_TPID = 0 ,
  PROTO_OPT_ETHERNET_SVLAN_PCP ,
  PROTO_OPT_ETHERNET_SVLAN_DEI ,
  PROTO_OPT_ETHERNET_SVLAN_VID ,
  PROTO_OPT_ETHERNET_CVLAN_TPID ,
  PROTO_OPT_ETHERNET_CVLAN_PCP ,
  PROTO_OPT_ETHERNET_CVLAN_DEI ,
  PROTO_OPT_ETHERNET_CVLAN_VID
}
 Protocol options for ethernet. More...
 

Detailed Description

Structures and functions for parsing ethernet headers.

Id
493eab4730bfc49eed40df89083939fbe8208475

Definition in file ethernet.h.


Data Structure Documentation

◆ ethernet_header_t

struct ethernet_header_t

Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.

Definition at line 78 of file ethernet.h.

Data Fields
uint8_t dst_addr[ETHER_ADDR_LEN]
uint16_t ether_type
uint8_t src_addr[ETHER_ADDR_LEN]

◆ fr_ethernet_proto_ctx_t

struct fr_ethernet_proto_ctx_t

Src/dst link layer information.

Definition at line 87 of file ethernet.h.

+ Collaboration diagram for fr_ethernet_proto_ctx_t:
Data Fields
uint8_t cvlan_dei CVLAN drop eligible indicator.
uint8_t cvlan_pcp CVLAN priority code point 0-6.
uint16_t cvlan_tpid CVLAN tag type. If 0, no CVLAN/SVLAN present.
uint16_t cvlan_vid CVLAN vlan ID.
fr_ethernet_t dst_addr
uint16_t ether_type Ether type. Usually 0x0800 (IPv4) 0x086DD (IPv6).
size_t payload_len Remaining bytes after the ethernet header has been parsed.
fr_ethernet_t src_addr
uint8_t svlan_dei SVLAN drop eligible indicator.
uint8_t svlan_pcp SVLAN priority code point 0-6.
uint16_t svlan_tpid SVLAN tag type. If 0, no SVLAN present.
uint16_t svlan_vid SVLAN vlan ID.

◆ vlan_header_t

struct vlan_header_t

A VLAN header.

Represents a single layer of 802.1Q or QinQ tagging.

Definition at line 67 of file ethernet.h.

Data Fields
uint16_t tag_control
  • 3 bits priority.
  • 1 bit DEI.
  • 12 bits VID.
uint16_t tag_type Tag type.

One of (0x8100 - CVLAN, 0x9100, 0x9200, 0x9300 - SVLAN).

Macro Definition Documentation

◆ ETHER_ADDR_LEN

#define ETHER_ADDR_LEN   6

Definition at line 33 of file ethernet.h.

◆ VLAN_DEI_UNPACK

#define VLAN_DEI_UNPACK (   _vlan)    (((*(uint8_t const *)&(_vlan)->tag_control) & 0x10) >> 4)

Unpack the Drop Eligible Indicator from the TCI.

Definition at line 43 of file ethernet.h.

◆ VLAN_PCP_UNPACK

#define VLAN_PCP_UNPACK (   _vlan)    (((*(uint8_t const *)&(_vlan)->tag_control) & 0xe0) >> 5)

Unpack the Priority Code Point from the TCI.

Definition at line 38 of file ethernet.h.

◆ VLAN_TCI_PACK

#define VLAN_TCI_PACK (   _pcp,
  _dei,
  _vid 
)    htons((((uint16_t)(_pcp) & 0xe0) << 13) | (((uint16_t)(_dei) & 0x01) << 12) | ((_vid) & 0x0fff))

Pack the PCP (Priority Code Point) DEI (Drop Eligible Indicator) and VID (VLAN ID)

Packs the PCP, DEI and VID into the TCI (Tag control information). Output will be a 16bit integer in network byte order.

Parameters
[in]_pcpPriority Code Point, a 3 bit value indicating the relative priority of the packet.
[in]_deiDrop eligible indicator. Boolean indicating whether this packet should be dropped in case of congestion.
[in]_vid12 bit VLAN identifier.

Definition at line 61 of file ethernet.h.

◆ VLAN_VID_UNPACK

#define VLAN_VID_UNPACK (   _vlan)    ((htons((_vlan)->tag_control) & 0x0fff))

Unpack the VLAN ID from the TCI.

Definition at line 48 of file ethernet.h.

Enumeration Type Documentation

◆ fr_ethernet_options_t

Protocol options for ethernet.

Enumerator
PROTO_OPT_ETHERNET_SVLAN_TPID 

Outer VLAN tag type.

PROTO_OPT_ETHERNET_SVLAN_PCP 

Outer VLAN priority code point.

PROTO_OPT_ETHERNET_SVLAN_DEI 

Outer VLAN drop eligible indicator.

PROTO_OPT_ETHERNET_SVLAN_VID 

Outer VLAN ID.

PROTO_OPT_ETHERNET_CVLAN_TPID 

Inner VLAN tag type.

PROTO_OPT_ETHERNET_CVLAN_PCP 

Inner VLAN priority code point.

PROTO_OPT_ETHERNET_CVLAN_DEI 

Inner VLAN drop eligible indicator.

PROTO_OPT_ETHERNET_CVLAN_VID 

Inner VLAN ID.

Definition at line 108 of file ethernet.h.