Lines Matching refs:drv
41 int wpa_driver_register_event_cb(struct wpa_driver_ndis_data *drv);
47 static void wpa_driver_ndis_poll(void *drv);
49 static int wpa_driver_ndis_adapter_init(struct wpa_driver_ndis_data *drv);
50 static int wpa_driver_ndis_adapter_open(struct wpa_driver_ndis_data *drv);
51 static void wpa_driver_ndis_adapter_close(struct wpa_driver_ndis_data *drv);
451 static int ndis_get_oid(struct wpa_driver_ndis_data *drv, unsigned int oid, in ndis_get_oid() argument
466 o->ptcDeviceName = drv->adapter_name; in ndis_get_oid()
468 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_QUERY_OID_VALUE, in ndis_get_oid()
506 if (!PacketRequest(drv->adapter, FALSE, o)) { in ndis_get_oid()
526 static int ndis_set_oid(struct wpa_driver_ndis_data *drv, unsigned int oid, in ndis_set_oid() argument
545 o->ptcDeviceName = drv->adapter_name; in ndis_set_oid()
549 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_SET_OID_VALUE, in ndis_set_oid()
575 if (!PacketRequest(drv->adapter, TRUE, o)) { in ndis_set_oid()
587 static int ndis_set_auth_mode(struct wpa_driver_ndis_data *drv, int mode) in ndis_set_auth_mode() argument
590 if (ndis_set_oid(drv, OID_802_11_AUTHENTICATION_MODE, in ndis_set_auth_mode()
601 static int ndis_get_auth_mode(struct wpa_driver_ndis_data *drv) in ndis_get_auth_mode() argument
605 res = ndis_get_oid(drv, OID_802_11_AUTHENTICATION_MODE, in ndis_get_auth_mode()
616 static int ndis_set_encr_status(struct wpa_driver_ndis_data *drv, int encr) in ndis_set_encr_status() argument
619 if (ndis_set_oid(drv, OID_802_11_ENCRYPTION_STATUS, in ndis_set_encr_status()
629 static int ndis_get_encr_status(struct wpa_driver_ndis_data *drv) in ndis_get_encr_status() argument
633 res = ndis_get_oid(drv, OID_802_11_ENCRYPTION_STATUS, in ndis_get_encr_status()
646 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_get_bssid() local
648 if (drv->wired) { in wpa_driver_ndis_get_bssid()
657 return ndis_get_oid(drv, OID_802_11_BSSID, (char *) bssid, ETH_ALEN) < in wpa_driver_ndis_get_bssid()
664 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_get_ssid() local
668 res = ndis_get_oid(drv, OID_802_11_SSID, (char *) &buf, sizeof(buf)); in wpa_driver_ndis_get_ssid()
671 if (drv->wired) { in wpa_driver_ndis_get_ssid()
683 static int wpa_driver_ndis_set_ssid(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_set_ssid() argument
696 drv->radio_enabled = 1; in wpa_driver_ndis_set_ssid()
697 return ndis_set_oid(drv, OID_802_11_SSID, (char *) &buf, sizeof(buf)); in wpa_driver_ndis_set_ssid()
703 static int wpa_driver_ndis_radio_off(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_radio_off() argument
705 drv->radio_enabled = 0; in wpa_driver_ndis_radio_off()
706 return ndis_set_oid(drv, OID_802_11_DISASSOCIATE, " ", 4); in wpa_driver_ndis_radio_off()
711 static int wpa_driver_ndis_disconnect(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_disconnect() argument
717 return wpa_driver_ndis_set_ssid(drv, (u8 *) ssid, SSID_MAX_LEN); in wpa_driver_ndis_disconnect()
724 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_deauthenticate() local
725 return wpa_driver_ndis_disconnect(drv); in wpa_driver_ndis_deauthenticate()
737 struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_scan_native80211() argument
747 res = ndis_set_oid(drv, OID_DOT11_SCAN_REQUEST, (char *) &req, in wpa_driver_ndis_scan_native80211()
749 eloop_cancel_timeout(wpa_driver_ndis_scan_timeout, drv, drv->ctx); in wpa_driver_ndis_scan_native80211()
750 eloop_register_timeout(7, 0, wpa_driver_ndis_scan_timeout, drv, in wpa_driver_ndis_scan_native80211()
751 drv->ctx); in wpa_driver_ndis_scan_native80211()
759 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_scan() local
762 if (drv->native80211) in wpa_driver_ndis_scan()
763 return wpa_driver_ndis_scan_native80211(drv, params); in wpa_driver_ndis_scan()
765 if (!drv->radio_enabled) { in wpa_driver_ndis_scan()
768 if (wpa_driver_ndis_disconnect(drv) < 0) { in wpa_driver_ndis_scan()
771 drv->radio_enabled = 1; in wpa_driver_ndis_scan()
774 res = ndis_set_oid(drv, OID_802_11_BSSID_LIST_SCAN, " ", 4); in wpa_driver_ndis_scan()
775 eloop_cancel_timeout(wpa_driver_ndis_scan_timeout, drv, drv->ctx); in wpa_driver_ndis_scan()
776 eloop_register_timeout(7, 0, wpa_driver_ndis_scan_timeout, drv, in wpa_driver_ndis_scan()
777 drv->ctx); in wpa_driver_ndis_scan()
816 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_get_scan_results() local
828 len = ndis_get_oid(drv, OID_802_11_BSSID_LIST, (char *) b, blen); in wpa_driver_ndis_get_scan_results()
902 static int wpa_driver_ndis_remove_key(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_remove_key() argument
918 res = ndis_set_oid(drv, OID_802_11_REMOVE_KEY, (char *) &rkey, in wpa_driver_ndis_remove_key()
922 res2 = ndis_set_oid(drv, OID_802_11_REMOVE_WEP, in wpa_driver_ndis_remove_key()
933 static int wpa_driver_ndis_add_wep(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_add_wep() argument
958 res = ndis_set_oid(drv, OID_802_11_ADD_WEP, (char *) wep, len); in wpa_driver_ndis_add_wep()
972 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_set_key() local
981 if (wpa_driver_ndis_get_bssid(drv, bssid) < 0) in wpa_driver_ndis_set_key()
990 return wpa_driver_ndis_remove_key(drv, key_idx, addr, bssid, in wpa_driver_ndis_set_key()
995 return wpa_driver_ndis_add_wep(drv, pairwise, key_idx, set_tx, in wpa_driver_ndis_set_key()
1029 res = ndis_set_oid(drv, OID_802_11_ADD_KEY, (char *) nkey, len); in wpa_driver_ndis_set_key()
1040 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_associate() local
1044 drv->mode = params->mode; in wpa_driver_ndis_associate()
1052 eloop_cancel_timeout(wpa_driver_ndis_poll_timeout, drv, NULL); in wpa_driver_ndis_associate()
1054 drv, NULL); in wpa_driver_ndis_associate()
1057 if (ndis_set_oid(drv, OID_802_11_INFRASTRUCTURE_MODE, in wpa_driver_ndis_associate()
1074 wpa_driver_ndis_set_key(drv->ifname, drv, WPA_ALG_WEP, in wpa_driver_ndis_associate()
1112 wpa_driver_ndis_set_key(drv->ifname, drv, WPA_ALG_WEP, in wpa_driver_ndis_associate()
1164 if (ndis_set_oid(drv, OID_802_11_PRIVACY_FILTER, in wpa_driver_ndis_associate()
1172 ndis_set_auth_mode(drv, auth_mode); in wpa_driver_ndis_associate()
1173 ndis_set_encr_status(drv, encr); in wpa_driver_ndis_associate()
1176 ndis_set_oid(drv, OID_802_11_BSSID, (char *) params->bssid, in wpa_driver_ndis_associate()
1178 drv->oid_bssid_set = 1; in wpa_driver_ndis_associate()
1179 } else if (drv->oid_bssid_set) { in wpa_driver_ndis_associate()
1180 ndis_set_oid(drv, OID_802_11_BSSID, "\xff\xff\xff\xff\xff\xff", in wpa_driver_ndis_associate()
1182 drv->oid_bssid_set = 0; in wpa_driver_ndis_associate()
1185 return wpa_driver_ndis_set_ssid(drv, params->ssid, params->ssid_len); in wpa_driver_ndis_associate()
1189 static int wpa_driver_ndis_set_pmkid(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_set_pmkid() argument
1196 entry = drv->pmkid; in wpa_driver_ndis_set_pmkid()
1199 if (count >= drv->no_of_pmkid) in wpa_driver_ndis_set_pmkid()
1210 entry = drv->pmkid; in wpa_driver_ndis_set_pmkid()
1217 ret = ndis_set_oid(drv, OID_802_11_PMKID, (char *) p, len); in wpa_driver_ndis_set_pmkid()
1226 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_add_pmkid() local
1229 if (drv->no_of_pmkid == 0) in wpa_driver_ndis_add_pmkid()
1233 entry = drv->pmkid; in wpa_driver_ndis_add_pmkid()
1247 entry->next = drv->pmkid; in wpa_driver_ndis_add_pmkid()
1248 drv->pmkid = entry; in wpa_driver_ndis_add_pmkid()
1255 entry->next = drv->pmkid; in wpa_driver_ndis_add_pmkid()
1256 drv->pmkid = entry; in wpa_driver_ndis_add_pmkid()
1260 return wpa_driver_ndis_set_pmkid(drv); in wpa_driver_ndis_add_pmkid()
1267 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_remove_pmkid() local
1270 if (drv->no_of_pmkid == 0) in wpa_driver_ndis_remove_pmkid()
1273 entry = drv->pmkid; in wpa_driver_ndis_remove_pmkid()
1281 drv->pmkid = entry->next; in wpa_driver_ndis_remove_pmkid()
1288 return wpa_driver_ndis_set_pmkid(drv); in wpa_driver_ndis_remove_pmkid()
1294 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_flush_pmkid() local
1299 if (drv->no_of_pmkid == 0) in wpa_driver_ndis_flush_pmkid()
1302 pmkid = drv->pmkid; in wpa_driver_ndis_flush_pmkid()
1303 drv->pmkid = NULL; in wpa_driver_ndis_flush_pmkid()
1314 prev_authmode = ndis_get_auth_mode(drv); in wpa_driver_ndis_flush_pmkid()
1316 ndis_set_auth_mode(drv, Ndis802_11AuthModeWPA2); in wpa_driver_ndis_flush_pmkid()
1323 ret = ndis_set_oid(drv, OID_802_11_PMKID, (char *) &p, 8); in wpa_driver_ndis_flush_pmkid()
1326 ndis_set_auth_mode(drv, prev_authmode); in wpa_driver_ndis_flush_pmkid()
1332 static int wpa_driver_ndis_get_associnfo(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_get_associnfo() argument
1341 len = ndis_get_oid(drv, OID_802_11_ASSOCIATION_INFORMATION, buf, in wpa_driver_ndis_get_associnfo()
1355 len = ndis_get_oid(drv, OID_802_11_ASSOCIATION_INFORMATION, in wpa_driver_ndis_get_associnfo()
1404 len = ndis_get_oid(drv, OID_802_11_BSSID_LIST, (char *) b, blen); in wpa_driver_ndis_get_associnfo()
1417 if (os_memcmp(drv->bssid, bss->MacAddress, ETH_ALEN) == 0 && in wpa_driver_ndis_get_associnfo()
1435 wpa_supplicant_event(drv->ctx, EVENT_ASSOCINFO, &data); in wpa_driver_ndis_get_associnfo()
1445 struct wpa_driver_ndis_data *drv = eloop_ctx; in wpa_driver_ndis_poll_timeout() local
1449 if (drv->wired) in wpa_driver_ndis_poll_timeout()
1452 if (wpa_driver_ndis_get_bssid(drv, bssid)) { in wpa_driver_ndis_poll_timeout()
1454 if (!is_zero_ether_addr(drv->bssid)) { in wpa_driver_ndis_poll_timeout()
1455 os_memset(drv->bssid, 0, ETH_ALEN); in wpa_driver_ndis_poll_timeout()
1456 wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL); in wpa_driver_ndis_poll_timeout()
1460 if (os_memcmp(drv->bssid, bssid, ETH_ALEN) != 0) { in wpa_driver_ndis_poll_timeout()
1461 os_memcpy(drv->bssid, bssid, ETH_ALEN); in wpa_driver_ndis_poll_timeout()
1462 wpa_driver_ndis_get_associnfo(drv); in wpa_driver_ndis_poll_timeout()
1463 wpa_supplicant_event(drv->ctx, EVENT_ASSOC, NULL); in wpa_driver_ndis_poll_timeout()
1473 poll = drv->mode == IEEE80211_MODE_IBSS; in wpa_driver_ndis_poll_timeout()
1482 drv, NULL); in wpa_driver_ndis_poll_timeout()
1489 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_poll() local
1490 eloop_cancel_timeout(wpa_driver_ndis_poll_timeout, drv, NULL); in wpa_driver_ndis_poll()
1491 wpa_driver_ndis_poll_timeout(drv, NULL); in wpa_driver_ndis_poll()
1497 void wpa_driver_ndis_event_connect(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_event_connect() argument
1500 if (wpa_driver_ndis_get_bssid(drv, drv->bssid) == 0) { in wpa_driver_ndis_event_connect()
1501 wpa_driver_ndis_get_associnfo(drv); in wpa_driver_ndis_event_connect()
1502 wpa_supplicant_event(drv->ctx, EVENT_ASSOC, NULL); in wpa_driver_ndis_event_connect()
1509 void wpa_driver_ndis_event_disconnect(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_event_disconnect() argument
1512 os_memset(drv->bssid, 0, ETH_ALEN); in wpa_driver_ndis_event_disconnect()
1513 wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL); in wpa_driver_ndis_event_disconnect()
1517 static void wpa_driver_ndis_event_auth(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_event_auth() argument
1545 wpa_supplicant_event(drv->ctx, EVENT_MICHAEL_MIC_FAILURE, in wpa_driver_ndis_event_auth()
1551 static void wpa_driver_ndis_event_pmkid(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_event_pmkid() argument
1588 wpa_supplicant_event(drv->ctx, EVENT_PMKID_CANDIDATE, in wpa_driver_ndis_event_pmkid()
1596 void wpa_driver_ndis_event_media_specific(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_event_media_specific() argument
1613 wpa_driver_ndis_event_auth(drv, data, data_len); in wpa_driver_ndis_event_media_specific()
1616 wpa_driver_ndis_event_pmkid(drv, data, data_len); in wpa_driver_ndis_event_media_specific()
1627 void wpa_driver_ndis_event_adapter_arrival(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_event_adapter_arrival() argument
1636 wpa_driver_ndis_adapter_close(drv); in wpa_driver_ndis_event_adapter_arrival()
1637 if (wpa_driver_ndis_adapter_init(drv) < 0 || in wpa_driver_ndis_event_adapter_arrival()
1638 wpa_driver_ndis_adapter_open(drv) < 0) { in wpa_driver_ndis_event_adapter_arrival()
1649 os_strlcpy(event.interface_status.ifname, drv->ifname, in wpa_driver_ndis_event_adapter_arrival()
1652 wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, &event); in wpa_driver_ndis_event_adapter_arrival()
1657 void wpa_driver_ndis_event_adapter_removal(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_event_adapter_removal() argument
1663 os_strlcpy(event.interface_status.ifname, drv->ifname, in wpa_driver_ndis_event_adapter_removal()
1666 wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, &event); in wpa_driver_ndis_event_adapter_removal()
1671 wpa_driver_ndis_get_wpa_capability(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_get_wpa_capability() argument
1675 if (ndis_set_auth_mode(drv, Ndis802_11AuthModeWPA) == 0 && in wpa_driver_ndis_get_wpa_capability()
1676 ndis_get_auth_mode(drv) == Ndis802_11AuthModeWPA) { in wpa_driver_ndis_get_wpa_capability()
1678 drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA; in wpa_driver_ndis_get_wpa_capability()
1681 if (ndis_set_auth_mode(drv, Ndis802_11AuthModeWPAPSK) == 0 && in wpa_driver_ndis_get_wpa_capability()
1682 ndis_get_auth_mode(drv) == Ndis802_11AuthModeWPAPSK) { in wpa_driver_ndis_get_wpa_capability()
1685 drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK; in wpa_driver_ndis_get_wpa_capability()
1688 if (ndis_set_encr_status(drv, Ndis802_11Encryption3Enabled) == 0 && in wpa_driver_ndis_get_wpa_capability()
1689 ndis_get_encr_status(drv) == Ndis802_11Encryption3KeyAbsent) { in wpa_driver_ndis_get_wpa_capability()
1691 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP; in wpa_driver_ndis_get_wpa_capability()
1694 if (ndis_set_encr_status(drv, Ndis802_11Encryption2Enabled) == 0 && in wpa_driver_ndis_get_wpa_capability()
1695 ndis_get_encr_status(drv) == Ndis802_11Encryption2KeyAbsent) { in wpa_driver_ndis_get_wpa_capability()
1697 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP; in wpa_driver_ndis_get_wpa_capability()
1700 if (ndis_set_encr_status(drv, Ndis802_11Encryption1Enabled) == 0 && in wpa_driver_ndis_get_wpa_capability()
1701 ndis_get_encr_status(drv) == Ndis802_11Encryption1KeyAbsent) { in wpa_driver_ndis_get_wpa_capability()
1703 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40 | in wpa_driver_ndis_get_wpa_capability()
1707 if (ndis_set_auth_mode(drv, Ndis802_11AuthModeShared) == 0 && in wpa_driver_ndis_get_wpa_capability()
1708 ndis_get_auth_mode(drv) == Ndis802_11AuthModeShared) { in wpa_driver_ndis_get_wpa_capability()
1709 drv->capa.auth |= WPA_DRIVER_AUTH_SHARED; in wpa_driver_ndis_get_wpa_capability()
1712 if (ndis_set_auth_mode(drv, Ndis802_11AuthModeOpen) == 0 && in wpa_driver_ndis_get_wpa_capability()
1713 ndis_get_auth_mode(drv) == Ndis802_11AuthModeOpen) { in wpa_driver_ndis_get_wpa_capability()
1714 drv->capa.auth |= WPA_DRIVER_AUTH_OPEN; in wpa_driver_ndis_get_wpa_capability()
1717 ndis_set_encr_status(drv, Ndis802_11EncryptionDisabled); in wpa_driver_ndis_get_wpa_capability()
1722 if (drv->capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA && in wpa_driver_ndis_get_wpa_capability()
1723 drv->capa.enc & (WPA_DRIVER_CAPA_ENC_TKIP | in wpa_driver_ndis_get_wpa_capability()
1726 drv->has_capability = 1; in wpa_driver_ndis_get_wpa_capability()
1733 drv->capa.key_mgmt, drv->capa.enc, drv->capa.auth); in wpa_driver_ndis_get_wpa_capability()
1737 static void wpa_driver_ndis_get_capability(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_get_capability() argument
1744 drv->capa.flags = WPA_DRIVER_FLAGS_DRIVER_IE; in wpa_driver_ndis_get_capability()
1746 len = ndis_get_oid(drv, OID_802_11_CAPABILITY, buf, sizeof(buf)); in wpa_driver_ndis_get_capability()
1748 wpa_driver_ndis_get_wpa_capability(drv); in wpa_driver_ndis_get_capability()
1763 drv->has_capability = 1; in wpa_driver_ndis_get_capability()
1764 drv->no_of_pmkid = c->NoOfPMKIDs; in wpa_driver_ndis_get_capability()
1778 drv->capa.auth |= WPA_DRIVER_AUTH_OPEN; in wpa_driver_ndis_get_capability()
1781 drv->capa.auth |= WPA_DRIVER_AUTH_SHARED; in wpa_driver_ndis_get_capability()
1784 drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA; in wpa_driver_ndis_get_capability()
1787 drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK; in wpa_driver_ndis_get_capability()
1790 drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_WPA2; in wpa_driver_ndis_get_capability()
1793 drv->capa.key_mgmt |= in wpa_driver_ndis_get_capability()
1797 drv->capa.key_mgmt |= in wpa_driver_ndis_get_capability()
1805 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP40; in wpa_driver_ndis_get_capability()
1806 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_WEP104; in wpa_driver_ndis_get_capability()
1809 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_TKIP; in wpa_driver_ndis_get_capability()
1812 drv->capa.enc |= WPA_DRIVER_CAPA_ENC_CCMP; in wpa_driver_ndis_get_capability()
1821 drv->capa.key_mgmt, drv->capa.enc, drv->capa.auth); in wpa_driver_ndis_get_capability()
1827 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_get_capa() local
1828 if (!drv->has_capability) in wpa_driver_ndis_get_capa()
1830 os_memcpy(capa, &drv->capa, sizeof(*capa)); in wpa_driver_ndis_get_capa()
1837 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_get_ifname() local
1838 return drv->ifname; in wpa_driver_ndis_get_ifname()
1844 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_get_mac_addr() local
1845 return drv->own_addr; in wpa_driver_ndis_get_mac_addr()
1855 struct wpa_driver_ndis_data *drv = eloop_data; in ndisuio_notification_receive() local
1860 if (!ReadMsgQueue(drv->event_queue, buf, NDISUIO_MSG_SIZE, &len, 0, in ndisuio_notification_receive()
1881 wpa_driver_ndis_event_adapter_arrival(drv); in ndisuio_notification_receive()
1887 wpa_driver_ndis_event_adapter_removal(drv); in ndisuio_notification_receive()
1892 SetEvent(drv->connected_event); in ndisuio_notification_receive()
1893 wpa_driver_ndis_event_connect(drv); in ndisuio_notification_receive()
1896 ResetEvent(drv->connected_event); in ndisuio_notification_receive()
1898 wpa_driver_ndis_event_disconnect(drv); in ndisuio_notification_receive()
1904 drv, hdr->pvStatusBuffer, hdr->uiStatusBufferSize); in ndisuio_notification_receive()
1907 drv, ((const u8 *) hdr) + hdr->uiOffsetToStatusBuffer, in ndisuio_notification_receive()
1919 static void ndisuio_notification_deinit(struct wpa_driver_ndis_data *drv) in ndisuio_notification_deinit() argument
1924 req.hMsgQueue = drv->event_queue; in ndisuio_notification_deinit()
1927 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_REQUEST_NOTIFICATION, in ndisuio_notification_deinit()
1934 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_CANCEL_NOTIFICATION, in ndisuio_notification_deinit()
1941 if (drv->event_queue) { in ndisuio_notification_deinit()
1942 eloop_unregister_event(drv->event_queue, in ndisuio_notification_deinit()
1943 sizeof(drv->event_queue)); in ndisuio_notification_deinit()
1944 CloseHandle(drv->event_queue); in ndisuio_notification_deinit()
1945 drv->event_queue = NULL; in ndisuio_notification_deinit()
1948 if (drv->connected_event) { in ndisuio_notification_deinit()
1949 CloseHandle(drv->connected_event); in ndisuio_notification_deinit()
1950 drv->connected_event = NULL; in ndisuio_notification_deinit()
1955 static int ndisuio_notification_init(struct wpa_driver_ndis_data *drv) in ndisuio_notification_init() argument
1960 drv->connected_event = in ndisuio_notification_init()
1962 if (drv->connected_event == NULL) { in ndisuio_notification_init()
1975 drv->event_queue = CreateMsgQueue(NULL, &opt); in ndisuio_notification_init()
1976 if (drv->event_queue == NULL) { in ndisuio_notification_init()
1980 ndisuio_notification_deinit(drv); in ndisuio_notification_init()
1985 req.hMsgQueue = drv->event_queue; in ndisuio_notification_init()
1997 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_REQUEST_NOTIFICATION, in ndisuio_notification_init()
2002 ndisuio_notification_deinit(drv); in ndisuio_notification_init()
2006 eloop_register_event(drv->event_queue, sizeof(drv->event_queue), in ndisuio_notification_init()
2007 ndisuio_notification_receive, drv, NULL); in ndisuio_notification_init()
2014 static int wpa_driver_ndis_get_names(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_get_names() argument
2032 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_QUERY_BINDING, in wpa_driver_ndis_get_names()
2061 if (os_strstr(name, drv->ifname)) { in wpa_driver_ndis_get_names()
2067 if (os_strncmp(desc, drv->ifname, os_strlen(drv->ifname)) == 0) in wpa_driver_ndis_get_names()
2078 drv->ifname); in wpa_driver_ndis_get_names()
2083 os_strlcpy(drv->ifname, in wpa_driver_ndis_get_names()
2085 sizeof(drv->ifname)); in wpa_driver_ndis_get_names()
2087 drv->adapter_name = wpa_strdup_tchar(drv->ifname); in wpa_driver_ndis_get_names()
2088 if (drv->adapter_name == NULL) { in wpa_driver_ndis_get_names()
2101 drv->adapter_desc = dup_binstr(desc, dlen); in wpa_driver_ndis_get_names()
2103 if (drv->adapter_desc == NULL) in wpa_driver_ndis_get_names()
2107 drv->adapter_desc); in wpa_driver_ndis_get_names()
2233 if (found_name == -1 && os_strstr(name[i], drv->ifname)) in wpa_driver_ndis_get_names()
2236 os_strncmp(desc[i], drv->ifname, os_strlen(drv->ifname)) == in wpa_driver_ndis_get_names()
2246 os_strlcpy(drv->ifname, in wpa_driver_ndis_get_names()
2249 sizeof(drv->ifname)); in wpa_driver_ndis_get_names()
2254 drv->ifname); in wpa_driver_ndis_get_names()
2269 drv->adapter_desc = dup_binstr(desc[i], dlen); in wpa_driver_ndis_get_names()
2271 if (drv->adapter_desc == NULL) in wpa_driver_ndis_get_names()
2275 drv->adapter_desc); in wpa_driver_ndis_get_names()
2341 static int wpa_driver_ndis_rebind_adapter(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_rebind_adapter() argument
2347 len = _tcslen(drv->adapter_name); in wpa_driver_ndis_rebind_adapter()
2360 memcpy(multi, drv->adapter_name, len * sizeof(TCHAR)); in wpa_driver_ndis_rebind_adapter()
2385 static int wpa_driver_ndis_set_wzc(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_set_wzc() argument
2407 return wpa_driver_ndis_rebind_adapter(drv); in wpa_driver_ndis_set_wzc()
2485 drv->wzc_disabled = 1; in wpa_driver_ndis_set_wzc()
2486 return wpa_driver_ndis_rebind_adapter(drv); in wpa_driver_ndis_set_wzc()
2555 if (os_strstr(drv->ifname, guid) == NULL) in wpa_driver_ndis_set_wzc()
2612 drv->wzc_disabled = 0; in wpa_driver_ndis_set_wzc()
2631 drv->wzc_disabled = 1; in wpa_driver_ndis_set_wzc()
2649 static int wpa_driver_ndis_set_wzc(struct wpa_driver_ndis_data *drv, in wpa_driver_ndis_set_wzc() argument
2673 static int wpa_driver_ndis_adapter_init(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_adapter_init() argument
2680 drv->ndisuio = CreateFile(NDISUIO_DEVICE_NAME, in wpa_driver_ndis_adapter_init()
2685 if (drv->ndisuio == INVALID_HANDLE_VALUE) { in wpa_driver_ndis_adapter_init()
2690 driver_ndis_ndisuio_handle = drv->ndisuio; in wpa_driver_ndis_adapter_init()
2693 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_BIND_WAIT, NULL, 0, in wpa_driver_ndis_adapter_init()
2697 CloseHandle(drv->ndisuio); in wpa_driver_ndis_adapter_init()
2698 drv->ndisuio = INVALID_HANDLE_VALUE; in wpa_driver_ndis_adapter_init()
2710 static int wpa_driver_ndis_adapter_open(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_adapter_open() argument
2724 len = pos + os_strlen(drv->ifname); in wpa_driver_ndis_adapter_open()
2730 ifname[i] = (WCHAR) drv->ifname[i - pos]; in wpa_driver_ndis_adapter_open()
2733 if (!DeviceIoControl(drv->ndisuio, IOCTL_NDISUIO_OPEN_DEVICE, in wpa_driver_ndis_adapter_open()
2740 CloseHandle(drv->ndisuio); in wpa_driver_ndis_adapter_open()
2741 drv->ndisuio = INVALID_HANDLE_VALUE; in wpa_driver_ndis_adapter_open()
2750 os_snprintf(ifname, sizeof(ifname), "\\Device\\NPF_%s", drv->ifname); in wpa_driver_ndis_adapter_open()
2751 drv->adapter = PacketOpenAdapter(ifname); in wpa_driver_ndis_adapter_open()
2752 if (drv->adapter == NULL) { in wpa_driver_ndis_adapter_open()
2762 static void wpa_driver_ndis_adapter_close(struct wpa_driver_ndis_data *drv) in wpa_driver_ndis_adapter_close() argument
2766 if (drv->ndisuio != INVALID_HANDLE_VALUE) in wpa_driver_ndis_adapter_close()
2767 CloseHandle(drv->ndisuio); in wpa_driver_ndis_adapter_close()
2769 if (drv->adapter) in wpa_driver_ndis_adapter_close()
2770 PacketCloseAdapter(drv->adapter); in wpa_driver_ndis_adapter_close()
2775 static int ndis_add_multicast(struct wpa_driver_ndis_data *drv) in ndis_add_multicast() argument
2777 if (ndis_set_oid(drv, OID_802_3_MULTICAST_LIST, in ndis_add_multicast()
2790 struct wpa_driver_ndis_data *drv; in wpa_driver_ndis_init() local
2793 drv = os_zalloc(sizeof(*drv)); in wpa_driver_ndis_init()
2794 if (drv == NULL) in wpa_driver_ndis_init()
2796 drv->ctx = ctx; in wpa_driver_ndis_init()
2807 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)); in wpa_driver_ndis_init()
2809 if (wpa_driver_ndis_adapter_init(drv) < 0) { in wpa_driver_ndis_init()
2810 os_free(drv); in wpa_driver_ndis_init()
2814 if (wpa_driver_ndis_get_names(drv) < 0) { in wpa_driver_ndis_init()
2815 wpa_driver_ndis_adapter_close(drv); in wpa_driver_ndis_init()
2816 os_free(drv); in wpa_driver_ndis_init()
2820 wpa_driver_ndis_set_wzc(drv, 0); in wpa_driver_ndis_init()
2822 if (wpa_driver_ndis_adapter_open(drv) < 0) { in wpa_driver_ndis_init()
2823 wpa_driver_ndis_adapter_close(drv); in wpa_driver_ndis_init()
2824 os_free(drv); in wpa_driver_ndis_init()
2828 if (ndis_get_oid(drv, OID_802_3_CURRENT_ADDRESS, in wpa_driver_ndis_init()
2829 (char *) drv->own_addr, ETH_ALEN) < 0) { in wpa_driver_ndis_init()
2832 wpa_driver_ndis_adapter_close(drv); in wpa_driver_ndis_init()
2833 os_free(drv); in wpa_driver_ndis_init()
2836 wpa_driver_ndis_get_capability(drv); in wpa_driver_ndis_init()
2840 wpa_driver_ndis_flush_pmkid(drv); in wpa_driver_ndis_init()
2846 wpa_driver_ndis_disconnect(drv); in wpa_driver_ndis_init()
2848 eloop_register_timeout(1, 0, wpa_driver_ndis_poll_timeout, drv, NULL); in wpa_driver_ndis_init()
2851 drv->events = ndis_events_init(&drv->events_pipe, &drv->event_avail, in wpa_driver_ndis_init()
2852 drv->ifname, drv->adapter_desc); in wpa_driver_ndis_init()
2853 if (drv->events == NULL) { in wpa_driver_ndis_init()
2854 wpa_driver_ndis_deinit(drv); in wpa_driver_ndis_init()
2857 eloop_register_event(drv->event_avail, sizeof(drv->event_avail), in wpa_driver_ndis_init()
2858 wpa_driver_ndis_event_pipe_cb, drv, NULL); in wpa_driver_ndis_init()
2862 if (ndisuio_notification_init(drv) < 0) { in wpa_driver_ndis_init()
2863 wpa_driver_ndis_deinit(drv); in wpa_driver_ndis_init()
2871 if (ndis_set_oid(drv, OID_802_11_INFRASTRUCTURE_MODE, in wpa_driver_ndis_init()
2880 res = ndis_get_oid(drv, OID_DOT11_CURRENT_OPERATION_MODE, buf, in wpa_driver_ndis_init()
2886 drv->native80211 = 1; in wpa_driver_ndis_init()
2887 } else if (!drv->has_capability || drv->capa.enc == 0) { in wpa_driver_ndis_init()
2895 drv->wired = 1; in wpa_driver_ndis_init()
2896 drv->capa.flags |= WPA_DRIVER_FLAGS_WIRED; in wpa_driver_ndis_init()
2897 drv->has_capability = 1; in wpa_driver_ndis_init()
2898 ndis_add_multicast(drv); in wpa_driver_ndis_init()
2902 return drv; in wpa_driver_ndis_init()
2908 struct wpa_driver_ndis_data *drv = priv; in wpa_driver_ndis_deinit() local
2911 if (drv->events) { in wpa_driver_ndis_deinit()
2912 eloop_unregister_event(drv->event_avail, in wpa_driver_ndis_deinit()
2913 sizeof(drv->event_avail)); in wpa_driver_ndis_deinit()
2914 ndis_events_deinit(drv->events); in wpa_driver_ndis_deinit()
2919 ndisuio_notification_deinit(drv); in wpa_driver_ndis_deinit()
2922 eloop_cancel_timeout(wpa_driver_ndis_scan_timeout, drv, drv->ctx); in wpa_driver_ndis_deinit()
2923 eloop_cancel_timeout(wpa_driver_ndis_poll_timeout, drv, NULL); in wpa_driver_ndis_deinit()
2924 wpa_driver_ndis_flush_pmkid(drv); in wpa_driver_ndis_deinit()
2925 wpa_driver_ndis_disconnect(drv); in wpa_driver_ndis_deinit()
2926 if (wpa_driver_ndis_radio_off(drv) < 0) { in wpa_driver_ndis_deinit()
2931 wpa_driver_ndis_adapter_close(drv); in wpa_driver_ndis_deinit()
2933 if (drv->wzc_disabled) in wpa_driver_ndis_deinit()
2934 wpa_driver_ndis_set_wzc(drv, 1); in wpa_driver_ndis_deinit()
2937 os_free(drv->adapter_name); in wpa_driver_ndis_deinit()
2939 os_free(drv->adapter_desc); in wpa_driver_ndis_deinit()
2940 os_free(drv); in wpa_driver_ndis_deinit()