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
49 static const int frequency_list
[] = {
50 2412, 2417, 2422, 2427, 2432, 2437, 2442,
51 2447, 2452, 2457, 2462, 2467, 2472, 2484
53 /*--------------------- Static Classes ----------------------------*/
55 /*--------------------- Static Variables --------------------------*/
56 //static int msglevel =MSG_LEVEL_DEBUG;
57 static int msglevel
=MSG_LEVEL_INFO
;
59 /*--------------------- Static Functions --------------------------*/
64 /*--------------------- Export Variables --------------------------*/
65 static void wpadev_setup(struct net_device
*dev
)
67 dev
->type
= ARPHRD_IEEE80211
;
68 dev
->hard_header_len
= ETH_HLEN
;
70 dev
->addr_len
= ETH_ALEN
;
71 dev
->tx_queue_len
= 1000;
73 memset(dev
->broadcast
,0xFF, ETH_ALEN
);
75 dev
->flags
= IFF_BROADCAST
|IFF_MULTICAST
;
80 * register netdev for wpa supplicant deamon
92 static int wpa_init_wpadev(PSDevice pDevice
)
95 struct net_device
*dev
= pDevice
->dev
;
98 pDevice
->wpadev
= alloc_netdev(sizeof(PSDevice
), "vntwpa", wpadev_setup
);
99 if (pDevice
->wpadev
== NULL
)
102 wpadev_priv
= netdev_priv(pDevice
->wpadev
);
103 *wpadev_priv
= *pDevice
;
104 memcpy(pDevice
->wpadev
->dev_addr
, dev
->dev_addr
, U_ETHER_ADDR_LEN
);
105 pDevice
->wpadev
->base_addr
= dev
->base_addr
;
106 pDevice
->wpadev
->irq
= dev
->irq
;
107 pDevice
->wpadev
->mem_start
= dev
->mem_start
;
108 pDevice
->wpadev
->mem_end
= dev
->mem_end
;
109 ret
= register_netdev(pDevice
->wpadev
);
111 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdev(WPA) failed!\n",
113 free_netdev(pDevice
->wpadev
);
117 if (pDevice
->skb
== NULL
) {
118 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
119 if (pDevice
->skb
== NULL
)
123 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdev %s for WPA management\n",
124 dev
->name
, pDevice
->wpadev
->name
);
132 * unregister net_device (wpadev)
143 static int wpa_release_wpadev(PSDevice pDevice
)
146 dev_kfree_skb(pDevice
->skb
);
150 if (pDevice
->wpadev
) {
151 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Netdevice %s unregistered\n",
152 pDevice
->dev
->name
, pDevice
->wpadev
->name
);
153 unregister_netdev(pDevice
->wpadev
);
154 free_netdev(pDevice
->wpadev
);
155 pDevice
->wpadev
= NULL
;
167 * Set enable/disable dev for wpa supplicant deamon
179 int wpa_set_wpadev(PSDevice pDevice
, int val
)
182 return wpa_init_wpadev(pDevice
);
184 return wpa_release_wpadev(pDevice
);
190 * Set WPA algorithm & keys
202 int wpa_set_keys(PSDevice pDevice
, void *ctx
, BOOL fcpfkernel
)
204 struct viawget_wpa_param
*param
=ctx
;
205 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
206 DWORD dwKeyIndex
= 0;
207 BYTE abyKey
[MAX_KEY_LEN
];
208 BYTE abySeq
[MAX_KEY_LEN
];
210 // NDIS_802_11_KEY_RSC KeyRSC;
211 BYTE byKeyDecMode
= KEY_CTL_WEP
;
216 if (param
->u
.wpa_key
.alg_name
> WPA_ALG_CCMP
)
219 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"param->u.wpa_key.alg_name = %d \n", param
->u
.wpa_key
.alg_name
);
220 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
221 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
222 pDevice
->bEncryptionEnable
= FALSE
;
223 pDevice
->byKeyIndex
= 0;
224 pDevice
->bTransmitKey
= FALSE
;
225 KeyvRemoveAllWEPKey(&(pDevice
->sKey
), pDevice
->PortOffset
);
226 for (uu
=0; uu
<MAX_KEY_TABLE
; uu
++) {
227 MACvDisableKeyEntry(pDevice
->PortOffset
, uu
);
232 //spin_unlock_irq(&pDevice->lock);
233 if(param
->u
.wpa_key
.key
&& fcpfkernel
) {
234 memcpy(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
);
237 spin_unlock_irq(&pDevice
->lock
);
238 if (param
->u
.wpa_key
.key
&&
239 copy_from_user(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
)) {
240 spin_lock_irq(&pDevice
->lock
);
243 spin_lock_irq(&pDevice
->lock
);
246 dwKeyIndex
= (DWORD
)(param
->u
.wpa_key
.key_index
);
248 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_WEP
) {
249 if (dwKeyIndex
> 3) {
253 if (param
->u
.wpa_key
.set_tx
) {
254 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
255 pDevice
->bTransmitKey
= TRUE
;
256 dwKeyIndex
|= (1 << 31);
258 KeybSetDefaultKey(&(pDevice
->sKey
),
259 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
260 param
->u
.wpa_key
.key_len
,
268 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
269 pDevice
->bEncryptionEnable
= TRUE
;
273 //spin_unlock_irq(&pDevice->lock);
274 if(param
->u
.wpa_key
.seq
&& fcpfkernel
) {
275 memcpy(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
);
278 spin_unlock_irq(&pDevice
->lock
);
279 if (param
->u
.wpa_key
.seq
&&
280 copy_from_user(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
)) {
281 spin_lock_irq(&pDevice
->lock
);
284 spin_lock_irq(&pDevice
->lock
);
287 if (param
->u
.wpa_key
.seq_len
> 0) {
288 for (ii
= 0 ; ii
< param
->u
.wpa_key
.seq_len
; ii
++) {
290 LODWORD(KeyRSC
) |= (abySeq
[ii
] << (ii
* 8));
292 HIDWORD(KeyRSC
) |= (abySeq
[ii
] << ((ii
-4) * 8));
293 //KeyRSC |= (abySeq[ii] << (ii * 8));
295 dwKeyIndex
|= 1 << 29;
298 if (param
->u
.wpa_key
.key_index
>= MAX_GROUP_KEY
) {
299 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return dwKeyIndex > 3\n");
303 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_TKIP
) {
304 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
307 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_CCMP
) {
308 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
311 if (param
->u
.wpa_key
.set_tx
)
312 dwKeyIndex
|= (1 << 31);
315 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
316 byKeyDecMode
= KEY_CTL_CCMP
;
317 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
318 byKeyDecMode
= KEY_CTL_TKIP
;
320 byKeyDecMode
= KEY_CTL_WEP
;
322 // Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled
323 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
324 if (param
->u
.wpa_key
.key_len
== MAX_KEY_LEN
)
325 byKeyDecMode
= KEY_CTL_TKIP
;
326 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
327 byKeyDecMode
= KEY_CTL_WEP
;
328 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
329 byKeyDecMode
= KEY_CTL_WEP
;
330 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
331 if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
332 byKeyDecMode
= KEY_CTL_WEP
;
333 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
334 byKeyDecMode
= KEY_CTL_WEP
;
337 // Check TKIP key length
338 if ((byKeyDecMode
== KEY_CTL_TKIP
) &&
339 (param
->u
.wpa_key
.key_len
!= MAX_KEY_LEN
)) {
340 // TKIP Key must be 256 bits
341 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - TKIP Key must be 256 bits\n"));
342 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return- TKIP Key must be 256 bits!\n");
345 // Check AES key length
346 if ((byKeyDecMode
== KEY_CTL_CCMP
) &&
347 (param
->u
.wpa_key
.key_len
!= AES_KEY_LEN
)) {
348 // AES Key must be 128 bits
349 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - AES Key must be 128 bits\n"));
353 // spin_lock_irq(&pDevice->lock);
354 if (IS_BROADCAST_ADDRESS(¶m
->addr
[0]) || (param
->addr
== NULL
)) {
355 // If IS_BROADCAST_ADDRESS, set the key as every key entry's group key.
356 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Groupe Key Assign.\n");
358 if ((KeybSetAllGroupKey(&(pDevice
->sKey
),
360 param
->u
.wpa_key
.key_len
,
365 pDevice
->byLocalID
) == TRUE
) &&
366 (KeybSetDefaultKey(&(pDevice
->sKey
),
368 param
->u
.wpa_key
.key_len
,
373 pDevice
->byLocalID
) == TRUE
) ) {
374 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GROUP Key Assign.\n");
377 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n"));
378 // spin_unlock_irq(&pDevice->lock);
383 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Assign.\n");
384 // BSSID not 0xffffffffffff
385 // Pairwise Key can't be WEP
386 if (byKeyDecMode
== KEY_CTL_WEP
) {
387 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key can't be WEP\n");
388 //spin_unlock_irq(&pDevice->lock);
392 dwKeyIndex
|= (1 << 30); // set pairwise key
393 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
394 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n"));
395 //spin_unlock_irq(&pDevice->lock);
398 if (KeybSetKey(&(pDevice
->sKey
),
401 param
->u
.wpa_key
.key_len
,
406 pDevice
->byLocalID
) == TRUE
) {
407 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Set\n");
411 if (IS_ETH_ADDRESS_EQUAL(¶m
->addr
[0], pDevice
->abyBSSID
)) {
412 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
413 //spin_unlock_irq(&pDevice->lock);
417 // Save Key and configure just before associate/reassociate to BSSID
418 // we do not implement now
419 //spin_unlock_irq(&pDevice->lock);
423 } // BSSID not 0xffffffffffff
424 if ((ret
== 0) && ((param
->u
.wpa_key
.set_tx
) != 0)) {
425 pDevice
->byKeyIndex
= (BYTE
)param
->u
.wpa_key
.key_index
;
426 pDevice
->bTransmitKey
= TRUE
;
428 pDevice
->bEncryptionEnable
= TRUE
;
429 //spin_unlock_irq(&pDevice->lock);
432 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n",
433 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][0],
434 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][1],
435 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][2],
436 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][3],
437 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][4]
448 * enable wpa auth & mode
460 static int wpa_set_wpa(PSDevice pDevice
,
461 struct viawget_wpa_param
*param
)
464 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
467 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
468 pMgmt
->bShareKeyAlgorithm
= FALSE
;
490 static int wpa_set_disassociate(PSDevice pDevice
,
491 struct viawget_wpa_param
*param
)
493 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
496 spin_lock_irq(&pDevice
->lock
);
497 if (pDevice
->bLinkPass
) {
498 if (!memcmp(param
->addr
, pMgmt
->abyCurrBSSID
, 6))
499 bScheduleCommand((HANDLE
)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
501 spin_unlock_irq(&pDevice
->lock
);
510 * enable scan process
522 static int wpa_set_scan(PSDevice pDevice
,
523 struct viawget_wpa_param
*param
)
527 spin_lock_irq(&pDevice
->lock
);
528 BSSvClearBSSList((HANDLE
)pDevice
, pDevice
->bLinkPass
);
529 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
530 spin_unlock_irq(&pDevice
->lock
);
551 static int wpa_get_bssid(PSDevice pDevice
,
552 struct viawget_wpa_param
*param
)
554 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
557 memcpy(param
->u
.wpa_associate
.bssid
, pMgmt
->abyCurrBSSID
, 6);
578 static int wpa_get_ssid(PSDevice pDevice
,
579 struct viawget_wpa_param
*param
)
581 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
582 PWLAN_IE_SSID pItemSSID
;
585 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
587 memcpy(param
->u
.wpa_associate
.ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
588 param
->u
.wpa_associate
.ssid_len
= pItemSSID
->len
;
609 static int wpa_get_scan(PSDevice pDevice
,
610 struct viawget_wpa_param
*param
)
612 struct viawget_scan_result
*scan_buf
;
613 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
614 PWLAN_IE_SSID pItemSSID
;
626 ptempBSS
= kmalloc(sizeof(KnownBSS
), (int)GFP_ATOMIC
);
628 if (ptempBSS
== NULL
) {
630 printk("bubble sort kmalloc memory fail@@@\n");
638 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
640 for(jj
=0;jj
<MAX_BSS_NUM
-ii
-1;jj
++) {
642 if((pMgmt
->sBSSList
[jj
].bActive
!=TRUE
) ||
644 ((pMgmt
->sBSSList
[jj
].uRSSI
>pMgmt
->sBSSList
[jj
+1].uRSSI
) &&(pMgmt
->sBSSList
[jj
+1].bActive
!=FALSE
))) {
646 memcpy(ptempBSS
,&pMgmt
->sBSSList
[jj
],sizeof(KnownBSS
));
648 memcpy(&pMgmt
->sBSSList
[jj
],&pMgmt
->sBSSList
[jj
+1],sizeof(KnownBSS
));
650 memcpy(&pMgmt
->sBSSList
[jj
+1],ptempBSS
,sizeof(KnownBSS
));
660 // printk("bubble sort result:\n");
662 //for (ii = 0; ii < MAX_BSS_NUM; ii++)
664 // printk("%d [%s]:RSSI=%d\n",ii,((PWLAN_IE_SSID)(pMgmt->sBSSList[ii].abySSID))->abySSID,
666 // pMgmt->sBSSList[ii].uRSSI);
670 //******mike:bubble sort by stronger RSSI*****//
676 pBSS
= &(pMgmt
->sBSSList
[0]);
677 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
678 pBSS
= &(pMgmt
->sBSSList
[ii
]);
684 pBuf
= kmalloc(sizeof(struct viawget_scan_result
) * count
, (int)GFP_ATOMIC
);
690 memset(pBuf
, 0, sizeof(struct viawget_scan_result
) * count
);
691 scan_buf
= (struct viawget_scan_result
*)pBuf
;
692 pBSS
= &(pMgmt
->sBSSList
[0]);
693 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
694 pBSS
= &(pMgmt
->sBSSList
[ii
]);
698 memcpy(scan_buf
->bssid
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
699 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
700 memcpy(scan_buf
->ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
701 scan_buf
->ssid_len
= pItemSSID
->len
;
702 scan_buf
->freq
= frequency_list
[pBSS
->uChannel
-1];
703 scan_buf
->caps
= pBSS
->wCapInfo
;
704 //scan_buf->caps = pBSS->wCapInfo;
708 //scan_buf->maxrate =
709 if (pBSS
->wWPALen
!= 0) {
710 scan_buf
->wpa_ie_len
= pBSS
->wWPALen
;
711 memcpy(scan_buf
->wpa_ie
, pBSS
->byWPAIE
, pBSS
->wWPALen
);
713 if (pBSS
->wRSNLen
!= 0) {
714 scan_buf
->rsn_ie_len
= pBSS
->wRSNLen
;
715 memcpy(scan_buf
->rsn_ie
, pBSS
->byRSNIE
, pBSS
->wRSNLen
);
717 scan_buf
= (struct viawget_scan_result
*)((PBYTE
)scan_buf
+ sizeof(struct viawget_scan_result
));
725 if (copy_to_user(param
->u
.scan_results
.buf
, pBuf
, sizeof(struct viawget_scan_result
) * count
)) {
728 param
->u
.scan_results
.scan_count
= count
;
729 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" param->u.scan_results.scan_count = %d\n", count
)
739 * set associate with AP
751 static int wpa_set_associate(PSDevice pDevice
,
752 struct viawget_wpa_param
*param
)
754 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
755 PWLAN_IE_SSID pItemSSID
;
756 BYTE abyNullAddr
[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
759 BOOL bWepEnabled
=FALSE
;
761 // set key type & algorithm
762 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pairwise_suite = %d\n", param
->u
.wpa_associate
.pairwise_suite
);
763 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"group_suite = %d\n", param
->u
.wpa_associate
.group_suite
);
764 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"key_mgmt_suite = %d\n", param
->u
.wpa_associate
.key_mgmt_suite
);
765 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"auth_alg = %d\n", param
->u
.wpa_associate
.auth_alg
);
766 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"mode = %d\n", param
->u
.wpa_associate
.mode
);
767 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ie_len = %d\n", param
->u
.wpa_associate
.wpa_ie_len
);
770 if (param
->u
.wpa_associate
.wpa_ie
&&
771 copy_from_user(&abyWPAIE
[0], param
->u
.wpa_associate
.wpa_ie
, param
->u
.wpa_associate
.wpa_ie_len
))
774 if (param
->u
.wpa_associate
.mode
== 1)
775 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
777 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
779 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
780 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
781 pItemSSID
->byElementID
= WLAN_EID_SSID
;
782 pItemSSID
->len
= param
->u
.wpa_associate
.ssid_len
;
783 memcpy(pItemSSID
->abySSID
, param
->u
.wpa_associate
.ssid
, pItemSSID
->len
);
785 if (memcmp(param
->u
.wpa_associate
.bssid
, &abyNullAddr
[0], 6) != 0)
786 memcpy(pMgmt
->abyDesireBSSID
, param
->u
.wpa_associate
.bssid
, 6);
789 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pItemSSID
->abySSID
);
792 if (param
->u
.wpa_associate
.wpa_ie_len
== 0) {
793 if (param
->u
.wpa_associate
.auth_alg
& AUTH_ALG_SHARED_KEY
)
794 pMgmt
->eAuthenMode
= WMAC_AUTH_SHAREKEY
;
796 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
797 } else if (abyWPAIE
[0] == RSN_INFO_ELEM
) {
798 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
799 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
801 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
803 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_WPA_NONE
)
804 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
805 else if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
806 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
808 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
811 switch (param
->u
.wpa_associate
.pairwise_suite
) {
813 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
816 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
820 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
824 if (param
->u
.wpa_associate
.group_suite
== CIPHER_CCMP
)
825 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
827 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
830 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
833 //DavidWang add for WPA_supplicant support open/share mode
835 if (pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) {
836 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
837 //pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY;
838 pMgmt
->bShareKeyAlgorithm
= TRUE
;
840 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) {
841 if(!bWepEnabled
) pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
842 else pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
843 //pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
844 //pMgmt->bShareKeyAlgorithm = FALSE; //20080717-06,<Modify> by chester//Fix Open mode, WEP encrytion
846 //mike save old encryption status
847 pDevice
->eOldEncryptionStatus
= pDevice
->eEncryptionStatus
;
849 if (pDevice
->eEncryptionStatus
!= Ndis802_11EncryptionDisabled
)
850 pDevice
->bEncryptionEnable
= TRUE
;
852 pDevice
->bEncryptionEnable
= FALSE
;
853 if (!((pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) ||
854 ((pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) && (bWepEnabled
==TRUE
))) ) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP
855 KeyvInitTable(&pDevice
->sKey
, pDevice
->PortOffset
);
856 spin_lock_irq(&pDevice
->lock
);
857 pDevice
->bLinkPass
= FALSE
;
858 memset(pMgmt
->abyCurrBSSID
, 0, 6);
859 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
860 netif_stop_queue(pDevice
->dev
);
861 //20080701-02,<Add> by Mike Liu
862 /*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
864 PKnownBSS pCurr
= NULL
;
865 pCurr
= BSSpSearchBSSList(pDevice
,
866 pMgmt
->abyDesireBSSID
,
867 pMgmt
->abyDesireSSID
,
868 pMgmt
->eConfigPHYMode
872 printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
873 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
876 /****************************************************************/
877 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, NULL
);
878 spin_unlock_irq(&pDevice
->lock
);
886 * wpa_ioctl main function supported for wpa supplicant
898 int wpa_ioctl(PSDevice pDevice
, struct iw_point
*p
)
900 struct viawget_wpa_param
*param
;
904 if (p
->length
< sizeof(struct viawget_wpa_param
) ||
905 p
->length
> VIAWGET_WPA_MAX_BUF_SIZE
|| !p
->pointer
)
908 param
= (struct viawget_wpa_param
*) kmalloc((int)p
->length
, (int)GFP_KERNEL
);
912 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
917 switch (param
->cmd
) {
918 case VIAWGET_SET_WPA
:
919 ret
= wpa_set_wpa(pDevice
, param
);
920 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_WPA \n");
923 case VIAWGET_SET_KEY
:
924 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_KEY \n");
925 spin_lock_irq(&pDevice
->lock
);
926 ret
= wpa_set_keys(pDevice
, param
, FALSE
);
927 spin_unlock_irq(&pDevice
->lock
);
930 case VIAWGET_SET_SCAN
:
931 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_SCAN \n");
932 ret
= wpa_set_scan(pDevice
, param
);
935 case VIAWGET_GET_SCAN
:
936 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SCAN\n");
937 ret
= wpa_get_scan(pDevice
, param
);
941 case VIAWGET_GET_SSID
:
942 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SSID \n");
943 ret
= wpa_get_ssid(pDevice
, param
);
947 case VIAWGET_GET_BSSID
:
948 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_BSSID \n");
949 ret
= wpa_get_bssid(pDevice
, param
);
953 case VIAWGET_SET_ASSOCIATE
:
954 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_ASSOCIATE \n");
955 ret
= wpa_set_associate(pDevice
, param
);
958 case VIAWGET_SET_DISASSOCIATE
:
959 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DISASSOCIATE \n");
960 ret
= wpa_set_disassociate(pDevice
, param
);
963 case VIAWGET_SET_DROP_UNENCRYPT
:
964 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DROP_UNENCRYPT \n");
967 case VIAWGET_SET_DEAUTHENTICATE
:
968 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DEAUTHENTICATE \n");
972 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ioctl: unknown cmd=%d\n",
978 if ((ret
== 0) && wpa_ioctl
) {
979 if (copy_to_user(p
->pointer
, param
, p
->length
)) {