|
|
@ -47,6 +47,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
#define HAVE_REMOTE
|
|
|
|
#define HAVE_REMOTE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Enable WinPcap specific extension: pcap_getevent()
|
|
|
|
|
|
|
|
#define WPCAP
|
|
|
|
#include "pcap.h"
|
|
|
|
#include "pcap.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct sEthernetSocket {
|
|
|
|
struct sEthernetSocket {
|
|
|
@ -54,6 +56,11 @@ struct sEthernetSocket {
|
|
|
|
struct bpf_program etherTypeFilter;
|
|
|
|
struct bpf_program etherTypeFilter;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct sEthernetHandleSet {
|
|
|
|
|
|
|
|
HANDLE *handles;
|
|
|
|
|
|
|
|
int nhandles;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUC__ /* detect MINGW */
|
|
|
|
#ifdef __GNUC__ /* detect MINGW */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __MINGW64_VERSION_MAJOR
|
|
|
|
#ifndef __MINGW64_VERSION_MAJOR
|
|
|
@ -90,7 +97,6 @@ typedef ULONG (WINAPI* pgetadaptersaddresses)(ULONG family, ULONG flags, PVOID r
|
|
|
|
|
|
|
|
|
|
|
|
static pgetadaptersaddresses GetAdaptersAddresses;
|
|
|
|
static pgetadaptersaddresses GetAdaptersAddresses;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool dllLoaded = false;
|
|
|
|
static bool dllLoaded = false;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
@ -115,6 +121,54 @@ loadDLLs(void)
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EthernetHandleSet
|
|
|
|
|
|
|
|
EthernetHandleSet_new(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EthernetHandleSet result = (EthernetHandleSet) GLOBAL_MALLOC(sizeof(struct sEthernetHandleSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result != NULL) {
|
|
|
|
|
|
|
|
result->handles = NULL;
|
|
|
|
|
|
|
|
result->nhandles = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
EthernetHandleSet_addSocket(EthernetHandleSet self, const EthernetSocket sock)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (self != NULL && sock != NULL) {
|
|
|
|
|
|
|
|
int i = self->nhandles++;
|
|
|
|
|
|
|
|
self->handles = (HANDLE *) realloc(self->handles, self->nhandles * sizeof(HANDLE));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self->handles[i] = pcap_getevent(sock->rawSocket);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
|
|
|
EthernetHandleSet_waitReady(EthernetHandleSet self, unsigned int timeoutMs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((self != NULL) && (self->nhandles > 0)) {
|
|
|
|
|
|
|
|
result = WaitForMultipleObjects(self->nhandles, self->handles, 0, timeoutMs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
EthernetHandleSet_destroy(EthernetHandleSet self)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (self->handles)
|
|
|
|
|
|
|
|
free(self->handles);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLOBAL_FREEMEM(self);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char*
|
|
|
|
static char*
|
|
|
|
getInterfaceName(int interfaceIndex)
|
|
|
|
getInterfaceName(int interfaceIndex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -215,8 +269,6 @@ getAdapterMacAddress(char* pcapAdapterName, uint8_t* macAddress)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Ethernet_getInterfaceMACAddress(const char* interfaceId, uint8_t* addr)
|
|
|
|
Ethernet_getInterfaceMACAddress(const char* interfaceId, uint8_t* addr)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -338,6 +390,28 @@ Ethernet_isSupported()
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EthernetHandleSet
|
|
|
|
|
|
|
|
EthernetHandleSet_new(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
EthernetHandleSet_addSocket(EthernetHandleSet self, const EthernetSocket sock)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
|
|
|
EthernetHandleSet_waitReady(EthernetHandleSet self, unsigned int timeoutMs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
EthernetHandleSet_destroy(EthernetHandleSet self)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Ethernet_getInterfaceMACAddress(const char* interfaceId, uint8_t* addr)
|
|
|
|
Ethernet_getInterfaceMACAddress(const char* interfaceId, uint8_t* addr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|