S2OPC OPCUA Toolkit
|
A platform independent API to use packet sockets. More...
Go to the source code of this file.
Macros | |
#define | ETHERNET_HEADER_SIZE 14 |
Typedefs | |
typedef struct SOPC_ETH_Socket_SendAddressInfo | SOPC_ETH_Socket_SendAddressInfo |
Socket addressing information for sending operation type. More... | |
typedef struct SOPC_ETH_Socket_ReceiveAddressInfo | SOPC_ETH_Socket_ReceiveAddressInfo |
Socket addressing information for listening operation type. More... | |
Functions | |
SOPC_ReturnStatus | SOPC_ETH_Socket_CreateSendAddressInfo (const char *interfaceName, const char *destMACaddr, SOPC_ETH_Socket_SendAddressInfo **sendAddInfo) |
Create a new address information for packet sending. More... | |
SOPC_ReturnStatus | SOPC_ETH_Socket_CreateReceiveAddressInfo (const char *interfaceName, bool recvMulticast, const char *destMACaddr, const char *sourceMACaddr, SOPC_ETH_Socket_ReceiveAddressInfo **recvAddInfo) |
Create a new address information for packet reception. More... | |
SOPC_ReturnStatus | SOPC_ETH_Socket_CreateToReceive (SOPC_ETH_Socket_ReceiveAddressInfo *receiveAddrInfo, bool setNonBlocking, Socket *sock) |
Create a new ETH socket, bind it using and add membership for multicast if active in receiveAddrInfo . Membership for multicast is added on specified interface in receiveAddrInfo or all compatible interfaces otherwise. More... | |
SOPC_ReturnStatus | SOPC_ETH_Socket_CreateToSend (SOPC_ETH_Socket_SendAddressInfo *sendAddrInfo, bool setNonBlocking, Socket *sock) |
Create a new ETH socket using sendAddrInfo properties. More... | |
SOPC_ReturnStatus | SOPC_ETH_Socket_SendTo (Socket sock, const SOPC_ETH_Socket_SendAddressInfo *sendAddrInfo, uint16_t etherType, SOPC_Buffer *buffer) |
Send data through the ETH socket to given IP address and port. More... | |
SOPC_ReturnStatus | SOPC_ETH_Socket_ReceiveFrom (Socket sock, const SOPC_ETH_Socket_ReceiveAddressInfo *receiveAddrInfo, bool checkEtherType, uint16_t etherType, SOPC_Buffer *buffer) |
Receive data on the ETH socket from given address info. More... | |
void | SOPC_ETH_Socket_Close (Socket *sock) |
Close the socket connection and/or clear the socket. More... | |
A platform independent API to use packet sockets.
#define ETHERNET_HEADER_SIZE 14 |
typedef struct SOPC_ETH_Socket_SendAddressInfo SOPC_ETH_Socket_SendAddressInfo |
Socket addressing information for sending operation type.
Socket addressing information for listening operation type.
SOPC_ReturnStatus SOPC_ETH_Socket_CreateSendAddressInfo | ( | const char * | interfaceName, |
const char * | destMACaddr, | ||
SOPC_ETH_Socket_SendAddressInfo ** | sendAddInfo | ||
) |
Create a new address information for packet sending.
interfaceName | Name of the network interface to use to send packet (mandatory) |
destMACaddr | Destination MAC address to send packet as a string representation (mandatory). It shall be hexadecimal values separated by character ':' and zero terminated. |
E.g.: "01-00-00-01-04-00"
[out] | sendAddInfo | Value pointed is set with a newly allocated and fulfilled send address information. Caller shall call SOPC_Free when not used anymore. |
SOPC_ReturnStatus SOPC_ETH_Socket_CreateReceiveAddressInfo | ( | const char * | interfaceName, |
bool | recvMulticast, | ||
const char * | destMACaddr, | ||
const char * | sourceMACaddr, | ||
SOPC_ETH_Socket_ReceiveAddressInfo ** | recvAddInfo | ||
) |
Create a new address information for packet reception.
interfaceName | Name of the network interface to use to receive packets (optional) | |
recvMulticast | If set, multicast packet reception is active. A multicast address should be specified in destMACaddr , otherwise packet reception is active for all multicast addresses. | |
destMACaddr | Destination MAC address of packets accepted as a string representation (optional). It shall be hexadecimal values separated by character ':' and zero terminated. It shall be set only if destMACaddr is set. E.g.: "01-00-00-01-04-00" | |
sourceMACaddr | Source MAC address of packets accepted as a string representation (optional). It shall be hexadecimal values separated by character ':' and zero terminated. E.g.: "0A:00:00:01:04:00" | |
[out] | recvAddInfo | Value pointed is set with a newly allocated and fulfilled receive address information. Caller shall call SOPC_Free when not used anymore. |
SOPC_ReturnStatus SOPC_ETH_Socket_CreateToReceive | ( | SOPC_ETH_Socket_ReceiveAddressInfo * | receiveAddrInfo, |
bool | setNonBlocking, | ||
Socket * | sock | ||
) |
Create a new ETH socket, bind it using and add membership for multicast if active in receiveAddrInfo
. Membership for multicast is added on specified interface in receiveAddrInfo
or all compatible interfaces otherwise.
receiveAddrInfo | Receive address information. It is used to bind socket to particular interface if defined and to add membership for multicast if defined. | |
setNonBlocking | Set the socket as non blocking | |
[out] | sock | Value pointed is set with the newly created socket. |
SOPC_ReturnStatus SOPC_ETH_Socket_CreateToSend | ( | SOPC_ETH_Socket_SendAddressInfo * | sendAddrInfo, |
bool | setNonBlocking, | ||
Socket * | sock | ||
) |
Create a new ETH socket using sendAddrInfo
properties.
sendAddrInfo | Send address information | |
setNonBlocking | Set the socket as non blocking | |
[out] | sock | Value pointed is set with the newly created socket. |
SOPC_ReturnStatus SOPC_ETH_Socket_SendTo | ( | Socket | sock, |
const SOPC_ETH_Socket_SendAddressInfo * | sendAddrInfo, | ||
uint16_t | etherType, | ||
SOPC_Buffer * | buffer | ||
) |
Send data through the ETH socket to given IP address and port.
sock | The socket used for sending |
sendAddrInfo | The address information for sending (source interface and destination MAC address) |
etherType | The EtherType value to indicate in Ethernet header |
buffer | The buffer containing data to be sent. Buffer containing buffer->length bytes. |
SOPC_ReturnStatus SOPC_ETH_Socket_ReceiveFrom | ( | Socket | sock, |
const SOPC_ETH_Socket_ReceiveAddressInfo * | receiveAddrInfo, | ||
bool | checkEtherType, | ||
uint16_t | etherType, | ||
SOPC_Buffer * | buffer | ||
) |
Receive data on the ETH socket from given address info.
sock | The socket used for receiving | |
receiveAddrInfo | The address information to use for reception. Check source address, dest address and protocol version if configured. | |
checkEtherType | If set, check Ethernet header protocol value of packet is etherType . | |
etherType | The expected EtherType value in Ethernet header, packets are ignored if different when checkEtherType is set. | |
[in,out] | buffer | The buffer with buffer->current_size bytes available. buffer->length is updated on reception. The content on reception includes the ethernet header content of 14 bytes:
|
void SOPC_ETH_Socket_Close | ( | Socket * | sock | ) |
Close the socket connection and/or clear the socket.
sock | The socket to disconnect and/or clear |