Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / drivers / staging / vt6656 / ioctl.c
blobcfe9c95d78074a076d80c1560751a1575fd65512
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 SWPAResult wpa_Result;
53 /*--------------------- Static Functions --------------------------*/
55 /*--------------------- Export Variables --------------------------*/
57 int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
59 PSCmdRequest pReq = (PSCmdRequest)rq;
60 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
61 int result = 0;
62 PWLAN_IE_SSID pItemSSID;
63 SCmdBSSJoin sJoinCmd;
64 SCmdZoneTypeSet sZoneTypeCmd;
65 SCmdScan sScanCmd;
66 SCmdStartAP sStartAPCmd;
67 SCmdSetWEP sWEPCmd;
68 SCmdValue sValue;
69 SBSSIDList sList;
70 SNodeList sNodeList;
71 PSBSSIDList pList;
72 PSNodeList pNodeList;
73 unsigned int cbListCount;
74 PKnownBSS pBSS;
75 PKnownNodeDB pNode;
76 unsigned int ii, jj;
77 SCmdLinkStatus sLinkStatus;
78 BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
79 BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
80 DWORD dwKeyIndex= 0;
81 BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
82 signed long ldBm;
84 pReq->wResult = 0;
86 switch(pReq->wCmdCode) {
88 case WLAN_CMD_BSS_SCAN:
90 if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
91 result = -EFAULT;
92 break;
95 pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
96 if (pItemSSID->len != 0) {
97 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
98 memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
100 spin_lock_irq(&pDevice->lock);
102 if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
103 BSSvClearBSSList((void *) pDevice, FALSE);
104 else
105 BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass);
107 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");
109 if (pItemSSID->len != 0)
110 bScheduleCommand((void *) pDevice,
111 WLAN_CMD_BSSID_SCAN,
112 abyScanSSID);
113 else
114 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
116 spin_unlock_irq(&pDevice->lock);
117 break;
119 case WLAN_CMD_ZONETYPE_SET:
120 //mike add :cann't support.
121 result=-EOPNOTSUPP;
122 break;
124 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
125 result = -EFAULT;
126 break;
129 if(sZoneTypeCmd.bWrite==TRUE) {
130 //////write zonetype
131 if(sZoneTypeCmd.ZoneType == ZoneType_USA) {
132 //set to USA
133 printk("set_ZoneType:USA\n");
135 else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) {
136 //set to Japan
137 printk("set_ZoneType:Japan\n");
139 else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) {
140 //set to Europe
141 printk("set_ZoneType:Europe\n");
144 else {
145 ///////read zonetype
146 BYTE zonetype=0;
149 if(zonetype == 0x00) { //USA
150 sZoneTypeCmd.ZoneType = ZoneType_USA;
152 else if(zonetype == 0x01) { //Japan
153 sZoneTypeCmd.ZoneType = ZoneType_Japan;
155 else if(zonetype == 0x02) { //Europe
156 sZoneTypeCmd.ZoneType = ZoneType_Europe;
158 else { //Unknown ZoneType
159 printk("Error:ZoneType[%x] Unknown ???\n",zonetype);
160 result = -EFAULT;
161 break;
163 if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
164 result = -EFAULT;
165 break;
169 break;
171 case WLAN_CMD_BSS_JOIN:
173 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
174 result = -EFAULT;
175 break;
178 pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
179 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
180 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
181 if (sJoinCmd.wBSSType == ADHOC) {
182 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
183 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
185 else {
186 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
187 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
189 if (sJoinCmd.bPSEnable == TRUE) {
190 pDevice->ePSMode = WMAC_POWER_FAST;
191 // pDevice->ePSMode = WMAC_POWER_MAX;
192 pMgmt->wListenInterval = 2;
193 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
195 else {
196 pDevice->ePSMode = WMAC_POWER_CAM;
197 pMgmt->wListenInterval = 1;
198 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n");
201 if (sJoinCmd.bShareKeyAuth == TRUE){
202 pMgmt->bShareKeyAlgorithm = TRUE;
203 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
205 else {
206 pMgmt->bShareKeyAlgorithm = FALSE;
207 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
209 pDevice->uChannel = sJoinCmd.uChannel;
210 netif_stop_queue(pDevice->dev);
211 spin_lock_irq(&pDevice->lock);
212 pMgmt->eCurrState = WMAC_STATE_IDLE;
213 bScheduleCommand((void *) pDevice,
214 WLAN_CMD_BSSID_SCAN,
215 pMgmt->abyDesireSSID);
216 bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
217 spin_unlock_irq(&pDevice->lock);
218 break;
220 case WLAN_CMD_SET_WEP:
221 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n");
222 memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP));
223 if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
224 result = -EFAULT;
225 break;
227 if (sWEPCmd.bEnableWep != TRUE) {
228 int uu;
230 pDevice->bEncryptionEnable = FALSE;
231 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
232 spin_lock_irq(&pDevice->lock);
233 for (uu = 0; uu < MAX_KEY_TABLE; uu++)
234 MACvDisableKeyEntry(pDevice, uu);
235 spin_unlock_irq(&pDevice->lock);
236 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n");
237 break;
240 for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) {
241 if (sWEPCmd.bWepKeyAvailable[ii]) {
242 if (ii == sWEPCmd.byKeyIndex)
243 //2006-1207-01<Modify>by Einsn Liu
244 // dwKeyIndex|= (1 << 31);
245 dwKeyIndex=ii|(1 << 31);
246 else
247 dwKeyIndex = ii;
248 spin_lock_irq(&pDevice->lock);
249 KeybSetDefaultKey( pDevice,
250 &(pDevice->sKey),
251 dwKeyIndex,
252 sWEPCmd.auWepKeyLength[ii],
253 NULL,
254 (PBYTE)&sWEPCmd.abyWepKey[ii][0],
255 KEY_CTL_WEP
257 spin_unlock_irq(&pDevice->lock);
261 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
262 pDevice->bTransmitKey = TRUE;
263 pDevice->bEncryptionEnable = TRUE;
264 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
266 break;
268 case WLAN_CMD_GET_LINK:
269 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n");
271 memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
273 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
274 sLinkStatus.wBSSType = ADHOC;
275 else
276 sLinkStatus.wBSSType = INFRA;
278 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
279 sLinkStatus.byState = ADHOC_JOINTED;
280 else
281 sLinkStatus.byState = ADHOC_STARTED;
283 sLinkStatus.uChannel = pMgmt->uCurrChannel;
284 if (pDevice->bLinkPass == TRUE) {
285 sLinkStatus.bLink = TRUE;
286 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
287 memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
288 memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
289 sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
290 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n");
292 else {
293 sLinkStatus.bLink = FALSE;
295 if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
296 result = -EFAULT;
297 break;
300 break;
302 case WLAN_CMD_GET_LISTLEN:
303 cbListCount = 0;
304 pBSS = &(pMgmt->sBSSList[0]);
305 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
306 pBSS = &(pMgmt->sBSSList[ii]);
307 if (!pBSS->bActive)
308 continue;
309 cbListCount++;
311 sList.uItem = cbListCount;
312 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
313 result = -EFAULT;
314 break;
316 pReq->wResult = 0;
317 break;
319 case WLAN_CMD_GET_LIST:
320 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
321 result = -EFAULT;
322 break;
324 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
325 if (pList == NULL) {
326 result = -ENOMEM;
327 break;
329 pList->uItem = sList.uItem;
330 pBSS = &(pMgmt->sBSSList[0]);
331 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
332 pBSS = &(pMgmt->sBSSList[jj]);
333 if (pBSS->bActive) {
334 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
335 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
336 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
337 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
338 pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm;
339 // pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI;
340 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
341 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
342 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
343 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
344 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
345 pList->sBSSIDList[ii].byNetType = INFRA;
347 else {
348 pList->sBSSIDList[ii].byNetType = ADHOC;
350 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
351 pList->sBSSIDList[ii].bWEPOn = TRUE;
353 else {
354 pList->sBSSIDList[ii].bWEPOn = FALSE;
356 ii ++;
357 if (ii >= pList->uItem)
358 break;
362 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
363 result = -EFAULT;
364 break;
366 kfree(pList);
367 pReq->wResult = 0;
368 break;
370 case WLAN_CMD_GET_MIB:
371 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
372 result = -EFAULT;
373 break;
375 break;
377 case WLAN_CMD_GET_STAT:
378 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
379 result = -EFAULT;
380 break;
382 break;
383 case WLAN_CMD_STOP_MAC:
385 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
386 // Todo xxxxxx
387 netif_stop_queue(pDevice->dev);
388 spin_lock_irq(&pDevice->lock);
389 if (pDevice->bRadioOff == FALSE) {
390 CARDbRadioPowerOff(pDevice);
392 pDevice->bLinkPass = FALSE;
393 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
394 memset(pMgmt->abyCurrBSSID, 0, 6);
395 pMgmt->eCurrState = WMAC_STATE_IDLE;
396 // del_timer(&pDevice->sTimerCommand);
397 // del_timer(&pMgmt->sTimerSecondCallback);
398 pDevice->bCmdRunning = FALSE;
399 spin_unlock_irq(&pDevice->lock);
401 break;
403 case WLAN_CMD_START_MAC:
405 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
406 // Todo xxxxxxx
407 if (pDevice->bRadioOff == TRUE)
408 CARDbRadioPowerOn(pDevice);
409 break;
411 case WLAN_CMD_SET_HOSTAPD:
413 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
415 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
416 result = -EFAULT;
417 break;
419 if (sValue.dwValue == 1) {
420 if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0){
421 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
423 else {
424 result = -EFAULT;
425 break;
428 else {
429 vt6656_hostap_set_hostapd(pDevice, 0, 1);
430 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
433 break;
435 case WLAN_CMD_SET_HOSTAPD_STA:
437 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
439 break;
440 case WLAN_CMD_SET_802_1X:
442 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
443 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
444 result = -EFAULT;
445 break;
448 if (sValue.dwValue == 1) {
449 pDevice->bEnable8021x = TRUE;
450 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
452 else {
453 pDevice->bEnable8021x = FALSE;
454 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
457 break;
460 case WLAN_CMD_SET_HOST_WEP:
462 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
463 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
464 result = -EFAULT;
465 break;
468 if (sValue.dwValue == 1) {
469 pDevice->bEnableHostWEP = TRUE;
470 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
472 else {
473 pDevice->bEnableHostWEP = FALSE;
474 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
477 break;
479 case WLAN_CMD_SET_WPA:
480 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
482 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
483 result = -EFAULT;
484 break;
486 if (sValue.dwValue == 1) {
487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
488 memcpy(pDevice->wpadev->dev_addr,
489 pDevice->dev->dev_addr,
490 ETH_ALEN);
491 pDevice->bWPADEVUp = TRUE;
493 else {
494 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
495 pDevice->bWPADEVUp = FALSE;
498 break;
500 case WLAN_CMD_AP_START:
502 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
503 if (pDevice->bRadioOff == TRUE) {
504 CARDbRadioPowerOn(pDevice);
505 add_timer(&pMgmt->sTimerSecondCallback);
507 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
508 result = -EFAULT;
509 break;
512 if (sStartAPCmd.wBSSType == AP) {
513 pMgmt->eConfigMode = WMAC_CONFIG_AP;
514 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
516 else {
517 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
518 result = -EFAULT;
519 break;
523 if (sStartAPCmd.wBBPType == PHY80211g) {
524 pMgmt->byAPBBType = PHY_TYPE_11G;
526 else if (sStartAPCmd.wBBPType == PHY80211a) {
527 pMgmt->byAPBBType = PHY_TYPE_11A;
529 else {
530 pMgmt->byAPBBType = PHY_TYPE_11B;
533 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
534 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
535 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
537 if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14))
538 pDevice->uChannel = sStartAPCmd.uChannel;
540 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
541 pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
542 else
543 pMgmt->wIBSSBeaconPeriod = 100;
545 if (sStartAPCmd.bShareKeyAuth == TRUE){
546 pMgmt->bShareKeyAlgorithm = TRUE;
547 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
549 else {
550 pMgmt->bShareKeyAlgorithm = FALSE;
551 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
553 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
555 if (sStartAPCmd.byBasicRate & BIT3) {
556 pMgmt->abyIBSSSuppRates[2] |= BIT7;
557 pMgmt->abyIBSSSuppRates[3] |= BIT7;
558 pMgmt->abyIBSSSuppRates[4] |= BIT7;
559 pMgmt->abyIBSSSuppRates[5] |= BIT7;
560 }else if (sStartAPCmd.byBasicRate & BIT2) {
561 pMgmt->abyIBSSSuppRates[2] |= BIT7;
562 pMgmt->abyIBSSSuppRates[3] |= BIT7;
563 pMgmt->abyIBSSSuppRates[4] |= BIT7;
564 }else if (sStartAPCmd.byBasicRate & BIT1) {
565 pMgmt->abyIBSSSuppRates[2] |= BIT7;
566 pMgmt->abyIBSSSuppRates[3] |= BIT7;
567 }else if (sStartAPCmd.byBasicRate & BIT1) {
568 pMgmt->abyIBSSSuppRates[2] |= BIT7;
569 }else {
570 //default 1,2M
571 pMgmt->abyIBSSSuppRates[2] |= BIT7;
572 pMgmt->abyIBSSSuppRates[3] |= BIT7;
575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
576 pMgmt->abyIBSSSuppRates[2],
577 pMgmt->abyIBSSSuppRates[3],
578 pMgmt->abyIBSSSuppRates[4],
579 pMgmt->abyIBSSSuppRates[5]
582 netif_stop_queue(pDevice->dev);
583 spin_lock_irq(&pDevice->lock);
584 bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
585 spin_unlock_irq(&pDevice->lock);
586 break;
588 case WLAN_CMD_GET_NODE_CNT:
590 cbListCount = 0;
591 pNode = &(pMgmt->sNodeDBTable[0]);
592 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
593 pNode = &(pMgmt->sNodeDBTable[ii]);
594 if (!pNode->bActive)
595 continue;
596 cbListCount++;
599 sNodeList.uItem = cbListCount;
600 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
601 result = -EFAULT;
602 break;
604 pReq->wResult = 0;
605 break;
607 case WLAN_CMD_GET_NODE_LIST:
609 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
610 result = -EFAULT;
611 break;
613 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
614 if (pNodeList == NULL) {
615 result = -ENOMEM;
616 break;
618 pNodeList->uItem = sNodeList.uItem;
619 pNode = &(pMgmt->sNodeDBTable[0]);
620 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
621 pNode = &(pMgmt->sNodeDBTable[ii]);
622 if (pNode->bActive) {
623 pNodeList->sNodeList[jj].wAID = pNode->wAID;
624 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
625 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
626 pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;
627 pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;
628 pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;
629 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
630 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
631 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
632 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
633 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
634 pNodeList->sNodeList[jj].abyWepKey[0],
635 pNodeList->sNodeList[jj].abyWepKey[1],
636 pNodeList->sNodeList[jj].abyWepKey[2],
637 pNodeList->sNodeList[jj].abyWepKey[3],
638 pNodeList->sNodeList[jj].abyWepKey[4]
640 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
641 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
642 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
643 pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;
644 jj ++;
645 if (jj >= pNodeList->uItem)
646 break;
649 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
650 result = -EFAULT;
651 break;
653 kfree(pNodeList);
654 pReq->wResult = 0;
655 break;
657 case 0xFF:
658 memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
659 wpa_Result.proto = 0;
660 wpa_Result.key_mgmt = 0;
661 wpa_Result.eap_type = 0;
662 wpa_Result.authenticated = FALSE;
663 pDevice->fWPA_Authened = FALSE;
664 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
665 result = -EFAULT;
666 break;
668 //DavidWang for some AP maybe good authenticate
669 if(wpa_Result.key_mgmt==0x20)
670 pMgmt->Cisco_cckm =1;
671 else
672 pMgmt->Cisco_cckm =0;
675 if(wpa_Result.authenticated==TRUE) {
677 union iwreq_data wrqu;
679 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
681 memset(&wrqu, 0, sizeof(wrqu));
682 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
683 wrqu.data.length =pItemSSID->len;
684 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
686 pDevice->fWPA_Authened = TRUE; //is successful peer to wpa_Result.authenticated?
689 //printk("get private wpa_supplicant announce WPA SM\n");
690 //printk("wpa-->ifname=%s\n",wpa_Result.ifname);
691 //printk("wpa-->proto=%d\n",wpa_Result.proto);
692 //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt);
693 //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type);
694 //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==TRUE)?"TRUE":"FALSE");
696 pReq->wResult = 0;
697 break;
699 default:
700 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
703 return result;