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
51 static const int frequency_list
[] = {
52 2412, 2417, 2422, 2427, 2432, 2437, 2442,
53 2447, 2452, 2457, 2462, 2467, 2472, 2484
55 /*--------------------- Static Classes ----------------------------*/
57 /*--------------------- Static Variables --------------------------*/
58 //static int msglevel =MSG_LEVEL_DEBUG;
59 static int msglevel
=MSG_LEVEL_INFO
;
61 /*--------------------- Static Functions --------------------------*/
66 /*--------------------- Export Variables --------------------------*/
67 static void wpadev_setup(struct net_device
*dev
)
69 dev
->type
= ARPHRD_IEEE80211
;
70 dev
->hard_header_len
= ETH_HLEN
;
72 dev
->addr_len
= ETH_ALEN
;
73 dev
->tx_queue_len
= 1000;
75 memset(dev
->broadcast
,0xFF, ETH_ALEN
);
77 dev
->flags
= IFF_BROADCAST
|IFF_MULTICAST
;
82 * register netdev for wpa supplicant deamon
94 static int wpa_init_wpadev(PSDevice pDevice
)
97 struct net_device
*dev
= pDevice
->dev
;
100 pDevice
->wpadev
= alloc_netdev(sizeof(PSDevice
), "vntwpa", wpadev_setup
);
101 if (pDevice
->wpadev
== NULL
)
104 wpadev_priv
= netdev_priv(pDevice
->wpadev
);
105 *wpadev_priv
= *pDevice
;
106 memcpy(pDevice
->wpadev
->dev_addr
, dev
->dev_addr
, ETH_ALEN
);
107 pDevice
->wpadev
->base_addr
= dev
->base_addr
;
108 pDevice
->wpadev
->irq
= dev
->irq
;
109 pDevice
->wpadev
->mem_start
= dev
->mem_start
;
110 pDevice
->wpadev
->mem_end
= dev
->mem_end
;
111 ret
= register_netdev(pDevice
->wpadev
);
113 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: register_netdev(WPA) failed!\n",
115 free_netdev(pDevice
->wpadev
);
119 if (pDevice
->skb
== NULL
) {
120 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
121 if (pDevice
->skb
== NULL
)
125 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Registered netdev %s for WPA management\n",
126 dev
->name
, pDevice
->wpadev
->name
);
134 * unregister net_device (wpadev)
145 static int wpa_release_wpadev(PSDevice pDevice
)
148 dev_kfree_skb(pDevice
->skb
);
152 if (pDevice
->wpadev
) {
153 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%s: Netdevice %s unregistered\n",
154 pDevice
->dev
->name
, pDevice
->wpadev
->name
);
155 unregister_netdev(pDevice
->wpadev
);
156 free_netdev(pDevice
->wpadev
);
157 pDevice
->wpadev
= NULL
;
169 * Set enable/disable dev for wpa supplicant deamon
181 int wpa_set_wpadev(PSDevice pDevice
, int val
)
184 return wpa_init_wpadev(pDevice
);
186 return wpa_release_wpadev(pDevice
);
191 * Set WPA algorithm & keys
203 int wpa_set_keys(PSDevice pDevice
, void *ctx
, BOOL fcpfkernel
)
205 struct viawget_wpa_param
*param
=ctx
;
206 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
207 DWORD dwKeyIndex
= 0;
208 BYTE abyKey
[MAX_KEY_LEN
];
209 BYTE abySeq
[MAX_KEY_LEN
];
211 // NDIS_802_11_KEY_RSC KeyRSC;
212 BYTE byKeyDecMode
= KEY_CTL_WEP
;
217 if (param
->u
.wpa_key
.alg_name
> WPA_ALG_CCMP
)
220 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"param->u.wpa_key.alg_name = %d \n", param
->u
.wpa_key
.alg_name
);
221 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
222 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
223 pDevice
->bEncryptionEnable
= FALSE
;
224 pDevice
->byKeyIndex
= 0;
225 pDevice
->bTransmitKey
= FALSE
;
226 for (uu
=0; uu
<MAX_KEY_TABLE
; uu
++) {
227 MACvDisableKeyEntry(pDevice
, 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 if (param
->u
.wpa_key
.key
&&
238 copy_from_user(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
)) {
239 spin_lock_irq(&pDevice
->lock
);
243 spin_lock_irq(&pDevice
->lock
);
245 dwKeyIndex
= (DWORD
)(param
->u
.wpa_key
.key_index
);
247 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_WEP
) {
248 if (dwKeyIndex
> 3) {
252 if (param
->u
.wpa_key
.set_tx
) {
253 pDevice
->byKeyIndex
= (BYTE
)dwKeyIndex
;
254 pDevice
->bTransmitKey
= TRUE
;
255 dwKeyIndex
|= (1 << 31);
257 KeybSetDefaultKey( pDevice
,
259 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
260 param
->u
.wpa_key
.key_len
,
267 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
268 pDevice
->bEncryptionEnable
= TRUE
;
272 spin_unlock_irq(&pDevice
->lock
);
273 if(param
->u
.wpa_key
.seq
&& fcpfkernel
) {
274 memcpy(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
);
277 if (param
->u
.wpa_key
.seq
&&
278 copy_from_user(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
)) {
279 spin_lock_irq(&pDevice
->lock
);
283 spin_lock_irq(&pDevice
->lock
);
285 if (param
->u
.wpa_key
.seq_len
> 0) {
286 for (ii
= 0 ; ii
< param
->u
.wpa_key
.seq_len
; ii
++) {
288 LODWORD(KeyRSC
) |= (abySeq
[ii
] << (ii
* 8));
290 HIDWORD(KeyRSC
) |= (abySeq
[ii
] << ((ii
-4) * 8));
291 //KeyRSC |= (abySeq[ii] << (ii * 8));
293 dwKeyIndex
|= 1 << 29;
296 if (param
->u
.wpa_key
.key_index
>= MAX_GROUP_KEY
) {
297 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return dwKeyIndex > 3\n");
301 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_TKIP
) {
302 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
305 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_CCMP
) {
306 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
309 if (param
->u
.wpa_key
.set_tx
)
310 dwKeyIndex
|= (1 << 31);
313 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
314 byKeyDecMode
= KEY_CTL_CCMP
;
315 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
316 byKeyDecMode
= KEY_CTL_TKIP
;
318 byKeyDecMode
= KEY_CTL_WEP
;
320 // Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled
321 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
322 if (param
->u
.wpa_key
.key_len
== MAX_KEY_LEN
)
323 byKeyDecMode
= KEY_CTL_TKIP
;
324 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
325 byKeyDecMode
= KEY_CTL_WEP
;
326 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
327 byKeyDecMode
= KEY_CTL_WEP
;
328 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
329 if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
330 byKeyDecMode
= KEY_CTL_WEP
;
331 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
332 byKeyDecMode
= KEY_CTL_WEP
;
335 // Check TKIP key length
336 if ((byKeyDecMode
== KEY_CTL_TKIP
) &&
337 (param
->u
.wpa_key
.key_len
!= MAX_KEY_LEN
)) {
338 // TKIP Key must be 256 bits
339 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - TKIP Key must be 256 bits\n"));
340 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return- TKIP Key must be 256 bits!\n");
343 // Check AES key length
344 if ((byKeyDecMode
== KEY_CTL_CCMP
) &&
345 (param
->u
.wpa_key
.key_len
!= AES_KEY_LEN
)) {
346 // AES Key must be 128 bits
347 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return - AES Key must be 128 bits\n");
351 if (is_broadcast_ether_addr(¶m
->addr
[0]) || (param
->addr
== NULL
)) {
352 /* if broadcast, set the key as every key entry's group key */
353 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Groupe Key Assign.\n");
355 if ((KeybSetAllGroupKey(pDevice
,
358 param
->u
.wpa_key
.key_len
,
363 (KeybSetDefaultKey(pDevice
,
366 param
->u
.wpa_key
.key_len
,
371 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GROUP Key Assign.\n");
374 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n"));
379 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Assign.\n");
380 // BSSID not 0xffffffffffff
381 // Pairwise Key can't be WEP
382 if (byKeyDecMode
== KEY_CTL_WEP
) {
383 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key can't be WEP\n");
387 dwKeyIndex
|= (1 << 30); // set pairwise key
388 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
389 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n"));
392 if (KeybSetKey(pDevice
,
396 param
->u
.wpa_key
.key_len
,
401 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Set\n");
405 if (!compare_ether_addr(¶m
->addr
[0], pDevice
->abyBSSID
)) {
406 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
410 // Save Key and configure just before associate/reassociate to BSSID
411 // we do not implement now
415 } // BSSID not 0xffffffffffff
416 if ((ret
== 0) && ((param
->u
.wpa_key
.set_tx
) != 0)) {
417 pDevice
->byKeyIndex
= (BYTE
)param
->u
.wpa_key
.key_index
;
418 pDevice
->bTransmitKey
= TRUE
;
420 pDevice
->bEncryptionEnable
= TRUE
;
423 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n",
424 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][0],
425 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][1],
426 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][2],
427 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][3],
428 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][4]
439 * enable wpa auth & mode
451 static int wpa_set_wpa(PSDevice pDevice
,
452 struct viawget_wpa_param
*param
)
455 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
458 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
459 pMgmt
->bShareKeyAlgorithm
= FALSE
;
481 static int wpa_set_disassociate(PSDevice pDevice
,
482 struct viawget_wpa_param
*param
)
484 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
487 spin_lock_irq(&pDevice
->lock
);
488 if (pDevice
->bLinkPass
) {
489 if (!memcmp(param
->addr
, pMgmt
->abyCurrBSSID
, 6))
490 bScheduleCommand((void *) pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
492 spin_unlock_irq(&pDevice
->lock
);
501 * enable scan process
513 static int wpa_set_scan(PSDevice pDevice
,
514 struct viawget_wpa_param
*param
)
518 /**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/
519 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
520 PWLAN_IE_SSID pItemSSID
;
521 printk("wpa_set_scan-->desired [ssid=%s,ssid_len=%d]\n",
522 param
->u
.scan_req
.ssid
,param
->u
.scan_req
.ssid_len
);
524 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
525 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
526 pItemSSID
->byElementID
= WLAN_EID_SSID
;
527 memcpy(pItemSSID
->abySSID
, param
->u
.scan_req
.ssid
, param
->u
.scan_req
.ssid_len
);
528 pItemSSID
->len
= param
->u
.scan_req
.ssid_len
;
530 spin_lock_irq(&pDevice
->lock
);
531 BSSvClearBSSList((void *) pDevice
, pDevice
->bLinkPass
);
532 /* bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); */
533 bScheduleCommand((void *) pDevice
,
535 pMgmt
->abyDesireSSID
);
536 spin_unlock_irq(&pDevice
->lock
);
557 static int wpa_get_bssid(PSDevice pDevice
,
558 struct viawget_wpa_param
*param
)
560 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
562 memcpy(param
->u
.wpa_associate
.bssid
, pMgmt
->abyCurrBSSID
, 6);
583 static int wpa_get_ssid(PSDevice pDevice
,
584 struct viawget_wpa_param
*param
)
586 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
587 PWLAN_IE_SSID pItemSSID
;
590 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
592 memcpy(param
->u
.wpa_associate
.ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
593 param
->u
.wpa_associate
.ssid_len
= pItemSSID
->len
;
614 static int wpa_get_scan(PSDevice pDevice
,
615 struct viawget_wpa_param
*param
)
617 struct viawget_scan_result
*scan_buf
;
618 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
619 PWLAN_IE_SSID pItemSSID
;
625 long ldBm
;//James //add
627 //******mike:bubble sort by stronger RSSI*****//
633 ptempBSS
= kmalloc(sizeof(KnownBSS
), (int)GFP_ATOMIC
);
635 if (ptempBSS
== NULL
) {
637 printk("bubble sort kmalloc memory fail@@@\n");
645 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
647 for (jj
= 0; jj
< MAX_BSS_NUM
- ii
- 1; jj
++) {
649 if ((pMgmt
->sBSSList
[jj
].bActive
!= TRUE
) ||
651 ((pMgmt
->sBSSList
[jj
].uRSSI
>pMgmt
->sBSSList
[jj
+1].uRSSI
) &&(pMgmt
->sBSSList
[jj
+1].bActive
!=FALSE
))) {
653 memcpy(ptempBSS
,&pMgmt
->sBSSList
[jj
],sizeof(KnownBSS
));
655 memcpy(&pMgmt
->sBSSList
[jj
],&pMgmt
->sBSSList
[jj
+1],sizeof(KnownBSS
));
657 memcpy(&pMgmt
->sBSSList
[jj
+1],ptempBSS
,sizeof(KnownBSS
));
667 // printk("bubble sort result:\n");
670 pBSS
= &(pMgmt
->sBSSList
[0]);
671 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
672 pBSS
= &(pMgmt
->sBSSList
[ii
]);
678 pBuf
= kcalloc(count
, sizeof(struct viawget_scan_result
), (int)GFP_ATOMIC
);
684 scan_buf
= (struct viawget_scan_result
*)pBuf
;
685 pBSS
= &(pMgmt
->sBSSList
[0]);
686 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
687 pBSS
= &(pMgmt
->sBSSList
[ii
]);
691 memcpy(scan_buf
->bssid
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
692 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
693 memcpy(scan_buf
->ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
694 scan_buf
->ssid_len
= pItemSSID
->len
;
695 scan_buf
->freq
= frequency_list
[pBSS
->uChannel
-1];
696 scan_buf
->caps
= pBSS
->wCapInfo
; //DavidWang for sharemode
698 RFvRSSITodBm(pDevice
, (BYTE
)(pBSS
->uRSSI
), &ldBm
);
700 scan_buf
->qual
= 100;
701 }else if(-ldBm
> 90) {
704 scan_buf
->qual
=(40-(-ldBm
-50))*100/40;
708 //scan_buf->caps = pBSS->wCapInfo;
711 scan_buf
->level
= ldBm
;
713 //scan_buf->maxrate =
714 if (pBSS
->wWPALen
!= 0) {
715 scan_buf
->wpa_ie_len
= pBSS
->wWPALen
;
716 memcpy(scan_buf
->wpa_ie
, pBSS
->byWPAIE
, pBSS
->wWPALen
);
718 if (pBSS
->wRSNLen
!= 0) {
719 scan_buf
->rsn_ie_len
= pBSS
->wRSNLen
;
720 memcpy(scan_buf
->rsn_ie
, pBSS
->byRSNIE
, pBSS
->wRSNLen
);
722 scan_buf
= (struct viawget_scan_result
*)((PBYTE
)scan_buf
+ sizeof(struct viawget_scan_result
));
730 if (copy_to_user(param
->u
.scan_results
.buf
, pBuf
, sizeof(struct viawget_scan_result
) * count
)) {
733 param
->u
.scan_results
.scan_count
= count
;
734 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" param->u.scan_results.scan_count = %d\n", count
)
744 * set associate with AP
756 static int wpa_set_associate(PSDevice pDevice
,
757 struct viawget_wpa_param
*param
)
759 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
760 PWLAN_IE_SSID pItemSSID
;
761 BYTE abyNullAddr
[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
764 BOOL bwepEnabled
=FALSE
;
766 // set key type & algorithm
767 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pairwise_suite = %d\n", param
->u
.wpa_associate
.pairwise_suite
);
768 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"group_suite = %d\n", param
->u
.wpa_associate
.group_suite
);
769 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"key_mgmt_suite = %d\n", param
->u
.wpa_associate
.key_mgmt_suite
);
770 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"auth_alg = %d\n", param
->u
.wpa_associate
.auth_alg
);
771 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"mode = %d\n", param
->u
.wpa_associate
.mode
);
772 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ie_len = %d\n", param
->u
.wpa_associate
.wpa_ie_len
);
773 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Roaming dBm = %d\n", param
->u
.wpa_associate
.roam_dbm
); //Davidwang
775 if (param
->u
.wpa_associate
.wpa_ie
&&
776 copy_from_user(&abyWPAIE
[0], param
->u
.wpa_associate
.wpa_ie
, param
->u
.wpa_associate
.wpa_ie_len
))
779 if (param
->u
.wpa_associate
.mode
== 1)
780 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
782 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
785 if (memcmp(param
->u
.wpa_associate
.bssid
, &abyNullAddr
[0], 6) != 0)
786 memcpy(pMgmt
->abyDesireBSSID
, param
->u
.wpa_associate
.bssid
, 6);
788 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
789 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
790 pItemSSID
->byElementID
= WLAN_EID_SSID
;
791 pItemSSID
->len
= param
->u
.wpa_associate
.ssid_len
;
792 memcpy(pItemSSID
->abySSID
, param
->u
.wpa_associate
.ssid
, pItemSSID
->len
);
794 if (param
->u
.wpa_associate
.wpa_ie_len
== 0) {
795 if (param
->u
.wpa_associate
.auth_alg
& AUTH_ALG_SHARED_KEY
)
796 pMgmt
->eAuthenMode
= WMAC_AUTH_SHAREKEY
;
798 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
799 } else if (abyWPAIE
[0] == RSN_INFO_ELEM
) {
800 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
801 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
803 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
805 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_WPA_NONE
)
806 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
807 else if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
808 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
810 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
813 switch (param
->u
.wpa_associate
.pairwise_suite
) {
815 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
818 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
822 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
824 // printk("****************wpa_set_associate:set CIPHER_WEP40_104\n");
827 if (param
->u
.wpa_associate
.group_suite
== CIPHER_CCMP
)
828 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
830 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
833 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
836 pMgmt
->Roam_dbm
= param
->u
.wpa_associate
.roam_dbm
;
837 // if ((pMgmt->Roam_dbm > 40)&&(pMgmt->Roam_dbm<80))
838 // pDevice->bEnableRoaming = TRUE;
840 if (pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) { //@wep-sharekey
841 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
842 pMgmt
->bShareKeyAlgorithm
= TRUE
;
844 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) {
845 if(bwepEnabled
==TRUE
) { //@open-wep
846 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
849 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
852 //mike save old encryption status
853 pDevice
->eOldEncryptionStatus
= pDevice
->eEncryptionStatus
;
855 if (pDevice
->eEncryptionStatus
!= Ndis802_11EncryptionDisabled
)
856 pDevice
->bEncryptionEnable
= TRUE
;
858 pDevice
->bEncryptionEnable
= FALSE
;
860 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) ||
861 ((pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) && (bwepEnabled
==TRUE
))) {
862 //mike re-comment:open-wep && sharekey-wep needn't do initial key!!
866 KeyvInitTable(pDevice
,&pDevice
->sKey
);
868 spin_lock_irq(&pDevice
->lock
);
869 pDevice
->bLinkPass
= FALSE
;
870 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
871 memset(pMgmt
->abyCurrBSSID
, 0, 6);
872 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
873 netif_stop_queue(pDevice
->dev
);
875 /*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
877 PKnownBSS pCurr
= NULL
;
878 pCurr
= BSSpSearchBSSList(pDevice
,
879 pMgmt
->abyDesireBSSID
,
880 pMgmt
->abyDesireSSID
,
881 pDevice
->eConfigPHYMode
885 printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
886 bScheduleCommand((void *) pDevice
,
888 pMgmt
->abyDesireSSID
);
891 /****************************************************************/
893 bScheduleCommand((void *) pDevice
, WLAN_CMD_SSID
, NULL
);
894 spin_unlock_irq(&pDevice
->lock
);
902 * wpa_ioctl main function supported for wpa supplicant
914 int wpa_ioctl(PSDevice pDevice
, struct iw_point
*p
)
916 struct viawget_wpa_param
*param
;
920 if (p
->length
< sizeof(struct viawget_wpa_param
) ||
921 p
->length
> VIAWGET_WPA_MAX_BUF_SIZE
|| !p
->pointer
)
924 param
= kmalloc((int)p
->length
, (int)GFP_KERNEL
);
928 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
933 switch (param
->cmd
) {
934 case VIAWGET_SET_WPA
:
935 ret
= wpa_set_wpa(pDevice
, param
);
936 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_WPA \n");
939 case VIAWGET_SET_KEY
:
940 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_KEY \n");
941 spin_lock_irq(&pDevice
->lock
);
942 ret
= wpa_set_keys(pDevice
, param
, FALSE
);
943 spin_unlock_irq(&pDevice
->lock
);
946 case VIAWGET_SET_SCAN
:
947 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_SCAN \n");
948 ret
= wpa_set_scan(pDevice
, param
);
951 case VIAWGET_GET_SCAN
:
952 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SCAN\n");
953 ret
= wpa_get_scan(pDevice
, param
);
957 case VIAWGET_GET_SSID
:
958 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SSID \n");
959 ret
= wpa_get_ssid(pDevice
, param
);
963 case VIAWGET_GET_BSSID
:
964 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_BSSID \n");
965 ret
= wpa_get_bssid(pDevice
, param
);
969 case VIAWGET_SET_ASSOCIATE
:
970 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_ASSOCIATE \n");
971 ret
= wpa_set_associate(pDevice
, param
);
974 case VIAWGET_SET_DISASSOCIATE
:
975 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DISASSOCIATE \n");
976 ret
= wpa_set_disassociate(pDevice
, param
);
979 case VIAWGET_SET_DROP_UNENCRYPT
:
980 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DROP_UNENCRYPT \n");
983 case VIAWGET_SET_DEAUTHENTICATE
:
984 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DEAUTHENTICATE \n");
988 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ioctl: unknown cmd=%d\n",
994 if ((ret
== 0) && wpa_ioctl
) {
995 if (copy_to_user(p
->pointer
, param
, p
->length
)) {