13#include <gtest/gtest.h>
23constexpr std::array<std::uint8_t, 6>
kControllerMac{0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
24constexpr std::array<std::uint8_t, 6> kDeviceMac{0x02, 0x00, 0x00, 0x00, 0x00, 0x01};
25constexpr std::array<std::uint8_t, 4> kVlanTag{0x81, 0x00, 0xC0, 0x00};
26constexpr std::uint16_t kProfinetEtherType = 0x8892;
39class SkipVlanTagsTest :
public ::testing::Test
49 static Bytes BuildUntaggedFrame()
51 Bytes frame{kDeviceMac.begin(), kDeviceMac.end()};
53 frame.push_back(
static_cast<std::uint8_t
>((kProfinetEtherType >> 8U) & 0xFFU));
54 frame.push_back(
static_cast<std::uint8_t
>(kProfinetEtherType & 0xFFU));
61TEST_F(SkipVlanTagsTest, UntaggedFrameReturnsOffset12)
68TEST_F(SkipVlanTagsTest, Single8021QTagReturnsOffset16)
72 frame.insert(
frame.begin() + 12, kVlanTag.begin(), kVlanTag.end());
78TEST_F(SkipVlanTagsTest, DoubleTaggedQinQFrameReturnsOffset20)
80 Bytes frame{kDeviceMac.begin(), kDeviceMac.end()};
82 frame.insert(
frame.end(), kControllerMac.begin(), kControllerMac.end());
85 frame.insert(
frame.end(), {0x88, 0xA8, 0x00, 0x00});
87 frame.insert(
frame.end(), kVlanTag.begin(), kVlanTag.end());
97TEST_F(SkipVlanTagsTest, ShortFrameReturnsEthernetHeaderLength)
constexpr MacAddress kControllerMac
TEST_F(AlarmListenerTests, InitializesWithEndpoint)
std::size_t SkipVlanTags(std::span< const std::uint8_t > frame) noexcept
Return the byte offset of the real EtherType in a raw Ethernet frame.
std::vector< std::uint8_t > Bytes
Generic byte buffer alias used throughout the library for raw wire data.
PROFINET protocol wire-format structures and serialization helpers.
Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack.