2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: handle wpa supplicant ioctl input/out functions
43 /*--------------------- Static Definitions -------------------------*/
45 #define VIAWGET_WPA_MAX_BUF_SIZE 1024
47 static const int frequency_list
[] = {
48 2412, 2417, 2422, 2427, 2432, 2437, 2442,
49 2447, 2452, 2457, 2462, 2467, 2472, 2484
51 /*--------------------- Static Classes ----------------------------*/
53 /*--------------------- Static Variables --------------------------*/
54 static int msglevel
= MSG_LEVEL_INFO
;
56 /*--------------------- Static Functions --------------------------*/
58 /*--------------------- Export Variables --------------------------*/
59 static void wpadev_setup(struct net_device
*dev
)
61 dev
->type
= ARPHRD_IEEE80211
;
62 dev
->hard_header_len
= ETH_HLEN
;
64 dev
->addr_len
= ETH_ALEN
;
65 dev
->tx_queue_len
= 1000;
67 memset(dev
->broadcast
, 0xFF, ETH_ALEN
);
69 dev
->flags
= IFF_BROADCAST
|IFF_MULTICAST
;
74 * register netdev for wpa supplicant daemon
86 static int wpa_init_wpadev(PSDevice pDevice
)
89 struct net_device
*dev
= pDevice
->dev
;
92 pDevice
->wpadev
= alloc_netdev(sizeof(PSDevice
), "vntwpa", wpadev_setup
);
93 if (pDevice
->wpadev
== NULL
)
96 wpadev_priv
= netdev_priv(pDevice
->wpadev
);
97 *wpadev_priv
= *pDevice
;
98 eth_hw_addr_inherit(pDevice
->wpadev
, dev
);
99 pDevice
->wpadev
->base_addr
= dev
->base_addr
;
100 pDevice
->wpadev
->irq
= dev
->irq
;
101 pDevice
->wpadev
->mem_start
= dev
->mem_start
;
102 pDevice
->wpadev
->mem_end
= dev
->mem_end
;
103 ret
= register_netdev(pDevice
->wpadev
);
105 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdev(WPA) failed!\n",
107 free_netdev(pDevice
->wpadev
);
111 if (pDevice
->skb
== NULL
) {
112 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
113 if (pDevice
->skb
== NULL
)
117 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdev %s for WPA management\n",
118 dev
->name
, pDevice
->wpadev
->name
);
125 * unregister net_device (wpadev)
136 static int wpa_release_wpadev(PSDevice pDevice
)
139 dev_kfree_skb(pDevice
->skb
);
143 if (pDevice
->wpadev
) {
144 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Netdevice %s unregistered\n",
145 pDevice
->dev
->name
, pDevice
->wpadev
->name
);
146 unregister_netdev(pDevice
->wpadev
);
147 free_netdev(pDevice
->wpadev
);
148 pDevice
->wpadev
= NULL
;
156 * Set enable/disable dev for wpa supplicant daemon
168 int wpa_set_wpadev(PSDevice pDevice
, int val
)
171 return wpa_init_wpadev(pDevice
);
173 return wpa_release_wpadev(pDevice
);
178 * Set WPA algorithm & keys
190 int wpa_set_keys(PSDevice pDevice
, void *ctx
,
191 bool fcpfkernel
) __must_hold(&pDevice
->lock
)
193 struct viawget_wpa_param
*param
= ctx
;
194 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
195 unsigned long dwKeyIndex
= 0;
196 unsigned char abyKey
[MAX_KEY_LEN
];
197 unsigned char abySeq
[MAX_KEY_LEN
];
199 unsigned char byKeyDecMode
= KEY_CTL_WEP
;
203 if (param
->u
.wpa_key
.alg_name
> WPA_ALG_CCMP
||
204 param
->u
.wpa_key
.key_len
> MAX_KEY_LEN
||
205 param
->u
.wpa_key
.seq_len
> MAX_KEY_LEN
)
208 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"param->u.wpa_key.alg_name = %d\n", param
->u
.wpa_key
.alg_name
);
209 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
210 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
211 pDevice
->bEncryptionEnable
= false;
212 pDevice
->byKeyIndex
= 0;
213 pDevice
->bTransmitKey
= false;
214 KeyvRemoveAllWEPKey(&(pDevice
->sKey
), pDevice
->PortOffset
);
215 for (uu
= 0; uu
< MAX_KEY_TABLE
; uu
++)
216 MACvDisableKeyEntry(pDevice
->PortOffset
, uu
);
221 if (param
->u
.wpa_key
.key
&& fcpfkernel
) {
222 memcpy(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
);
224 spin_unlock_irq(&pDevice
->lock
);
225 if (param
->u
.wpa_key
.key
&&
226 copy_from_user(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
)) {
227 spin_lock_irq(&pDevice
->lock
);
230 spin_lock_irq(&pDevice
->lock
);
233 dwKeyIndex
= (unsigned long)(param
->u
.wpa_key
.key_index
);
235 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_WEP
) {
236 if (dwKeyIndex
> 3) {
239 if (param
->u
.wpa_key
.set_tx
) {
240 pDevice
->byKeyIndex
= (unsigned char)dwKeyIndex
;
241 pDevice
->bTransmitKey
= true;
242 dwKeyIndex
|= (1 << 31);
244 KeybSetDefaultKey(&(pDevice
->sKey
),
245 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
246 param
->u
.wpa_key
.key_len
,
254 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
255 pDevice
->bEncryptionEnable
= true;
259 if (param
->u
.wpa_key
.seq
&& fcpfkernel
) {
260 memcpy(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
);
262 spin_unlock_irq(&pDevice
->lock
);
263 if (param
->u
.wpa_key
.seq
&&
264 copy_from_user(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
)) {
265 spin_lock_irq(&pDevice
->lock
);
268 spin_lock_irq(&pDevice
->lock
);
271 if (param
->u
.wpa_key
.seq_len
> 0) {
272 for (ii
= 0; ii
< param
->u
.wpa_key
.seq_len
; ii
++) {
274 LODWORD(KeyRSC
) |= (abySeq
[ii
] << (ii
* 8));
276 HIDWORD(KeyRSC
) |= (abySeq
[ii
] << ((ii
-4) * 8));
278 dwKeyIndex
|= 1 << 29;
281 if (param
->u
.wpa_key
.key_index
>= MAX_GROUP_KEY
) {
282 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return dwKeyIndex > 3\n");
286 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_TKIP
)
287 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
289 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_CCMP
)
290 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
292 if (param
->u
.wpa_key
.set_tx
)
293 dwKeyIndex
|= (1 << 31);
295 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
296 byKeyDecMode
= KEY_CTL_CCMP
;
297 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
298 byKeyDecMode
= KEY_CTL_TKIP
;
300 byKeyDecMode
= KEY_CTL_WEP
;
302 // Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled
303 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
304 if (param
->u
.wpa_key
.key_len
== MAX_KEY_LEN
)
305 byKeyDecMode
= KEY_CTL_TKIP
;
306 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
307 byKeyDecMode
= KEY_CTL_WEP
;
308 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
309 byKeyDecMode
= KEY_CTL_WEP
;
310 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
311 if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
312 byKeyDecMode
= KEY_CTL_WEP
;
313 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
314 byKeyDecMode
= KEY_CTL_WEP
;
317 // Check TKIP key length
318 if ((byKeyDecMode
== KEY_CTL_TKIP
) &&
319 (param
->u
.wpa_key
.key_len
!= MAX_KEY_LEN
)) {
320 // TKIP Key must be 256 bits
321 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return- TKIP Key must be 256 bits!\n");
324 // Check AES key length
325 if ((byKeyDecMode
== KEY_CTL_CCMP
) &&
326 (param
->u
.wpa_key
.key_len
!= AES_KEY_LEN
)) {
327 // AES Key must be 128 bits
331 // spin_lock_irq(&pDevice->lock);
332 if (is_broadcast_ether_addr(¶m
->addr
[0]) || (param
->addr
== NULL
)) {
333 // If is_broadcast_ether_addr, set the key as every key entry's group key.
334 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Groupe Key Assign.\n");
336 if (KeybSetAllGroupKey(&(pDevice
->sKey
),
338 param
->u
.wpa_key
.key_len
,
340 (unsigned char *)abyKey
,
343 pDevice
->byLocalID
) &&
344 KeybSetDefaultKey(&(pDevice
->sKey
),
346 param
->u
.wpa_key
.key_len
,
348 (unsigned char *)abyKey
,
351 pDevice
->byLocalID
)) {
352 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GROUP Key Assign.\n");
359 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Assign.\n");
360 // BSSID not 0xffffffffffff
361 // Pairwise Key can't be WEP
362 if (byKeyDecMode
== KEY_CTL_WEP
) {
363 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key can't be WEP\n");
367 dwKeyIndex
|= (1 << 30); // set pairwise key
368 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
)
371 if (KeybSetKey(&(pDevice
->sKey
),
374 param
->u
.wpa_key
.key_len
,
376 (unsigned char *)abyKey
,
379 pDevice
->byLocalID
)) {
380 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Set\n");
386 } // BSSID not 0xffffffffffff
387 if ((ret
== 0) && ((param
->u
.wpa_key
.set_tx
) != 0)) {
388 pDevice
->byKeyIndex
= (unsigned char)param
->u
.wpa_key
.key_index
;
389 pDevice
->bTransmitKey
= true;
391 pDevice
->bEncryptionEnable
= true;
398 * enable wpa auth & mode
410 static int wpa_set_wpa(PSDevice pDevice
,
411 struct viawget_wpa_param
*param
)
413 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
415 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
416 pMgmt
->bShareKeyAlgorithm
= false;
435 static int wpa_set_disassociate(PSDevice pDevice
,
436 struct viawget_wpa_param
*param
)
438 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
440 spin_lock_irq(&pDevice
->lock
);
441 if (pDevice
->bLinkPass
) {
442 if (!memcmp(param
->addr
, pMgmt
->abyCurrBSSID
, 6))
443 bScheduleCommand((void *)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
445 spin_unlock_irq(&pDevice
->lock
);
452 * enable scan process
464 static int wpa_set_scan(PSDevice pDevice
,
465 struct viawget_wpa_param
*param
)
467 spin_lock_irq(&pDevice
->lock
);
468 BSSvClearBSSList((void *)pDevice
, pDevice
->bLinkPass
);
469 bScheduleCommand((void *)pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
470 spin_unlock_irq(&pDevice
->lock
);
489 static int wpa_get_bssid(PSDevice pDevice
,
490 struct viawget_wpa_param
*param
)
492 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
494 memcpy(param
->u
.wpa_associate
.bssid
, pMgmt
->abyCurrBSSID
, 6);
513 static int wpa_get_ssid(PSDevice pDevice
,
514 struct viawget_wpa_param
*param
)
516 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
517 PWLAN_IE_SSID pItemSSID
;
519 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
521 memcpy(param
->u
.wpa_associate
.ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
522 param
->u
.wpa_associate
.ssid_len
= pItemSSID
->len
;
541 static int wpa_get_scan(PSDevice pDevice
,
542 struct viawget_wpa_param
*param
)
544 struct viawget_scan_result
*scan_buf
;
545 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
546 PWLAN_IE_SSID pItemSSID
;
554 unsigned char *ptempBSS
;
556 ptempBSS
= kmalloc(sizeof(KnownBSS
), GFP_ATOMIC
);
558 if (ptempBSS
== NULL
) {
559 printk(KERN_ERR
"bubble sort kmalloc memory fail@@@\n");
567 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
568 for (jj
= 0; jj
< MAX_BSS_NUM
- ii
- 1; jj
++) {
569 if ((pMgmt
->sBSSList
[jj
].bActive
!= true) ||
571 ((pMgmt
->sBSSList
[jj
].uRSSI
> pMgmt
->sBSSList
[jj
+ 1].uRSSI
) && (pMgmt
->sBSSList
[jj
+ 1].bActive
!= false))) {
572 memcpy(ptempBSS
, &pMgmt
->sBSSList
[jj
], sizeof(KnownBSS
));
574 memcpy(&pMgmt
->sBSSList
[jj
], &pMgmt
->sBSSList
[jj
+ 1], sizeof(KnownBSS
));
576 memcpy(&pMgmt
->sBSSList
[jj
+ 1], ptempBSS
, sizeof(KnownBSS
));
587 //******mike:bubble sort by stronger RSSI*****//
590 pBSS
= &(pMgmt
->sBSSList
[0]);
591 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
592 pBSS
= &(pMgmt
->sBSSList
[ii
]);
598 pBuf
= kcalloc(count
, sizeof(struct viawget_scan_result
), GFP_ATOMIC
);
604 scan_buf
= (struct viawget_scan_result
*)pBuf
;
605 pBSS
= &(pMgmt
->sBSSList
[0]);
606 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
607 pBSS
= &(pMgmt
->sBSSList
[ii
]);
611 memcpy(scan_buf
->bssid
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
612 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
613 memcpy(scan_buf
->ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
614 scan_buf
->ssid_len
= pItemSSID
->len
;
615 scan_buf
->freq
= frequency_list
[pBSS
->uChannel
-1];
616 scan_buf
->caps
= pBSS
->wCapInfo
;
618 if (pBSS
->wWPALen
!= 0) {
619 scan_buf
->wpa_ie_len
= pBSS
->wWPALen
;
620 memcpy(scan_buf
->wpa_ie
, pBSS
->byWPAIE
, pBSS
->wWPALen
);
622 if (pBSS
->wRSNLen
!= 0) {
623 scan_buf
->rsn_ie_len
= pBSS
->wRSNLen
;
624 memcpy(scan_buf
->rsn_ie
, pBSS
->byRSNIE
, pBSS
->wRSNLen
);
626 scan_buf
= (struct viawget_scan_result
*)((unsigned char *)scan_buf
+ sizeof(struct viawget_scan_result
));
634 if (copy_to_user(param
->u
.scan_results
.buf
, pBuf
, sizeof(struct viawget_scan_result
) * count
))
637 param
->u
.scan_results
.scan_count
= count
;
638 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" param->u.scan_results.scan_count = %d\n", count
);
646 * set associate with AP
658 static int wpa_set_associate(PSDevice pDevice
,
659 struct viawget_wpa_param
*param
)
661 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
662 PWLAN_IE_SSID pItemSSID
;
663 unsigned char abyNullAddr
[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
664 unsigned char abyWPAIE
[64];
665 bool bWepEnabled
= false;
667 // set key type & algorithm
668 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pairwise_suite = %d\n", param
->u
.wpa_associate
.pairwise_suite
);
669 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"group_suite = %d\n", param
->u
.wpa_associate
.group_suite
);
670 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"key_mgmt_suite = %d\n", param
->u
.wpa_associate
.key_mgmt_suite
);
671 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"auth_alg = %d\n", param
->u
.wpa_associate
.auth_alg
);
672 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"mode = %d\n", param
->u
.wpa_associate
.mode
);
673 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ie_len = %d\n", param
->u
.wpa_associate
.wpa_ie_len
);
675 if (param
->u
.wpa_associate
.wpa_ie_len
) {
676 if (!param
->u
.wpa_associate
.wpa_ie
)
678 if (param
->u
.wpa_associate
.wpa_ie_len
> sizeof(abyWPAIE
))
680 if (copy_from_user(&abyWPAIE
[0], param
->u
.wpa_associate
.wpa_ie
, param
->u
.wpa_associate
.wpa_ie_len
))
684 if (param
->u
.wpa_associate
.mode
== 1)
685 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
687 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
689 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
690 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
691 pItemSSID
->byElementID
= WLAN_EID_SSID
;
692 pItemSSID
->len
= param
->u
.wpa_associate
.ssid_len
;
693 memcpy(pItemSSID
->abySSID
, param
->u
.wpa_associate
.ssid
, pItemSSID
->len
);
695 if (memcmp(param
->u
.wpa_associate
.bssid
, &abyNullAddr
[0], 6) != 0)
696 memcpy(pMgmt
->abyDesireBSSID
, param
->u
.wpa_associate
.bssid
, 6);
698 bScheduleCommand((void *)pDevice
, WLAN_CMD_BSSID_SCAN
, pItemSSID
->abySSID
);
700 if (param
->u
.wpa_associate
.wpa_ie_len
== 0) {
701 if (param
->u
.wpa_associate
.auth_alg
& AUTH_ALG_SHARED_KEY
)
702 pMgmt
->eAuthenMode
= WMAC_AUTH_SHAREKEY
;
704 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
705 } else if (abyWPAIE
[0] == RSN_INFO_ELEM
) {
706 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
707 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
709 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
711 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_WPA_NONE
)
712 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
713 else if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
714 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
716 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
719 switch (param
->u
.wpa_associate
.pairwise_suite
) {
721 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
724 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
728 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
732 if (param
->u
.wpa_associate
.group_suite
== CIPHER_CCMP
)
733 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
735 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
738 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
741 //DavidWang add for WPA_supplicant support open/share mode
743 if (pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) {
744 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
745 pMgmt
->bShareKeyAlgorithm
= true;
746 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) {
747 if (!bWepEnabled
) pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
748 else pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
750 //mike save old encryption status
751 pDevice
->eOldEncryptionStatus
= pDevice
->eEncryptionStatus
;
753 if (pDevice
->eEncryptionStatus
!= Ndis802_11EncryptionDisabled
)
754 pDevice
->bEncryptionEnable
= true;
756 pDevice
->bEncryptionEnable
= false;
757 if (!((pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) ||
758 ((pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) && bWepEnabled
))) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP
759 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
760 spin_lock_irq(&pDevice
->lock
);
761 pDevice
->bLinkPass
= false;
762 memset(pMgmt
->abyCurrBSSID
, 0, 6);
763 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
764 netif_stop_queue(pDevice
->dev
);
765 //20080701-02,<Add> by Mike Liu
766 /*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
768 PKnownBSS pCurr
= NULL
;
769 pCurr
= BSSpSearchBSSList(pDevice
,
770 pMgmt
->abyDesireBSSID
,
771 pMgmt
->abyDesireSSID
,
772 pMgmt
->eConfigPHYMode
776 printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
777 bScheduleCommand((void *)pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
780 /****************************************************************/
781 bScheduleCommand((void *)pDevice
, WLAN_CMD_SSID
, NULL
);
782 spin_unlock_irq(&pDevice
->lock
);
789 * wpa_ioctl main function supported for wpa supplicant
801 int wpa_ioctl(PSDevice pDevice
, struct iw_point
*p
)
803 struct viawget_wpa_param
*param
;
807 if (p
->length
< sizeof(struct viawget_wpa_param
) ||
808 p
->length
> VIAWGET_WPA_MAX_BUF_SIZE
|| !p
->pointer
)
811 param
= kmalloc((int)p
->length
, GFP_KERNEL
);
815 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
820 switch (param
->cmd
) {
821 case VIAWGET_SET_WPA
:
822 ret
= wpa_set_wpa(pDevice
, param
);
823 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_WPA\n");
826 case VIAWGET_SET_KEY
:
827 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_KEY\n");
828 spin_lock_irq(&pDevice
->lock
);
829 ret
= wpa_set_keys(pDevice
, param
, false);
830 spin_unlock_irq(&pDevice
->lock
);
833 case VIAWGET_SET_SCAN
:
834 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_SCAN\n");
835 ret
= wpa_set_scan(pDevice
, param
);
838 case VIAWGET_GET_SCAN
:
839 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SCAN\n");
840 ret
= wpa_get_scan(pDevice
, param
);
844 case VIAWGET_GET_SSID
:
845 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SSID\n");
846 ret
= wpa_get_ssid(pDevice
, param
);
850 case VIAWGET_GET_BSSID
:
851 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_BSSID\n");
852 ret
= wpa_get_bssid(pDevice
, param
);
856 case VIAWGET_SET_ASSOCIATE
:
857 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_ASSOCIATE\n");
858 ret
= wpa_set_associate(pDevice
, param
);
861 case VIAWGET_SET_DISASSOCIATE
:
862 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DISASSOCIATE\n");
863 ret
= wpa_set_disassociate(pDevice
, param
);
866 case VIAWGET_SET_DROP_UNENCRYPT
:
867 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DROP_UNENCRYPT\n");
870 case VIAWGET_SET_DEAUTHENTICATE
:
871 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DEAUTHENTICATE\n");
875 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ioctl: unknown cmd=%d\n",
881 if ((ret
== 0) && wpa_ioctl
) {
882 if (copy_to_user(p
->pointer
, param
, p
->length
)) {