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
, U_ETHER_ADDR_LEN
);
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
);
192 * Set WPA algorithm & keys
204 int wpa_set_keys(PSDevice pDevice
, void *ctx
, BOOL fcpfkernel
)
206 struct viawget_wpa_param
*param
=ctx
;
207 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
208 DWORD dwKeyIndex
= 0;
209 BYTE abyKey
[MAX_KEY_LEN
];
210 BYTE abySeq
[MAX_KEY_LEN
];
212 // NDIS_802_11_KEY_RSC KeyRSC;
213 BYTE byKeyDecMode
= KEY_CTL_WEP
;
218 if (param
->u
.wpa_key
.alg_name
> WPA_ALG_CCMP
)
221 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"param->u.wpa_key.alg_name = %d \n", param
->u
.wpa_key
.alg_name
);
222 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_NONE
) {
223 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
224 pDevice
->bEncryptionEnable
= FALSE
;
225 pDevice
->byKeyIndex
= 0;
226 pDevice
->bTransmitKey
= FALSE
;
227 for (uu
=0; uu
<MAX_KEY_TABLE
; uu
++) {
228 MACvDisableKeyEntry(pDevice
, uu
);
233 spin_unlock_irq(&pDevice
->lock
);
234 if(param
->u
.wpa_key
.key
&& fcpfkernel
) {
235 memcpy(&abyKey
[0], param
->u
.wpa_key
.key
, param
->u
.wpa_key
.key_len
);
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
);
244 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
,
260 dwKeyIndex
& ~(BIT30
| USE_KEYRSC
),
261 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 if (param
->u
.wpa_key
.seq
&&
279 copy_from_user(&abySeq
[0], param
->u
.wpa_key
.seq
, param
->u
.wpa_key
.seq_len
)) {
280 spin_lock_irq(&pDevice
->lock
);
284 spin_lock_irq(&pDevice
->lock
);
286 if (param
->u
.wpa_key
.seq_len
> 0) {
287 for (ii
= 0 ; ii
< param
->u
.wpa_key
.seq_len
; ii
++) {
289 LODWORD(KeyRSC
) |= (abySeq
[ii
] << (ii
* 8));
291 HIDWORD(KeyRSC
) |= (abySeq
[ii
] << ((ii
-4) * 8));
292 //KeyRSC |= (abySeq[ii] << (ii * 8));
294 dwKeyIndex
|= 1 << 29;
297 if (param
->u
.wpa_key
.key_index
>= MAX_GROUP_KEY
) {
298 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return dwKeyIndex > 3\n");
302 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_TKIP
) {
303 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
306 if (param
->u
.wpa_key
.alg_name
== WPA_ALG_CCMP
) {
307 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
310 if (param
->u
.wpa_key
.set_tx
)
311 dwKeyIndex
|= (1 << 31);
314 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
)
315 byKeyDecMode
= KEY_CTL_CCMP
;
316 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
)
317 byKeyDecMode
= KEY_CTL_TKIP
;
319 byKeyDecMode
= KEY_CTL_WEP
;
321 // Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled
322 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
323 if (param
->u
.wpa_key
.key_len
== MAX_KEY_LEN
)
324 byKeyDecMode
= KEY_CTL_TKIP
;
325 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
326 byKeyDecMode
= KEY_CTL_WEP
;
327 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
328 byKeyDecMode
= KEY_CTL_WEP
;
329 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
330 if (param
->u
.wpa_key
.key_len
== WLAN_WEP40_KEYLEN
)
331 byKeyDecMode
= KEY_CTL_WEP
;
332 else if (param
->u
.wpa_key
.key_len
== WLAN_WEP104_KEYLEN
)
333 byKeyDecMode
= KEY_CTL_WEP
;
336 // Check TKIP key length
337 if ((byKeyDecMode
== KEY_CTL_TKIP
) &&
338 (param
->u
.wpa_key
.key_len
!= MAX_KEY_LEN
)) {
339 // TKIP Key must be 256 bits
340 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - TKIP Key must be 256 bits\n"));
341 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return- TKIP Key must be 256 bits!\n");
344 // Check AES key length
345 if ((byKeyDecMode
== KEY_CTL_CCMP
) &&
346 (param
->u
.wpa_key
.key_len
!= AES_KEY_LEN
)) {
347 // AES Key must be 128 bits
348 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return - AES Key must be 128 bits\n");
353 if (IS_BROADCAST_ADDRESS(¶m
->addr
[0]) || (param
->addr
== NULL
)) {
354 // If IS_BROADCAST_ADDRESS, set the key as every key entry's group key.
355 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Groupe Key Assign.\n");
357 if ((KeybSetAllGroupKey(pDevice
,
360 param
->u
.wpa_key
.key_len
,
365 (KeybSetDefaultKey(pDevice
,
368 param
->u
.wpa_key
.key_len
,
373 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GROUP Key Assign.\n");
376 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n"));
381 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Assign.\n");
382 // BSSID not 0xffffffffffff
383 // Pairwise Key can't be WEP
384 if (byKeyDecMode
== KEY_CTL_WEP
) {
385 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key can't be WEP\n");
389 dwKeyIndex
|= (1 << 30); // set pairwise key
390 if (pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) {
391 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n"));
394 if (KeybSetKey(pDevice
,
398 param
->u
.wpa_key
.key_len
,
403 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pairwise Key Set\n");
407 if (IS_ETH_ADDRESS_EQUAL(¶m
->addr
[0], pDevice
->abyBSSID
)) {
408 //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
412 // Save Key and configure just before associate/reassociate to BSSID
413 // we do not implement now
417 } // BSSID not 0xffffffffffff
418 if ((ret
== 0) && ((param
->u
.wpa_key
.set_tx
) != 0)) {
419 pDevice
->byKeyIndex
= (BYTE
)param
->u
.wpa_key
.key_index
;
420 pDevice
->bTransmitKey
= TRUE
;
422 pDevice
->bEncryptionEnable
= TRUE
;
425 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n",
426 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][0],
427 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][1],
428 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][2],
429 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][3],
430 pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][4]
441 * enable wpa auth & mode
453 static int wpa_set_wpa(PSDevice pDevice
,
454 struct viawget_wpa_param
*param
)
457 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
460 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
461 pMgmt
->bShareKeyAlgorithm
= FALSE
;
483 static int wpa_set_disassociate(PSDevice pDevice
,
484 struct viawget_wpa_param
*param
)
486 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
489 spin_lock_irq(&pDevice
->lock
);
490 if (pDevice
->bLinkPass
) {
491 if (!memcmp(param
->addr
, pMgmt
->abyCurrBSSID
, 6))
492 bScheduleCommand((HANDLE
)pDevice
, WLAN_CMD_DISASSOCIATE
, NULL
);
494 spin_unlock_irq(&pDevice
->lock
);
503 * enable scan process
515 static int wpa_set_scan(PSDevice pDevice
,
516 struct viawget_wpa_param
*param
)
520 //2007-0919-01<Add>by MikeLiu
521 /**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/
522 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
523 PWLAN_IE_SSID pItemSSID
;
524 printk("wpa_set_scan-->desired [ssid=%s,ssid_len=%d]\n",
525 param
->u
.scan_req
.ssid
,param
->u
.scan_req
.ssid_len
);
527 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
528 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
529 pItemSSID
->byElementID
= WLAN_EID_SSID
;
530 memcpy(pItemSSID
->abySSID
, param
->u
.scan_req
.ssid
, param
->u
.scan_req
.ssid_len
);
531 pItemSSID
->len
= param
->u
.scan_req
.ssid_len
;
533 spin_lock_irq(&pDevice
->lock
);
534 BSSvClearBSSList((HANDLE
)pDevice
, pDevice
->bLinkPass
);
535 // bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
536 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
537 spin_unlock_irq(&pDevice
->lock
);
558 static int wpa_get_bssid(PSDevice pDevice
,
559 struct viawget_wpa_param
*param
)
561 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
563 memcpy(param
->u
.wpa_associate
.bssid
, pMgmt
->abyCurrBSSID
, 6);
584 static int wpa_get_ssid(PSDevice pDevice
,
585 struct viawget_wpa_param
*param
)
587 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
588 PWLAN_IE_SSID pItemSSID
;
591 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
593 memcpy(param
->u
.wpa_associate
.ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
594 param
->u
.wpa_associate
.ssid_len
= pItemSSID
->len
;
615 static int wpa_get_scan(PSDevice pDevice
,
616 struct viawget_wpa_param
*param
)
618 struct viawget_scan_result
*scan_buf
;
619 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
620 PWLAN_IE_SSID pItemSSID
;
626 long ldBm
;//James //add
628 //******mike:bubble sort by stronger RSSI*****//
634 ptempBSS
= kmalloc(sizeof(KnownBSS
), (int)GFP_ATOMIC
);
636 if (ptempBSS
== NULL
) {
638 printk("bubble sort kmalloc memory fail@@@\n");
646 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
648 for(jj
=0;jj
<MAX_BSS_NUM
-ii
-1;jj
++) {
650 if((pMgmt
->sBSSList
[jj
].bActive
!=TRUE
) ||
652 ((pMgmt
->sBSSList
[jj
].uRSSI
>pMgmt
->sBSSList
[jj
+1].uRSSI
) &&(pMgmt
->sBSSList
[jj
+1].bActive
!=FALSE
))) {
654 memcpy(ptempBSS
,&pMgmt
->sBSSList
[jj
],sizeof(KnownBSS
));
656 memcpy(&pMgmt
->sBSSList
[jj
],&pMgmt
->sBSSList
[jj
+1],sizeof(KnownBSS
));
658 memcpy(&pMgmt
->sBSSList
[jj
+1],ptempBSS
,sizeof(KnownBSS
));
668 // printk("bubble sort result:\n");
671 pBSS
= &(pMgmt
->sBSSList
[0]);
672 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
673 pBSS
= &(pMgmt
->sBSSList
[ii
]);
679 pBuf
= kmalloc(sizeof(struct viawget_scan_result
) * count
, (int)GFP_ATOMIC
);
685 memset(pBuf
, 0, sizeof(struct viawget_scan_result
) * count
);
686 scan_buf
= (struct viawget_scan_result
*)pBuf
;
687 pBSS
= &(pMgmt
->sBSSList
[0]);
688 for (ii
= 0, jj
= 0; ii
< MAX_BSS_NUM
; ii
++) {
689 pBSS
= &(pMgmt
->sBSSList
[ii
]);
693 memcpy(scan_buf
->bssid
, pBSS
->abyBSSID
, WLAN_BSSID_LEN
);
694 pItemSSID
= (PWLAN_IE_SSID
)pBSS
->abySSID
;
695 memcpy(scan_buf
->ssid
, pItemSSID
->abySSID
, pItemSSID
->len
);
696 scan_buf
->ssid_len
= pItemSSID
->len
;
697 scan_buf
->freq
= frequency_list
[pBSS
->uChannel
-1];
698 scan_buf
->caps
= pBSS
->wCapInfo
; //DavidWang for sharemode
699 //20080717-05,<Add> by James Li
700 RFvRSSITodBm(pDevice
, (BYTE
)(pBSS
->uRSSI
), &ldBm
);
702 scan_buf
->qual
= 100;
703 }else if(-ldBm
> 90) {
706 scan_buf
->qual
=(40-(-ldBm
-50))*100/40;
710 //scan_buf->caps = pBSS->wCapInfo;
713 scan_buf
->level
= ldBm
;
714 //20080717-05,<Add> by James Li--End
715 //scan_buf->maxrate =
716 if (pBSS
->wWPALen
!= 0) {
717 scan_buf
->wpa_ie_len
= pBSS
->wWPALen
;
718 memcpy(scan_buf
->wpa_ie
, pBSS
->byWPAIE
, pBSS
->wWPALen
);
720 if (pBSS
->wRSNLen
!= 0) {
721 scan_buf
->rsn_ie_len
= pBSS
->wRSNLen
;
722 memcpy(scan_buf
->rsn_ie
, pBSS
->byRSNIE
, pBSS
->wRSNLen
);
724 scan_buf
= (struct viawget_scan_result
*)((PBYTE
)scan_buf
+ sizeof(struct viawget_scan_result
));
732 if (copy_to_user(param
->u
.scan_results
.buf
, pBuf
, sizeof(struct viawget_scan_result
) * count
)) {
735 param
->u
.scan_results
.scan_count
= count
;
736 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" param->u.scan_results.scan_count = %d\n", count
)
746 * set associate with AP
758 static int wpa_set_associate(PSDevice pDevice
,
759 struct viawget_wpa_param
*param
)
761 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
762 PWLAN_IE_SSID pItemSSID
;
763 BYTE abyNullAddr
[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
766 BOOL bwepEnabled
=FALSE
;
768 // set key type & algorithm
769 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pairwise_suite = %d\n", param
->u
.wpa_associate
.pairwise_suite
);
770 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"group_suite = %d\n", param
->u
.wpa_associate
.group_suite
);
771 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"key_mgmt_suite = %d\n", param
->u
.wpa_associate
.key_mgmt_suite
);
772 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"auth_alg = %d\n", param
->u
.wpa_associate
.auth_alg
);
773 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"mode = %d\n", param
->u
.wpa_associate
.mode
);
774 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ie_len = %d\n", param
->u
.wpa_associate
.wpa_ie_len
);
775 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Roaming dBm = %d\n", param
->u
.wpa_associate
.roam_dbm
); //Davidwang
777 if (param
->u
.wpa_associate
.wpa_ie
&&
778 copy_from_user(&abyWPAIE
[0], param
->u
.wpa_associate
.wpa_ie
, param
->u
.wpa_associate
.wpa_ie_len
))
781 if (param
->u
.wpa_associate
.mode
== 1)
782 pMgmt
->eConfigMode
= WMAC_CONFIG_IBSS_STA
;
784 pMgmt
->eConfigMode
= WMAC_CONFIG_ESS_STA
;
787 if (memcmp(param
->u
.wpa_associate
.bssid
, &abyNullAddr
[0], 6) != 0)
788 memcpy(pMgmt
->abyDesireBSSID
, param
->u
.wpa_associate
.bssid
, 6);
790 memset(pMgmt
->abyDesireSSID
, 0, WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1);
791 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
792 pItemSSID
->byElementID
= WLAN_EID_SSID
;
793 pItemSSID
->len
= param
->u
.wpa_associate
.ssid_len
;
794 memcpy(pItemSSID
->abySSID
, param
->u
.wpa_associate
.ssid
, pItemSSID
->len
);
796 if (param
->u
.wpa_associate
.wpa_ie_len
== 0) {
797 if (param
->u
.wpa_associate
.auth_alg
& AUTH_ALG_SHARED_KEY
)
798 pMgmt
->eAuthenMode
= WMAC_AUTH_SHAREKEY
;
800 pMgmt
->eAuthenMode
= WMAC_AUTH_OPEN
;
801 } else if (abyWPAIE
[0] == RSN_INFO_ELEM
) {
802 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
803 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2PSK
;
805 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA2
;
807 if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_WPA_NONE
)
808 pMgmt
->eAuthenMode
= WMAC_AUTH_WPANONE
;
809 else if (param
->u
.wpa_associate
.key_mgmt_suite
== KEY_MGMT_PSK
)
810 pMgmt
->eAuthenMode
= WMAC_AUTH_WPAPSK
;
812 pMgmt
->eAuthenMode
= WMAC_AUTH_WPA
;
815 switch (param
->u
.wpa_associate
.pairwise_suite
) {
817 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
820 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
824 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
826 // printk("****************wpa_set_associate:set CIPHER_WEP40_104\n");
829 if (param
->u
.wpa_associate
.group_suite
== CIPHER_CCMP
)
830 pDevice
->eEncryptionStatus
= Ndis802_11Encryption3Enabled
;
832 pDevice
->eEncryptionStatus
= Ndis802_11Encryption2Enabled
;
835 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
838 pMgmt
->Roam_dbm
= param
->u
.wpa_associate
.roam_dbm
;
839 // if ((pMgmt->Roam_dbm > 40)&&(pMgmt->Roam_dbm<80))
840 // pDevice->bEnableRoaming = TRUE;
842 if (pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) { //@wep-sharekey
843 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
844 pMgmt
->bShareKeyAlgorithm
= TRUE
;
846 else if (pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) {
847 if(bwepEnabled
==TRUE
) { //@open-wep
848 pDevice
->eEncryptionStatus
= Ndis802_11Encryption1Enabled
;
851 pDevice
->eEncryptionStatus
= Ndis802_11EncryptionDisabled
;
854 //mike save old encryption status
855 pDevice
->eOldEncryptionStatus
= pDevice
->eEncryptionStatus
;
857 if (pDevice
->eEncryptionStatus
!= Ndis802_11EncryptionDisabled
)
858 pDevice
->bEncryptionEnable
= TRUE
;
860 pDevice
->bEncryptionEnable
= FALSE
;
862 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_SHAREKEY
) ||
863 ((pMgmt
->eAuthenMode
== WMAC_AUTH_OPEN
) && (bwepEnabled
==TRUE
))) {
864 //mike re-comment:open-wep && sharekey-wep needn't do initial key!!
868 KeyvInitTable(pDevice
,&pDevice
->sKey
);
870 spin_lock_irq(&pDevice
->lock
);
871 pDevice
->bLinkPass
= FALSE
;
872 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
873 memset(pMgmt
->abyCurrBSSID
, 0, 6);
874 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
875 netif_stop_queue(pDevice
->dev
);
877 //20080701-02,<Add> by Mike Liu
878 /*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
880 PKnownBSS pCurr
= NULL
;
881 pCurr
= BSSpSearchBSSList(pDevice
,
882 pMgmt
->abyDesireBSSID
,
883 pMgmt
->abyDesireSSID
,
884 pDevice
->eConfigPHYMode
888 printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
889 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
892 /****************************************************************/
894 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, NULL
);
895 spin_unlock_irq(&pDevice
->lock
);
903 * wpa_ioctl main function supported for wpa supplicant
915 int wpa_ioctl(PSDevice pDevice
, struct iw_point
*p
)
917 struct viawget_wpa_param
*param
;
921 if (p
->length
< sizeof(struct viawget_wpa_param
) ||
922 p
->length
> VIAWGET_WPA_MAX_BUF_SIZE
|| !p
->pointer
)
925 param
= (struct viawget_wpa_param
*) kmalloc((int)p
->length
, (int)GFP_KERNEL
);
929 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
934 switch (param
->cmd
) {
935 case VIAWGET_SET_WPA
:
936 ret
= wpa_set_wpa(pDevice
, param
);
937 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_WPA \n");
940 case VIAWGET_SET_KEY
:
941 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_KEY \n");
942 spin_lock_irq(&pDevice
->lock
);
943 ret
= wpa_set_keys(pDevice
, param
, FALSE
);
944 spin_unlock_irq(&pDevice
->lock
);
947 case VIAWGET_SET_SCAN
:
948 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_SCAN \n");
949 ret
= wpa_set_scan(pDevice
, param
);
952 case VIAWGET_GET_SCAN
:
953 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SCAN\n");
954 ret
= wpa_get_scan(pDevice
, param
);
958 case VIAWGET_GET_SSID
:
959 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_SSID \n");
960 ret
= wpa_get_ssid(pDevice
, param
);
964 case VIAWGET_GET_BSSID
:
965 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_GET_BSSID \n");
966 ret
= wpa_get_bssid(pDevice
, param
);
970 case VIAWGET_SET_ASSOCIATE
:
971 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_ASSOCIATE \n");
972 ret
= wpa_set_associate(pDevice
, param
);
975 case VIAWGET_SET_DISASSOCIATE
:
976 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DISASSOCIATE \n");
977 ret
= wpa_set_disassociate(pDevice
, param
);
980 case VIAWGET_SET_DROP_UNENCRYPT
:
981 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DROP_UNENCRYPT \n");
984 case VIAWGET_SET_DEAUTHENTICATE
:
985 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"VIAWGET_SET_DEAUTHENTICATE \n");
989 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wpa_ioctl: unknown cmd=%d\n",
995 if ((ret
== 0) && wpa_ioctl
) {
996 if (copy_to_user(p
->pointer
, param
, p
->length
)) {