You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.9 KiB
C
121 lines
2.9 KiB
C
![]()
11 years ago
|
/*
|
||
![]()
11 years ago
|
* ethernet_hal.h
|
||
![]()
11 years ago
|
*
|
||
![]()
11 years ago
|
* Copyright 2013, 2014 Michael Zillgith
|
||
![]()
11 years ago
|
*
|
||
|
* This file is part of libIEC61850.
|
||
|
*
|
||
|
* libIEC61850 is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* libIEC61850 is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
* See COPYING file for the complete license text.
|
||
|
*/
|
||
|
|
||
![]()
11 years ago
|
#ifndef ETHERNET_HAL_H_
|
||
|
#define ETHERNET_HAL_H_
|
||
![]()
11 years ago
|
|
||
|
#include <stdint.h>
|
||
![]()
11 years ago
|
#include <stdbool.h>
|
||
![]()
11 years ago
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/*! \addtogroup hal
|
||
|
*
|
||
|
* @{
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* @defgroup HAL_ETHERNET Direct access to the ethernet layer (optional - required by GOOSE and Sampled Values)
|
||
|
*
|
||
|
* @{
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
![]()
11 years ago
|
* \brief Opaque handle that represents an Ethernet "socket".
|
||
![]()
11 years ago
|
*/
|
||
|
typedef struct sEthernetSocket* EthernetSocket;
|
||
|
|
||
|
/**
|
||
![]()
11 years ago
|
* \brief Return the MAC address of an Ethernet interface.
|
||
![]()
11 years ago
|
*
|
||
|
* The result are the six bytes that make up the Ethernet MAC address.
|
||
|
*
|
||
|
* \param interfaceId the ID of the Ethernet interface
|
||
|
* \param addr pointer to a buffer to store the MAC address
|
||
|
*/
|
||
|
void
|
||
|
Ethernet_getInterfaceMACAddress(char* interfaceId, uint8_t* addr);
|
||
|
|
||
|
/**
|
||
![]()
11 years ago
|
* \brief Create an Ethernet socket using the specified interface and
|
||
![]()
11 years ago
|
* destination MAC address.
|
||
|
*
|
||
|
* \param interfaceId the ID of the Ethernet interface
|
||
|
* \param destAddress byte array that contains the Ethernet MAC address
|
||
|
*/
|
||
|
EthernetSocket
|
||
|
Ethernet_createSocket(char* interfaceId, uint8_t* destAddress);
|
||
|
|
||
![]()
11 years ago
|
/**
|
||
|
* \brief destroy the ethernet socket
|
||
|
*
|
||
|
* \param ethSocket the ethernet socket handle
|
||
|
*/
|
||
![]()
11 years ago
|
void
|
||
|
Ethernet_destroySocket(EthernetSocket ethSocket);
|
||
|
|
||
|
void
|
||
|
Ethernet_sendPacket(EthernetSocket ethSocket, uint8_t* buffer, int packetSize);
|
||
|
|
||
![]()
11 years ago
|
/*
|
||
|
* \brief set a protocol filter for the specified etherType
|
||
|
*
|
||
|
* \param ethSocket the ethernet socket handle
|
||
|
* \param etherType the ether type of messages to accept
|
||
|
*/
|
||
![]()
11 years ago
|
void
|
||
|
Ethernet_setProtocolFilter(EthernetSocket ethSocket, uint16_t etherType);
|
||
|
|
||
![]()
11 years ago
|
/**
|
||
|
* \brief receive an ethernet packet (non-blocking)
|
||
|
*
|
||
|
* \param ethSocket the ethernet socket handle
|
||
|
* \param buffer the buffer to copy the message to
|
||
|
* \param the maximum size of the buffer
|
||
|
*
|
||
|
* \return size of message received in bytes
|
||
|
*/
|
||
![]()
11 years ago
|
int
|
||
![]()
11 years ago
|
Ethernet_receivePacket(EthernetSocket ethSocket, uint8_t* buffer, int bufferSize);
|
||
|
|
||
|
/**
|
||
|
* \brief Indicates if runtime provides support for direct Ethernet access
|
||
|
*
|
||
|
* \return true if Ethernet support is available, false otherwise
|
||
|
*/
|
||
|
bool
|
||
|
Ethernet_isSupported(void);
|
||
![]()
11 years ago
|
|
||
|
/*! @} */
|
||
|
|
||
|
/*! @} */
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
![]()
11 years ago
|
#endif /* ETHERNET_HAL_H_ */
|