libiec61850  1.2.0
hal_ethernet.h
Go to the documentation of this file.
1 /*
2  * ethernet_hal.h
3  *
4  * Copyright 2013, 2014 Michael Zillgith
5  *
6  * This file is part of libIEC61850.
7  *
8  * libIEC61850 is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * libIEC61850 is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
24 #ifndef ETHERNET_HAL_H_
25 #define ETHERNET_HAL_H_
26 
27 #include <stdint.h>
28 #include <stdbool.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
49 typedef struct sEthernetSocket* EthernetSocket;
50 
52 typedef struct sEthernetHandleSet* EthernetHandleSet;
53 
59 EthernetHandleSet
61 
68 void
69 EthernetHandleSet_addSocket(EthernetHandleSet self, const EthernetSocket sock);
70 
77 void
78 EthernetHandleSet_removeSocket(EthernetHandleSet self, const EthernetSocket sock);
79 
92 int
93 EthernetHandleSet_waitReady(EthernetHandleSet self, unsigned int timeoutMs);
94 
100 void
101 EthernetHandleSet_destroy(EthernetHandleSet self);
102 
111 void
112 Ethernet_getInterfaceMACAddress(const char* interfaceId, uint8_t* addr);
113 
121 EthernetSocket
122 Ethernet_createSocket(const char* interfaceId, uint8_t* destAddress);
123 
129 void
130 Ethernet_destroySocket(EthernetSocket ethSocket);
131 
132 void
133 Ethernet_sendPacket(EthernetSocket ethSocket, uint8_t* buffer, int packetSize);
134 
135 /*
136  * \brief set a protocol filter for the specified etherType
137  *
138  * \param ethSocket the ethernet socket handle
139  * \param etherType the ether type of messages to accept
140  */
141 void
142 Ethernet_setProtocolFilter(EthernetSocket ethSocket, uint16_t etherType);
143 
153 int
154 Ethernet_receivePacket(EthernetSocket ethSocket, uint8_t* buffer, int bufferSize);
155 
161 bool
163 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif /* ETHERNET_HAL_H_ */
int EthernetHandleSet_waitReady(EthernetHandleSet self, unsigned int timeoutMs)
wait for a socket to become ready
int Ethernet_receivePacket(EthernetSocket ethSocket, uint8_t *buffer, int bufferSize)
receive an ethernet packet (non-blocking)
struct sEthernetSocket * EthernetSocket
Opaque handle that represents an Ethernet "socket".
Definition: hal_ethernet.h:49
void Ethernet_destroySocket(EthernetSocket ethSocket)
destroy the ethernet socket
void EthernetHandleSet_destroy(EthernetHandleSet self)
destroy the EthernetHandleSet instance
void Ethernet_setProtocolFilter(EthernetSocket ethSocket, uint16_t etherType)
struct sEthernetHandleSet * EthernetHandleSet
Definition: hal_ethernet.h:52
void EthernetHandleSet_addSocket(EthernetHandleSet self, const EthernetSocket sock)
add a socket to an existing handle set
void Ethernet_getInterfaceMACAddress(const char *interfaceId, uint8_t *addr)
Return the MAC address of an Ethernet interface.
EthernetHandleSet EthernetHandleSet_new(void)
Create a new connection handle set (EthernetHandleSet)
void Ethernet_sendPacket(EthernetSocket ethSocket, uint8_t *buffer, int packetSize)
void EthernetHandleSet_removeSocket(EthernetHandleSet self, const EthernetSocket sock)
remove a socket from an existing handle set
EthernetSocket Ethernet_createSocket(const char *interfaceId, uint8_t *destAddress)
Create an Ethernet socket using the specified interface and destination MAC address.
bool Ethernet_isSupported(void)
Indicates if runtime provides support for direct Ethernet access.