diff options
author | Guy Harris <gharris@sonic.net> | 2020-05-29 10:41:44 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2020-05-29 10:41:44 -0700 |
commit | a0562fd46a55d49c7f4262216e9f773a9ab33d60 (patch) | |
tree | 4a2d96269b689e2663109bb32306ce68b2a2abd4 /pcap-airpcap.c | |
parent | 62f2e4d8fa5ab489eb2ec7a53ccdc475222cb589 (diff) |
airpcap: make all AirPcap calls through function pointers.
We load the AirPcap DLL at run time, rather than statically linking with
it, so we must make all calls to AirPcap routines through function
pointers set when we first load the DLL.
Call AirPcapClose() and AirpcapFreeDeviceList() through the existing
pointers.
Add a new pointer for AirpcapSetDeviceMacFlags(), set it at DLL load
time, and call through that pointer.
Diffstat (limited to 'pcap-airpcap.c')
-rw-r--r-- | pcap-airpcap.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pcap-airpcap.c b/pcap-airpcap.c index a939992c..70cdbf16 100644 --- a/pcap-airpcap.c +++ b/pcap-airpcap.c @@ -60,6 +60,7 @@ typedef BOOL (*AirpcapGetDeviceListHandler)(PAirpcapDeviceDescription *, PCHAR); typedef VOID (*AirpcapFreeDeviceListHandler)(PAirpcapDeviceDescription); typedef PAirpcapHandle (*AirpcapOpenHandler)(PCHAR, PCHAR); typedef VOID (*AirpcapCloseHandler)(PAirpcapHandle); +typedef BOOL (*AirpcapSetDeviceMacFlagsHandler)(PAirpcapHandle, UINT); typedef BOOL (*AirpcapSetLinkTypeHandler)(PAirpcapHandle, AirpcapLinkType); typedef BOOL (*AirpcapGetLinkTypeHandler)(PAirpcapHandle, PAirpcapLinkType); typedef BOOL (*AirpcapSetKernelBufferHandler)(PAirpcapHandle, UINT); @@ -75,6 +76,7 @@ static AirpcapGetDeviceListHandler p_AirpcapGetDeviceList; static AirpcapFreeDeviceListHandler p_AirpcapFreeDeviceList; static AirpcapOpenHandler p_AirpcapOpen; static AirpcapCloseHandler p_AirpcapClose; +static AirpcapSetDeviceMacFlagsHandler p_AirpcapSetDeviceMacFlags; static AirpcapSetLinkTypeHandler p_AirpcapSetLinkType; static AirpcapGetLinkTypeHandler p_AirpcapGetLinkType; static AirpcapSetKernelBufferHandler p_AirpcapSetKernelBuffer; @@ -178,6 +180,7 @@ load_airpcap_functions(void) p_AirpcapFreeDeviceList = (AirpcapFreeDeviceListHandler) pcap_find_function(airpcap_lib, "AirpcapFreeDeviceList"); p_AirpcapOpen = (AirpcapOpenHandler) pcap_find_function(airpcap_lib, "AirpcapOpen"); p_AirpcapClose = (AirpcapCloseHandler) pcap_find_function(airpcap_lib, "AirpcapClose"); + p_AirpcapSetDeviceMacFlags = (AirpcapSetDeviceMacFlagsHandler) pcap_find_function(airpcap_lib, "AirpcapSetDeviceMacFlags"); p_AirpcapSetLinkType = (AirpcapSetLinkTypeHandler) pcap_find_function(airpcap_lib, "AirpcapSetLinkType"); p_AirpcapGetLinkType = (AirpcapGetLinkTypeHandler) pcap_find_function(airpcap_lib, "AirpcapGetLinkType"); p_AirpcapSetKernelBuffer = (AirpcapSetKernelBufferHandler) pcap_find_function(airpcap_lib, "AirpcapSetKernelBuffer"); @@ -196,6 +199,7 @@ load_airpcap_functions(void) p_AirpcapFreeDeviceList != NULL && p_AirpcapOpen != NULL && p_AirpcapClose != NULL && + p_AirpcapSetDeviceMacFlags != NULL && p_AirpcapSetLinkType != NULL && p_AirpcapGetLinkType != NULL && p_AirpcapSetKernelBuffer != NULL && @@ -718,7 +722,7 @@ airpcap_cleanup(pcap_t *p) struct pcap_airpcap *pa = p->priv; if (pa->adapter != NULL) { - AirpcapClose(pa->adapter); + p_AirpcapClose(pa->adapter); pa->adapter = NULL; } pcap_cleanup_live_common(p); @@ -743,10 +747,10 @@ airpcap_activate(pcap_t *p) * Always turn off the "ACK frames sent to the card" mode. */ if (p->opt.rfmon) { - status = AirpcapSetDeviceMacFlags(pa->adapter, + status = p_AirpcapSetDeviceMacFlags(pa->adapter, AIRPCAP_MF_MONITOR_MODE_ON); } else - status = AirpcapSetDeviceMacFlags(pa->adapter, + status = p_AirpcapSetDeviceMacFlags(pa->adapter, AIRPCAP_MF_ACK_FRAMES_ON); if (!status) { AirpcapClose(pa->adapter); @@ -975,7 +979,7 @@ airpcap_findalldevs(pcap_if_list_t *devlistp, char *errbuf) /* * Failure. */ - AirpcapFreeDeviceList(airpcap_devices); + p_AirpcapFreeDeviceList(airpcap_devices); return (-1); } } |