PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::AsioEthernetSocket Class Referencefinal

Platform-independent raw Ethernet transport using Asio. More...

#include <asioEthernetSocket.h>

+ Inheritance diagram for profinet::AsioEthernetSocket:
+ Collaboration diagram for profinet::AsioEthernetSocket:

Classes

class  EthernetPacketBackend
 Private packet-capture backend for complete Ethernet frames. More...
 

Public Member Functions

 AsioEthernetSocket (asio::io_context &ioContext, const std::string &interface, std::uint16_t ethertype=0)
 Construct an Ethernet transport for a network interface.
 
 ~AsioEthernetSocket () override
 Destroy the Ethernet transport.
 
 AsioEthernetSocket (const AsioEthernetSocket &)=delete
 
AsioEthernetSocket & operator= (const AsioEthernetSocket &)=delete
 
 AsioEthernetSocket (AsioEthernetSocket &&)=delete
 
AsioEthernetSocket & operator= (AsioEthernetSocket &&)=delete
 
void Send (const std::vector< std::uint8_t > &frame) override
 Send one complete Ethernet frame.
 
void SetTimeout (std::chrono::milliseconds timeout) override
 Set the receive timeout.
 
std::vector< std::uint8_t > Recv () override
 Receive one complete Ethernet frame.
 
- Public Member Functions inherited from profinet::IRawEthernetSocket
virtual ~IRawEthernetSocket ()=default
 Virtual destructor for polymorphic use.
 

Private Attributes

asio::io_context & ioContext
 Asio execution context supplied by the caller.
 
std::unique_ptr< EthernetPacketBackend > backend
 Platform packet-access implementation.
 

Friends

class EthernetPacketBackendTestFixture
 Grants backend tests access to the private packet backend.
 

Detailed Description

Platform-independent raw Ethernet transport using Asio.

Provides complete Ethernet frame transmission and reception while hiding the operating-system packet capture mechanism from the rest of the PROFINET stack.

The implementation uses an internal EthernetPacketBackend. Asio remains responsible for asynchronous execution and receive readiness, while the backend handles platform-specific Ethernet packet access.

Protocol components must use IRawEthernetSocket and must not depend on EthernetPacketBackend or any operating-system networking API.

Architecture flow for packet capture backends.

Definition at line 48 of file asioEthernetSocket.h.

Constructor & Destructor Documentation

◆ AsioEthernetSocket() [1/3]

profinet::AsioEthernetSocket::AsioEthernetSocket ( asio::io_context &  ioContext,
const std::string &  interface,
std::uint16_t  ethertype = 0 
)

Construct an Ethernet transport for a network interface.

Parameters
ioContextAsio execution context used for receive readiness.
interfaceNetwork interface name or packet-capture device name.
ethertypeOptional EtherType filter. Zero accepts all Ethernet frame types and filtering is then performed by the backend.
Exceptions
SocketErrorWhen the interface cannot be opened.
PermissionDeniedErrorWhen packet access is denied.

Definition at line 10 of file asioEthernetSocket.cpp.

◆ ~AsioEthernetSocket()

profinet::AsioEthernetSocket::~AsioEthernetSocket ( )
overridedefault

Destroy the Ethernet transport.

◆ AsioEthernetSocket() [2/3]

profinet::AsioEthernetSocket::AsioEthernetSocket ( const AsioEthernetSocket &  )
delete

◆ AsioEthernetSocket() [3/3]

profinet::AsioEthernetSocket::AsioEthernetSocket ( AsioEthernetSocket &&  )
delete

Member Function Documentation

◆ operator=() [1/2]

AsioEthernetSocket & profinet::AsioEthernetSocket::operator= ( AsioEthernetSocket &&  )
delete

◆ operator=() [2/2]

AsioEthernetSocket & profinet::AsioEthernetSocket::operator= ( const AsioEthernetSocket &  )
delete

◆ Recv()

std::vector< std::uint8_t > profinet::AsioEthernetSocket::Recv ( )
overridevirtual

Receive one complete Ethernet frame.

Returns
Received Ethernet frame, or an empty vector on timeout.
Exceptions
SocketErrorWhen packet reception fails.

Implements profinet::IRawEthernetSocket.

Definition at line 27 of file asioEthernetSocket.cpp.

References backend.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ Send()

void profinet::AsioEthernetSocket::Send ( const std::vector< std::uint8_t > &  frame)
overridevirtual

Send one complete Ethernet frame.

Parameters
frameComplete Ethernet frame including the Ethernet header.
Exceptions
SocketErrorWhen packet transmission fails.

Implements profinet::IRawEthernetSocket.

Definition at line 17 of file asioEthernetSocket.cpp.

References backend, and frame.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ SetTimeout()

void profinet::AsioEthernetSocket::SetTimeout ( std::chrono::milliseconds  timeout)
overridevirtual

Set the receive timeout.

Parameters
timeoutReceive timeout. Zero means wait indefinitely.

Implements profinet::IRawEthernetSocket.

Definition at line 22 of file asioEthernetSocket.cpp.

References backend.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ EthernetPacketBackendTestFixture

friend class EthernetPacketBackendTestFixture
friend

Grants backend tests access to the private packet backend.

The backend remains an implementation detail of AsioEthernetSocket and is not exposed as part of the production transport API.

Definition at line 96 of file asioEthernetSocket.h.

Member Data Documentation

◆ backend

std::unique_ptr<EthernetPacketBackend> profinet::AsioEthernetSocket::backend
private

Platform packet-access implementation.

Definition at line 102 of file asioEthernetSocket.h.

Referenced by Recv(), Send(), and SetTimeout().

◆ ioContext

asio::io_context& profinet::AsioEthernetSocket::ioContext
private

Asio execution context supplied by the caller.

Definition at line 99 of file asioEthernetSocket.h.

Referenced by profinet::AsioEthernetSocket::EthernetPacketBackend::Recv().


The documentation for this class was generated from the following files: