25 #include <arpa/inet.h>
26 #include <freeradius-devel/io/proto.h>
53 p +=
sizeof(*ether_hdr);
57 "data in buffer (%zu bytes)",
sizeof(*ether_hdr), data_len);
66 vlan_hdr = (
void const *)p;
67 for (i = 0; i < 3; i++) {
77 if ((
uint8_t const *)(++vlan_hdr) >= end)
goto ood;
78 ether_type = ntohs(vlan_hdr->
tag_type);
87 vlan_hdr = (
void const *)p;
174 svlan_hdr = (
void *)p;
175 p +=
sizeof(*svlan_hdr);
177 cvlan_hdr = (
void *)p;
178 p +=
sizeof(*cvlan_hdr);
180 ether_type = (
void *)p;
181 p +=
sizeof(*ether_type);
205 cvlan_hdr = (
void *)p;
206 p +=
sizeof(*cvlan_hdr);
208 ether_type = (
void *)p;
209 p +=
sizeof(*ether_type);
245 memcpy(tmp_addr, ether_ctx->
dst_addr.
addr,
sizeof(tmp_addr));
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static ssize_t fr_ethernet_decode(void *proto_ctx, uint8_t const *data, size_t data_len)
Decodes an ethernet header with up to two levels of VLAN nesting.
static int fr_ethernet_get_option(fr_value_box_t *out, void const *proto_ctx, fr_proto_opt_group_t group, int opt)
Retrieve an option value from the proto_ctx.
static ssize_t fr_ethernet_encode(void *proto_ctx, uint8_t *data, size_t data_len)
Encodes an ethernet header and up to two levels of VLAN nesting.
static void fr_ethernet_invert(void *proto_ctx)
Inverts addresses, so that a decoder proto_ctx can be used for encoding.
static int fr_ethernet_set_option(void *proto_ctx, fr_proto_opt_group_t group, int opt, fr_value_box_t *in)
Set an option in the proto_ctx.
fr_proto_lib_t const libfreeradius_ethernet
Structures and functions for parsing ethernet headers.
uint16_t ether_type
Ether type. Usually 0x0800 (IPv4) 0x086DD (IPv6).
uint8_t dst_addr[ETHER_ADDR_LEN]
uint16_t svlan_tpid
SVLAN tag type. If 0, no SVLAN present.
uint16_t cvlan_tpid
CVLAN tag type. If 0, no CVLAN/SVLAN present.
uint16_t cvlan_vid
CVLAN vlan ID.
uint16_t svlan_vid
SVLAN vlan ID.
#define VLAN_VID_UNPACK(_vlan)
Unpack the VLAN ID from the TCI.
uint8_t cvlan_dei
CVLAN drop eligible indicator.
size_t payload_len
Remaining bytes after the ethernet header has been parsed.
uint8_t svlan_dei
SVLAN drop eligible indicator.
#define VLAN_DEI_UNPACK(_vlan)
Unpack the Drop Eligible Indicator from the TCI.
#define VLAN_TCI_PACK(_pcp, _dei, _vid)
Pack the PCP (Priority Code Point) DEI (Drop Eligible Indicator) and VID (VLAN ID)
@ PROTO_OPT_ETHERNET_SVLAN_PCP
Outer VLAN priority code point.
@ PROTO_OPT_ETHERNET_CVLAN_PCP
Inner VLAN priority code point.
@ PROTO_OPT_ETHERNET_CVLAN_VID
Inner VLAN ID.
@ PROTO_OPT_ETHERNET_SVLAN_VID
Outer VLAN ID.
@ PROTO_OPT_ETHERNET_CVLAN_DEI
Inner VLAN drop eligible indicator.
@ PROTO_OPT_ETHERNET_SVLAN_DEI
Outer VLAN drop eligible indicator.
@ PROTO_OPT_ETHERNET_SVLAN_TPID
Outer VLAN tag type.
@ PROTO_OPT_ETHERNET_CVLAN_TPID
Inner VLAN tag type.
uint16_t tag_type
Tag type.
#define VLAN_PCP_UNPACK(_vlan)
Unpack the Priority Code Point from the TCI.
uint8_t svlan_pcp
SVLAN priority code point 0-6.
uint8_t src_addr[ETHER_ADDR_LEN]
uint8_t cvlan_pcp
CVLAN priority code point 0-6.
Src/dst link layer information.
uint8_t addr[6]
Ethernet address.
fr_proto_opt_group_t
Option contexts.
@ PROTO_OPT_GROUP_L2
Generic layer 2 options.
@ PROTO_OPT_GROUP_CUSTOM
Custom options exported by the library.
@ PROTO_OPT_L2_NEXT_PROTOCOL
Next protocol (if available).
@ PROTO_OPT_L2_SRC_ADDRESS
Source address.
@ PROTO_OPT_L2_DST_ADDRESS
Destination address.
@ PROTO_OPT_L2_PAYLOAD_LEN
The public structure exported by protocol encoding/decoding libraries.
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
#define fr_value_box(_box, _var, _tainted)
Automagically fill in a box, determining the value type from the type of the C variable.
static always_inline int fr_value_box_ethernet_addr(fr_value_box_t *dst, fr_dict_attr_t const *enumv, fr_ethernet_t const *src, bool tainted)
static int fr_value_unbox_ethernet_addr(fr_ethernet_t *dst, fr_value_box_t *src)
Unbox an ethernet value (6 bytes, network byte order)
#define fr_value_unbox_shallow(_var, _box)
Unbox simple types performing type checks.
#define fr_value_box_init(_vb, _type, _enumv, _tainted)
Initialise a fr_value_box_t.
static size_t char ** out