Deleted Added
full compact
driver_ndis.c (209158) driver_ndis.c (214734)
1/*
2 * WPA Supplicant - Windows/NDIS driver interface
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *

--- 26 unchanged lines hidden (view full) ---

35#include <winioctl.h>
36#include <nuiouser.h>
37#include <devload.h>
38#endif /* _WIN32_WCE */
39
40#include "common.h"
41#include "driver.h"
42#include "eloop.h"
1/*
2 * WPA Supplicant - Windows/NDIS driver interface
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *

--- 26 unchanged lines hidden (view full) ---

35#include <winioctl.h>
36#include <nuiouser.h>
37#include <devload.h>
38#endif /* _WIN32_WCE */
39
40#include "common.h"
41#include "driver.h"
42#include "eloop.h"
43#include "ieee802_11_defs.h"
43#include "common/ieee802_11_defs.h"
44#include "driver_ndis.h"
45
46int wpa_driver_register_event_cb(struct wpa_driver_ndis_data *drv);
47#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
48void wpa_driver_ndis_event_pipe_cb(void *eloop_data, void *user_data);
49#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
50
51static void wpa_driver_ndis_deinit(void *priv);

--- 297 unchanged lines hidden (view full) ---

349 ULONG Version;
350 ULONG NumCandidates;
351 PMKID_CANDIDATE CandidateList[1];
352} NDIS_802_11_PMKID_CANDIDATE_LIST;
353
354#endif /* OID_802_11_CAPABILITY */
355
356
44#include "driver_ndis.h"
45
46int wpa_driver_register_event_cb(struct wpa_driver_ndis_data *drv);
47#ifdef CONFIG_NDIS_EVENTS_INTEGRATED
48void wpa_driver_ndis_event_pipe_cb(void *eloop_data, void *user_data);
49#endif /* CONFIG_NDIS_EVENTS_INTEGRATED */
50
51static void wpa_driver_ndis_deinit(void *priv);

--- 297 unchanged lines hidden (view full) ---

349 ULONG Version;
350 ULONG NumCandidates;
351 PMKID_CANDIDATE CandidateList[1];
352} NDIS_802_11_PMKID_CANDIDATE_LIST;
353
354#endif /* OID_802_11_CAPABILITY */
355
356
357#ifndef OID_DOT11_CURRENT_OPERATION_MODE
358/* Native 802.11 OIDs */
359#define OID_DOT11_NDIS_START 0x0D010300
360#define OID_DOT11_CURRENT_OPERATION_MODE (OID_DOT11_NDIS_START + 8)
361#define OID_DOT11_SCAN_REQUEST (OID_DOT11_NDIS_START + 11)
362
363typedef enum _DOT11_BSS_TYPE {
364 dot11_BSS_type_infrastructure = 1,
365 dot11_BSS_type_independent = 2,
366 dot11_BSS_type_any = 3
367} DOT11_BSS_TYPE, * PDOT11_BSS_TYPE;
368
369typedef UCHAR DOT11_MAC_ADDRESS[6];
370typedef DOT11_MAC_ADDRESS * PDOT11_MAC_ADDRESS;
371
372typedef enum _DOT11_SCAN_TYPE {
373 dot11_scan_type_active = 1,
374 dot11_scan_type_passive = 2,
375 dot11_scan_type_auto = 3,
376 dot11_scan_type_forced = 0x80000000
377} DOT11_SCAN_TYPE, * PDOT11_SCAN_TYPE;
378
379typedef struct _DOT11_SCAN_REQUEST_V2 {
380 DOT11_BSS_TYPE dot11BSSType;
381 DOT11_MAC_ADDRESS dot11BSSID;
382 DOT11_SCAN_TYPE dot11ScanType;
383 BOOLEAN bRestrictedScan;
384 ULONG udot11SSIDsOffset;
385 ULONG uNumOfdot11SSIDs;
386 BOOLEAN bUseRequestIE;
387 ULONG uRequestIDsOffset;
388 ULONG uNumOfRequestIDs;
389 ULONG uPhyTypeInfosOffset;
390 ULONG uNumOfPhyTypeInfos;
391 ULONG uIEsOffset;
392 ULONG uIEsLength;
393 UCHAR ucBuffer[1];
394} DOT11_SCAN_REQUEST_V2, * PDOT11_SCAN_REQUEST_V2;
395
396#endif /* OID_DOT11_CURRENT_OPERATION_MODE */
397
357#ifdef CONFIG_USE_NDISUIO
358#ifndef _WIN32_WCE
359#ifdef __MINGW32_VERSION
360typedef ULONG NDIS_OID;
361#endif /* __MINGW32_VERSION */
362/* from nuiouser.h */
363#define FSCTL_NDISUIO_BASE FILE_DEVICE_NETWORK
364

--- 329 unchanged lines hidden (view full) ---

694static int wpa_driver_ndis_disassociate(void *priv, const u8 *addr,
695 int reason_code)
696{
697 struct wpa_driver_ndis_data *drv = priv;
698 return wpa_driver_ndis_disconnect(drv);
699}
700
701
398#ifdef CONFIG_USE_NDISUIO
399#ifndef _WIN32_WCE
400#ifdef __MINGW32_VERSION
401typedef ULONG NDIS_OID;
402#endif /* __MINGW32_VERSION */
403/* from nuiouser.h */
404#define FSCTL_NDISUIO_BASE FILE_DEVICE_NETWORK
405

--- 329 unchanged lines hidden (view full) ---

735static int wpa_driver_ndis_disassociate(void *priv, const u8 *addr,
736 int reason_code)
737{
738 struct wpa_driver_ndis_data *drv = priv;
739 return wpa_driver_ndis_disconnect(drv);
740}
741
742
702static int wpa_driver_ndis_set_wpa(void *priv, int enabled)
743static void wpa_driver_ndis_scan_timeout(void *eloop_ctx, void *timeout_ctx)
703{
744{
704 wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled);
705 return 0;
745 wpa_printf(MSG_DEBUG, "Scan timeout - try to get results");
746 wpa_supplicant_event(timeout_ctx, EVENT_SCAN_RESULTS, NULL);
706}
707
708
747}
748
749
709static void wpa_driver_ndis_scan_timeout(void *eloop_ctx, void *timeout_ctx)
750static int wpa_driver_ndis_scan_native80211(
751 struct wpa_driver_ndis_data *drv,
752 struct wpa_driver_scan_params *params)
710{
753{
711 wpa_printf(MSG_DEBUG, "Scan timeout - try to get results");
712 wpa_supplicant_event(timeout_ctx, EVENT_SCAN_RESULTS, NULL);
754 DOT11_SCAN_REQUEST_V2 req;
755 int res;
756
757 os_memset(&req, 0, sizeof(req));
758 req.dot11BSSType = dot11_BSS_type_any;
759 os_memset(req.dot11BSSID, 0xff, ETH_ALEN);
760 req.dot11ScanType = dot11_scan_type_auto;
761 res = ndis_set_oid(drv, OID_DOT11_SCAN_REQUEST, (char *) &req,
762 sizeof(req));
763 eloop_cancel_timeout(wpa_driver_ndis_scan_timeout, drv, drv->ctx);
764 eloop_register_timeout(7, 0, wpa_driver_ndis_scan_timeout, drv,
765 drv->ctx);
766 return res;
713}
714
715
767}
768
769
716static int wpa_driver_ndis_scan(void *priv, const u8 *ssid, size_t ssid_len)
770static int wpa_driver_ndis_scan(void *priv,
771 struct wpa_driver_scan_params *params)
717{
718 struct wpa_driver_ndis_data *drv = priv;
719 int res;
720
772{
773 struct wpa_driver_ndis_data *drv = priv;
774 int res;
775
776 if (drv->native80211)
777 return wpa_driver_ndis_scan_native80211(drv, params);
778
721 if (!drv->radio_enabled) {
722 wpa_printf(MSG_DEBUG, "NDIS: turning radio on before the first"
723 " scan");
724 if (wpa_driver_ndis_disconnect(drv) < 0) {
725 wpa_printf(MSG_DEBUG, "NDIS: failed to enable radio");
726 }
727 drv->radio_enabled = 1;
728 }
729
730 res = ndis_set_oid(drv, OID_802_11_BSSID_LIST_SCAN, " ", 4);
731 eloop_cancel_timeout(wpa_driver_ndis_scan_timeout, drv, drv->ctx);
732 eloop_register_timeout(7, 0, wpa_driver_ndis_scan_timeout, drv,
733 drv->ctx);
734 return res;
735}
736
737
779 if (!drv->radio_enabled) {
780 wpa_printf(MSG_DEBUG, "NDIS: turning radio on before the first"
781 " scan");
782 if (wpa_driver_ndis_disconnect(drv) < 0) {
783 wpa_printf(MSG_DEBUG, "NDIS: failed to enable radio");
784 }
785 drv->radio_enabled = 1;
786 }
787
788 res = ndis_set_oid(drv, OID_802_11_BSSID_LIST_SCAN, " ", 4);
789 eloop_cancel_timeout(wpa_driver_ndis_scan_timeout, drv, drv->ctx);
790 eloop_register_timeout(7, 0, wpa_driver_ndis_scan_timeout, drv,
791 drv->ctx);
792 return res;
793}
794
795
796static const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie)
797{
798 const u8 *end, *pos;
799
800 pos = (const u8 *) (res + 1);
801 end = pos + res->ie_len;
802
803 while (pos + 1 < end) {
804 if (pos + 2 + pos[1] > end)
805 break;
806 if (pos[0] == ie)
807 return pos;
808 pos += 2 + pos[1];
809 }
810
811 return NULL;
812}
813
814
738static struct wpa_scan_res * wpa_driver_ndis_add_scan_ssid(
739 struct wpa_scan_res *r, NDIS_802_11_SSID *ssid)
740{
741 struct wpa_scan_res *nr;
742 u8 *pos;
743
744 if (wpa_scan_get_ie(r, WLAN_EID_SSID))
745 return r; /* SSID IE already present */

--- 162 unchanged lines hidden (view full) ---

908 res = ndis_set_oid(drv, OID_802_11_ADD_WEP, (char *) wep, len);
909
910 os_free(wep);
911
912 return res;
913}
914
915
815static struct wpa_scan_res * wpa_driver_ndis_add_scan_ssid(
816 struct wpa_scan_res *r, NDIS_802_11_SSID *ssid)
817{
818 struct wpa_scan_res *nr;
819 u8 *pos;
820
821 if (wpa_scan_get_ie(r, WLAN_EID_SSID))
822 return r; /* SSID IE already present */

--- 162 unchanged lines hidden (view full) ---

985 res = ndis_set_oid(drv, OID_802_11_ADD_WEP, (char *) wep, len);
986
987 os_free(wep);
988
989 return res;
990}
991
992
916static int wpa_driver_ndis_set_key(void *priv, wpa_alg alg, const u8 *addr,
993static int wpa_driver_ndis_set_key(const char *ifname, void *priv,
994 enum wpa_alg alg, const u8 *addr,
917 int key_idx, int set_tx,
918 const u8 *seq, size_t seq_len,
919 const u8 *key, size_t key_len)
920{
921 struct wpa_driver_ndis_data *drv = priv;
922 size_t len, i;
923 NDIS_802_11_KEY *nkey;
924 int res, pairwise;

--- 91 unchanged lines hidden (view full) ---

1016 /* Re-set WEP keys if static WEP configuration is used. */
1017 u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1018 int i;
1019 for (i = 0; i < 4; i++) {
1020 if (!params->wep_key[i])
1021 continue;
1022 wpa_printf(MSG_DEBUG, "NDIS: Re-setting static WEP "
1023 "key %d", i);
995 int key_idx, int set_tx,
996 const u8 *seq, size_t seq_len,
997 const u8 *key, size_t key_len)
998{
999 struct wpa_driver_ndis_data *drv = priv;
1000 size_t len, i;
1001 NDIS_802_11_KEY *nkey;
1002 int res, pairwise;

--- 91 unchanged lines hidden (view full) ---

1094 /* Re-set WEP keys if static WEP configuration is used. */
1095 u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1096 int i;
1097 for (i = 0; i < 4; i++) {
1098 if (!params->wep_key[i])
1099 continue;
1100 wpa_printf(MSG_DEBUG, "NDIS: Re-setting static WEP "
1101 "key %d", i);
1024 wpa_driver_ndis_set_key(drv, WPA_ALG_WEP, bcast, i,
1102 wpa_driver_ndis_set_key(drv->ifname, drv, WPA_ALG_WEP,
1103 bcast, i,
1025 i == params->wep_tx_keyidx,
1026 NULL, 0, params->wep_key[i],
1027 params->wep_key_len[i]);
1028 }
1029 }
1030
1031 if (params->wpa_ie == NULL || params->wpa_ie_len == 0) {
1104 i == params->wep_tx_keyidx,
1105 NULL, 0, params->wep_key[i],
1106 params->wep_key_len[i]);
1107 }
1108 }
1109
1110 if (params->wpa_ie == NULL || params->wpa_ie_len == 0) {
1032 if (params->auth_alg & AUTH_ALG_SHARED_KEY) {
1033 if (params->auth_alg & AUTH_ALG_OPEN_SYSTEM)
1111 if (params->auth_alg & WPA_AUTH_ALG_SHARED) {
1112 if (params->auth_alg & WPA_AUTH_ALG_OPEN)
1034 auth_mode = Ndis802_11AuthModeAutoSwitch;
1035 else
1036 auth_mode = Ndis802_11AuthModeShared;
1037 } else
1038 auth_mode = Ndis802_11AuthModeOpen;
1039 priv_mode = Ndis802_11PrivFilterAcceptAll;
1040 } else if (params->wpa_ie[0] == WLAN_EID_RSN) {
1041 priv_mode = Ndis802_11PrivFilter8021xWEP;

--- 1755 unchanged lines hidden (view full) ---

2797 }
2798#endif /* _WIN32_WCE */
2799
2800 /* Set mode here in case card was configured for ad-hoc mode
2801 * previously. */
2802 mode = Ndis802_11Infrastructure;
2803 if (ndis_set_oid(drv, OID_802_11_INFRASTRUCTURE_MODE,
2804 (char *) &mode, sizeof(mode)) < 0) {
1113 auth_mode = Ndis802_11AuthModeAutoSwitch;
1114 else
1115 auth_mode = Ndis802_11AuthModeShared;
1116 } else
1117 auth_mode = Ndis802_11AuthModeOpen;
1118 priv_mode = Ndis802_11PrivFilterAcceptAll;
1119 } else if (params->wpa_ie[0] == WLAN_EID_RSN) {
1120 priv_mode = Ndis802_11PrivFilter8021xWEP;

--- 1755 unchanged lines hidden (view full) ---

2876 }
2877#endif /* _WIN32_WCE */
2878
2879 /* Set mode here in case card was configured for ad-hoc mode
2880 * previously. */
2881 mode = Ndis802_11Infrastructure;
2882 if (ndis_set_oid(drv, OID_802_11_INFRASTRUCTURE_MODE,
2883 (char *) &mode, sizeof(mode)) < 0) {
2884 char buf[8];
2885 int res;
2805 wpa_printf(MSG_DEBUG, "NDIS: Failed to set "
2806 "OID_802_11_INFRASTRUCTURE_MODE (%d)",
2807 (int) mode);
2808 /* Try to continue anyway */
2809
2886 wpa_printf(MSG_DEBUG, "NDIS: Failed to set "
2887 "OID_802_11_INFRASTRUCTURE_MODE (%d)",
2888 (int) mode);
2889 /* Try to continue anyway */
2890
2810 if (!drv->has_capability && drv->capa.enc == 0) {
2891 res = ndis_get_oid(drv, OID_DOT11_CURRENT_OPERATION_MODE, buf,
2892 sizeof(buf));
2893 if (res > 0) {
2894 wpa_printf(MSG_INFO, "NDIS: The driver seems to use "
2895 "Native 802.11 OIDs. These are not yet "
2896 "fully supported.");
2897 drv->native80211 = 1;
2898 } else if (!drv->has_capability || drv->capa.enc == 0) {
2899 /*
2900 * Note: This will also happen with NDIS 6 drivers with
2901 * Vista.
2902 */
2811 wpa_printf(MSG_DEBUG, "NDIS: Driver did not provide "
2812 "any wireless capabilities - assume it is "
2813 "a wired interface");
2814 drv->wired = 1;
2903 wpa_printf(MSG_DEBUG, "NDIS: Driver did not provide "
2904 "any wireless capabilities - assume it is "
2905 "a wired interface");
2906 drv->wired = 1;
2907 drv->capa.flags |= WPA_DRIVER_FLAGS_WIRED;
2908 drv->has_capability = 1;
2815 ndis_add_multicast(drv);
2816 }
2817 }
2818
2819 return drv;
2820}
2821
2822

--- 269 unchanged lines hidden (view full) ---

3092}
3093
3094
3095const struct wpa_driver_ops wpa_driver_ndis_ops = {
3096 "ndis",
3097 "Windows NDIS driver",
3098 wpa_driver_ndis_get_bssid,
3099 wpa_driver_ndis_get_ssid,
2909 ndis_add_multicast(drv);
2910 }
2911 }
2912
2913 return drv;
2914}
2915
2916

--- 269 unchanged lines hidden (view full) ---

3186}
3187
3188
3189const struct wpa_driver_ops wpa_driver_ndis_ops = {
3190 "ndis",
3191 "Windows NDIS driver",
3192 wpa_driver_ndis_get_bssid,
3193 wpa_driver_ndis_get_ssid,
3100 wpa_driver_ndis_set_wpa,
3101 wpa_driver_ndis_set_key,
3102 wpa_driver_ndis_init,
3103 wpa_driver_ndis_deinit,
3104 NULL /* set_param */,
3105 NULL /* set_countermeasures */,
3194 wpa_driver_ndis_set_key,
3195 wpa_driver_ndis_init,
3196 wpa_driver_ndis_deinit,
3197 NULL /* set_param */,
3198 NULL /* set_countermeasures */,
3106 NULL /* set_drop_unencrypted */,
3107 wpa_driver_ndis_scan,
3108 NULL /* get_scan_results */,
3109 wpa_driver_ndis_deauthenticate,
3110 wpa_driver_ndis_disassociate,
3111 wpa_driver_ndis_associate,
3199 wpa_driver_ndis_deauthenticate,
3200 wpa_driver_ndis_disassociate,
3201 wpa_driver_ndis_associate,
3112 NULL /* set_auth_alg */,
3113 wpa_driver_ndis_add_pmkid,
3114 wpa_driver_ndis_remove_pmkid,
3115 wpa_driver_ndis_flush_pmkid,
3116 wpa_driver_ndis_get_capa,
3117 wpa_driver_ndis_poll,
3118 wpa_driver_ndis_get_ifname,
3119 wpa_driver_ndis_get_mac_addr,
3120 NULL /* send_eapol */,

--- 4 unchanged lines hidden (view full) ---

3125 NULL /* set_ssid */,
3126 NULL /* set_bssid */,
3127 NULL /* send_mlme */,
3128 NULL /* mlme_add_sta */,
3129 NULL /* mlme_remove_sta */,
3130 NULL /* update_ft_ies */,
3131 NULL /* send_ft_action */,
3132 wpa_driver_ndis_get_scan_results,
3202 wpa_driver_ndis_add_pmkid,
3203 wpa_driver_ndis_remove_pmkid,
3204 wpa_driver_ndis_flush_pmkid,
3205 wpa_driver_ndis_get_capa,
3206 wpa_driver_ndis_poll,
3207 wpa_driver_ndis_get_ifname,
3208 wpa_driver_ndis_get_mac_addr,
3209 NULL /* send_eapol */,

--- 4 unchanged lines hidden (view full) ---

3214 NULL /* set_ssid */,
3215 NULL /* set_bssid */,
3216 NULL /* send_mlme */,
3217 NULL /* mlme_add_sta */,
3218 NULL /* mlme_remove_sta */,
3219 NULL /* update_ft_ies */,
3220 NULL /* send_ft_action */,
3221 wpa_driver_ndis_get_scan_results,
3133 NULL /* set_probe_req_ie */,
3134 NULL /* set_mode */,
3135 NULL /* set_country */,
3136 NULL /* global_init */,
3137 NULL /* global_deinit */,
3138 NULL /* init2 */,
3222 NULL /* set_country */,
3223 NULL /* global_init */,
3224 NULL /* global_deinit */,
3225 NULL /* init2 */,
3139 wpa_driver_ndis_get_interfaces
3226 wpa_driver_ndis_get_interfaces,
3227 wpa_driver_ndis_scan,
3228 NULL /* authenticate */,
3229 NULL /* set_beacon */,
3230 NULL /* hapd_init */,
3231 NULL /* hapd_deinit */,
3232 NULL /* set_ieee8021x */,
3233 NULL /* set_privacy */,
3234 NULL /* get_seqnum */,
3235 NULL /* flush */,
3236 NULL /* set_generic_elem */,
3237 NULL /* read_sta_data */,
3238 NULL /* hapd_send_eapol */,
3239 NULL /* sta_deauth */,
3240 NULL /* sta_disassoc */,
3241 NULL /* sta_remove */,
3242 NULL /* hapd_get_ssid */,
3243 NULL /* hapd_set_ssid */,
3244 NULL /* hapd_set_countermeasures */,
3245 NULL /* sta_add */,
3246 NULL /* get_inact_sec */,
3247 NULL /* sta_clear_stats */,
3248 NULL /* set_freq */,
3249 NULL /* set_rts */,
3250 NULL /* set_frag */,
3251 NULL /* sta_set_flags */,
3252 NULL /* set_rate_sets */,
3253 NULL /* set_cts_protect */,
3254 NULL /* set_preamble */,
3255 NULL /* set_short_slot_time */,
3256 NULL /* set_tx_queue_params */,
3257 NULL /* valid_bss_mask */,
3258 NULL /* if_add */,
3259 NULL /* if_remove */,
3260 NULL /* set_sta_vlan */,
3261 NULL /* commit */,
3262 NULL /* send_ether */,
3263 NULL /* set_radius_acl_auth */,
3264 NULL /* set_radius_acl_expire */,
3265 NULL /* set_ht_params */,
3266 NULL /* set_ap_wps_ie */,
3267 NULL /* set_supp_port */,
3268 NULL /* set_wds_sta */,
3269 NULL /* send_action */,
3270 NULL /* remain_on_channel */,
3271 NULL /* cancel_remain_on_channel */,
3272 NULL /* probe_req_report */,
3273 NULL /* disable_11b_rates */,
3274 NULL /* deinit_ap */,
3275 NULL /* suspend */,
3276 NULL /* resume */,
3277 NULL /* signal_monitor */,
3278 NULL /* send_frame */
3140};
3279};