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
45 /*--------------------- Static Definitions -------------------------*/
47 #define VIAWGET_WPA_MAX_BUF_SIZE 1024
49 static const int frequency_list
[] = {
50 2412, 2417, 2422, 2427, 2432, 2437, 2442,
51 2447, 2452, 2457, 2462, 2467, 2472, 2484
54 /*--------------------- Static Classes ----------------------------*/
56 /*--------------------- Static Variables --------------------------*/
57 static int msglevel
= MSG_LEVEL_INFO
;
59 /*--------------------- Static Functions --------------------------*/
61 /*--------------------- Export Variables --------------------------*/
62 static void wpadev_setup(struct net_device
*dev
)
64 dev
->type
= ARPHRD_IEEE80211
;
65 dev
->hard_header_len
= ETH_HLEN
;
67 dev
->addr_len
= ETH_ALEN
;
68 dev
->tx_queue_len
= 1000;
70 memset(dev
->broadcast
, 0xFF, ETH_ALEN
);
72 dev
->flags
= IFF_BROADCAST
| IFF_MULTICAST
;
77 * register netdev for wpa supplicant deamon
88 static int wpa_init_wpadev(PSDevice pDevice
)
91 struct net_device
*dev
= pDevice
->dev
;
94 pDevice
->wpadev
= alloc_netdev(sizeof(PSDevice
), "vntwpa", wpadev_setup
);
95 if (pDevice
->wpadev
== NULL
)
98 wpadev_priv
= netdev_priv(pDevice
->wpadev
);
99 *wpadev_priv
= *pDevice
;
100 memcpy(pDevice
->wpadev
->dev_addr
, dev
->dev_addr
, ETH_ALEN
);
101 pDevice
->wpadev
->base_addr
= dev
->base_addr
;
102 pDevice
->wpadev
->irq
= dev
->irq
;
103 pDevice
->wpadev
->mem_start
= dev
->mem_start
;
104 pDevice
->wpadev
->mem_end
= dev
->mem_end
;
105 ret
= register_netdev(pDevice
->wpadev
);
107 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdev(WPA) failed!\n",
109 free_netdev(pDevice
->wpadev
);
113 if (pDevice
->skb
== NULL
) {
114 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
115 if (pDevice
->skb
== NULL
)
119 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdev %s for WPA management\n",
120 dev
->name
, pDevice
->wpadev
->name
);
127 * unregister net_device (wpadev)
137 static int wpa_release_wpadev(PSDevice pDevice
)
140 dev_kfree_skb(pDevice
->skb
);
144 if (pDevice
->wpadev
) {
145 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Netdevice %s unregistered\n",
146 pDevice
->dev
->name
, pDevice
->wpadev
->name
);
147 unregister_netdev(pDevice
->wpadev
);
148 free_netdev(pDevice
->wpadev
);
149 pDevice
->wpadev
= NULL
;
157 * Set enable/disable dev for wpa supplicant deamon
168 int wpa_set_wpadev(PSDevice pDevice
, int val
)
171 return wpa_init_wpadev(pDevice
);
172 return wpa_release_wpadev(pDevice
);
177 * Set WPA algorithm & keys
188 int wpa_set_keys(PSDevice pDevice
, void *ctx
, BOOL fcpfkernel
)
190 struct viawget_wpa_param
*param
= ctx
;
191 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
192 DWORD dwKeyIndex
= 0;
193 BYTE abyKey
[MAX_KEY_LEN
];
194 BYTE abySeq
[MAX_KEY_LEN
];
196 BYTE byKeyDecMode
= KEY_CTL_WEP
;
201 if (param
->u
.wpa_key
.alg_name
> WPA_ALG_CCMP
)
204 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"param->u.wpa_key.alg_name = %d \n",
205 param
->u
.wpa_key
.alg_name
);
206 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
207 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
208 pDevice
->bEncryptionEnable
= FALSE
;
209 pDevice
->byKeyIndex
= 0;
210 pDevice
->bTransmitKey
= FALSE
;
211 for (uu
=0; uu
<MAX_KEY_TABLE
; uu
++) {
212 MACvDisableKeyEntry(pDevice
, uu
);
217 if (param
->u
.wpa_key
.key
&& param
->u
.wpa_key
.key_len
> sizeof(abyKey
))
220 spin_unlock_irq(&pDevice
->lock
);
221 if (param
->u
.wpa_key
.key
&& fcpfkernel
) {
222 memcpy(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
);
224 if (param
->u
.wpa_key
.key
&&
225 copy_from_user(&abyKey
[0], param
->u
.wpa_key
.key
,
226 param
->u
.wpa_key
.key_len
)) {
227 spin_lock_irq(&pDevice
->lock
);
231 spin_lock_irq(&pDevice
->lock
);
233 dwKeyIndex
= (DWORD
)(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
= (BYTE
)dwKeyIndex
;
241 pDevice
->bTransmitKey
= TRUE
;
242 dwKeyIndex
|= (1 << 31);
244 KeybSetDefaultKey( pDevice
,
246 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
247 param
->u
.wpa_key
.key_len
,
254 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
255 pDevice
->bEncryptionEnable
= TRUE
;
260 if (param
->u
.wpa_key
.seq
&& param
->u
.wpa_key
.seq_len
> sizeof(abySeq
))
263 spin_unlock_irq(&pDevice
->lock
);
264 if (param
->u
.wpa_key
.seq
&& fcpfkernel
) {
265 memcpy(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
);
267 if (param
->u
.wpa_key
.seq
&&
268 copy_from_user(&abySeq
[0], param
->u
.wpa_key
.seq
,
269 param
->u
.wpa_key
.seq_len
)) {
270 spin_lock_irq(&pDevice
->lock
);
274 spin_lock_irq(&pDevice
->lock
);
276 if (param
->u
.wpa_key
.seq_len
> 0) {
277 for (ii
= 0 ; ii
< param
->u
.wpa_key
.seq_len
; ii
++) {
279 LODWORD(KeyRSC
) |= (abySeq
[ii
] << (ii
* 8));
281 HIDWORD(KeyRSC
) |= (abySeq
[ii
] << ((ii
-4) * 8));
283 dwKeyIndex
|= 1 << 29;
286 if (param
->u
.wpa_key
.key_index
>= MAX_GROUP_KEY
) {
287 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return dwKeyIndex > 3\n");
291 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_TKIP
) {
292 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
295 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_CCMP
) {
296 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
299 if (param
->u
.wpa_key
.set_tx
)
300 dwKeyIndex
|= (1 << 31);
303 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
304 byKeyDecMode
= KEY_CTL_CCMP
;
305 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
306 byKeyDecMode
= KEY_CTL_TKIP
;
308 byKeyDecMode
= KEY_CTL_WEP
;
310 // Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled
311 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
312 if (param
->u
.wpa_key
.key_len
== MAX_KEY_LEN
)
313 byKeyDecMode
= KEY_CTL_TKIP
;
314 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
315 byKeyDecMode
= KEY_CTL_WEP
;
316 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
317 byKeyDecMode
= KEY_CTL_WEP
;
318 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
319 if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
320 byKeyDecMode
= KEY_CTL_WEP
;
321 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
322 byKeyDecMode
= KEY_CTL_WEP
;
325 // Check TKIP key length
326 if ((byKeyDecMode
== KEY_CTL_TKIP
) &&
327 (param
->u
.wpa_key
.key_len
!= MAX_KEY_LEN
)) {
328 // TKIP Key must be 256 bits
329 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return- TKIP Key must be 256 bits!\n");
332 // Check AES key length
333 if ((byKeyDecMode
== KEY_CTL_CCMP
) &&
334 (param
->u
.wpa_key
.key_len
!= AES_KEY_LEN
)) {
335 // AES Key must be 128 bits
336 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return - AES Key must be 128 bits\n");
340 if (is_broadcast_ether_addr(¶m
->addr
[0]) || (param
->addr
== NULL
)) {
341 /* if broadcast, set the key as every key entry's group key */
342 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Groupe Key Assign.\n");
344 if ((KeybSetAllGroupKey(pDevice
, &(pDevice
->sKey
), dwKeyIndex
,
345 param
->u
.wpa_key
.key_len
,
350 (KeybSetDefaultKey(pDevice
,
353 param
->u
.wpa_key
.key_len
,
358 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GROUP Key Assign.\n");
363 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Assign.\n");
364 // BSSID not 0xffffffffffff
365 // Pairwise Key can't be WEP
366 if (byKeyDecMode
== KEY_CTL_WEP
) {
367 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key can't be WEP\n");
370 dwKeyIndex
|= (1 << 30); // set pairwise key
371 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
372 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n"));
375 if (KeybSetKey(pDevice
, &(pDevice
->sKey
), ¶m
->addr
[0],
376 dwKeyIndex
, param
->u
.wpa_key
.key_len
,
377 (PQWORD
) &(KeyRSC
), (PBYTE
)abyKey
, byKeyDecMode
379 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Set\n");
382 if (!compare_ether_addr(¶m
->addr
[0], pDevice
->abyBSSID
)) {
383 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
386 // Save Key and configure just before associate/reassociate to BSSID
387 // we do not implement now
391 } // BSSID not 0xffffffffffff
392 if ((ret
== 0) && ((param
->u
.wpa_key
.set_tx
) != 0)) {
393 pDevice
->byKeyIndex
= (BYTE
)param
->u
.wpa_key
.key_index
;
394 pDevice
->bTransmitKey
= TRUE
;
396 pDevice
->bEncryptionEnable
= TRUE
;
404 * enable wpa auth & mode
415 static int wpa_set_wpa(PSDevice pDevice
, struct viawget_wpa_param
*param
)
417 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
420 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
421 pMgmt
->bShareKeyAlgorithm
= FALSE
;
439 static int wpa_set_disassociate(PSDevice pDevice
, struct viawget_wpa_param
*param
)
441 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
444 spin_lock_irq(&pDevice
->lock
);
445 if (pDevice
->bLinkPass
) {
446 if (!memcmp(param
->addr
, pMgmt
->abyCurrBSSID
, 6))
447 bScheduleCommand((void *)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
449 spin_unlock_irq(&pDevice
->lock
);
456 * enable scan process
467 static int wpa_set_scan(PSDevice pDevice
, struct viawget_wpa_param
*param
)
471 /**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/
472 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
473 PWLAN_IE_SSID pItemSSID
;
474 printk("wpa_set_scan-->desired [ssid=%s,ssid_len=%d]\n",
475 param
->u
.scan_req
.ssid
,param
->u
.scan_req
.ssid_len
);
477 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
478 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
479 pItemSSID
->byElementID
= WLAN_EID_SSID
;
480 memcpy(pItemSSID
->abySSID
, param
->u
.scan_req
.ssid
, param
->u
.scan_req
.ssid_len
);
481 pItemSSID
->len
= param
->u
.scan_req
.ssid_len
;
483 spin_lock_irq(&pDevice
->lock
);
484 BSSvClearBSSList((void *) pDevice
, pDevice
->bLinkPass
);
485 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
,
486 pMgmt
->abyDesireSSID
);
487 spin_unlock_irq(&pDevice
->lock
);
505 static int wpa_get_bssid(PSDevice pDevice
, struct viawget_wpa_param
*param
)
507 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
509 memcpy(param
->u
.wpa_associate
.bssid
, pMgmt
->abyCurrBSSID
, 6);
527 static int wpa_get_ssid(PSDevice pDevice
, struct viawget_wpa_param
*param
)
529 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
530 PWLAN_IE_SSID pItemSSID
;
533 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
535 memcpy(param
->u
.wpa_associate
.ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
536 param
->u
.wpa_associate
.ssid_len
= pItemSSID
->len
;
554 static int wpa_get_scan(PSDevice pDevice
, struct viawget_wpa_param
*param
)
556 struct viawget_scan_result
*scan_buf
;
557 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
558 PWLAN_IE_SSID pItemSSID
;
565 long ldBm
; //James //add
567 //******mike:bubble sort by stronger RSSI*****//
570 ptempBSS
= kmalloc(sizeof(KnownBSS
), GFP_ATOMIC
);
572 if (ptempBSS
== NULL
) {
573 printk("bubble sort kmalloc memory fail@@@\n");
578 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
579 for (jj
= 0; jj
< MAX_BSS_NUM
- ii
- 1; jj
++) {
580 if ((pMgmt
->sBSSList
[jj
].bActive
!= TRUE
)
581 || ((pMgmt
->sBSSList
[jj
].uRSSI
> pMgmt
->sBSSList
[jj
+ 1].uRSSI
)
582 && (pMgmt
->sBSSList
[jj
+ 1].bActive
!= FALSE
))) {
583 memcpy(ptempBSS
,&pMgmt
->sBSSList
[jj
], sizeof(KnownBSS
));
584 memcpy(&pMgmt
->sBSSList
[jj
], &pMgmt
->sBSSList
[jj
+ 1],
586 memcpy(&pMgmt
->sBSSList
[jj
+ 1], ptempBSS
, sizeof(KnownBSS
));
593 pBSS
= &(pMgmt
->sBSSList
[0]);
594 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
595 pBSS
= &(pMgmt
->sBSSList
[ii
]);
601 pBuf
= kcalloc(count
, sizeof(struct viawget_scan_result
), GFP_ATOMIC
);
607 scan_buf
= (struct viawget_scan_result
*)pBuf
;
608 pBSS
= &(pMgmt
->sBSSList
[0]);
609 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
610 pBSS
= &(pMgmt
->sBSSList
[ii
]);
614 memcpy(scan_buf
->bssid
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
615 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
616 memcpy(scan_buf
->ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
617 scan_buf
->ssid_len
= pItemSSID
->len
;
618 scan_buf
->freq
= frequency_list
[pBSS
->uChannel
-1];
619 scan_buf
->caps
= pBSS
->wCapInfo
; // DavidWang for sharemode
621 RFvRSSITodBm(pDevice
, (BYTE
)(pBSS
->uRSSI
), &ldBm
);
623 scan_buf
->qual
= 100;
627 scan_buf
->qual
=(40-(-ldBm
-50))*100/40;
630 //scan_buf->caps = pBSS->wCapInfo;
633 scan_buf
->level
= ldBm
;
635 //scan_buf->maxrate =
636 if (pBSS
->wWPALen
!= 0) {
637 scan_buf
->wpa_ie_len
= pBSS
->wWPALen
;
638 memcpy(scan_buf
->wpa_ie
, pBSS
->byWPAIE
, pBSS
->wWPALen
);
640 if (pBSS
->wRSNLen
!= 0) {
641 scan_buf
->rsn_ie_len
= pBSS
->wRSNLen
;
642 memcpy(scan_buf
->rsn_ie
, pBSS
->byRSNIE
, pBSS
->wRSNLen
);
644 scan_buf
= (struct viawget_scan_result
*)((PBYTE
)scan_buf
+ sizeof(struct viawget_scan_result
));
652 if (copy_to_user(param
->u
.scan_results
.buf
, pBuf
, sizeof(struct viawget_scan_result
) * count
))
655 param
->u
.scan_results
.scan_count
= count
;
656 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" param->u.scan_results.scan_count = %d\n", count
);
664 * set associate with AP
675 static int wpa_set_associate(PSDevice pDevice
, struct viawget_wpa_param
*param
)
677 PSMgmtObject pMgmt
= &pDevice
->sMgmtObj
;
678 PWLAN_IE_SSID pItemSSID
;
679 BYTE abyNullAddr
[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
682 BOOL bwepEnabled
=FALSE
;
684 // set key type & algorithm
685 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pairwise_suite = %d\n", param
->u
.wpa_associate
.pairwise_suite
);
686 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"group_suite = %d\n", param
->u
.wpa_associate
.group_suite
);
687 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"key_mgmt_suite = %d\n", param
->u
.wpa_associate
.key_mgmt_suite
);
688 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"auth_alg = %d\n", param
->u
.wpa_associate
.auth_alg
);
689 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"mode = %d\n", param
->u
.wpa_associate
.mode
);
690 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ie_len = %d\n", param
->u
.wpa_associate
.wpa_ie_len
);
691 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Roaming dBm = %d\n", param
->u
.wpa_associate
.roam_dbm
); // Davidwang
693 if (param
->u
.wpa_associate
.wpa_ie
) {
694 if (param
->u
.wpa_associate
.wpa_ie_len
> sizeof(abyWPAIE
))
697 if (copy_from_user(&abyWPAIE
[0], param
->u
.wpa_associate
.wpa_ie
,
698 param
->u
.wpa_associate
.wpa_ie_len
))
702 if (param
->u
.wpa_associate
.mode
== 1)
703 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
705 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
708 if (memcmp(param
->u
.wpa_associate
.bssid
, &abyNullAddr
[0], 6) != 0)
709 memcpy(pMgmt
->abyDesireBSSID
, param
->u
.wpa_associate
.bssid
, 6);
711 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
712 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
713 pItemSSID
->byElementID
= WLAN_EID_SSID
;
714 pItemSSID
->len
= param
->u
.wpa_associate
.ssid_len
;
715 memcpy(pItemSSID
->abySSID
, param
->u
.wpa_associate
.ssid
, pItemSSID
->len
);
717 if (param
->u
.wpa_associate
.wpa_ie_len
== 0) {
718 if (param
->u
.wpa_associate
.auth_alg
& AUTH_ALG_SHARED_KEY
)
719 pMgmt
->eAuthenMode
= WMAC_AUTH_SHAREKEY
;
721 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
722 } else if (abyWPAIE
[0] == RSN_INFO_ELEM
) {
723 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
724 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
726 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
728 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_WPA_NONE
)
729 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
730 else if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
731 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
733 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
736 switch (param
->u
.wpa_associate
.pairwise_suite
) {
738 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
741 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
745 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
749 if (param
->u
.wpa_associate
.group_suite
== CIPHER_CCMP
)
750 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
752 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
755 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
758 pMgmt
->Roam_dbm
= param
->u
.wpa_associate
.roam_dbm
;
759 if (pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) { // @wep-sharekey
760 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
761 pMgmt
->bShareKeyAlgorithm
= TRUE
;
762 } else if (pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) {
763 if(bwepEnabled
==TRUE
) { //@open-wep
764 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
767 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
770 // mike save old encryption status
771 pDevice
->eOldEncryptionStatus
= pDevice
->eEncryptionStatus
;
773 if (pDevice
->eEncryptionStatus
!= Ndis802_11EncryptionDisabled
)
774 pDevice
->bEncryptionEnable
= TRUE
;
776 pDevice
->bEncryptionEnable
= FALSE
;
778 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) ||
779 ((pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) && (bwepEnabled
==TRUE
))) {
780 // mike re-comment:open-wep && sharekey-wep needn't do initial key!!
782 KeyvInitTable(pDevice
,&pDevice
->sKey
);
785 spin_lock_irq(&pDevice
->lock
);
786 pDevice
->bLinkPass
= FALSE
;
787 ControlvMaskByte(pDevice
, MESSAGE_REQUEST_MACREG
, MAC_REG_PAPEDELAY
, LEDSTS_STS
, LEDSTS_SLOW
);
788 memset(pMgmt
->abyCurrBSSID
, 0, 6);
789 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
790 netif_stop_queue(pDevice
->dev
);
792 /******* search if ap_scan=2, which is associating request in hidden ssid mode ****/
794 PKnownBSS pCurr
= NULL
;
795 pCurr
= BSSpSearchBSSList(pDevice
,
796 pMgmt
->abyDesireBSSID
,
797 pMgmt
->abyDesireSSID
,
798 pDevice
->eConfigPHYMode
802 printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
803 bScheduleCommand((void *)pDevice
,
805 pMgmt
->abyDesireSSID
);
808 /****************************************************************/
810 bScheduleCommand((void *)pDevice
, WLAN_CMD_SSID
, NULL
);
811 spin_unlock_irq(&pDevice
->lock
);
818 * wpa_ioctl main function supported for wpa supplicant
829 int wpa_ioctl(PSDevice pDevice
, struct iw_point
*p
)
831 struct viawget_wpa_param
*param
;
835 if (p
->length
< sizeof(struct viawget_wpa_param
) ||
836 p
->length
> VIAWGET_WPA_MAX_BUF_SIZE
|| !p
->pointer
)
839 param
= kmalloc((int)p
->length
, GFP_KERNEL
);
843 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
848 switch (param
->cmd
) {
849 case VIAWGET_SET_WPA
:
850 ret
= wpa_set_wpa(pDevice
, param
);
851 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_WPA \n");
854 case VIAWGET_SET_KEY
:
855 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_KEY \n");
856 spin_lock_irq(&pDevice
->lock
);
857 ret
= wpa_set_keys(pDevice
, param
, FALSE
);
858 spin_unlock_irq(&pDevice
->lock
);
861 case VIAWGET_SET_SCAN
:
862 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_SCAN \n");
863 ret
= wpa_set_scan(pDevice
, param
);
866 case VIAWGET_GET_SCAN
:
867 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SCAN\n");
868 ret
= wpa_get_scan(pDevice
, param
);
872 case VIAWGET_GET_SSID
:
873 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SSID \n");
874 ret
= wpa_get_ssid(pDevice
, param
);
878 case VIAWGET_GET_BSSID
:
879 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_BSSID \n");
880 ret
= wpa_get_bssid(pDevice
, param
);
884 case VIAWGET_SET_ASSOCIATE
:
885 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_ASSOCIATE \n");
886 ret
= wpa_set_associate(pDevice
, param
);
889 case VIAWGET_SET_DISASSOCIATE
:
890 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DISASSOCIATE \n");
891 ret
= wpa_set_disassociate(pDevice
, param
);
894 case VIAWGET_SET_DROP_UNENCRYPT
:
895 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DROP_UNENCRYPT \n");
898 case VIAWGET_SET_DEAUTHENTICATE
:
899 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DEAUTHENTICATE \n");
903 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ioctl: unknown cmd=%d\n",
909 if ((ret
== 0) && wpa_ioctl
) {
910 if (copy_to_user(p
->pointer
, param
, p
->length
)) {