216TEST_F(AsioEthernetSocketTests, InjectedEthernetFrameCanBeCapturedByPeer)
218 const std::string
interface = GetTestInterface();
220 if (interface.empty())
222 GTEST_SKIP() <<
"Set PROFINET_TEST_INTERFACE to run live Ethernet tests";
229 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
230 0x02, 0x00, 0x00, 0x00, 0x00, 0x01,
232 0x01, 0x02, 0x03, 0x04};
240 ASSERT_FALSE(received.empty());
241 EXPECT_EQ(received,
frame);
245TEST_F(AsioEthernetSocketTests, EtherTypeFilterAcceptsVlanTaggedFrame)
247 const std::string
interface = GetTestInterface();
249 if (interface.empty())
252 <<
"Set PROFINET_TEST_INTERFACE to run live Ethernet tests";
263 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
264 0x02, 0x00, 0x00, 0x00, 0x00, 0x02,
270 0x01, 0x02, 0x03, 0x04};
278 ASSERT_FALSE(received.empty());
279 EXPECT_EQ(received,
frame);
285TEST_F(AsioEthernetSocketTests, UnicastFrameCanBeReceivedByPeer)
287 const std::string
interface = GetTestInterface();
289 if (interface.empty())
291 GTEST_SKIP() <<
"Set PROFINET_TEST_INTERFACE to run live Ethernet tests";
298 0xA0, 0xD3, 0x85, 0x00, 0xF6, 0x13,
299 0x08, 0x00, 0x27, 0x31, 0x39, 0xDC,
301 0x01, 0x02, 0x03, 0x04};
309 ASSERT_FALSE(received.empty());
310 EXPECT_EQ(received,
frame);
315TEST_F(AsioEthernetSocketTests, ConcurrentUnicastFrameCanBeReceivedByPeer)
317 const std::string
interface = GetTestInterface();
319 if (interface.empty())
321 GTEST_SKIP() <<
"Set PROFINET_TEST_INTERFACE to run live Ethernet tests";
328 0xA0, 0xD3, 0x85, 0x00, 0xF6, 0x13,
329 0x08, 0x00, 0x27, 0x31, 0x39, 0xDC,
331 0x01, 0x02, 0x03, 0x04};
334 std::jthread receiverThread([&]
337 received = receiver.
Recv();
342 receiverThread.join();
344 ASSERT_FALSE(received.empty());
345 EXPECT_EQ(received,
frame);
350TEST_F(AsioEthernetSocketTests, PeerCanReceiveAndRespondToController)
352 const std::string
interface = GetTestInterface();
354 if (interface.empty())
356 GTEST_SKIP() <<
"Set PROFINET_TEST_INTERFACE to run live Ethernet tests";
358 constexpr std::uint16_t testEtherType = 0x88B5;
363 0xA0, 0xD3, 0x85, 0x00, 0xF6, 0x13,
364 0x08, 0x00, 0x27, 0x31, 0x39, 0xDC,
366 0x01, 0x02, 0x03, 0x04};
368 const Bytes response{
369 0x08, 0x00, 0x27, 0x31, 0x39, 0xDC,
370 0xA0, 0xD3, 0x85, 0x00, 0xF6, 0x13,
372 0x05, 0x06, 0x07, 0x08};
374 Bytes receivedRequest;
375 std::exception_ptr peerException;
377 std::jthread peerThread([&]
383 receivedRequest = peer.
Recv();
385 if (receivedRequest.empty())
387 throw std::runtime_error(
"Peer did not receive request");
390 if (receivedRequest != request)
392 throw std::runtime_error(
"Peer received unexpected request");
399 peerException = std::current_exception();
413 std::rethrow_exception(peerException);
416 ASSERT_EQ(receivedRequest, request);
420 ASSERT_FALSE(receivedResponse.empty());
421 EXPECT_EQ(receivedResponse, response);
Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack.