2 * WPA Supplicant - driver interaction with Ralink Wireless Client
3 * Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2007, Snowpin Lee <snowpin_lee@ralinktech.com.tw>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Alternatively, this software may be distributed under the terms of BSD
13 * See README and COPYING for more details.
18 #include <sys/ioctl.h>
20 #include "wireless_copy.h"
23 #include "l2_packet/l2_packet.h"
25 #include "common/ieee802_11_defs.h"
26 #include "priv_netlink.h"
28 #include "linux_ioctl.h"
29 #include "driver_ralink.h"
31 static void wpa_driver_ralink_scan_timeout(void *eloop_ctx
, void *timeout_ctx
);
33 #define MAX_SSID_LEN 32
35 struct wpa_driver_ralink_data
{
38 struct netlink_data
*netlink
;
39 char ifname
[IFNAMSIZ
+ 1];
41 size_t assoc_req_ies_len
;
43 size_t assoc_resp_ies_len
;
45 struct ndis_pmkid_entry
*pmkid
;
46 int we_version_compiled
;
53 static int ralink_set_oid(struct wpa_driver_ralink_data
*drv
,
54 unsigned short oid
, char *data
, int len
)
62 os_memset(&iwr
, 0, sizeof(iwr
));
63 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
64 iwr
.u
.data
.flags
= oid
;
65 iwr
.u
.data
.flags
|= OID_GET_SET_TOGGLE
;
68 os_memcpy(buf
, data
, len
);
70 iwr
.u
.data
.pointer
= (caddr_t
) buf
;
71 iwr
.u
.data
.length
= len
;
73 if (ioctl(drv
->ioctl_sock
, RT_PRIV_IOCTL
, &iwr
) < 0) {
74 wpa_printf(MSG_DEBUG
, "%s: oid=0x%x len (%d) failed",
84 ralink_get_new_driver_flag(struct wpa_driver_ralink_data
*drv
)
89 os_memset(&iwr
, 0, sizeof(iwr
));
90 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
91 iwr
.u
.data
.pointer
= (UCHAR
*) &enabled
;
92 iwr
.u
.data
.flags
= RT_OID_NEW_DRIVER
;
94 if (ioctl(drv
->ioctl_sock
, RT_PRIV_IOCTL
, &iwr
) < 0) {
95 wpa_printf(MSG_DEBUG
, "%s: failed", __func__
);
99 return (enabled
== 1) ? 1 : 0;
102 static int wpa_driver_ralink_get_bssid(void *priv
, u8
*bssid
)
104 struct wpa_driver_ralink_data
*drv
= priv
;
108 if (drv
->g_driver_down
== 1)
111 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
113 os_memset(&iwr
, 0, sizeof(iwr
));
114 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
116 if (ioctl(drv
->ioctl_sock
, SIOCGIWAP
, &iwr
) < 0) {
117 perror("ioctl[SIOCGIWAP]");
120 os_memcpy(bssid
, iwr
.u
.ap_addr
.sa_data
, ETH_ALEN
);
125 static int wpa_driver_ralink_get_ssid(void *priv
, u8
*ssid
)
127 struct wpa_driver_ralink_data
*drv
= priv
;
129 struct wpa_supplicant
*wpa_s
= drv
->ctx
;
130 struct wpa_ssid
*entry
;
134 u8 ssid_str
[MAX_SSID_LEN
];
141 BOOLEAN ieee8021x_mode
= FALSE
;
142 BOOLEAN ieee8021x_required_key
= FALSE
;
145 if (drv
->g_driver_down
== 1)
148 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
150 os_memset(&iwr
, 0, sizeof(iwr
));
151 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
152 iwr
.u
.essid
.pointer
= (caddr_t
) ssid
;
153 iwr
.u
.essid
.length
= 32;
155 if (ioctl(drv
->ioctl_sock
, SIOCGIWESSID
, &iwr
) < 0) {
156 perror("ioctl[SIOCGIWESSID]");
159 ret
= iwr
.u
.essid
.length
;
165 os_memset(ssid_str
, 0, MAX_SSID_LEN
);
166 os_memcpy(ssid_str
, ssid
, ssid_len
);
168 if (drv
->ap_scan
== 0) {
169 /* Read BSSID form driver */
170 if (wpa_driver_ralink_get_bssid(priv
, bssid
) < 0) {
171 wpa_printf(MSG_WARNING
, "Could not read BSSID from "
177 entry
= wpa_s
->conf
->ssid
;
179 if (!entry
->disabled
&& ssid_len
== entry
->ssid_len
&&
180 os_memcmp(ssid_str
, entry
->ssid
, ssid_len
) == 0 &&
181 (!entry
->bssid_set
||
182 os_memcmp(bssid
, entry
->bssid
, ETH_ALEN
) == 0)) {
183 /* match the config of driver */
191 wpa_printf(MSG_DEBUG
, "Ready to set 802.1x mode and "
192 "ieee_required_keys parameters to driver");
194 /* set 802.1x mode and ieee_required_keys parameter */
195 if (entry
->key_mgmt
== WPA_KEY_MGMT_IEEE8021X_NO_WPA
) {
196 if ((entry
->eapol_flags
& (EAPOL_FLAG_REQUIRE_KEY_UNICAST
| EAPOL_FLAG_REQUIRE_KEY_BROADCAST
)))
197 ieee8021x_required_key
= TRUE
;
198 ieee8021x_mode
= TRUE
;
201 if (ralink_set_oid(drv
, OID_802_11_SET_IEEE8021X
, (char *) &ieee8021x_mode
, sizeof(BOOLEAN
)) < 0)
203 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set OID_802_11_SET_IEEE8021X(%d)", (int) ieee8021x_mode
);
207 wpa_printf(MSG_DEBUG
, "ieee8021x_mode is %s", ieee8021x_mode
? "TRUE" : "FALSE");
210 if (ralink_set_oid(drv
, OID_802_11_SET_IEEE8021X_REQUIRE_KEY
, (char *) &ieee8021x_required_key
, sizeof(BOOLEAN
)) < 0)
212 wpa_printf(MSG_DEBUG
, "ERROR: Failed to set OID_802_11_SET_IEEE8021X_REQUIRE_KEY(%d)", (int) ieee8021x_required_key
);
216 wpa_printf(MSG_DEBUG
, "ieee8021x_required_key is %s and eapol_flag(%d)", ieee8021x_required_key
? "TRUE" : "FALSE",
226 static int wpa_driver_ralink_set_ssid(struct wpa_driver_ralink_data
*drv
,
227 const u8
*ssid
, size_t ssid_len
)
229 NDIS_802_11_SSID
*buf
;
233 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
235 buf
= os_zalloc(sizeof(NDIS_802_11_SSID
));
238 os_memset(buf
, 0, sizeof(buf
));
239 buf
->SsidLength
= ssid_len
;
240 os_memcpy(buf
->Ssid
, ssid
, ssid_len
);
241 os_memset(&iwr
, 0, sizeof(iwr
));
242 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
244 iwr
.u
.data
.flags
= OID_802_11_SSID
;
245 iwr
.u
.data
.flags
|= OID_GET_SET_TOGGLE
;
246 iwr
.u
.data
.pointer
= (caddr_t
) buf
;
247 iwr
.u
.data
.length
= sizeof(NDIS_802_11_SSID
);
249 if (ioctl(drv
->ioctl_sock
, RT_PRIV_IOCTL
, &iwr
) < 0) {
250 perror("ioctl[RT_PRIV_IOCTL] -- OID_802_11_SSID");
257 static void wpa_driver_ralink_event_pmkid(struct wpa_driver_ralink_data
*drv
,
258 const u8
*data
, size_t data_len
)
260 NDIS_802_11_PMKID_CANDIDATE_LIST
*pmkid
;
262 union wpa_event_data event
;
264 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
267 wpa_printf(MSG_DEBUG
, "RALINK: Too short PMKID Candidate List "
268 "Event (len=%lu)", (unsigned long) data_len
);
271 pmkid
= (NDIS_802_11_PMKID_CANDIDATE_LIST
*) data
;
272 wpa_printf(MSG_DEBUG
, "RALINK: PMKID Candidate List Event - Version %d"
274 (int) pmkid
->Version
, (int) pmkid
->NumCandidates
);
276 if (pmkid
->Version
!= 1) {
277 wpa_printf(MSG_DEBUG
, "RALINK: Unsupported PMKID Candidate "
278 "List Version %d", (int) pmkid
->Version
);
282 if (data_len
< 8 + pmkid
->NumCandidates
* sizeof(PMKID_CANDIDATE
)) {
283 wpa_printf(MSG_DEBUG
, "RALINK: PMKID Candidate List "
291 os_memset(&event
, 0, sizeof(event
));
292 for (i
= 0; i
< pmkid
->NumCandidates
; i
++) {
293 PMKID_CANDIDATE
*p
= &pmkid
->CandidateList
[i
];
294 wpa_printf(MSG_DEBUG
, "RALINK: %lu: " MACSTR
" Flags 0x%x",
295 (unsigned long) i
, MAC2STR(p
->BSSID
),
297 os_memcpy(event
.pmkid_candidate
.bssid
, p
->BSSID
, ETH_ALEN
);
298 event
.pmkid_candidate
.index
= i
;
299 event
.pmkid_candidate
.preauth
=
300 p
->Flags
& NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
301 wpa_supplicant_event(drv
->ctx
, EVENT_PMKID_CANDIDATE
,
306 static int wpa_driver_ralink_set_pmkid(struct wpa_driver_ralink_data
*drv
)
308 int len
, count
, i
, ret
;
309 struct ndis_pmkid_entry
*entry
;
310 NDIS_802_11_PMKID
*p
;
312 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
318 if (count
>= drv
->no_of_pmkid
)
322 len
= 8 + count
* sizeof(BSSID_INFO
);
327 p
->BSSIDInfoCount
= count
;
329 for (i
= 0; i
< count
; i
++) {
330 os_memcpy(&p
->BSSIDInfo
[i
].BSSID
, entry
->bssid
, ETH_ALEN
);
331 os_memcpy(&p
->BSSIDInfo
[i
].PMKID
, entry
->pmkid
, 16);
334 wpa_hexdump(MSG_MSGDUMP
, "NDIS: OID_802_11_PMKID",
335 (const u8
*) p
, len
);
336 ret
= ralink_set_oid(drv
, OID_802_11_PMKID
, (char *) p
, len
);
341 static int wpa_driver_ralink_add_pmkid(void *priv
, const u8
*bssid
,
344 struct wpa_driver_ralink_data
*drv
= priv
;
345 struct ndis_pmkid_entry
*entry
, *prev
;
347 if (drv
->g_driver_down
== 1)
350 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
352 if (drv
->no_of_pmkid
== 0)
358 if (os_memcmp(entry
->bssid
, bssid
, ETH_ALEN
) == 0)
365 /* Replace existing entry for this BSSID and move it into the
366 * beginning of the list. */
367 os_memcpy(entry
->pmkid
, pmkid
, 16);
369 prev
->next
= entry
->next
;
370 entry
->next
= drv
->pmkid
;
374 entry
= os_malloc(sizeof(*entry
));
376 os_memcpy(entry
->bssid
, bssid
, ETH_ALEN
);
377 os_memcpy(entry
->pmkid
, pmkid
, 16);
378 entry
->next
= drv
->pmkid
;
383 return wpa_driver_ralink_set_pmkid(drv
);
387 static int wpa_driver_ralink_remove_pmkid(void *priv
, const u8
*bssid
,
390 struct wpa_driver_ralink_data
*drv
= priv
;
391 struct ndis_pmkid_entry
*entry
, *prev
;
393 if (drv
->g_driver_down
== 1)
396 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
398 if (drv
->no_of_pmkid
== 0)
405 if (os_memcmp(entry
->bssid
, bssid
, ETH_ALEN
) == 0 &&
406 os_memcmp(entry
->pmkid
, pmkid
, 16) == 0) {
408 prev
->next
= entry
->next
;
410 drv
->pmkid
= entry
->next
;
417 return wpa_driver_ralink_set_pmkid(drv
);
421 static int wpa_driver_ralink_flush_pmkid(void *priv
)
423 struct wpa_driver_ralink_data
*drv
= priv
;
425 struct ndis_pmkid_entry
*pmkid
, *prev
;
427 if (drv
->g_driver_down
== 1)
430 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
432 if (drv
->no_of_pmkid
== 0)
443 os_memset(&p
, 0, sizeof(p
));
445 p
.BSSIDInfoCount
= 0;
446 wpa_hexdump(MSG_MSGDUMP
, "NDIS: OID_802_11_PMKID (flush)",
448 return ralink_set_oid(drv
, OID_802_11_PMKID
, (char *) &p
, 8);
452 wpa_driver_ralink_event_wireless_custom(struct wpa_driver_ralink_data
*drv
,
453 void *ctx
, char *custom
)
455 union wpa_event_data data
;
456 u8
*req_ies
= NULL
, *resp_ies
= NULL
;
458 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
460 wpa_printf(MSG_DEBUG
, "Custom wireless event: '%s'", custom
);
462 os_memset(&data
, 0, sizeof(data
));
464 if (os_strncmp(custom
, "MLME-MICHAELMICFAILURE.indication", 33) == 0) {
465 /* receive a MICFAILURE report */
466 data
.michael_mic_failure
.unicast
=
467 os_strstr(custom
, " unicast") != NULL
;
468 /* TODO: parse parameters(?) */
469 wpa_supplicant_event(ctx
, EVENT_MICHAEL_MIC_FAILURE
, &data
);
470 } else if (os_strncmp(custom
, "ASSOCINFO_ReqIEs=", 17) == 0) {
471 /* receive assoc. req. IEs */
478 * bytes = strlen(spos); ==> bug, bytes may less than original
479 * size by using this way to get size. snowpin 20070312
483 bytes
= drv
->assoc_req_ies_len
;
485 req_ies
= os_malloc(bytes
);
488 os_memcpy(req_ies
, spos
, bytes
);
489 data
.assoc_info
.req_ies
= req_ies
;
490 data
.assoc_info
.req_ies_len
= bytes
;
492 /* skip the '\0' byte */
495 data
.assoc_info
.resp_ies
= NULL
;
496 data
.assoc_info
.resp_ies_len
= 0;
498 if (os_strncmp(spos
, " RespIEs=", 9) == 0) {
499 /* receive assoc. resp. IEs */
501 /* get IE's length */
502 bytes
= os_strlen(spos
);
506 resp_ies
= os_malloc(bytes
);
507 if (resp_ies
== NULL
)
509 os_memcpy(resp_ies
, spos
, bytes
);
510 data
.assoc_info
.resp_ies
= resp_ies
;
511 data
.assoc_info
.resp_ies_len
= bytes
;
514 wpa_supplicant_event(ctx
, EVENT_ASSOCINFO
, &data
);
517 /* free allocated memory */
523 static void ralink_interface_up(struct wpa_driver_ralink_data
*drv
)
525 union wpa_event_data event
;
526 int enable_wpa_supplicant
= 0;
527 drv
->g_driver_down
= 0;
528 os_memset(&event
, 0, sizeof(event
));
529 os_snprintf(event
.interface_status
.ifname
,
530 sizeof(event
.interface_status
.ifname
), "%s", drv
->ifname
);
532 event
.interface_status
.ievent
= EVENT_INTERFACE_ADDED
;
533 wpa_supplicant_event(drv
->ctx
, EVENT_INTERFACE_STATUS
, &event
);
535 if (drv
->ap_scan
== 1)
536 enable_wpa_supplicant
= 1;
538 enable_wpa_supplicant
= 2;
539 /* trigger driver support wpa_supplicant */
540 if (ralink_set_oid(drv
, RT_OID_WPA_SUPPLICANT_SUPPORT
,
541 (PCHAR
) &enable_wpa_supplicant
, sizeof(UCHAR
)) < 0)
543 wpa_printf(MSG_INFO
, "RALINK: Failed to set "
544 "RT_OID_WPA_SUPPLICANT_SUPPORT(%d)",
545 (int) enable_wpa_supplicant
);
546 wpa_printf(MSG_ERROR
, "ralink. Driver does not support "
552 wpa_driver_ralink_event_wireless(struct wpa_driver_ralink_data
*drv
,
553 void *ctx
, char *data
, int len
)
555 struct iw_event iwe_buf
, *iwe
= &iwe_buf
;
556 char *pos
, *end
, *custom
, *buf
, *assoc_info_buf
, *info_pos
;
558 BOOLEAN ieee8021x_required_key
= FALSE
;
561 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
563 assoc_info_buf
= info_pos
= NULL
;
567 while (pos
+ IW_EV_LCP_LEN
<= end
) {
568 /* Event data may be unaligned, so make a local, aligned copy
569 * before processing. */
570 os_memcpy(&iwe_buf
, pos
, IW_EV_LCP_LEN
);
571 wpa_printf(MSG_DEBUG
, "Wireless event: cmd=0x%x len=%d",
573 if (iwe
->len
<= IW_EV_LCP_LEN
)
576 custom
= pos
+ IW_EV_POINT_LEN
;
578 if (drv
->we_version_compiled
> 18 && iwe
->cmd
== IWEVCUSTOM
) {
579 /* WE-19 removed the pointer from struct iw_point */
580 char *dpos
= (char *) &iwe_buf
.u
.data
.length
;
581 int dlen
= dpos
- (char *) &iwe_buf
;
582 os_memcpy(dpos
, pos
+ IW_EV_LCP_LEN
,
583 sizeof(struct iw_event
) - dlen
);
585 os_memcpy(&iwe_buf
, pos
, sizeof(struct iw_event
));
586 custom
+= IW_EV_POINT_OFF
;
591 if (custom
+ iwe
->u
.data
.length
> end
)
593 buf
= os_malloc(iwe
->u
.data
.length
+ 1);
596 os_memcpy(buf
, custom
, iwe
->u
.data
.length
);
597 buf
[iwe
->u
.data
.length
] = '\0';
599 if (drv
->ap_scan
== 1) {
600 if ((iwe
->u
.data
.flags
== RT_ASSOC_EVENT_FLAG
)
601 || (iwe
->u
.data
.flags
==
602 RT_REQIE_EVENT_FLAG
) ||
603 (iwe
->u
.data
.flags
== RT_RESPIE_EVENT_FLAG
)
604 || (iwe
->u
.data
.flags
==
605 RT_ASSOCINFO_EVENT_FLAG
)) {
606 if (drv
->scanning_done
== 0) {
613 if (iwe
->u
.data
.flags
== RT_ASSOC_EVENT_FLAG
) {
614 wpa_supplicant_event(ctx
, EVENT_ASSOC
, NULL
);
615 wpa_printf(MSG_DEBUG
, "Custom wireless event: "
616 "receive ASSOCIATED_EVENT !!!");
617 } else if (iwe
->u
.data
.flags
== RT_REQIE_EVENT_FLAG
) {
618 wpa_printf(MSG_DEBUG
, "Custom wireless event: "
619 "receive ReqIEs !!!");
621 os_malloc(iwe
->u
.data
.length
);
622 if (drv
->assoc_req_ies
== NULL
) {
627 drv
->assoc_req_ies_len
= iwe
->u
.data
.length
;
628 os_memcpy(drv
->assoc_req_ies
, custom
,
630 } else if (iwe
->u
.data
.flags
== RT_RESPIE_EVENT_FLAG
) {
631 wpa_printf(MSG_DEBUG
, "Custom wireless event: "
632 "receive RespIEs !!!");
633 drv
->assoc_resp_ies
=
634 os_malloc(iwe
->u
.data
.length
);
635 if (drv
->assoc_resp_ies
== NULL
) {
636 os_free(drv
->assoc_req_ies
);
637 drv
->assoc_req_ies
= NULL
;
642 drv
->assoc_resp_ies_len
= iwe
->u
.data
.length
;
643 os_memcpy(drv
->assoc_resp_ies
, custom
,
645 } else if (iwe
->u
.data
.flags
==
646 RT_ASSOCINFO_EVENT_FLAG
) {
647 wpa_printf(MSG_DEBUG
, "Custom wireless event: "
648 "receive ASSOCINFO_EVENT !!!");
651 os_zalloc(drv
->assoc_req_ies_len
+
652 drv
->assoc_resp_ies_len
+ 1);
654 if (assoc_info_buf
== NULL
) {
655 os_free(drv
->assoc_req_ies
);
656 drv
->assoc_req_ies
= NULL
;
657 os_free(drv
->assoc_resp_ies
);
658 drv
->assoc_resp_ies
= NULL
;
663 if (drv
->assoc_req_ies
) {
664 os_memcpy(assoc_info_buf
,
666 drv
->assoc_req_ies_len
);
668 info_pos
= assoc_info_buf
+
669 drv
->assoc_req_ies_len
;
670 if (drv
->assoc_resp_ies
) {
673 drv
->assoc_resp_ies_len
);
675 assoc_info_buf
[drv
->assoc_req_ies_len
+
676 drv
->assoc_resp_ies_len
] = '\0';
677 wpa_driver_ralink_event_wireless_custom(
678 drv
, ctx
, assoc_info_buf
);
679 os_free(drv
->assoc_req_ies
);
680 drv
->assoc_req_ies
= NULL
;
681 os_free(drv
->assoc_resp_ies
);
682 drv
->assoc_resp_ies
= NULL
;
683 os_free(assoc_info_buf
);
684 } else if (iwe
->u
.data
.flags
== RT_DISASSOC_EVENT_FLAG
)
686 wpa_printf(MSG_DEBUG
, "Custom wireless event: "
687 "receive DISASSOCIATED_EVENT !!!");
688 wpa_supplicant_event(ctx
, EVENT_DISASSOC
,
690 } else if (iwe
->u
.data
.flags
== RT_PMKIDCAND_FLAG
) {
691 wpa_printf(MSG_DEBUG
, "Custom wireless event: "
692 "receive PMKIDCAND_EVENT !!!");
693 wpa_driver_ralink_event_pmkid(
694 drv
, (const u8
*) custom
,
696 } else if (iwe
->u
.data
.flags
== RT_INTERFACE_DOWN
) {
697 drv
->g_driver_down
= 1;
699 } else if (iwe
->u
.data
.flags
== RT_INTERFACE_UP
) {
700 ralink_interface_up(drv
);
702 wpa_driver_ralink_event_wireless_custom(
714 wpa_driver_ralink_event_rtm_newlink(void *ctx
, struct ifinfomsg
*ifi
,
717 struct wpa_driver_ralink_data
*drv
= ctx
;
718 int attrlen
, rta_len
;
721 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
723 wpa_hexdump(MSG_DEBUG
, "ifi: ", (u8
*) ifi
, sizeof(struct ifinfomsg
));
726 wpa_printf(MSG_DEBUG
, "attrlen=%d", attrlen
);
727 attr
= (struct rtattr
*) buf
;
728 wpa_hexdump(MSG_DEBUG
, "attr1: ", (u8
*) attr
, sizeof(struct rtattr
));
729 rta_len
= RTA_ALIGN(sizeof(struct rtattr
));
730 wpa_hexdump(MSG_DEBUG
, "attr2: ", (u8
*)attr
,rta_len
);
731 while (RTA_OK(attr
, attrlen
)) {
732 wpa_printf(MSG_DEBUG
, "rta_type=%02x\n", attr
->rta_type
);
733 if (attr
->rta_type
== IFLA_WIRELESS
) {
734 wpa_driver_ralink_event_wireless(
736 ((char *) attr
) + rta_len
,
737 attr
->rta_len
- rta_len
);
739 attr
= RTA_NEXT(attr
, attrlen
);
740 wpa_hexdump(MSG_DEBUG
, "attr3: ",
741 (u8
*) attr
, sizeof(struct rtattr
));
746 ralink_get_we_version_compiled(struct wpa_driver_ralink_data
*drv
)
749 UINT we_version_compiled
= 0;
751 os_memset(&iwr
, 0, sizeof(iwr
));
752 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
753 iwr
.u
.data
.pointer
= (caddr_t
) &we_version_compiled
;
754 iwr
.u
.data
.flags
= RT_OID_WE_VERSION_COMPILED
;
756 if (ioctl(drv
->ioctl_sock
, RT_PRIV_IOCTL
, &iwr
) < 0) {
757 wpa_printf(MSG_DEBUG
, "%s: failed", __func__
);
761 drv
->we_version_compiled
= we_version_compiled
;
766 static void * wpa_driver_ralink_init(void *ctx
, const char *ifname
)
769 struct wpa_driver_ralink_data
*drv
;
771 UCHAR enable_wpa_supplicant
= 0;
772 struct netlink_config
*cfg
;
774 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
776 /* open socket to kernel */
777 if ((s
= socket(AF_INET
, SOCK_DGRAM
, 0)) < 0) {
782 os_strlcpy(ifr
.ifr_name
, ifname
, IFNAMSIZ
);
784 if (ioctl(s
, SIOCGIFINDEX
, &ifr
) < 0) {
785 perror(ifr
.ifr_name
);
789 drv
= os_zalloc(sizeof(*drv
));
793 drv
->scanning_done
= 1;
794 drv
->ap_scan
= 1; /* for now - let's assume ap_scan=1 is used */
796 os_strlcpy(drv
->ifname
, ifname
, sizeof(drv
->ifname
));
798 drv
->g_driver_down
= 0;
800 cfg
= os_zalloc(sizeof(*cfg
));
802 close(drv
->ioctl_sock
);
807 cfg
->newlink_cb
= wpa_driver_ralink_event_rtm_newlink
;
808 drv
->netlink
= netlink_init(cfg
);
809 if (drv
->netlink
== NULL
) {
811 close(drv
->ioctl_sock
);
816 drv
->no_of_pmkid
= 4; /* Number of PMKID saved supported */
818 linux_set_iface_flags(drv
->ioctl_sock
, drv
->ifname
, 1);
819 ralink_get_we_version_compiled(drv
);
820 wpa_driver_ralink_flush_pmkid(drv
);
822 if (drv
->ap_scan
== 1)
823 enable_wpa_supplicant
= 1;
825 enable_wpa_supplicant
= 2;
826 /* trigger driver support wpa_supplicant */
827 if (ralink_set_oid(drv
, RT_OID_WPA_SUPPLICANT_SUPPORT
,
828 (PCHAR
) &enable_wpa_supplicant
, sizeof(UCHAR
)) < 0)
830 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
831 "RT_OID_WPA_SUPPLICANT_SUPPORT(%d)",
832 (int) enable_wpa_supplicant
);
833 wpa_printf(MSG_ERROR
, "RALINK: Driver does not support "
836 close(drv
->ioctl_sock
);
841 if (drv
->ap_scan
== 1)
842 drv
->scanning_done
= 0;
847 static void wpa_driver_ralink_deinit(void *priv
)
849 struct wpa_driver_ralink_data
*drv
= priv
;
850 UCHAR enable_wpa_supplicant
;
852 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
854 enable_wpa_supplicant
= 0;
856 if (drv
->g_driver_down
== 0) {
857 /* trigger driver disable wpa_supplicant support */
858 if (ralink_set_oid(drv
, RT_OID_WPA_SUPPLICANT_SUPPORT
,
859 (char *) &enable_wpa_supplicant
,
860 sizeof(BOOLEAN
)) < 0) {
861 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
862 "RT_OID_WPA_SUPPLICANT_SUPPORT(%d)",
863 (int) enable_wpa_supplicant
);
866 wpa_driver_ralink_flush_pmkid(drv
);
869 /* linux_set_iface_flags(drv->ioctl_sock, drv->ifname, 0); */
872 eloop_cancel_timeout(wpa_driver_ralink_scan_timeout
, drv
, drv
->ctx
);
873 netlink_deinit(drv
->netlink
);
874 close(drv
->ioctl_sock
);
878 static void wpa_driver_ralink_scan_timeout(void *eloop_ctx
, void *timeout_ctx
)
880 struct wpa_driver_ralink_data
*drv
= eloop_ctx
;
882 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
884 wpa_printf(MSG_DEBUG
, "Scan timeout - try to get results");
885 wpa_supplicant_event(timeout_ctx
, EVENT_SCAN_RESULTS
, NULL
);
887 drv
->scanning_done
= 1;
891 static int wpa_driver_ralink_scan(void *priv
,
892 struct wpa_driver_scan_params
*params
)
894 struct wpa_driver_ralink_data
*drv
= priv
;
898 if (drv
->g_driver_down
== 1)
901 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
904 if (ssid_len
> IW_ESSID_MAX_SIZE
) {
905 wpa_printf(MSG_DEBUG
, "%s: too long SSID (%lu)",
906 __FUNCTION__
, (unsigned long) ssid_len
);
910 /* wpa_driver_ralink_set_ssid(drv, ssid, ssid_len); */
913 if (ralink_set_oid(drv
, RT_OID_WPS_PROBE_REQ_IE
,
914 (char *) params
->extra_ies
, params
->extra_ies_len
) <
916 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
917 "RT_OID_WPS_PROBE_REQ_IE");
920 os_memset(&iwr
, 0, sizeof(iwr
));
921 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
923 if (ioctl(drv
->ioctl_sock
, SIOCSIWSCAN
, &iwr
) < 0) {
924 perror("ioctl[SIOCSIWSCAN]");
928 /* Not all drivers generate "scan completed" wireless event, so try to
929 * read results after a timeout. */
930 eloop_cancel_timeout(wpa_driver_ralink_scan_timeout
, drv
, drv
->ctx
);
931 eloop_register_timeout(4, 0, wpa_driver_ralink_scan_timeout
, drv
,
934 drv
->scanning_done
= 0;
939 static struct wpa_scan_results
*
940 wpa_driver_ralink_get_scan_results(void *priv
)
942 struct wpa_driver_ralink_data
*drv
= priv
;
945 NDIS_802_11_BSSID_LIST_EX
*wsr
;
946 NDIS_WLAN_BSSID_EX
*wbi
;
950 struct wpa_scan_results
*res
;
952 if (drv
->g_driver_down
== 1)
954 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
956 if (drv
->we_version_compiled
>= 17)
962 buf
= os_zalloc(buf_len
);
963 iwr
.u
.data
.length
= buf_len
;
967 wsr
= (NDIS_802_11_BSSID_LIST_EX
*) buf
;
969 wsr
->NumberOfItems
= 0;
970 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
971 iwr
.u
.data
.pointer
= (void *) buf
;
972 iwr
.u
.data
.flags
= OID_802_11_BSSID_LIST
;
974 if (ioctl(drv
->ioctl_sock
, RT_PRIV_IOCTL
, &iwr
) == 0)
977 if (errno
== E2BIG
&& buf_len
< 65535) {
982 buf_len
= 65535; /* 16-bit length field */
983 wpa_printf(MSG_DEBUG
, "Scan results did not fit - "
984 "trying larger buffer (%lu bytes)",
985 (unsigned long) buf_len
);
987 perror("ioctl[RT_PRIV_IOCTL]");
993 res
= os_zalloc(sizeof(*res
));
999 res
->res
= os_zalloc(wsr
->NumberOfItems
*
1000 sizeof(struct wpa_scan_res
*));
1001 if (res
->res
== NULL
) {
1007 for (ap_num
= 0, wbi
= wsr
->Bssid
; ap_num
< wsr
->NumberOfItems
;
1009 struct wpa_scan_res
*r
= NULL
;
1010 size_t extra_len
= 0, var_ie_len
= 0;
1013 /* SSID data element */
1014 extra_len
+= 2 + wbi
->Ssid
.SsidLength
;
1015 var_ie_len
= wbi
->IELength
- sizeof(NDIS_802_11_FIXED_IEs
);
1016 r
= os_zalloc(sizeof(*r
) + extra_len
+ var_ie_len
);
1019 res
->res
[res
->num
++] = r
;
1021 wpa_printf(MSG_DEBUG
, "SSID - %s", wbi
->Ssid
.Ssid
);
1023 wpa_hexdump(MSG_DEBUG
, "RALINK: AP IEs",
1024 (u8
*) &wbi
->IEs
[0], wbi
->IELength
);
1026 os_memcpy(r
->bssid
, wbi
->MacAddress
, ETH_ALEN
);
1028 extra_len
+= (2 + wbi
->Ssid
.SsidLength
);
1029 r
->ie_len
= extra_len
+ var_ie_len
;
1030 pos2
= (u8
*) (r
+ 1);
1033 * Generate a fake SSID IE since the driver did not report
1036 *pos2
++ = WLAN_EID_SSID
;
1037 *pos2
++ = wbi
->Ssid
.SsidLength
;
1038 os_memcpy(pos2
, wbi
->Ssid
.Ssid
, wbi
->Ssid
.SsidLength
);
1039 pos2
+= wbi
->Ssid
.SsidLength
;
1041 r
->freq
= (wbi
->Configuration
.DSConfig
/ 1000);
1043 pos
= (u8
*) wbi
+ sizeof(*wbi
) - 1;
1045 pos
+= sizeof(NDIS_802_11_FIXED_IEs
) - 2;
1046 os_memcpy(&(r
->caps
), pos
, 2);
1049 if (wbi
->IELength
> sizeof(NDIS_802_11_FIXED_IEs
))
1050 os_memcpy(pos2
, pos
, var_ie_len
);
1052 wbi
= (NDIS_WLAN_BSSID_EX
*) ((u8
*) wbi
+ wbi
->Length
);
1059 static int ralink_set_auth_mode(struct wpa_driver_ralink_data
*drv
,
1060 NDIS_802_11_AUTHENTICATION_MODE mode
)
1062 NDIS_802_11_AUTHENTICATION_MODE auth_mode
= mode
;
1064 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1066 if (ralink_set_oid(drv
, OID_802_11_AUTHENTICATION_MODE
,
1067 (char *) &auth_mode
, sizeof(auth_mode
)) < 0) {
1068 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1069 "OID_802_11_AUTHENTICATION_MODE (%d)",
1076 static int ralink_set_encr_type(struct wpa_driver_ralink_data
*drv
,
1077 NDIS_802_11_WEP_STATUS encr_type
)
1079 NDIS_802_11_WEP_STATUS wep_status
= encr_type
;
1081 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1083 if (ralink_set_oid(drv
, OID_802_11_WEP_STATUS
,
1084 (char *) &wep_status
, sizeof(wep_status
)) < 0) {
1085 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1086 "OID_802_11_WEP_STATUS (%d)",
1094 static int wpa_driver_ralink_remove_key(struct wpa_driver_ralink_data
*drv
,
1095 int key_idx
, const u8
*addr
,
1096 const u8
*bssid
, int pairwise
)
1098 NDIS_802_11_REMOVE_KEY rkey
;
1099 NDIS_802_11_KEY_INDEX _index
;
1102 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1104 os_memset(&rkey
, 0, sizeof(rkey
));
1106 rkey
.Length
= sizeof(rkey
);
1107 rkey
.KeyIndex
= key_idx
;
1110 rkey
.KeyIndex
|= 1 << 30;
1112 os_memcpy(rkey
.BSSID
, bssid
, ETH_ALEN
);
1114 res
= ralink_set_oid(drv
, OID_802_11_REMOVE_KEY
, (char *) &rkey
,
1117 /* AlbertY@20060210 removed it */
1118 if (0 /* !pairwise */) {
1119 res2
= ralink_set_oid(drv
, OID_802_11_REMOVE_WEP
,
1120 (char *) &_index
, sizeof(_index
));
1124 if (res
< 0 && res2
< 0)
1129 static int wpa_driver_ralink_add_wep(struct wpa_driver_ralink_data
*drv
,
1130 int pairwise
, int key_idx
, int set_tx
,
1131 const u8
*key
, size_t key_len
)
1133 NDIS_802_11_WEP
*wep
;
1137 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1140 wep
= os_zalloc(len
);
1145 wep
->KeyIndex
= key_idx
;
1148 wep
->KeyIndex
|= 0x80000000;
1150 wep
->KeyLength
= key_len
;
1151 os_memcpy(wep
->KeyMaterial
, key
, key_len
);
1153 wpa_hexdump_key(MSG_MSGDUMP
, "RALINK: OID_802_11_ADD_WEP",
1154 (const u8
*) wep
, len
);
1155 res
= ralink_set_oid(drv
, OID_802_11_ADD_WEP
, (char *) wep
, len
);
1162 static int wpa_driver_ralink_set_key(const char *ifname
, void *priv
,
1163 enum wpa_alg alg
, const u8
*addr
,
1164 int key_idx
, int set_tx
,
1165 const u8
*seq
, size_t seq_len
,
1166 const u8
*key
, size_t key_len
)
1168 struct wpa_driver_ralink_data
*drv
= priv
;
1170 NDIS_802_11_KEY
*nkey
;
1174 if (drv
->g_driver_down
== 1)
1177 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1179 drv
->bAddWepKey
= FALSE
;
1181 if (addr
== NULL
|| os_memcmp(addr
, "\xff\xff\xff\xff\xff\xff",
1185 wpa_driver_ralink_get_bssid(drv
, bssid
);
1189 os_memcpy(bssid
, addr
, ETH_ALEN
);
1192 if (alg
== WPA_ALG_NONE
|| key_len
== 0) {
1193 return wpa_driver_ralink_remove_key(drv
, key_idx
, addr
, bssid
,
1197 if (alg
== WPA_ALG_WEP
) {
1198 drv
->bAddWepKey
= TRUE
;
1199 return wpa_driver_ralink_add_wep(drv
, pairwise
, key_idx
,
1200 set_tx
, key
, key_len
);
1203 len
= 12 + 6 + 6 + 8 + key_len
;
1205 nkey
= os_zalloc(len
);
1210 nkey
->KeyIndex
= key_idx
;
1213 nkey
->KeyIndex
|= 1 << 31;
1216 nkey
->KeyIndex
|= 1 << 30;
1219 nkey
->KeyIndex
|= 1 << 29;
1221 nkey
->KeyLength
= key_len
;
1222 os_memcpy(nkey
->BSSID
, bssid
, ETH_ALEN
);
1224 if (seq
&& seq_len
) {
1225 for (i
= 0; i
< seq_len
; i
++)
1226 nkey
->KeyRSC
|= seq
[i
] << (i
* 8);
1228 if (alg
== WPA_ALG_TKIP
&& key_len
== 32) {
1229 os_memcpy(nkey
->KeyMaterial
, key
, 16);
1230 os_memcpy(nkey
->KeyMaterial
+ 16, key
+ 24, 8);
1231 os_memcpy(nkey
->KeyMaterial
+ 24, key
+ 16, 8);
1233 os_memcpy(nkey
->KeyMaterial
, key
, key_len
);
1236 wpa_printf(MSG_DEBUG
, "%s: alg=%d key_idx=%d set_tx=%d seq_len=%lu "
1237 "key_len=%lu", __FUNCTION__
, alg
, key_idx
, set_tx
,
1238 (unsigned long) seq_len
, (unsigned long) key_len
);
1240 wpa_hexdump_key(MSG_MSGDUMP
, "RALINK: OID_802_11_ADD_KEY",
1241 (const u8
*) nkey
, len
);
1242 res
= ralink_set_oid(drv
, OID_802_11_ADD_KEY
, (char *) nkey
, len
);
1248 static int wpa_driver_ralink_disassociate(void *priv
, const u8
*addr
,
1251 struct wpa_driver_ralink_data
*drv
= priv
;
1253 if (drv
->g_driver_down
== 1)
1255 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1256 if (ralink_set_oid(drv
, OID_802_11_DISASSOCIATE
, " ", 4) < 0) {
1257 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1258 "OID_802_11_DISASSOCIATE");
1264 static int wpa_driver_ralink_deauthenticate(void *priv
, const u8
*addr
,
1267 struct wpa_driver_ralink_data
*drv
= priv
;
1269 wpa_printf(MSG_DEBUG
, "g_driver_down = %d", drv
->g_driver_down
);
1271 if (drv
->g_driver_down
== 1)
1274 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1275 if (ralink_get_new_driver_flag(drv
) == 0) {
1276 return wpa_driver_ralink_disassociate(priv
, addr
, reason_code
);
1278 MLME_DEAUTH_REQ_STRUCT mlme
;
1279 os_memset(&mlme
, 0, sizeof(MLME_DEAUTH_REQ_STRUCT
));
1280 mlme
.Reason
= reason_code
;
1281 os_memcpy(mlme
.Addr
, addr
, MAC_ADDR_LEN
);
1282 return ralink_set_oid(drv
, OID_802_11_DEAUTHENTICATION
,
1284 sizeof(MLME_DEAUTH_REQ_STRUCT
));
1288 static int wpa_driver_ralink_set_gen_ie(void *priv
, const u8
*ie
,
1291 struct wpa_driver_ralink_data
*drv
= priv
;
1295 os_memset(&iwr
, 0, sizeof(iwr
));
1296 os_strlcpy(iwr
.ifr_name
, drv
->ifname
, IFNAMSIZ
);
1297 iwr
.u
.data
.pointer
= (caddr_t
) ie
;
1298 iwr
.u
.data
.length
= ie_len
;
1300 wpa_hexdump(MSG_DEBUG
, "wpa_driver_ralink_set_gen_ie: ",
1303 if (ioctl(drv
->ioctl_sock
, SIOCSIWGENIE
, &iwr
) < 0) {
1304 perror("ioctl[SIOCSIWGENIE]");
1312 wpa_driver_ralink_associate(void *priv
,
1313 struct wpa_driver_associate_params
*params
)
1315 struct wpa_driver_ralink_data
*drv
= priv
;
1317 NDIS_802_11_NETWORK_INFRASTRUCTURE mode
;
1318 NDIS_802_11_AUTHENTICATION_MODE auth_mode
;
1319 NDIS_802_11_WEP_STATUS encr
;
1320 BOOLEAN ieee8021xMode
;
1321 BOOLEAN ieee8021x_required_key
= TRUE
;
1323 if (drv
->g_driver_down
== 1)
1325 wpa_printf(MSG_DEBUG
, "%s", __FUNCTION__
);
1327 if (params
->mode
== IEEE80211_MODE_IBSS
)
1328 mode
= Ndis802_11IBSS
;
1330 mode
= Ndis802_11Infrastructure
;
1332 if (ralink_set_oid(drv
, OID_802_11_INFRASTRUCTURE_MODE
,
1333 (char *) &mode
, sizeof(mode
)) < 0) {
1334 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1335 "OID_802_11_INFRASTRUCTURE_MODE (%d)",
1337 /* Try to continue anyway */
1340 if (params
->key_mgmt_suite
== KEY_MGMT_WPS
) {
1341 UCHAR enable_wps
= 0x80;
1342 /* trigger driver support wpa_supplicant */
1343 if (ralink_set_oid(drv
, RT_OID_WPA_SUPPLICANT_SUPPORT
,
1344 (PCHAR
) &enable_wps
, sizeof(UCHAR
)) < 0) {
1345 wpa_printf(MSG_INFO
, "RALINK: Failed to set "
1346 "RT_OID_WPA_SUPPLICANT_SUPPORT (%d)",
1350 wpa_driver_ralink_set_gen_ie(priv
, params
->wpa_ie
,
1351 params
->wpa_ie_len
);
1353 ralink_set_auth_mode(drv
, Ndis802_11AuthModeOpen
);
1355 ralink_set_encr_type(drv
, Ndis802_11EncryptionDisabled
);
1358 UCHAR enable_wpa_supplicant
;
1360 if (drv
->ap_scan
== 1)
1361 enable_wpa_supplicant
= 0x01;
1363 enable_wpa_supplicant
= 0x02;
1365 /* trigger driver support wpa_supplicant */
1366 if (ralink_set_oid(drv
, RT_OID_WPA_SUPPLICANT_SUPPORT
,
1367 (PCHAR
) &enable_wpa_supplicant
,
1368 sizeof(UCHAR
)) < 0) {
1369 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1370 "RT_OID_WPA_SUPPLICANT_SUPPORT (%d)",
1371 (int) enable_wpa_supplicant
);
1374 wpa_driver_ralink_set_gen_ie(priv
, (u8
*) "", 0);
1375 #endif /* CONFIG_WPS */
1377 if (params
->wpa_ie
== NULL
|| params
->wpa_ie_len
== 0) {
1378 if (params
->auth_alg
& WPA_AUTH_ALG_SHARED
) {
1379 if (params
->auth_alg
& WPA_AUTH_ALG_OPEN
)
1380 auth_mode
= Ndis802_11AuthModeAutoSwitch
;
1382 auth_mode
= Ndis802_11AuthModeShared
;
1384 auth_mode
= Ndis802_11AuthModeOpen
;
1385 } else if (params
->wpa_ie
[0] == WLAN_EID_RSN
) {
1386 if (params
->key_mgmt_suite
== KEY_MGMT_PSK
)
1387 auth_mode
= Ndis802_11AuthModeWPA2PSK
;
1389 auth_mode
= Ndis802_11AuthModeWPA2
;
1391 if (params
->key_mgmt_suite
== KEY_MGMT_WPA_NONE
)
1392 auth_mode
= Ndis802_11AuthModeWPANone
;
1393 else if (params
->key_mgmt_suite
== KEY_MGMT_PSK
)
1394 auth_mode
= Ndis802_11AuthModeWPAPSK
;
1396 auth_mode
= Ndis802_11AuthModeWPA
;
1399 switch (params
->pairwise_suite
) {
1401 encr
= Ndis802_11Encryption3Enabled
;
1404 encr
= Ndis802_11Encryption2Enabled
;
1408 encr
= Ndis802_11Encryption1Enabled
;
1411 if (params
->group_suite
== CIPHER_CCMP
)
1412 encr
= Ndis802_11Encryption3Enabled
;
1413 else if (params
->group_suite
== CIPHER_TKIP
)
1414 encr
= Ndis802_11Encryption2Enabled
;
1416 encr
= Ndis802_11EncryptionDisabled
;
1419 encr
= Ndis802_11EncryptionDisabled
;
1423 ralink_set_auth_mode(drv
, auth_mode
);
1425 /* notify driver that IEEE8021x mode is enabled */
1426 if (params
->key_mgmt_suite
== KEY_MGMT_802_1X_NO_WPA
) {
1427 ieee8021xMode
= TRUE
;
1428 if (drv
->bAddWepKey
)
1429 ieee8021x_required_key
= FALSE
;
1431 ieee8021xMode
= FALSE
;
1433 if (ralink_set_oid(drv
, OID_802_11_SET_IEEE8021X_REQUIRE_KEY
,
1434 (char *) &ieee8021x_required_key
,
1435 sizeof(BOOLEAN
)) < 0) {
1436 wpa_printf(MSG_DEBUG
, "ERROR: Failed to set "
1437 "OID_802_11_SET_IEEE8021X_REQUIRE_KEY(%d)",
1438 (int) ieee8021x_required_key
);
1440 wpa_printf(MSG_DEBUG
, "ieee8021x_required_key is %s",
1441 ieee8021x_required_key
? "TRUE" : "FALSE");
1444 if (ralink_set_oid(drv
, OID_802_11_SET_IEEE8021X
,
1445 (char *) &ieee8021xMode
, sizeof(BOOLEAN
)) <
1447 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1448 "OID_802_11_SET_IEEE8021X(%d)",
1449 (int) ieee8021xMode
);
1452 ralink_set_encr_type(drv
, encr
);
1454 if ((ieee8021xMode
== FALSE
) &&
1455 (encr
== Ndis802_11Encryption1Enabled
)) {
1458 if (ralink_set_oid(drv
, OID_802_11_DROP_UNENCRYPTED
,
1459 (char *) &enabled
, sizeof(enabled
))
1461 wpa_printf(MSG_DEBUG
, "RALINK: Failed to set "
1462 "OID_802_11_DROP_UNENCRYPTED(%d)",
1468 return wpa_driver_ralink_set_ssid(drv
, params
->ssid
, params
->ssid_len
);
1472 wpa_driver_ralink_set_countermeasures(void *priv
, int enabled
)
1474 struct wpa_driver_ralink_data
*drv
= priv
;
1475 if (drv
->g_driver_down
== 1)
1477 wpa_printf(MSG_DEBUG
, "%s: enabled=%d", __FUNCTION__
, enabled
);
1478 return ralink_set_oid(drv
, OID_SET_COUNTERMEASURES
, (char *) &enabled
,
1482 const struct wpa_driver_ops wpa_driver_ralink_ops
= {
1484 .desc
= "Ralink Wireless Client driver",
1485 .get_bssid
= wpa_driver_ralink_get_bssid
,
1486 .get_ssid
= wpa_driver_ralink_get_ssid
,
1487 .set_key
= wpa_driver_ralink_set_key
,
1488 .init
= wpa_driver_ralink_init
,
1489 .deinit
= wpa_driver_ralink_deinit
,
1490 .set_countermeasures
= wpa_driver_ralink_set_countermeasures
,
1491 .scan2
= wpa_driver_ralink_scan
,
1492 .get_scan_results2
= wpa_driver_ralink_get_scan_results
,
1493 .deauthenticate
= wpa_driver_ralink_deauthenticate
,
1494 .disassociate
= wpa_driver_ralink_disassociate
,
1495 .associate
= wpa_driver_ralink_associate
,
1496 .add_pmkid
= wpa_driver_ralink_add_pmkid
,
1497 .remove_pmkid
= wpa_driver_ralink_remove_pmkid
,
1498 .flush_pmkid
= wpa_driver_ralink_flush_pmkid
,