18#include <gtest/gtest.h>
38 h.
payload = {0xFF, 0xFF, 0x00, 0x00};
48 EXPECT_EQ(decoded.
xId, h.
xId);
67 std::vector<std::uint8_t> ipPayload = {
81 static_cast<std::uint8_t
>(1));
85 static_cast<std::uint8_t
>(2));
89 static_cast<std::size_t
>(12));
93 EXPECT_EQ(ip.
address,
"192.168.1.1");
94 EXPECT_EQ(ip.
netmask,
"255.255.255.0");
95 EXPECT_EQ(ip.
gateway,
"192.168.1.254");
116 EXPECT_EQ(decoded.
dst, eth.
dst);
117 EXPECT_EQ(decoded.
src, eth.
src);
130 static_cast<std::size_t
>(12));
134 static_cast<std::size_t
>(4));
138 static_cast<std::size_t
>(6));
142 static_cast<std::size_t
>(80));
146 static_cast<std::size_t
>(20));
150 static_cast<std::size_t
>(64));
154 static_cast<std::size_t
>(6));
158 static_cast<std::size_t
>(58));
162 static_cast<std::size_t
>(32));
166 static_cast<std::size_t
>(60));
170 static_cast<std::size_t
>(60));
174 static_cast<std::size_t
>(22));
178 static_cast<std::size_t
>(60));
182 static_cast<std::size_t
>(60));
186 static_cast<std::size_t
>(70));
190 static_cast<std::size_t
>(6));
194 static_cast<std::size_t
>(12));
198 static_cast<std::size_t
>(46));
202 static_cast<std::size_t
>(26));
206 static_cast<std::size_t
>(12));
210 static_cast<std::size_t
>(26));
214 static_cast<std::size_t
>(22));
218 static_cast<std::size_t
>(12));
222 static_cast<std::size_t
>(6));
226 static_cast<std::size_t
>(64));
230 static_cast<std::size_t
>(64));
265 static_cast<std::uint8_t
>(0xDE));
269 static_cast<std::uint8_t
>(0xA0));
273 static_cast<std::uint8_t
>(0x00));
277 static_cast<std::uint8_t
>(0x01));
280TEST(EthernetVLANHeaderTests, RejectsTruncatedHeader)
282 constexpr std::size_t kHeaderSize = 18U;
284 for (std::size_t size = 0U; size < kHeaderSize; ++size)
286 const Bytes data(size);
292TEST(EthernetVLANHeaderTests, AcceptsCompleteHeader)
294 constexpr std::size_t kHeaderSize = 18U;
296 Bytes data(kHeaderSize, 0U);
TEST_F(AlarmListenerTests, InitializesWithEndpoint)
TEST(AlarmEndpointTests, DefaultTransportIsLayer2)
MacAddress String2Mac(const std::string &macStr)
Parse a colon-separated MAC address string.
constexpr std::uint16_t PROFINET_ETHERTYPE
EtherType value identifying PROFINET frames (0x8892).
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.
static constexpr std::size_t kSize
Size in bytes of this object.
Decoded IPv4 address/netmask/gateway triple.
std::string gateway
IPv4 default gateway.
std::string netmask
IPv4 subnet mask, e.g. "255.255.255.0".
std::string address
IPv4 address, e.g. "192.168.1.1".
ARBlockReq: establishes an Application Relationship (sent in the CONNECT request).
Bytes ToBytes() const
Serialize this block back to raw bytes.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
AlarmAck-PDU: acknowledges receipt of an AlarmNotification-PDU.
static constexpr std::size_t kSize
Size in bytes of this PDU.
Bytes ToBytes() const
Serialize this PDU back to raw bytes.
AlarmCRBlockReq: requests establishment of the alarm connection (part of the CONNECT request).
Bytes ToBytes() const
Serialize this block back to raw bytes.
static constexpr std::size_t kSize
Size in bytes of this block.
static constexpr std::size_t kSize
Size in bytes of this block.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this PDU.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
DCP response block: Option(1) + SubOption(1) + Length(2) + Status(2) + payload.
std::uint8_t suboption
DCP suboption code.
static PNDCPBlock Parse(const Bytes &data)
Parse a DCP response block from raw bytes.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
std::uint8_t option
DCP option code.
IPConfiguration ParseIp() const
Interpret this block's payload as an IP configuration triple.
Bytes payload
Block payload (excludes Status).
static constexpr std::size_t kSize
Size in bytes of this description.
static constexpr std::size_t kSize
Size in bytes of this block.
static constexpr std::size_t kSize
Size in bytes of this block.
IODWriteReqHeader: request header for writing a data record.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this block.
Bytes ToBytes() const
Serialize this block back to raw bytes.
static constexpr std::size_t kSize
Size in bytes of this block.
static constexpr std::size_t kSize
Size in bytes of this record.
static constexpr std::size_t kSize
Size in bytes of this record.
static constexpr std::size_t kSize
Size in bytes of this record.
static constexpr std::size_t kSize
Size in bytes of this record.
static constexpr std::size_t kSize
Size in bytes of this record.
static constexpr std::size_t kSize
Size in bytes of this record.
static constexpr std::size_t kFixedSize
Size in bytes of the fixed portion of this wrapper.