|
|
@ -29,6 +29,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "libiec61850_platform_includes.h"
|
|
|
|
#include "libiec61850_platform_includes.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DEBUG_HAL_ETHERNET
|
|
|
|
|
|
|
|
#define DEBUG_HAL_ETHERNET 1
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_INCLUDE_ETHERNET_WINDOWS == 1)
|
|
|
|
#if (CONFIG_INCLUDE_ETHERNET_WINDOWS == 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -95,11 +99,11 @@ loadDLLs(void)
|
|
|
|
HINSTANCE hDll = LoadLibrary("iphlpapi.dll");
|
|
|
|
HINSTANCE hDll = LoadLibrary("iphlpapi.dll");
|
|
|
|
|
|
|
|
|
|
|
|
if (hDll == NULL) {
|
|
|
|
if (hDll == NULL) {
|
|
|
|
|
|
|
|
if (DEBUG_HAL_ETHERNET)
|
|
|
|
printf("Error loading iphlpapi.dll!\n");
|
|
|
|
printf("Error loading iphlpapi.dll!\n");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetAdaptersAddresses = (pgetadaptersaddresses) GetProcAddress(hDll,
|
|
|
|
GetAdaptersAddresses = (pgetadaptersaddresses) GetProcAddress(hDll,
|
|
|
|
"GetAdaptersAddresses");
|
|
|
|
"GetAdaptersAddresses");
|
|
|
|
|
|
|
|
|
|
|
@ -111,7 +115,6 @@ loadDLLs(void)
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char*
|
|
|
|
static char*
|
|
|
|
getInterfaceName(int interfaceIndex)
|
|
|
|
getInterfaceName(int interfaceIndex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -137,6 +140,7 @@ getInterfaceName(int interfaceIndex)
|
|
|
|
if (i == interfaceIndex) {
|
|
|
|
if (i == interfaceIndex) {
|
|
|
|
interfaceName = (char*) malloc(strlen(device->name) + 1);
|
|
|
|
interfaceName = (char*) malloc(strlen(device->name) + 1);
|
|
|
|
strcpy(interfaceName, device->name);
|
|
|
|
strcpy(interfaceName, device->name);
|
|
|
|
|
|
|
|
if (DEBUG_HAL_ETHERNET)
|
|
|
|
printf("Use interface (%s)\n", interfaceName);
|
|
|
|
printf("Use interface (%s)\n", interfaceName);
|
|
|
|
ifaceFound = true;
|
|
|
|
ifaceFound = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -147,6 +151,7 @@ getInterfaceName(int interfaceIndex)
|
|
|
|
|
|
|
|
|
|
|
|
if (!ifaceFound)
|
|
|
|
if (!ifaceFound)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (DEBUG_HAL_ETHERNET)
|
|
|
|
printf("No ethernet interfaces found! Make sure WinPcap is installed.\n");
|
|
|
|
printf("No ethernet interfaces found! Make sure WinPcap is installed.\n");
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -180,13 +185,16 @@ getAdapterMacAddress(char* pcapAdapterName, uint8_t* macAddress)
|
|
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DEBUG_HAL_ETHERNET) {
|
|
|
|
printf("Adapter %s: ", pAddress->AdapterName);
|
|
|
|
printf("Adapter %s: ", pAddress->AdapterName);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < (int) addressLength; i++) {
|
|
|
|
for (i = 0; i < (int) addressLength; i++) {
|
|
|
|
printf("%02x ", pAddress->PhysicalAddress[i]);
|
|
|
|
printf("%02x ", pAddress->PhysicalAddress[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strstr(pcapAdapterName, pAddress->AdapterName) != 0) {
|
|
|
|
if (strstr(pcapAdapterName, pAddress->AdapterName) != 0) {
|
|
|
|
|
|
|
|
if (DEBUG_HAL_ETHERNET)
|
|
|
|
printf(" requested found!");
|
|
|
|
printf(" requested found!");
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < (int) addressLength; i++) {
|
|
|
|
for (i = 0; i < (int) addressLength; i++) {
|
|
|
|