aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2005-12-18 20:02:58 (GMT)
committerJouni Malinen <j@w1.fi>2005-12-18 20:02:58 (GMT)
commita5e8053a11996cc1447158e3882b11b5833d9db5 (patch)
treeb1347e270de5e47ddad50674ab8a5d2de6c1d1e3
parent7ece73abae989a0f7f84d28780e7d26ea7235830 (diff)
downloadhostap-history-a5e8053a11996cc1447158e3882b11b5833d9db5.zip
hostap-history-a5e8053a11996cc1447158e3882b11b5833d9db5.tar.gz
hostap-history-a5e8053a11996cc1447158e3882b11b5833d9db5.tar.bz2
Added C version of ndis_events.cpp and made it possible to build this
with MinGW so that CONFIG_NDIS_EVENTS_INTEGRATED can be used more easily on cross-compilation builds (e.g., automated release builds). MinGW does not have all the needed include files and libraries. However, these can be easily used from Platform SDK (couple of #pragma lines need to be commented out to get rid of compiler warnings from gcc). WbemUuid.Lib can be linked in to get WMI-related symbols for ndis_events.c; PLATFORMSDKLIB can be set in .config to point to the Lib directory of Platform SDK installation and include files can be copied to a directory that is added to the list of include directories with -I<dir> in CFLAGS. Cleaned up ndis_events interface by using a private structure that is stored in NDIS driver data and passed to the deinit call. This allows ndis_events.c to store all the needed data there without needing global variables.
-rw-r--r--wpa_supplicant/ChangeLog3
-rw-r--r--wpa_supplicant/Makefile13
-rw-r--r--wpa_supplicant/defconfig6
-rw-r--r--wpa_supplicant/driver_ndis.c21
-rw-r--r--wpa_supplicant/driver_ndis.h8
-rw-r--r--wpa_supplicant/ndis_events.c421
-rw-r--r--wpa_supplicant/ndis_events.cpp30
7 files changed, 482 insertions, 20 deletions
diff --git a/wpa_supplicant/ChangeLog b/wpa_supplicant/ChangeLog
index d3dd493..d068549 100644
--- a/wpa_supplicant/ChangeLog
+++ b/wpa_supplicant/ChangeLog
@@ -57,6 +57,9 @@ ChangeLog for wpa_supplicant
* added support for loading trusted CA certificates from Windows
certificate store: ca_cert="cert_store://<name>", where <name> is
likely CA (Intermediate CA certificates) or ROOT (root certificates)
+ * added C version of ndis_events.cpp and made it possible to build this
+ with MinGW so that CONFIG_NDIS_EVENTS_INTEGRATED can be used more
+ easily on cross-compilation builds
2005-11-20 - v0.4.7 (beginning of 0.4.x stable releases)
* l2_packet_pcap: fixed wired IEEE 802.1X authentication with libpcap
diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index 819a634..e07094c 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -465,8 +465,19 @@ OBJS_t := $(OBJS) eapol_test.o ../hostapd/radius.o ../hostapd/radius_client.o
OBJS_t2 := $(OBJS) preauth_test.o
OBJS += $(CONFIG_MAIN).o drivers.o $(OBJS_d)
+ifdef CONFIG_NDIS_EVENTS_INTEGRATED
+CFLAGS += -DCONFIG_NDIS_EVENTS_INTEGRATED
+OBJS += ndis_events.o
+EXTRALIBS += -loleaut32 -lole32 -luuid
+ifdef PLATFORMSDKLIB
+EXTRALIBS += $(PLATFORMSDKLIB)/WbemUuid.Lib
+else
+EXTRALIBS += WbemUuid.Lib
+endif
+endif
+
wpa_supplicant: .config $(OBJS)
- $(CC) -o wpa_supplicant $(OBJS) $(LIBS)
+ $(CC) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
eapol_test: .config $(OBJS_t)
$(CC) -o eapol_test $(OBJS_t) $(LIBS)
diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig
index f9fd2eb..8df6aa7 100644
--- a/wpa_supplicant/defconfig
+++ b/wpa_supplicant/defconfig
@@ -209,3 +209,9 @@ CONFIG_BACKEND=file
# IEEE 802.11i/IEEE 802.11e STAKey negotiation for direct link connection
#CONFIG_STAKEY=y
+
+# Integrate ndis_events.exe functionality into wpa_supplicant.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
diff --git a/wpa_supplicant/driver_ndis.c b/wpa_supplicant/driver_ndis.c
index 06c2ff8..1db206f 100644
--- a/wpa_supplicant/driver_ndis.c
+++ b/wpa_supplicant/driver_ndis.c
@@ -1694,17 +1694,13 @@ static void * wpa_driver_ndis_init(void *ctx, const char *ifname)
eloop_register_timeout(1, 0, wpa_driver_ndis_poll_timeout, drv, NULL);
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
- {
- int ndis_events_init(HANDLE *read_pipe, HANDLE *event);
- if (ndis_events_init(&drv->events_pipe, &drv->event_avail)) {
- wpa_driver_ndis_deinit(drv);
- return NULL;
- }
- drv->integrated_events_initialized = 1;
- eloop_register_event(&drv->event_avail,
- sizeof(drv->event_avail),
- wpa_driver_ndis_event_pipe_cb, drv, NULL);
+ drv->events = ndis_events_init(&drv->events_pipe, &drv->event_avail);
+ if (drv->events == NULL) {
+ wpa_driver_ndis_deinit(drv);
+ return NULL;
}
+ eloop_register_event(&drv->event_avail, sizeof(drv->event_avail),
+ wpa_driver_ndis_event_pipe_cb, drv, NULL);
#else /* CONFIG_NDIS_EVENTS_INTEGRATED */
wpa_driver_register_event_cb(drv);
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
@@ -1736,11 +1732,10 @@ static void wpa_driver_ndis_deinit(void *priv)
struct wpa_driver_ndis_data *drv = priv;
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
- if (drv->integrated_events_initialized) {
- void ndis_events_deinit(void);
+ if (drv->events) {
eloop_unregister_event(&drv->event_avail,
sizeof(drv->event_avail));
- ndis_events_deinit();
+ ndis_events_deinit(drv->events);
}
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
diff --git a/wpa_supplicant/driver_ndis.h b/wpa_supplicant/driver_ndis.h
index 8c8d639..defd9b5 100644
--- a/wpa_supplicant/driver_ndis.h
+++ b/wpa_supplicant/driver_ndis.h
@@ -15,6 +15,12 @@
#ifndef DRIVER_NDIS_H
#define DRIVER_NDIS_H
+#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
+struct ndis_events_data;
+struct ndis_events_data * ndis_events_init(HANDLE *read_pipe, HANDLE *event);
+void ndis_events_deinit(struct ndis_events_data *events);
+#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
+
struct ndis_pmkid_entry {
struct ndis_pmkid_entry *next;
u8 bssid[ETH_ALEN];
@@ -39,8 +45,8 @@ struct wpa_driver_ndis_data {
char *adapter_desc;
int wired;
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
- int integrated_events_initialized;
HANDLE events_pipe, event_avail;
+ struct ndis_events_data *events;
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
};
diff --git a/wpa_supplicant/ndis_events.c b/wpa_supplicant/ndis_events.c
new file mode 100644
index 0000000..19ca696
--- /dev/null
+++ b/wpa_supplicant/ndis_events.c
@@ -0,0 +1,421 @@
+/*
+ * ndis_events - Receive NdisMIndicateStatus() events using WMI
+ * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#define _WIN32_WINNT 0x0400
+
+#include "includes.h"
+
+#ifndef COBJMACROS
+#define COBJMACROS
+#endif /* COBJMACROS */
+#include <wbemidl.h>
+
+#include "common.h"
+
+
+struct ndis_events_data {
+ IWbemObjectSink sink;
+ IWbemObjectSinkVtbl sink_vtbl;
+
+ IWbemServices *pSvc;
+ IWbemLocator *pLoc;
+
+ HANDLE read_pipe, write_pipe, event_avail;
+ UINT ref;
+};
+
+enum event_types { EVENT_CONNECT, EVENT_DISCONNECT, EVENT_MEDIA_SPECIFIC };
+
+
+static int ndis_events_constructor(struct ndis_events_data *events)
+{
+ events->ref = 1;
+
+ if (!CreatePipe(&events->read_pipe, &events->write_pipe, NULL, 512)) {
+ wpa_printf(MSG_ERROR, "CreatePipe() failed: %d",
+ (int) GetLastError());
+ return -1;
+ }
+ events->event_avail = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (events->event_avail == NULL) {
+ wpa_printf(MSG_ERROR, "CreateEvent() failed: %d",
+ (int) GetLastError());
+ CloseHandle(events->read_pipe);
+ CloseHandle(events->write_pipe);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static void ndis_events_destructor(struct ndis_events_data *events)
+{
+ CloseHandle(events->read_pipe);
+ CloseHandle(events->write_pipe);
+ CloseHandle(events->event_avail);
+}
+
+
+static HRESULT STDMETHODCALLTYPE
+ndis_events_query_interface(IWbemObjectSink *this, REFIID riid, void **obj)
+{
+ *obj = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IWbemObjectSink)) {
+ *obj = this;
+ IWbemObjectSink_AddRef(this);
+ return NOERROR;
+ }
+
+ return E_NOINTERFACE;
+}
+
+
+static ULONG STDMETHODCALLTYPE ndis_events_add_ref(IWbemObjectSink *this)
+{
+ struct ndis_events_data *events = (struct ndis_events_data *) this;
+ return ++events->ref;
+}
+
+
+static ULONG STDMETHODCALLTYPE ndis_events_release(IWbemObjectSink *this)
+{
+ struct ndis_events_data *events = (struct ndis_events_data *) this;
+
+ if (--events->ref != 0)
+ return events->ref;
+
+ ndis_events_destructor(events);
+ free(events);
+ return 0;
+}
+
+
+static int ndis_events_send_event(struct ndis_events_data *events,
+ enum event_types type, BSTR instance,
+ char *data, size_t data_len)
+{
+ char buf[512], *pos, *end;
+ int len, _type;
+ DWORD written;
+
+ end = buf + sizeof(buf);
+ _type = (int) type;
+ memcpy(buf, &_type, sizeof(_type));
+ pos = buf + sizeof(_type);
+
+ len = _snprintf(pos + 1, end - pos - 1, "%S", instance);
+ if (len < 0)
+ return -1;
+ if (len > 255)
+ len = 255;
+ *pos = (unsigned char) len;
+ pos += 1 + len;
+ if (data) {
+ if (data_len > 255 || 1 + data_len > (size_t) (end - pos)) {
+ wpa_printf(MSG_DEBUG, "Not enough room for send_event "
+ "data (%d)", data_len);
+ return -1;
+ }
+ *pos++ = (unsigned char) data_len;
+ memcpy(pos, data, data_len);
+ pos += data_len;
+ }
+
+ if (WriteFile(events->write_pipe, buf, pos - buf, &written, NULL)) {
+ SetEvent(events->event_avail);
+ return 0;
+ }
+ wpa_printf(MSG_INFO, "WriteFile() failed: %d", (int) GetLastError());
+ return -1;
+}
+
+
+static void ndis_events_media_connect(struct ndis_events_data *events,
+ IWbemClassObject *pObj)
+{
+ VARIANT vt;
+ HRESULT hr;
+ wpa_printf(MSG_DEBUG, "MSNdis_StatusMediaConnect");
+ hr = IWbemClassObject_Get(pObj, L"InstanceName", 0, &vt, NULL, NULL);
+ if (SUCCEEDED(hr)) {
+ wpa_printf(MSG_DEBUG, " InstanceName: '%S'", vt.bstrVal);
+ ndis_events_send_event(events, EVENT_CONNECT, vt.bstrVal,
+ NULL, 0);
+ VariantClear(&vt);
+ }
+}
+
+
+static void ndis_events_media_disconnect(struct ndis_events_data *events,
+ IWbemClassObject *pObj)
+{
+ VARIANT vt;
+ HRESULT hr;
+ wpa_printf(MSG_DEBUG, "MSNdis_StatusMediaDisconnect");
+ hr = IWbemClassObject_Get(pObj, L"InstanceName", 0, &vt, NULL, NULL);
+ if (SUCCEEDED(hr)) {
+ wpa_printf(MSG_DEBUG, " InstanceName: '%S'", vt.bstrVal);
+ ndis_events_send_event(events, EVENT_DISCONNECT, vt.bstrVal,
+ NULL, 0);
+ VariantClear(&vt);
+ }
+}
+
+
+static void ndis_events_media_specific(struct ndis_events_data *events,
+ IWbemClassObject *pObj)
+{
+ VARIANT vt;
+ HRESULT hr;
+ LONG lower, upper, k;
+ UCHAR ch;
+ char *data, *pos;
+ size_t data_len;
+
+ wpa_printf(MSG_DEBUG, "MSNdis_StatusMediaSpecificIndication");
+
+ /* This is the StatusBuffer from NdisMIndicateStatus() call */
+ hr = IWbemClassObject_Get(pObj, L"NdisStatusMediaSpecificIndication",
+ 0, &vt, NULL, NULL);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_DEBUG, "Could not get "
+ "NdisStatusMediaSpecificIndication from "
+ "the object?!");
+ return;
+ }
+
+ SafeArrayGetLBound(V_ARRAY(&vt), 1, &lower);
+ SafeArrayGetUBound(V_ARRAY(&vt), 1, &upper);
+ data_len = upper - lower + 1;
+ data = malloc(data_len);
+ if (data == NULL) {
+ wpa_printf(MSG_DEBUG, "Failed to allocate buffer for event "
+ "data");
+ VariantClear(&vt);
+ return;
+ }
+
+ pos = data;
+ for (k = lower; k <= upper; k++) {
+ SafeArrayGetElement(V_ARRAY(&vt), &k, &ch);
+ *pos++ = ch;
+ }
+ wpa_hexdump(MSG_DEBUG, "MediaSpecificEvent", data, data_len);
+
+ VariantClear(&vt);
+
+ hr = IWbemClassObject_Get(pObj, L"InstanceName", 0, &vt, NULL, NULL);
+ if (SUCCEEDED(hr)) {
+ wpa_printf(MSG_DEBUG, " InstanceName: '%S'", vt.bstrVal);
+ ndis_events_send_event(events, EVENT_MEDIA_SPECIFIC,
+ vt.bstrVal, data, data_len);
+ VariantClear(&vt);
+ }
+
+ free(data);
+}
+
+
+static HRESULT STDMETHODCALLTYPE
+ndis_events_indicate(IWbemObjectSink *this, long lObjectCount,
+ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObjArray)
+{
+ struct ndis_events_data *events = (struct ndis_events_data *) this;
+ long i;
+
+ /* wpa_printf(MSG_DEBUG, "Notification received - %d object(s)",
+ lObjectCount); */
+
+ for (i = 0; i < lObjectCount; i++) {
+ IWbemClassObject *pObj = ppObjArray[i];
+ HRESULT hr;
+ VARIANT vtClass;
+
+ hr = IWbemClassObject_Get(pObj, L"__CLASS", 0, &vtClass, NULL,
+ NULL);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_DEBUG, "Failed to get __CLASS from "
+ "event.");
+ break;
+ }
+ /* wpa_printf(MSG_DEBUG, "CLASS: '%S'", vtClass.bstrVal); */
+
+ if (wcscmp(vtClass.bstrVal,
+ L"MSNdis_StatusMediaSpecificIndication") == 0) {
+ ndis_events_media_specific(events, pObj);
+ } else if (wcscmp(vtClass.bstrVal,
+ L"MSNdis_StatusMediaConnect") == 0) {
+ ndis_events_media_connect(events, pObj);
+ } else if (wcscmp(vtClass.bstrVal,
+ L"MSNdis_StatusMediaDisconnect") == 0) {
+ ndis_events_media_disconnect(events, pObj);
+ } else {
+ wpa_printf(MSG_DEBUG, "Unepected event - __CLASS: "
+ "'%S'", vtClass.bstrVal);
+ }
+
+ VariantClear(&vtClass);
+ }
+
+ return WBEM_NO_ERROR;
+}
+
+
+static HRESULT STDMETHODCALLTYPE
+ndis_events_set_status(IWbemObjectSink *this, long lFlags, HRESULT hResult,
+ BSTR strParam, IWbemClassObject __RPC_FAR *pObjParam)
+{
+ return WBEM_NO_ERROR;
+}
+
+
+static int register_async_notification(IWbemObjectSink *pDestSink,
+ IWbemServices *pSvc)
+{
+ HRESULT hr;
+ int err = 0;
+ BSTR lang = SysAllocString(L"WQL");
+
+ BSTR query = SysAllocString(
+ L"SELECT * FROM MSNdis_StatusMediaConnect");
+ hr = IWbemServices_ExecNotificationQueryAsync(pSvc, lang, query, 0, 0,
+ pDestSink);
+ SysFreeString(query);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_DEBUG, "ExecNotificationQueryAsync for "
+ "MSNdis_StatusMediaConnect failed with hresult of "
+ "0x%x", (int) hr);
+ err = -1;
+ }
+
+ query = SysAllocString(
+ L"SELECT * FROM MSNdis_StatusMediaDisconnect");
+ hr = IWbemServices_ExecNotificationQueryAsync(pSvc, lang, query, 0, 0,
+ pDestSink);
+ SysFreeString(query);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_DEBUG, "ExecNotificationQueryAsync for "
+ "MSNdis_StatusMediaDisconnect failed with hresult "
+ "of 0x%x", (int) hr);
+ err = -1;
+ }
+
+ query = SysAllocString(
+ L"SELECT * FROM MSNdis_StatusMediaSpecificIndication");
+ hr = IWbemServices_ExecNotificationQueryAsync(pSvc, lang, query, 0, 0,
+ pDestSink);
+ SysFreeString(query);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_DEBUG, "ExecNotificationQueryAsync for "
+ "MSNdis_StatusMediaSpecificIndication failed with "
+ "hresult of 0x%x", (int) hr);
+ err = -1;
+ }
+
+ SysFreeString(lang);
+
+ return err;
+}
+
+
+void ndis_events_deinit(struct ndis_events_data *events)
+{
+ IWbemServices_CancelAsyncCall(events->pSvc, &events->sink);
+ IWbemObjectSink_Release(&events->sink);
+ IWbemServices_Release(events->pSvc);
+ IWbemLocator_Release(events->pLoc);
+ CoUninitialize();
+}
+
+
+struct ndis_events_data *
+ndis_events_init(HANDLE *read_pipe, HANDLE *event_avail)
+{
+ HRESULT hr;
+ IWbemObjectSink *pSink;
+ struct ndis_events_data *events;
+
+ events = malloc(sizeof(*events));
+ if (events == NULL) {
+ wpa_printf(MSG_ERROR, "Could not allocate sink for events.");
+ return NULL;
+ }
+ memset(events, 0, sizeof(*events));
+
+ hr = CoInitializeEx(0, COINIT_MULTITHREADED);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_ERROR, "CoInitializeEx() failed - returned "
+ "0x%x", (int) hr);
+ free(events);
+ return NULL;
+ }
+
+ hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
+ RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
+ RPC_C_IMP_LEVEL_IMPERSONATE,
+ NULL, EOAC_SECURE_REFS, NULL);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_ERROR, "CoInitializeSecurity() failed - "
+ "returned 0x%x", (int) hr);
+ free(events);
+ return NULL;
+ }
+
+ hr = CoCreateInstance(&CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
+ &IID_IWbemLocator, (LPVOID *) &events->pLoc);
+ if (FAILED(hr)) {
+ wpa_printf(MSG_ERROR, "CoCreateInstance() failed - returned "
+ "0x%x", (int) hr);
+ CoUninitialize();
+ free(events);
+ return NULL;
+ }
+
+ hr = IWbemLocator_ConnectServer(events->pLoc, L"ROOT\\WMI", NULL, NULL,
+ 0, 0, 0, 0, &events->pSvc);
+ if (hr) {
+ wpa_printf(MSG_ERROR, "Could not connect to server - error "
+ "0x%x", (int) hr);
+ CoUninitialize();
+ free(events);
+ return NULL;
+ }
+ wpa_printf(MSG_DEBUG, "Connected to ROOT\\WMI.");
+
+ ndis_events_constructor(events);
+ pSink = &events->sink;
+ pSink->lpVtbl = &events->sink_vtbl;
+ events->sink_vtbl.QueryInterface = ndis_events_query_interface;
+ events->sink_vtbl.AddRef = ndis_events_add_ref;
+ events->sink_vtbl.Release = ndis_events_release;
+ events->sink_vtbl.Indicate = ndis_events_indicate;
+ events->sink_vtbl.SetStatus = ndis_events_set_status;
+
+ if (register_async_notification(pSink, events->pSvc) < 0) {
+ wpa_printf(MSG_DEBUG, "Failed to register async "
+ "notifications");
+ CoUninitialize();
+ ndis_events_destructor(events);
+ free(events);
+ return NULL;
+ }
+
+ *read_pipe = events->read_pipe;
+ *event_avail = events->event_avail;
+
+ return events;
+}
diff --git a/wpa_supplicant/ndis_events.cpp b/wpa_supplicant/ndis_events.cpp
index cb8d2f2..613de46 100644
--- a/wpa_supplicant/ndis_events.cpp
+++ b/wpa_supplicant/ndis_events.cpp
@@ -19,6 +19,9 @@
#include <wbemidl.h>
#include <winsock.h>
+struct ndis_events_data {
+};
+
class CNdisSink : public IWbemObjectSink
{
@@ -69,12 +72,12 @@ CNdisSink::CNdisSink()
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
if (!CreatePipe(&read_pipe, &write_pipe, NULL, 512)) {
- printf("CreatePipe() failed: %s\n", (int) GetLastError());
+ printf("CreatePipe() failed: %d\n", (int) GetLastError());
return;
}
event_avail = CreateEvent(NULL, TRUE, FALSE, NULL);
if (event_avail == NULL) {
- printf("CreateEvent() failed: %s\n", (int) GetLastError());
+ printf("CreateEvent() failed: %d\n", (int) GetLastError());
CloseHandle(read_pipe);
CloseHandle(write_pipe);
return;
@@ -360,7 +363,7 @@ static IWbemServices *pSvc = 0;
static IWbemLocator *pLoc = NULL;
static CNdisSink *pSink = NULL;
-void ndis_events_deinit(void)
+void ndis_events_deinit(struct ndis_events_data *events)
{
pSvc->CancelAsyncCall(pSink);
pSink->Release();
@@ -371,7 +374,7 @@ void ndis_events_deinit(void)
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
-int ndis_events_init(HANDLE *read_pipe, HANDLE *event_avail)
+int ndis_events_main(HANDLE *read_pipe, HANDLE *event_avail)
#else
int main(int argc, char *argv[])
#endif
@@ -438,7 +441,7 @@ int main(int argc, char *argv[])
/* Just wait.. sink will be called with events.. */
while (getchar() != '\n');
- ndis_events_deinit();
+ ndis_events_deinit(NULL);
WSACleanup();
#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
@@ -447,5 +450,22 @@ int main(int argc, char *argv[])
}
#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
+struct ndis_events_data *
+ndis_events_init(HANDLE *read_pipe, HANDLE *event_avail)
+{
+ struct ndis_events_data *events;
+
+ events = (struct ndis_events_data *) malloc(sizeof(*events));
+ if (events == NULL)
+ return NULL;
+
+ if (ndis_events_main(read_pipe, event_avail)) {
+ free(events);
+ return NULL;
+ }
+
+ return events;
+}
+
}
#endif