wl1251: only call ieee80211_beacon_loss in managed mode
[linux-2.6/btrfs-unstable.git] / drivers / staging / vt6655 / ioctl.c
blobb5cd2e44e53dac9079c9964bdbe97cc10fb2c907
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 "rf.h"
41 static int msglevel = MSG_LEVEL_INFO;
43 #ifdef WPA_SM_Transtatus
44 SWPAResult wpa_Result;
45 #endif
47 int private_ioctl(PSDevice pDevice, struct ifreq *rq)
49 PSCmdRequest pReq = (PSCmdRequest)rq;
50 PSMgmtObject pMgmt = pDevice->pMgmt;
51 int result = 0;
52 PWLAN_IE_SSID pItemSSID;
53 SCmdBSSJoin sJoinCmd;
54 SCmdZoneTypeSet sZoneTypeCmd;
55 SCmdScan sScanCmd;
56 SCmdStartAP sStartAPCmd;
57 SCmdSetWEP sWEPCmd;
58 SCmdValue sValue;
59 SBSSIDList sList;
60 SNodeList sNodeList;
61 PSBSSIDList pList;
62 PSNodeList pNodeList;
63 unsigned int cbListCount;
64 PKnownBSS pBSS;
65 PKnownNodeDB pNode;
66 unsigned int ii, jj;
67 unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
68 unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
69 unsigned long dwKeyIndex = 0;
70 unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
71 long ldBm;
73 pReq->wResult = 0;
75 switch (pReq->wCmdCode) {
76 case WLAN_CMD_BSS_SCAN:
77 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");
78 if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
79 result = -EFAULT;
80 break;
83 pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
84 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
85 return -EINVAL;
86 if (pItemSSID->len != 0) {
87 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
88 memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
91 if (pDevice->bMACSuspend == true) {
92 if (pDevice->bRadioOff == true)
93 CARDbRadioPowerOn(pDevice);
94 vMgrTimerInit(pDevice);
95 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
96 add_timer(&pMgmt->sTimerSecondCallback);
97 pDevice->bMACSuspend = false;
99 spin_lock_irq(&pDevice->lock);
100 if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
101 BSSvClearBSSList((void *)pDevice, false);
102 else
103 BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
105 if (pItemSSID->len != 0)
106 bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
107 else
108 bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
109 spin_unlock_irq(&pDevice->lock);
110 break;
112 case WLAN_CMD_ZONETYPE_SET:
113 /* mike add :can't support. */
114 result = -EOPNOTSUPP;
115 break;
117 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
118 result = -EFAULT;
119 break;
122 if (sZoneTypeCmd.bWrite == true) {
123 /* write zonetype */
124 if (sZoneTypeCmd.ZoneType == ZoneType_USA) {
125 /* set to USA */
126 printk("set_ZoneType:USA\n");
127 } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) {
128 /* set to Japan */
129 printk("set_ZoneType:Japan\n");
130 } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) {
131 /* set to Europe */
132 printk("set_ZoneType:Europe\n");
134 } else {
135 /* read zonetype */
136 unsigned char zonetype = 0;
138 if (zonetype == 0x00) { /* USA */
139 sZoneTypeCmd.ZoneType = ZoneType_USA;
140 } else if (zonetype == 0x01) { /* Japan */
141 sZoneTypeCmd.ZoneType = ZoneType_Japan;
142 } else if (zonetype == 0x02) { /* Europe */
143 sZoneTypeCmd.ZoneType = ZoneType_Europe;
144 } else { /* Unknown ZoneType */
145 printk("Error:ZoneType[%x] Unknown ???\n", zonetype);
146 result = -EFAULT;
147 break;
149 if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
150 result = -EFAULT;
151 break;
154 break;
156 case WLAN_CMD_BSS_JOIN:
157 if (pDevice->bMACSuspend == true) {
158 if (pDevice->bRadioOff == true)
159 CARDbRadioPowerOn(pDevice);
160 vMgrTimerInit(pDevice);
161 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
162 add_timer(&pMgmt->sTimerSecondCallback);
163 pDevice->bMACSuspend = false;
166 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
167 result = -EFAULT;
168 break;
171 pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
172 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
173 return -EINVAL;
174 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
175 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
176 if (sJoinCmd.wBSSType == ADHOC) {
177 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
178 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
179 } else {
180 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
181 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
183 if (sJoinCmd.bPSEnable == true) {
184 pDevice->ePSMode = WMAC_POWER_FAST;
185 pMgmt->wListenInterval = 2;
186 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
187 } else {
188 pDevice->ePSMode = WMAC_POWER_CAM;
189 pMgmt->wListenInterval = 1;
190 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n");
193 if (sJoinCmd.bShareKeyAuth == true) {
194 pMgmt->bShareKeyAlgorithm = true;
195 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
196 } else {
197 pMgmt->bShareKeyAlgorithm = false;
198 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
200 pDevice->uChannel = sJoinCmd.uChannel;
201 netif_stop_queue(pDevice->dev);
202 spin_lock_irq(&pDevice->lock);
203 pMgmt->eCurrState = WMAC_STATE_IDLE;
204 bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
205 bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
206 spin_unlock_irq(&pDevice->lock);
207 break;
209 case WLAN_CMD_SET_WEP:
210 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n");
211 memset(&sWEPCmd, 0, sizeof(SCmdSetWEP));
212 if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
213 result = -EFAULT;
214 break;
216 if (sWEPCmd.bEnableWep != true) {
217 pDevice->bEncryptionEnable = false;
218 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
219 MACvDisableDefaultKey(pDevice->PortOffset);
220 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n");
221 break;
224 for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) {
225 if (sWEPCmd.bWepKeyAvailable[ii]) {
226 if (ii == sWEPCmd.byKeyIndex)
227 dwKeyIndex = ii | (1 << 31);
228 else
229 dwKeyIndex = ii;
231 KeybSetDefaultKey(&(pDevice->sKey),
232 dwKeyIndex,
233 sWEPCmd.auWepKeyLength[ii],
234 NULL,
235 (unsigned char *)&sWEPCmd.abyWepKey[ii][0],
236 KEY_CTL_WEP,
237 pDevice->PortOffset,
238 pDevice->byLocalID);
241 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
242 pDevice->bTransmitKey = true;
243 pDevice->bEncryptionEnable = true;
244 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
245 break;
247 case WLAN_CMD_GET_LINK: {
248 SCmdLinkStatus sLinkStatus;
250 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n");
252 memset(&sLinkStatus, 0, sizeof(sLinkStatus));
254 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
255 sLinkStatus.wBSSType = ADHOC;
256 else
257 sLinkStatus.wBSSType = INFRA;
259 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
260 sLinkStatus.byState = ADHOC_JOINTED;
261 else
262 sLinkStatus.byState = ADHOC_STARTED;
264 sLinkStatus.uChannel = pMgmt->uCurrChannel;
265 if (pDevice->bLinkPass == true) {
266 sLinkStatus.bLink = true;
267 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
268 memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
269 memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
270 sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
271 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Link Success!\n");
272 } else {
273 sLinkStatus.bLink = false;
274 sLinkStatus.uLinkRate = 0;
276 if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
277 result = -EFAULT;
278 break;
280 break;
282 case WLAN_CMD_GET_LISTLEN:
283 cbListCount = 0;
284 pBSS = &(pMgmt->sBSSList[0]);
285 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
286 pBSS = &(pMgmt->sBSSList[ii]);
287 if (!pBSS->bActive)
288 continue;
289 cbListCount++;
291 sList.uItem = cbListCount;
292 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
293 result = -EFAULT;
294 break;
296 pReq->wResult = 0;
297 break;
299 case WLAN_CMD_GET_LIST:
300 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
301 result = -EFAULT;
302 break;
304 if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) {
305 result = -EINVAL;
306 break;
308 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
309 if (pList == NULL) {
310 result = -ENOMEM;
311 break;
313 pList->uItem = sList.uItem;
314 pBSS = &(pMgmt->sBSSList[0]);
315 for (ii = 0, jj = 0; jj < MAX_BSS_NUM; jj++) {
316 pBSS = &(pMgmt->sBSSList[jj]);
317 if (pBSS->bActive) {
318 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
319 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
320 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
321 /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */
322 RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
323 pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
324 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
325 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
326 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
327 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
328 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo))
329 pList->sBSSIDList[ii].byNetType = INFRA;
330 else
331 pList->sBSSIDList[ii].byNetType = ADHOC;
333 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo))
334 pList->sBSSIDList[ii].bWEPOn = true;
335 else
336 pList->sBSSIDList[ii].bWEPOn = false;
338 ii++;
339 if (ii >= pList->uItem)
340 break;
344 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
345 result = -EFAULT;
346 break;
348 kfree(pList);
349 pReq->wResult = 0;
350 break;
352 case WLAN_CMD_GET_MIB:
353 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
354 result = -EFAULT;
355 break;
357 break;
359 case WLAN_CMD_GET_STAT:
360 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
361 result = -EFAULT;
362 break;
364 break;
366 case WLAN_CMD_STOP_MAC:
367 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
368 netif_stop_queue(pDevice->dev);
370 spin_lock_irq(&pDevice->lock);
371 if (pDevice->bRadioOff == false)
372 CARDbRadioPowerOff(pDevice);
374 pDevice->bLinkPass = false;
375 memset(pMgmt->abyCurrBSSID, 0, 6);
376 pMgmt->eCurrState = WMAC_STATE_IDLE;
377 del_timer(&pDevice->sTimerCommand);
378 del_timer(&pMgmt->sTimerSecondCallback);
379 pDevice->bCmdRunning = false;
380 pDevice->bMACSuspend = true;
381 MACvIntDisable(pDevice->PortOffset);
382 spin_unlock_irq(&pDevice->lock);
383 break;
385 case WLAN_CMD_START_MAC:
386 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
388 if (pDevice->bMACSuspend == true) {
389 if (pDevice->bRadioOff == true)
390 CARDbRadioPowerOn(pDevice);
391 vMgrTimerInit(pDevice);
392 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
393 add_timer(&pMgmt->sTimerSecondCallback);
394 pDevice->bMACSuspend = false;
396 break;
398 case WLAN_CMD_SET_HOSTAPD:
399 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
401 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
402 result = -EFAULT;
403 break;
405 if (sValue.dwValue == 1) {
406 if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) {
407 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
408 } else {
409 result = -EFAULT;
410 break;
412 } else {
413 vt6655_hostap_set_hostapd(pDevice, 0, 1);
414 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
416 break;
418 case WLAN_CMD_SET_HOSTAPD_STA:
419 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
420 break;
422 case WLAN_CMD_SET_802_1X:
423 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
424 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
425 result = -EFAULT;
426 break;
429 if (sValue.dwValue == 1) {
430 pDevice->bEnable8021x = true;
431 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
432 } else {
433 pDevice->bEnable8021x = false;
434 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
436 break;
438 case WLAN_CMD_SET_HOST_WEP:
439 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
440 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
441 result = -EFAULT;
442 break;
445 if (sValue.dwValue == 1) {
446 pDevice->bEnableHostWEP = true;
447 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
448 } else {
449 pDevice->bEnableHostWEP = false;
450 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
452 break;
454 case WLAN_CMD_SET_WPA:
455 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
457 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
458 result = -EFAULT;
459 break;
461 if (sValue.dwValue == 1) {
462 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
463 eth_hw_addr_inherit(pDevice->wpadev, pDevice->dev);
464 pDevice->bWPADEVUp = true;
465 } else {
466 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
467 pDevice->bWPADEVUp = false;
469 break;
471 case WLAN_CMD_AP_START:
472 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
473 if (pDevice->bRadioOff == true) {
474 CARDbRadioPowerOn(pDevice);
475 vMgrTimerInit(pDevice);
476 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
477 add_timer(&pMgmt->sTimerSecondCallback);
479 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
480 result = -EFAULT;
481 break;
484 if (sStartAPCmd.wBSSType == AP) {
485 pMgmt->eConfigMode = WMAC_CONFIG_AP;
486 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
487 } else {
488 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
489 result = -EFAULT;
490 break;
493 if (sStartAPCmd.wBBPType == PHY80211g)
494 pMgmt->byAPBBType = PHY_TYPE_11G;
495 else if (sStartAPCmd.wBBPType == PHY80211a)
496 pMgmt->byAPBBType = PHY_TYPE_11A;
497 else
498 pMgmt->byAPBBType = PHY_TYPE_11B;
500 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
501 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
502 return -EINVAL;
503 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
504 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
506 if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))
507 pDevice->uChannel = sStartAPCmd.uChannel;
509 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
510 pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
511 else
512 pMgmt->wIBSSBeaconPeriod = 100;
514 if (sStartAPCmd.bShareKeyAuth == true) {
515 pMgmt->bShareKeyAlgorithm = true;
516 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
517 } else {
518 pMgmt->bShareKeyAlgorithm = false;
519 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
521 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
523 if (sStartAPCmd.byBasicRate & BIT3) {
524 pMgmt->abyIBSSSuppRates[2] |= BIT7;
525 pMgmt->abyIBSSSuppRates[3] |= BIT7;
526 pMgmt->abyIBSSSuppRates[4] |= BIT7;
527 pMgmt->abyIBSSSuppRates[5] |= BIT7;
528 } else if (sStartAPCmd.byBasicRate & BIT2) {
529 pMgmt->abyIBSSSuppRates[2] |= BIT7;
530 pMgmt->abyIBSSSuppRates[3] |= BIT7;
531 pMgmt->abyIBSSSuppRates[4] |= BIT7;
532 } else if (sStartAPCmd.byBasicRate & BIT1) {
533 pMgmt->abyIBSSSuppRates[2] |= BIT7;
534 pMgmt->abyIBSSSuppRates[3] |= BIT7;
535 } else if (sStartAPCmd.byBasicRate & BIT1) {
536 pMgmt->abyIBSSSuppRates[2] |= BIT7;
537 } else {
538 /* default 1,2M */
539 pMgmt->abyIBSSSuppRates[2] |= BIT7;
540 pMgmt->abyIBSSSuppRates[3] |= BIT7;
543 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %*ph\n",
544 4, pMgmt->abyIBSSSuppRates + 2);
546 netif_stop_queue(pDevice->dev);
547 spin_lock_irq(&pDevice->lock);
548 bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
549 spin_unlock_irq(&pDevice->lock);
550 break;
552 case WLAN_CMD_GET_NODE_CNT:
553 cbListCount = 0;
554 pNode = &(pMgmt->sNodeDBTable[0]);
555 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
556 pNode = &(pMgmt->sNodeDBTable[ii]);
557 if (!pNode->bActive)
558 continue;
559 cbListCount++;
562 sNodeList.uItem = cbListCount;
563 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
564 result = -EFAULT;
565 break;
567 pReq->wResult = 0;
568 break;
570 case WLAN_CMD_GET_NODE_LIST:
571 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
572 result = -EFAULT;
573 break;
575 if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) {
576 result = -EINVAL;
577 break;
579 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
580 if (pNodeList == NULL) {
581 result = -ENOMEM;
582 break;
584 pNodeList->uItem = sNodeList.uItem;
585 pNode = &(pMgmt->sNodeDBTable[0]);
586 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
587 pNode = &(pMgmt->sNodeDBTable[ii]);
588 if (pNode->bActive) {
589 pNodeList->sNodeList[jj].wAID = pNode->wAID;
590 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
591 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
592 pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount;
593 pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt;
594 pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags;
595 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
596 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
597 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
598 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
599 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
600 pNodeList->sNodeList[jj].abyWepKey[0],
601 pNodeList->sNodeList[jj].abyWepKey[1],
602 pNodeList->sNodeList[jj].abyWepKey[2],
603 pNodeList->sNodeList[jj].abyWepKey[3],
604 pNodeList->sNodeList[jj].abyWepKey[4]);
605 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
606 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
607 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
608 pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio;
609 jj++;
610 if (jj >= pNodeList->uItem)
611 break;
614 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
615 result = -EFAULT;
616 break;
618 kfree(pNodeList);
619 pReq->wResult = 0;
620 break;
622 #ifdef WPA_SM_Transtatus
623 case 0xFF:
624 memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
625 wpa_Result.proto = 0;
626 wpa_Result.key_mgmt = 0;
627 wpa_Result.eap_type = 0;
628 wpa_Result.authenticated = false;
629 pDevice->fWPA_Authened = false;
630 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
631 result = -EFAULT;
632 break;
635 if (wpa_Result.authenticated == true) {
636 #ifdef SndEvt_ToAPI
638 union iwreq_data wrqu;
640 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
642 memset(&wrqu, 0, sizeof(wrqu));
643 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
644 wrqu.data.length = pItemSSID->len;
645 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
647 #endif
648 pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */
650 pReq->wResult = 0;
651 break;
652 #endif
654 default:
655 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
658 return result;