Lines Matching full:events

2  * ndis_events - Receive NdisMIndicateStatus() events using WMI
115 static int ndis_events_get_adapter(struct ndis_events_data *events,
119 static int ndis_events_constructor(struct ndis_events_data *events) in ndis_events_constructor() argument
121 events->ref = 1; in ndis_events_constructor()
123 if (!CreatePipe(&events->read_pipe, &events->write_pipe, NULL, 512)) { in ndis_events_constructor()
128 events->event_avail = CreateEvent(NULL, TRUE, FALSE, NULL); in ndis_events_constructor()
129 if (events->event_avail == NULL) { in ndis_events_constructor()
132 CloseHandle(events->read_pipe); in ndis_events_constructor()
133 CloseHandle(events->write_pipe); in ndis_events_constructor()
141 static void ndis_events_destructor(struct ndis_events_data *events) in ndis_events_destructor() argument
143 CloseHandle(events->read_pipe); in ndis_events_destructor()
144 CloseHandle(events->write_pipe); in ndis_events_destructor()
145 CloseHandle(events->event_avail); in ndis_events_destructor()
146 IWbemServices_Release(events->pSvc); in ndis_events_destructor()
147 IWbemLocator_Release(events->pLoc); in ndis_events_destructor()
171 struct ndis_events_data *events = (struct ndis_events_data *) this; in ndis_events_add_ref() local
172 return ++events->ref; in ndis_events_add_ref()
178 struct ndis_events_data *events = (struct ndis_events_data *) this; in ndis_events_release() local
180 if (--events->ref != 0) in ndis_events_release()
181 return events->ref; in ndis_events_release()
183 ndis_events_destructor(events); in ndis_events_release()
185 os_free(events->adapter_desc); in ndis_events_release()
186 os_free(events->ifname); in ndis_events_release()
187 os_free(events); in ndis_events_release()
192 static int ndis_events_send_event(struct ndis_events_data *events, in ndis_events_send_event() argument
217 if (WriteFile(events->write_pipe, buf, pos - buf, &written, NULL)) { in ndis_events_send_event()
218 SetEvent(events->event_avail); in ndis_events_send_event()
226 static void ndis_events_media_connect(struct ndis_events_data *events) in ndis_events_media_connect() argument
229 ndis_events_send_event(events, EVENT_CONNECT, NULL, 0); in ndis_events_media_connect()
233 static void ndis_events_media_disconnect(struct ndis_events_data *events) in ndis_events_media_disconnect() argument
236 ndis_events_send_event(events, EVENT_DISCONNECT, NULL, 0); in ndis_events_media_disconnect()
240 static void ndis_events_media_specific(struct ndis_events_data *events, in ndis_events_media_specific() argument
282 ndis_events_send_event(events, EVENT_MEDIA_SPECIFIC, data, data_len); in ndis_events_media_specific()
288 static void ndis_events_adapter_arrival(struct ndis_events_data *events) in ndis_events_adapter_arrival() argument
291 ndis_events_send_event(events, EVENT_ADAPTER_ARRIVAL, NULL, 0); in ndis_events_adapter_arrival()
295 static void ndis_events_adapter_removal(struct ndis_events_data *events) in ndis_events_adapter_removal() argument
298 ndis_events_send_event(events, EVENT_ADAPTER_REMOVAL, NULL, 0); in ndis_events_adapter_removal()
306 struct ndis_events_data *events = (struct ndis_events_data *) this; in ndis_events_indicate() local
309 if (events->terminating) { in ndis_events_indicate()
345 ndis_events_get_adapter(events, events->ifname, NULL); in ndis_events_indicate()
348 if (wcscmp(events->adapter_desc, vt.bstrVal) != 0) { in ndis_events_indicate()
361 ndis_events_media_specific(events, pObj); in ndis_events_indicate()
364 ndis_events_media_connect(events); in ndis_events_indicate()
367 ndis_events_media_disconnect(events); in ndis_events_indicate()
370 ndis_events_adapter_arrival(events); in ndis_events_indicate()
373 ndis_events_adapter_removal(events); in ndis_events_indicate()
439 void ndis_events_deinit(struct ndis_events_data *events) in ndis_events_deinit() argument
441 events->terminating = 1; in ndis_events_deinit()
442 IWbemServices_CancelAsyncCall(events->pSvc, &events->sink); in ndis_events_deinit()
443 IWbemObjectSink_Release(&events->sink); in ndis_events_deinit()
451 static int ndis_events_use_desc(struct ndis_events_data *events, in ndis_events_use_desc() argument
458 if (events->adapter_desc == NULL) in ndis_events_use_desc()
473 events->adapter_desc = os_malloc((len + 1) * sizeof(WCHAR)); in ndis_events_use_desc()
474 if (events->adapter_desc == NULL) { in ndis_events_use_desc()
478 _snwprintf(events->adapter_desc, len + 1, L"%S", tmp); in ndis_events_use_desc()
484 static int ndis_events_get_adapter(struct ndis_events_data *events, in ndis_events_get_adapter() argument
500 * MSNdis events. If this fails, use the provided description. in ndis_events_get_adapter()
503 os_free(events->adapter_desc); in ndis_events_get_adapter()
504 events->adapter_desc = NULL; in ndis_events_get_adapter()
507 events->pLoc, L"ROOT\\CIMV2", NULL, NULL, 0, 0, 0, 0, &pSvc); in ndis_events_get_adapter()
511 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
529 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
541 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
552 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
571 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
582 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
592 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
597 events->adapter_desc = _wcsdup(vt.bstrVal); in ndis_events_get_adapter()
613 if (events->adapter_desc == NULL) in ndis_events_get_adapter()
614 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
627 if (events->adapter_desc == NULL) in ndis_events_get_adapter()
628 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
655 if (events->adapter_desc == NULL) in ndis_events_get_adapter()
656 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
668 if (events->adapter_desc == NULL) in ndis_events_get_adapter()
669 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
680 if (events->adapter_desc == NULL) in ndis_events_get_adapter()
681 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
687 os_free(events->adapter_desc); in ndis_events_get_adapter()
688 events->adapter_desc = _wcsdup(vt.bstrVal); in ndis_events_get_adapter()
695 if (events->adapter_desc == NULL) in ndis_events_get_adapter()
696 return ndis_events_use_desc(events, desc); in ndis_events_get_adapter()
708 struct ndis_events_data *events; in ndis_events_init() local
710 events = os_zalloc(sizeof(*events)); in ndis_events_init()
711 if (events == NULL) { in ndis_events_init()
712 wpa_printf(MSG_ERROR, "Could not allocate sink for events."); in ndis_events_init()
715 events->ifname = os_strdup(ifname); in ndis_events_init()
716 if (events->ifname == NULL) { in ndis_events_init()
717 os_free(events); in ndis_events_init()
726 os_free(events); in ndis_events_init()
744 os_free(events); in ndis_events_init()
751 (LPVOID *) (void *) &events->pLoc); in ndis_events_init()
756 os_free(events); in ndis_events_init()
760 if (ndis_events_get_adapter(events, ifname, desc) < 0) { in ndis_events_init()
762 os_free(events); in ndis_events_init()
766 events->adapter_desc); in ndis_events_init()
769 events->pLoc, L"ROOT\\WMI", NULL, NULL, in ndis_events_init()
770 0, 0, 0, 0, &events->pSvc); in ndis_events_init()
775 os_free(events->adapter_desc); in ndis_events_init()
776 os_free(events); in ndis_events_init()
781 ndis_events_constructor(events); in ndis_events_init()
782 pSink = &events->sink; in ndis_events_init()
783 pSink->lpVtbl = &events->sink_vtbl; in ndis_events_init()
784 events->sink_vtbl.QueryInterface = ndis_events_query_interface; in ndis_events_init()
785 events->sink_vtbl.AddRef = ndis_events_add_ref; in ndis_events_init()
786 events->sink_vtbl.Release = ndis_events_release; in ndis_events_init()
787 events->sink_vtbl.Indicate = ndis_events_indicate; in ndis_events_init()
788 events->sink_vtbl.SetStatus = ndis_events_set_status; in ndis_events_init()
790 if (register_async_notification(pSink, events->pSvc) < 0) { in ndis_events_init()
793 ndis_events_destructor(events); in ndis_events_init()
794 os_free(events->adapter_desc); in ndis_events_init()
795 os_free(events); in ndis_events_init()
799 *read_pipe = events->read_pipe; in ndis_events_init()
800 *event_avail = events->event_avail; in ndis_events_init()
802 return events; in ndis_events_init()