[ARM] pxa: Gumstix Verdex PCMCIA support
[linux-2.6/verdex.git] / drivers / staging / vt6656 / ioctl.c
blobd94131fe52434b8bc5364a4db3596ae5517c3317
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
19 * File: ioctl.c
21 * Purpose: private ioctl functions
23 * Author: Lyndon Chen
25 * Date: Auguest 20, 2003
27 * Functions:
29 * Revision History:
33 #include "ioctl.h"
34 #include "iocmd.h"
35 #include "mac.h"
36 #include "card.h"
37 #include "hostap.h"
38 #include "wpactl.h"
39 #include "control.h"
40 #include "rndis.h"
41 #include "rf.h"
43 /*--------------------- Static Definitions -------------------------*/
45 /*--------------------- Static Classes ----------------------------*/
47 /*--------------------- Static Variables --------------------------*/
48 //static int msglevel =MSG_LEVEL_DEBUG;
49 static int msglevel =MSG_LEVEL_INFO;
51 #ifdef WPA_SM_Transtatus
52 SWPAResult wpa_Result;
53 #endif
55 /*--------------------- Static Functions --------------------------*/
57 /*--------------------- Export Variables --------------------------*/
59 int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
61 PSCmdRequest pReq = (PSCmdRequest)rq;
62 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
63 int result = 0;
64 PWLAN_IE_SSID pItemSSID;
65 SCmdBSSJoin sJoinCmd;
66 SCmdZoneTypeSet sZoneTypeCmd;
67 SCmdScan sScanCmd;
68 SCmdStartAP sStartAPCmd;
69 SCmdSetWEP sWEPCmd;
70 SCmdValue sValue;
71 SBSSIDList sList;
72 SNodeList sNodeList;
73 PSBSSIDList pList;
74 PSNodeList pNodeList;
75 UINT cbListCount;
76 PKnownBSS pBSS;
77 PKnownNodeDB pNode;
78 UINT ii, jj;
79 SCmdLinkStatus sLinkStatus;
80 BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
81 BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
82 DWORD dwKeyIndex= 0;
83 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
84 LONG ldBm;
86 pReq->wResult = 0;
88 switch(pReq->wCmdCode) {
90 case WLAN_CMD_BSS_SCAN:
92 if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
93 result = -EFAULT;
94 break;
97 pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
98 if (pItemSSID->len != 0) {
99 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
100 memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
102 spin_lock_irq(&pDevice->lock);
103 if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
104 BSSvClearBSSList((HANDLE)pDevice, FALSE);
105 else
106 BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
107 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin \n");
109 if (pItemSSID->len != 0)
110 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
111 else
112 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
113 spin_unlock_irq(&pDevice->lock);
114 break;
116 case WLAN_CMD_ZONETYPE_SET:
117 //mike add :cann't support.
118 result=-EOPNOTSUPP;
119 break;
121 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
122 result = -EFAULT;
123 break;
126 if(sZoneTypeCmd.bWrite==TRUE) {
127 //////write zonetype
128 if(sZoneTypeCmd.ZoneType == ZoneType_USA) {
129 //set to USA
130 printk("set_ZoneType:USA\n");
132 else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) {
133 //set to Japan
134 printk("set_ZoneType:Japan\n");
136 else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) {
137 //set to Europe
138 printk("set_ZoneType:Europe\n");
141 else {
142 ///////read zonetype
143 BYTE zonetype=0;
146 if(zonetype == 0x00) { //USA
147 sZoneTypeCmd.ZoneType = ZoneType_USA;
149 else if(zonetype == 0x01) { //Japan
150 sZoneTypeCmd.ZoneType = ZoneType_Japan;
152 else if(zonetype == 0x02) { //Europe
153 sZoneTypeCmd.ZoneType = ZoneType_Europe;
155 else { //Unknow ZoneType
156 printk("Error:ZoneType[%x] Unknown ???\n",zonetype);
157 result = -EFAULT;
158 break;
160 if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
161 result = -EFAULT;
162 break;
166 break;
168 case WLAN_CMD_BSS_JOIN:
170 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
171 result = -EFAULT;
172 break;
175 pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
176 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
177 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
178 if (sJoinCmd.wBSSType == ADHOC) {
179 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
180 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
182 else {
183 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
184 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
186 if (sJoinCmd.bPSEnable == TRUE) {
187 pDevice->ePSMode = WMAC_POWER_FAST;
188 // pDevice->ePSMode = WMAC_POWER_MAX;
189 pMgmt->wListenInterval = 2;
190 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
192 else {
193 pDevice->ePSMode = WMAC_POWER_CAM;
194 pMgmt->wListenInterval = 1;
195 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n");
198 if (sJoinCmd.bShareKeyAuth == TRUE){
199 pMgmt->bShareKeyAlgorithm = TRUE;
200 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
202 else {
203 pMgmt->bShareKeyAlgorithm = FALSE;
204 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
206 pDevice->uChannel = sJoinCmd.uChannel;
207 netif_stop_queue(pDevice->dev);
208 spin_lock_irq(&pDevice->lock);
209 pMgmt->eCurrState = WMAC_STATE_IDLE;
210 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
211 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
212 spin_unlock_irq(&pDevice->lock);
213 break;
215 case WLAN_CMD_SET_WEP:
216 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n");
217 memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP));
218 if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
219 result = -EFAULT;
220 break;
222 if (sWEPCmd.bEnableWep != TRUE) {
223 int uu;
225 pDevice->bEncryptionEnable = FALSE;
226 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
227 spin_lock_irq(&pDevice->lock);
228 for(uu=0;uu<MAX_KEY_TABLE;uu++)
229 MACvDisableKeyEntry(pDevice,uu);
230 spin_unlock_irq(&pDevice->lock);
231 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable. \n");
232 break;
235 for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) {
236 if (sWEPCmd.bWepKeyAvailable[ii]) {
237 if (ii == sWEPCmd.byKeyIndex)
238 //2006-1207-01<Modify>by Einsn Liu
239 // dwKeyIndex|= (1 << 31);
240 dwKeyIndex=ii|(1 << 31);
241 else
242 dwKeyIndex = ii;
243 spin_lock_irq(&pDevice->lock);
244 KeybSetDefaultKey( pDevice,
245 &(pDevice->sKey),
246 dwKeyIndex,
247 sWEPCmd.auWepKeyLength[ii],
248 NULL,
249 (PBYTE)&sWEPCmd.abyWepKey[ii][0],
250 KEY_CTL_WEP
252 spin_unlock_irq(&pDevice->lock);
256 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
257 pDevice->bTransmitKey = TRUE;
258 pDevice->bEncryptionEnable = TRUE;
259 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
261 break;
263 case WLAN_CMD_GET_LINK:
264 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n");
266 memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
268 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
269 sLinkStatus.wBSSType = ADHOC;
270 else
271 sLinkStatus.wBSSType = INFRA;
273 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
274 sLinkStatus.byState = ADHOC_JOINTED;
275 else
276 sLinkStatus.byState = ADHOC_STARTED;
278 sLinkStatus.uChannel = pMgmt->uCurrChannel;
279 if (pDevice->bLinkPass == TRUE) {
280 sLinkStatus.bLink = TRUE;
281 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
282 memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
283 memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
284 sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
285 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n");
287 else {
288 sLinkStatus.bLink = FALSE;
290 if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
291 result = -EFAULT;
292 break;
295 break;
297 case WLAN_CMD_GET_LISTLEN:
298 cbListCount = 0;
299 pBSS = &(pMgmt->sBSSList[0]);
300 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
301 pBSS = &(pMgmt->sBSSList[ii]);
302 if (!pBSS->bActive)
303 continue;
304 cbListCount++;
306 sList.uItem = cbListCount;
307 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
308 result = -EFAULT;
309 break;
311 pReq->wResult = 0;
312 break;
314 case WLAN_CMD_GET_LIST:
315 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
316 result = -EFAULT;
317 break;
319 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
320 if (pList == NULL) {
321 result = -ENOMEM;
322 break;
324 pList->uItem = sList.uItem;
325 pBSS = &(pMgmt->sBSSList[0]);
326 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
327 pBSS = &(pMgmt->sBSSList[jj]);
328 if (pBSS->bActive) {
329 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
330 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
331 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
332 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
333 pList->sBSSIDList[ii].uRSSI = (UINT)ldBm;
334 // pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI;
335 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
336 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
337 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
338 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
339 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
340 pList->sBSSIDList[ii].byNetType = INFRA;
342 else {
343 pList->sBSSIDList[ii].byNetType = ADHOC;
345 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
346 pList->sBSSIDList[ii].bWEPOn = TRUE;
348 else {
349 pList->sBSSIDList[ii].bWEPOn = FALSE;
351 ii ++;
352 if (ii >= pList->uItem)
353 break;
357 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
358 result = -EFAULT;
359 break;
361 kfree(pList);
362 pReq->wResult = 0;
363 break;
365 case WLAN_CMD_GET_MIB:
366 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
367 result = -EFAULT;
368 break;
370 break;
372 case WLAN_CMD_GET_STAT:
373 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
374 result = -EFAULT;
375 break;
377 break;
378 case WLAN_CMD_STOP_MAC:
380 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
381 // Todo xxxxxx
382 netif_stop_queue(pDevice->dev);
383 spin_lock_irq(&pDevice->lock);
384 if (pDevice->bRadioOff == FALSE) {
385 CARDbRadioPowerOff(pDevice);
387 pDevice->bLinkPass = FALSE;
388 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
389 memset(pMgmt->abyCurrBSSID, 0, 6);
390 pMgmt->eCurrState = WMAC_STATE_IDLE;
391 // del_timer(&pDevice->sTimerCommand);
392 // del_timer(&pMgmt->sTimerSecondCallback);
393 pDevice->bCmdRunning = FALSE;
394 spin_unlock_irq(&pDevice->lock);
396 break;
398 case WLAN_CMD_START_MAC:
400 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
401 // Todo xxxxxxx
402 if (pDevice->bRadioOff == TRUE)
403 CARDbRadioPowerOn(pDevice);
404 break;
406 case WLAN_CMD_SET_HOSTAPD:
408 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
410 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
411 result = -EFAULT;
412 break;
414 if (sValue.dwValue == 1) {
415 if (hostap_set_hostapd(pDevice, 1, 1) == 0){
416 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
418 else {
419 result = -EFAULT;
420 break;
423 else {
424 hostap_set_hostapd(pDevice, 0, 1);
425 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
428 break;
430 case WLAN_CMD_SET_HOSTAPD_STA:
432 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
434 break;
435 case WLAN_CMD_SET_802_1X:
437 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
438 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
439 result = -EFAULT;
440 break;
443 if (sValue.dwValue == 1) {
444 pDevice->bEnable8021x = TRUE;
445 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
447 else {
448 pDevice->bEnable8021x = FALSE;
449 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
452 break;
455 case WLAN_CMD_SET_HOST_WEP:
457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
458 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
459 result = -EFAULT;
460 break;
463 if (sValue.dwValue == 1) {
464 pDevice->bEnableHostWEP = TRUE;
465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
467 else {
468 pDevice->bEnableHostWEP = FALSE;
469 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
472 break;
474 case WLAN_CMD_SET_WPA:
475 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
477 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
478 result = -EFAULT;
479 break;
481 if (sValue.dwValue == 1) {
482 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
483 memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, U_ETHER_ADDR_LEN);
484 pDevice->bWPADEVUp = TRUE;
486 else {
487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
488 pDevice->bWPADEVUp = FALSE;
491 break;
493 case WLAN_CMD_AP_START:
495 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
496 if (pDevice->bRadioOff == TRUE) {
497 CARDbRadioPowerOn(pDevice);
498 add_timer(&pMgmt->sTimerSecondCallback);
500 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
501 result = -EFAULT;
502 break;
505 if (sStartAPCmd.wBSSType == AP) {
506 pMgmt->eConfigMode = WMAC_CONFIG_AP;
507 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
509 else {
510 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
511 result = -EFAULT;
512 break;
516 if (sStartAPCmd.wBBPType == PHY80211g) {
517 pMgmt->byAPBBType = PHY_TYPE_11G;
519 else if (sStartAPCmd.wBBPType == PHY80211a) {
520 pMgmt->byAPBBType = PHY_TYPE_11A;
522 else {
523 pMgmt->byAPBBType = PHY_TYPE_11B;
526 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
527 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
528 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
530 if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14))
531 pDevice->uChannel = sStartAPCmd.uChannel;
533 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
534 pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
535 else
536 pMgmt->wIBSSBeaconPeriod = 100;
538 if (sStartAPCmd.bShareKeyAuth == TRUE){
539 pMgmt->bShareKeyAlgorithm = TRUE;
540 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
542 else {
543 pMgmt->bShareKeyAlgorithm = FALSE;
544 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
546 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
548 if (sStartAPCmd.byBasicRate & BIT3) {
549 pMgmt->abyIBSSSuppRates[2] |= BIT7;
550 pMgmt->abyIBSSSuppRates[3] |= BIT7;
551 pMgmt->abyIBSSSuppRates[4] |= BIT7;
552 pMgmt->abyIBSSSuppRates[5] |= BIT7;
553 }else if (sStartAPCmd.byBasicRate & BIT2) {
554 pMgmt->abyIBSSSuppRates[2] |= BIT7;
555 pMgmt->abyIBSSSuppRates[3] |= BIT7;
556 pMgmt->abyIBSSSuppRates[4] |= BIT7;
557 }else if (sStartAPCmd.byBasicRate & BIT1) {
558 pMgmt->abyIBSSSuppRates[2] |= BIT7;
559 pMgmt->abyIBSSSuppRates[3] |= BIT7;
560 }else if (sStartAPCmd.byBasicRate & BIT1) {
561 pMgmt->abyIBSSSuppRates[2] |= BIT7;
562 }else {
563 //default 1,2M
564 pMgmt->abyIBSSSuppRates[2] |= BIT7;
565 pMgmt->abyIBSSSuppRates[3] |= BIT7;
568 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
569 pMgmt->abyIBSSSuppRates[2],
570 pMgmt->abyIBSSSuppRates[3],
571 pMgmt->abyIBSSSuppRates[4],
572 pMgmt->abyIBSSSuppRates[5]
575 netif_stop_queue(pDevice->dev);
576 spin_lock_irq(&pDevice->lock);
577 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
578 spin_unlock_irq(&pDevice->lock);
579 break;
581 case WLAN_CMD_GET_NODE_CNT:
583 cbListCount = 0;
584 pNode = &(pMgmt->sNodeDBTable[0]);
585 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
586 pNode = &(pMgmt->sNodeDBTable[ii]);
587 if (!pNode->bActive)
588 continue;
589 cbListCount++;
592 sNodeList.uItem = cbListCount;
593 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
594 result = -EFAULT;
595 break;
597 pReq->wResult = 0;
598 break;
600 case WLAN_CMD_GET_NODE_LIST:
602 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
603 result = -EFAULT;
604 break;
606 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
607 if (pNodeList == NULL) {
608 result = -ENOMEM;
609 break;
611 pNodeList->uItem = sNodeList.uItem;
612 pNode = &(pMgmt->sNodeDBTable[0]);
613 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
614 pNode = &(pMgmt->sNodeDBTable[ii]);
615 if (pNode->bActive) {
616 pNodeList->sNodeList[jj].wAID = pNode->wAID;
617 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
618 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
619 pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;
620 pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;
621 pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;
622 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
623 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
624 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
625 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
626 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
627 pNodeList->sNodeList[jj].abyWepKey[0],
628 pNodeList->sNodeList[jj].abyWepKey[1],
629 pNodeList->sNodeList[jj].abyWepKey[2],
630 pNodeList->sNodeList[jj].abyWepKey[3],
631 pNodeList->sNodeList[jj].abyWepKey[4]
633 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
634 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
635 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
636 pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;
637 jj ++;
638 if (jj >= pNodeList->uItem)
639 break;
642 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
643 result = -EFAULT;
644 break;
646 kfree(pNodeList);
647 pReq->wResult = 0;
648 break;
650 #ifdef WPA_SM_Transtatus
651 case 0xFF:
652 memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
653 wpa_Result.proto = 0;
654 wpa_Result.key_mgmt = 0;
655 wpa_Result.eap_type = 0;
656 wpa_Result.authenticated = FALSE;
657 pDevice->fWPA_Authened = FALSE;
658 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
659 result = -EFAULT;
660 break;
662 //DavidWang for some AP maybe good authenticate
663 if(wpa_Result.key_mgmt==0x20)
664 pMgmt->Cisco_cckm =1;
665 else
666 pMgmt->Cisco_cckm =0;
667 //DavidWang
669 if(wpa_Result.authenticated==TRUE) {
670 #ifdef SndEvt_ToAPI
672 union iwreq_data wrqu;
674 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
676 memset(&wrqu, 0, sizeof(wrqu));
677 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
678 wrqu.data.length =pItemSSID->len;
679 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
681 #endif
682 pDevice->fWPA_Authened = TRUE; //is sucessful peer to wpa_Result.authenticated?
685 //printk("get private wpa_supplicant announce WPA SM\n");
686 //printk("wpa-->ifname=%s\n",wpa_Result.ifname);
687 //printk("wpa-->proto=%d\n",wpa_Result.proto);
688 //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt);
689 //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type);
690 //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE");
692 pReq->wResult = 0;
693 break;
694 #endif
696 default:
697 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
700 return result;