libIEC61850  1.0.1
Open-source IEC 61850 MMS/GOOSE/SV server and client library
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 
59 void
60 Ethernet_getInterfaceMACAddress(const char* interfaceId, uint8_t* addr);
61 
69 EthernetSocket
70 Ethernet_createSocket(const char* interfaceId, uint8_t* destAddress);
71 
77 void
78 Ethernet_destroySocket(EthernetSocket ethSocket);
79 
80 void
81 Ethernet_sendPacket(EthernetSocket ethSocket, uint8_t* buffer, int packetSize);
82 
83 /*
84  * \brief set a protocol filter for the specified etherType
85  *
86  * \param ethSocket the ethernet socket handle
87  * \param etherType the ether type of messages to accept
88  */
89 void
90 Ethernet_setProtocolFilter(EthernetSocket ethSocket, uint16_t etherType);
91 
101 int
102 Ethernet_receivePacket(EthernetSocket ethSocket, uint8_t* buffer, int bufferSize);
103 
109 bool
111 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* ETHERNET_HAL_H_ */
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 Ethernet_setProtocolFilter(EthernetSocket ethSocket, uint16_t etherType)
void Ethernet_getInterfaceMACAddress(const char *interfaceId, uint8_t *addr)
Return the MAC address of an Ethernet interface.
void Ethernet_sendPacket(EthernetSocket ethSocket, uint8_t *buffer, int packetSize)
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.