39 constexpr auto dst_mac() const noexcept -> std::span<const uint8_t, 6> {
40 return std::span<const uint8_t, 6>(
dst, 6);
43 constexpr auto src_mac() const noexcept -> std::span<const uint8_t, 6> {
44 return std::span<const uint8_t, 6>(
src, 6);
50static_assert(
sizeof(EtherHeader) == 14,
"Wrong Ethernet header size");
51static_assert(
alignof(EtherHeader) == 1,
"Wrong Ethernet header alignment");
84 return static_cast<VlanPcp>((
raw >> 13) & 0x7u);
87 constexpr bool dei() const noexcept {
return ((
raw >> 12) & 0x1u) != 0; }
89 constexpr auto vid() const noexcept -> uint16_t {
90 return static_cast<uint16_t
>(
raw & 0x0FFFu);
94 raw =
static_cast<uint16_t
>((
raw & 0x1FFFu) | ((uint16_t(v) & 0x7u) << 13));
98 raw =
static_cast<uint16_t
>((
raw & 0xEFFFu) | (uint16_t(v ? 1 : 0) << 12));
102 raw =
static_cast<uint16_t
>((
raw & 0xF000u) | (v & 0x0FFFu));
124static_assert(
sizeof(VlanHeader) == 4,
"Wrong VLAN header size");
125static_assert(
alignof(VlanHeader) == 1,
"Wrong VLAN header alignment");
constexpr _Tp autoswap(_Tp tp)
Byte-swap a value if the host is little-endian.
Definition utils.hxx:13
EtherType
Ethernet frame EtherType values (network byte order).
Definition ether.hxx:19
@ IPv4
Definition ether.hxx:20
@ VLAN
Definition ether.hxx:22
@ ARP
Definition ether.hxx:21
@ IPv6
Definition ether.hxx:23
VlanPcp
VLAN Priority Code Point (PCP) values (3 bits).
Definition ether.hxx:61
@ p4
Definition ether.hxx:66
@ p2
Definition ether.hxx:64
@ p0
Definition ether.hxx:62
@ p7
Definition ether.hxx:69
@ p3
Definition ether.hxx:65
@ p6
Definition ether.hxx:68
@ p1
Definition ether.hxx:63
@ p5
Definition ether.hxx:67
VLAN Tag Control Information (TCI) helpers and layout.
Definition ether.hxx:80
constexpr void set_dei(bool v) noexcept
Definition ether.hxx:97
constexpr auto vid() const noexcept -> uint16_t
Definition ether.hxx:89
constexpr bool dei() const noexcept
Definition ether.hxx:87
constexpr auto pcp() const noexcept -> VlanPcp
Definition ether.hxx:83
uint16_t raw
Definition ether.hxx:81
constexpr void set_pcp(VlanPcp v) noexcept
Definition ether.hxx:93
constexpr void set_vid(uint16_t v) noexcept
Definition ether.hxx:101