Staging: vt6655: add some range checks before memcpy()
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / vt6655 / ioctl.c
blob432a20993c6ef2ac3eb855a5dfb5eae4011b8400
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 SCmdLinkStatus sLinkStatus;
68 unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
69 unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
70 unsigned long dwKeyIndex = 0;
71 unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
72 long ldBm;
74 pReq->wResult = 0;
76 switch (pReq->wCmdCode) {
77 case WLAN_CMD_BSS_SCAN:
78 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");
79 if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
80 result = -EFAULT;
81 break;
84 pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
85 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
86 return -EINVAL;
87 if (pItemSSID->len != 0) {
88 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
89 memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
92 if (pDevice->bMACSuspend == true) {
93 if (pDevice->bRadioOff == true)
94 CARDbRadioPowerOn(pDevice);
95 vMgrTimerInit(pDevice);
96 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
97 add_timer(&pMgmt->sTimerSecondCallback);
98 pDevice->bMACSuspend = false;
100 spin_lock_irq(&pDevice->lock);
101 if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
102 BSSvClearBSSList((void *)pDevice, false);
103 else
104 BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
106 if (pItemSSID->len != 0)
107 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
108 else
109 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
110 spin_unlock_irq(&pDevice->lock);
111 break;
113 case WLAN_CMD_ZONETYPE_SET:
114 /* mike add :cann't support. */
115 result = -EOPNOTSUPP;
116 break;
118 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
119 result = -EFAULT;
120 break;
123 if (sZoneTypeCmd.bWrite == true) {
124 /* write zonetype */
125 if (sZoneTypeCmd.ZoneType == ZoneType_USA) {
126 /* set to USA */
127 printk("set_ZoneType:USA\n");
128 } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) {
129 /* set to Japan */
130 printk("set_ZoneType:Japan\n");
131 } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) {
132 /* set to Europe */
133 printk("set_ZoneType:Europe\n");
135 } else {
136 /* read zonetype */
137 unsigned char zonetype = 0;
139 if (zonetype == 0x00) { /* USA */
140 sZoneTypeCmd.ZoneType = ZoneType_USA;
141 } else if (zonetype == 0x01) { /* Japan */
142 sZoneTypeCmd.ZoneType = ZoneType_Japan;
143 } else if (zonetype == 0x02) { /* Europe */
144 sZoneTypeCmd.ZoneType = ZoneType_Europe;
145 } else { /* Unknown ZoneType */
146 printk("Error:ZoneType[%x] Unknown ???\n", zonetype);
147 result = -EFAULT;
148 break;
150 if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
151 result = -EFAULT;
152 break;
155 break;
157 case WLAN_CMD_BSS_JOIN:
158 if (pDevice->bMACSuspend == true) {
159 if (pDevice->bRadioOff == true)
160 CARDbRadioPowerOn(pDevice);
161 vMgrTimerInit(pDevice);
162 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
163 add_timer(&pMgmt->sTimerSecondCallback);
164 pDevice->bMACSuspend = false;
167 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
168 result = -EFAULT;
169 break;
172 pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
173 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
174 return -EINVAL;
175 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
176 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
177 if (sJoinCmd.wBSSType == ADHOC) {
178 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
179 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
180 } else {
181 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
182 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
184 if (sJoinCmd.bPSEnable == true) {
185 pDevice->ePSMode = WMAC_POWER_FAST;
186 pMgmt->wListenInterval = 2;
187 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
188 } else {
189 pDevice->ePSMode = WMAC_POWER_CAM;
190 pMgmt->wListenInterval = 1;
191 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n");
194 if (sJoinCmd.bShareKeyAuth == true) {
195 pMgmt->bShareKeyAlgorithm = true;
196 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
197 } else {
198 pMgmt->bShareKeyAlgorithm = false;
199 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
201 pDevice->uChannel = sJoinCmd.uChannel;
202 netif_stop_queue(pDevice->dev);
203 spin_lock_irq(&pDevice->lock);
204 pMgmt->eCurrState = WMAC_STATE_IDLE;
205 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
206 bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
207 spin_unlock_irq(&pDevice->lock);
208 break;
210 case WLAN_CMD_SET_WEP:
211 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n");
212 memset(&sWEPCmd, 0, sizeof(SCmdSetWEP));
213 if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
214 result = -EFAULT;
215 break;
217 if (sWEPCmd.bEnableWep != true) {
218 pDevice->bEncryptionEnable = false;
219 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
220 MACvDisableDefaultKey(pDevice->PortOffset);
221 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n");
222 break;
225 for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) {
226 if (sWEPCmd.bWepKeyAvailable[ii]) {
227 if (ii == sWEPCmd.byKeyIndex)
228 dwKeyIndex = ii | (1 << 31);
229 else
230 dwKeyIndex = ii;
232 KeybSetDefaultKey(&(pDevice->sKey),
233 dwKeyIndex,
234 sWEPCmd.auWepKeyLength[ii],
235 NULL,
236 (unsigned char *)&sWEPCmd.abyWepKey[ii][0],
237 KEY_CTL_WEP,
238 pDevice->PortOffset,
239 pDevice->byLocalID);
242 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
243 pDevice->bTransmitKey = true;
244 pDevice->bEncryptionEnable = true;
245 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
246 break;
248 case WLAN_CMD_GET_LINK:
249 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n");
251 memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
253 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
254 sLinkStatus.wBSSType = ADHOC;
255 else
256 sLinkStatus.wBSSType = INFRA;
258 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
259 sLinkStatus.byState = ADHOC_JOINTED;
260 else
261 sLinkStatus.byState = ADHOC_STARTED;
263 sLinkStatus.uChannel = pMgmt->uCurrChannel;
264 if (pDevice->bLinkPass == true) {
265 sLinkStatus.bLink = true;
266 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
267 memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
268 memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
269 sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
270 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success!\n");
271 } else {
272 sLinkStatus.bLink = false;
273 sLinkStatus.uLinkRate = 0;
275 if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
276 result = -EFAULT;
277 break;
279 break;
281 case WLAN_CMD_GET_LISTLEN:
282 cbListCount = 0;
283 pBSS = &(pMgmt->sBSSList[0]);
284 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
285 pBSS = &(pMgmt->sBSSList[ii]);
286 if (!pBSS->bActive)
287 continue;
288 cbListCount++;
290 sList.uItem = cbListCount;
291 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
292 result = -EFAULT;
293 break;
295 pReq->wResult = 0;
296 break;
298 case WLAN_CMD_GET_LIST:
299 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
300 result = -EFAULT;
301 break;
303 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
304 if (pList == NULL) {
305 result = -ENOMEM;
306 break;
308 pList->uItem = sList.uItem;
309 pBSS = &(pMgmt->sBSSList[0]);
310 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
311 pBSS = &(pMgmt->sBSSList[jj]);
312 if (pBSS->bActive) {
313 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
314 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
315 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
316 /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */
317 RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
318 pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
319 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
320 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
321 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
322 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
323 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
324 pList->sBSSIDList[ii].byNetType = INFRA;
325 } else {
326 pList->sBSSIDList[ii].byNetType = ADHOC;
328 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
329 pList->sBSSIDList[ii].bWEPOn = true;
330 } else {
331 pList->sBSSIDList[ii].bWEPOn = false;
333 ii++;
334 if (ii >= pList->uItem)
335 break;
339 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
340 result = -EFAULT;
341 break;
343 kfree(pList);
344 pReq->wResult = 0;
345 break;
347 case WLAN_CMD_GET_MIB:
348 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
349 result = -EFAULT;
350 break;
352 break;
354 case WLAN_CMD_GET_STAT:
355 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
356 result = -EFAULT;
357 break;
359 break;
361 case WLAN_CMD_STOP_MAC:
362 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
363 netif_stop_queue(pDevice->dev);
365 spin_lock_irq(&pDevice->lock);
366 if (pDevice->bRadioOff == false) {
367 CARDbRadioPowerOff(pDevice);
369 pDevice->bLinkPass = false;
370 memset(pMgmt->abyCurrBSSID, 0, 6);
371 pMgmt->eCurrState = WMAC_STATE_IDLE;
372 del_timer(&pDevice->sTimerCommand);
373 del_timer(&pMgmt->sTimerSecondCallback);
374 pDevice->bCmdRunning = false;
375 pDevice->bMACSuspend = true;
376 MACvIntDisable(pDevice->PortOffset);
377 spin_unlock_irq(&pDevice->lock);
378 break;
380 case WLAN_CMD_START_MAC:
381 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
383 if (pDevice->bMACSuspend == true) {
384 if (pDevice->bRadioOff == true)
385 CARDbRadioPowerOn(pDevice);
386 vMgrTimerInit(pDevice);
387 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
388 add_timer(&pMgmt->sTimerSecondCallback);
389 pDevice->bMACSuspend = false;
391 break;
393 case WLAN_CMD_SET_HOSTAPD:
394 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
396 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
397 result = -EFAULT;
398 break;
400 if (sValue.dwValue == 1) {
401 if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) {
402 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
403 } else {
404 result = -EFAULT;
405 break;
407 } else {
408 vt6655_hostap_set_hostapd(pDevice, 0, 1);
409 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
411 break;
413 case WLAN_CMD_SET_HOSTAPD_STA:
414 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
415 break;
417 case WLAN_CMD_SET_802_1X:
418 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
419 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
420 result = -EFAULT;
421 break;
424 if (sValue.dwValue == 1) {
425 pDevice->bEnable8021x = true;
426 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
427 } else {
428 pDevice->bEnable8021x = false;
429 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
431 break;
433 case WLAN_CMD_SET_HOST_WEP:
434 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
435 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
436 result = -EFAULT;
437 break;
440 if (sValue.dwValue == 1) {
441 pDevice->bEnableHostWEP = true;
442 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
443 } else {
444 pDevice->bEnableHostWEP = false;
445 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
447 break;
449 case WLAN_CMD_SET_WPA:
450 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
452 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
453 result = -EFAULT;
454 break;
456 if (sValue.dwValue == 1) {
457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
458 memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN);
459 pDevice->bWPADEVUp = true;
460 } else {
461 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
462 pDevice->bWPADEVUp = false;
464 break;
466 case WLAN_CMD_AP_START:
467 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
468 if (pDevice->bRadioOff == true) {
469 CARDbRadioPowerOn(pDevice);
470 vMgrTimerInit(pDevice);
471 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
472 add_timer(&pMgmt->sTimerSecondCallback);
474 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
475 result = -EFAULT;
476 break;
479 if (sStartAPCmd.wBSSType == AP) {
480 pMgmt->eConfigMode = WMAC_CONFIG_AP;
481 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
482 } else {
483 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
484 result = -EFAULT;
485 break;
488 if (sStartAPCmd.wBBPType == PHY80211g) {
489 pMgmt->byAPBBType = PHY_TYPE_11G;
490 } else if (sStartAPCmd.wBBPType == PHY80211a) {
491 pMgmt->byAPBBType = PHY_TYPE_11A;
492 } else {
493 pMgmt->byAPBBType = PHY_TYPE_11B;
496 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
497 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
498 return -EINVAL;
499 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
500 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
502 if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))
503 pDevice->uChannel = sStartAPCmd.uChannel;
505 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
506 pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
507 else
508 pMgmt->wIBSSBeaconPeriod = 100;
510 if (sStartAPCmd.bShareKeyAuth == true) {
511 pMgmt->bShareKeyAlgorithm = true;
512 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
513 } else {
514 pMgmt->bShareKeyAlgorithm = false;
515 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
517 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
519 if (sStartAPCmd.byBasicRate & BIT3) {
520 pMgmt->abyIBSSSuppRates[2] |= BIT7;
521 pMgmt->abyIBSSSuppRates[3] |= BIT7;
522 pMgmt->abyIBSSSuppRates[4] |= BIT7;
523 pMgmt->abyIBSSSuppRates[5] |= BIT7;
524 } else if (sStartAPCmd.byBasicRate & BIT2) {
525 pMgmt->abyIBSSSuppRates[2] |= BIT7;
526 pMgmt->abyIBSSSuppRates[3] |= BIT7;
527 pMgmt->abyIBSSSuppRates[4] |= BIT7;
528 } else if (sStartAPCmd.byBasicRate & BIT1) {
529 pMgmt->abyIBSSSuppRates[2] |= BIT7;
530 pMgmt->abyIBSSSuppRates[3] |= BIT7;
531 } else if (sStartAPCmd.byBasicRate & BIT1) {
532 pMgmt->abyIBSSSuppRates[2] |= BIT7;
533 } else {
534 /* default 1,2M */
535 pMgmt->abyIBSSSuppRates[2] |= BIT7;
536 pMgmt->abyIBSSSuppRates[3] |= BIT7;
539 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
540 pMgmt->abyIBSSSuppRates[2],
541 pMgmt->abyIBSSSuppRates[3],
542 pMgmt->abyIBSSSuppRates[4],
543 pMgmt->abyIBSSSuppRates[5]);
545 netif_stop_queue(pDevice->dev);
546 spin_lock_irq(&pDevice->lock);
547 bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
548 spin_unlock_irq(&pDevice->lock);
549 break;
551 case WLAN_CMD_GET_NODE_CNT:
552 cbListCount = 0;
553 pNode = &(pMgmt->sNodeDBTable[0]);
554 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
555 pNode = &(pMgmt->sNodeDBTable[ii]);
556 if (!pNode->bActive)
557 continue;
558 cbListCount++;
561 sNodeList.uItem = cbListCount;
562 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
563 result = -EFAULT;
564 break;
566 pReq->wResult = 0;
567 break;
569 case WLAN_CMD_GET_NODE_LIST:
570 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
571 result = -EFAULT;
572 break;
574 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
575 if (pNodeList == NULL) {
576 result = -ENOMEM;
577 break;
579 pNodeList->uItem = sNodeList.uItem;
580 pNode = &(pMgmt->sNodeDBTable[0]);
581 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
582 pNode = &(pMgmt->sNodeDBTable[ii]);
583 if (pNode->bActive) {
584 pNodeList->sNodeList[jj].wAID = pNode->wAID;
585 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
586 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
587 pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount;
588 pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt;
589 pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags;
590 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
591 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
592 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
593 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
594 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
595 pNodeList->sNodeList[jj].abyWepKey[0],
596 pNodeList->sNodeList[jj].abyWepKey[1],
597 pNodeList->sNodeList[jj].abyWepKey[2],
598 pNodeList->sNodeList[jj].abyWepKey[3],
599 pNodeList->sNodeList[jj].abyWepKey[4]);
600 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
601 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
602 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
603 pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio;
604 jj++;
605 if (jj >= pNodeList->uItem)
606 break;
609 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
610 result = -EFAULT;
611 break;
613 kfree(pNodeList);
614 pReq->wResult = 0;
615 break;
617 #ifdef WPA_SM_Transtatus
618 case 0xFF:
619 memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
620 wpa_Result.proto = 0;
621 wpa_Result.key_mgmt = 0;
622 wpa_Result.eap_type = 0;
623 wpa_Result.authenticated = false;
624 pDevice->fWPA_Authened = false;
625 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
626 result = -EFAULT;
627 break;
630 if (wpa_Result.authenticated == true) {
631 #ifdef SndEvt_ToAPI
633 union iwreq_data wrqu;
635 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
637 memset(&wrqu, 0, sizeof(wrqu));
638 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
639 wrqu.data.length = pItemSSID->len;
640 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
642 #endif
643 pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */
645 pReq->wResult = 0;
646 break;
647 #endif
649 default:
650 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
653 return result;