Staging: vt6656: whitespace cleanups in ioctl.c
[pandora-kernel.git] / drivers / staging / vt6656 / ioctl.c
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
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.
9  *
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.
14  *
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.
18  *
19  * File: ioctl.c
20  *
21  * Purpose:  private ioctl functions
22  *
23  * Author: Lyndon Chen
24  *
25  * Date: Auguest 20, 2003
26  *
27  * Functions:
28  *
29  * Revision History:
30  *
31  */
32
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"
42
43 SWPAResult wpa_Result;
44 static int msglevel = MSG_LEVEL_INFO;
45
46 int private_ioctl(PSDevice pDevice, struct ifreq *rq)
47 {
48
49         PSCmdRequest    pReq = (PSCmdRequest)rq;
50         PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
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         BYTE            abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
69         BYTE            abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
70         DWORD           dwKeyIndex = 0;
71         BYTE            abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
72         signed long     ldBm;
73
74         pReq->wResult = 0;
75
76         switch (pReq->wCmdCode) {
77         case WLAN_CMD_BSS_SCAN:
78                 if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
79                         result = -EFAULT;
80                         break;
81                 }
82
83                 pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
84                 if (pItemSSID->len != 0) {
85                         memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
86                         memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
87                 }
88                 spin_lock_irq(&pDevice->lock);
89
90                 if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
91                         BSSvClearBSSList((void *)pDevice, FALSE);
92                 else
93                         BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
94
95                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");
96
97                 if (pItemSSID->len != 0)
98                         bScheduleCommand((void *)pDevice,
99                                          WLAN_CMD_BSSID_SCAN,
100                                          abyScanSSID);
101                 else
102                         bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
103
104                 spin_unlock_irq(&pDevice->lock);
105                 break;
106
107         case WLAN_CMD_ZONETYPE_SET:
108                 result = -EOPNOTSUPP;
109                 break;
110
111                 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
112                         result = -EFAULT;
113                         break;
114                 }
115
116                 if (sZoneTypeCmd.bWrite == TRUE) {
117                         /* write zonetype */
118                         if (sZoneTypeCmd.ZoneType == ZoneType_USA) {
119                                 /* set to USA */
120                                 printk("set_ZoneType:USA\n");
121                         } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) {
122                                 /* set to Japan */
123                                 printk("set_ZoneType:Japan\n");
124                         } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) {
125                                 /* set to Europe */
126                                 printk("set_ZoneType:Europe\n");
127                         }
128                 } else {
129                         /* read zonetype */
130                         BYTE zonetype = 0;
131
132                         if (zonetype == 0x00) {        /* USA */
133                                 sZoneTypeCmd.ZoneType = ZoneType_USA;
134                         } else if (zonetype == 0x01) { /* Japan */
135                                 sZoneTypeCmd.ZoneType = ZoneType_Japan;
136                         } else if (zonetype == 0x02) { /* Europe */
137                                 sZoneTypeCmd.ZoneType = ZoneType_Europe;
138                         } else {                       /* Unknown ZoneType */
139                                 printk("Error:ZoneType[%x] Unknown ???\n", zonetype);
140                                 result = -EFAULT;
141                                 break;
142                         }
143
144                         if (copy_to_user(pReq->data, &sZoneTypeCmd,
145                                                 sizeof(SCmdZoneTypeSet))) {
146                                 result = -EFAULT;
147                                 break;
148                         }
149                 }
150                 break;
151         case WLAN_CMD_BSS_JOIN:
152                 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
153                         result = -EFAULT;
154                         break;
155                 }
156
157                 pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
158                 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
159                 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
160                 if (sJoinCmd.wBSSType == ADHOC) {
161                         pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
162                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
163                 } else {
164                         pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
165                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
166                 }
167                 if (sJoinCmd.bPSEnable == TRUE) {
168                         pDevice->ePSMode = WMAC_POWER_FAST;
169                         pMgmt->wListenInterval = 2;
170                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
171                 } else {
172                         pDevice->ePSMode = WMAC_POWER_CAM;
173                         pMgmt->wListenInterval = 1;
174                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n");
175                 }
176
177                 if (sJoinCmd.bShareKeyAuth == TRUE) {
178                         pMgmt->bShareKeyAlgorithm = TRUE;
179                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
180                 } else {
181                         pMgmt->bShareKeyAlgorithm = FALSE;
182                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
183                 }
184
185                 pDevice->uChannel = sJoinCmd.uChannel;
186                 netif_stop_queue(pDevice->dev);
187                 spin_lock_irq(&pDevice->lock);
188                 pMgmt->eCurrState = WMAC_STATE_IDLE;
189                 bScheduleCommand((void *) pDevice,
190                                  WLAN_CMD_BSSID_SCAN,
191                                  pMgmt->abyDesireSSID);
192                 bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
193                 spin_unlock_irq(&pDevice->lock);
194                 break;
195
196         case WLAN_CMD_SET_WEP:
197                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n");
198                 memset(&sWEPCmd, 0, sizeof(SCmdSetWEP));
199                 if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
200                         result = -EFAULT;
201                         break;
202                 }
203                 if (sWEPCmd.bEnableWep != TRUE) {
204                         int uu;
205
206                         pDevice->bEncryptionEnable = FALSE;
207                         pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
208                         spin_lock_irq(&pDevice->lock);
209                         for (uu = 0; uu < MAX_KEY_TABLE; uu++)
210                                 MACvDisableKeyEntry(pDevice, uu);
211                         spin_unlock_irq(&pDevice->lock);
212                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n");
213                         break;
214                 }
215
216                 for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) {
217                         if (sWEPCmd.bWepKeyAvailable[ii]) {
218                                 if (ii == sWEPCmd.byKeyIndex)
219                                         dwKeyIndex = ii | (1 << 31);
220                                 else
221                                         dwKeyIndex = ii;
222                                 spin_lock_irq(&pDevice->lock);
223                                 KeybSetDefaultKey(pDevice, &(pDevice->sKey),
224                                                   dwKeyIndex,
225                                                   sWEPCmd.auWepKeyLength[ii],
226                                                   NULL,
227                                                   (PBYTE)&sWEPCmd.abyWepKey[ii][0],
228                                                   KEY_CTL_WEP);
229                                 spin_unlock_irq(&pDevice->lock);
230                         }
231                 }
232                 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
233                 pDevice->bTransmitKey = TRUE;
234                 pDevice->bEncryptionEnable = TRUE;
235                 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
236                 break;
237
238         case WLAN_CMD_GET_LINK:
239                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n");
240
241                 memset(sLinkStatus.abySSID, 0, WLAN_SSID_MAXLEN + 1);
242
243                 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
244                         sLinkStatus.wBSSType = ADHOC;
245                 else
246                         sLinkStatus.wBSSType = INFRA;
247
248                 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
249                         sLinkStatus.byState = ADHOC_JOINTED;
250                 else
251                         sLinkStatus.byState = ADHOC_STARTED;
252
253                 sLinkStatus.uChannel = pMgmt->uCurrChannel;
254                 if (pDevice->bLinkPass == TRUE) {
255                         sLinkStatus.bLink = TRUE;
256                         pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
257                         memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
258                         memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
259                         sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
260                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Link Success!\n");
261                 } else {
262                         sLinkStatus.bLink = FALSE;
263                         sLinkStatus.uLinkRate = 0;
264                 }
265                 if (copy_to_user(pReq->data, &sLinkStatus,
266                                         sizeof(SCmdLinkStatus))) {
267                         result = -EFAULT;
268                         break;
269                 }
270                 break;
271
272         case WLAN_CMD_GET_LISTLEN:
273                 cbListCount = 0;
274                 pBSS = &(pMgmt->sBSSList[0]);
275                 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
276                         pBSS = &(pMgmt->sBSSList[ii]);
277                         if (!pBSS->bActive)
278                                 continue;
279                         cbListCount++;
280                 }
281                 sList.uItem = cbListCount;
282                 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
283                         result = -EFAULT;
284                         break;
285                 }
286                 pReq->wResult = 0;
287                 break;
288
289         case WLAN_CMD_GET_LIST:
290                 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
291                         result = -EFAULT;
292                         break;
293                 }
294                 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
295                 if (pList == NULL) {
296                         result = -ENOMEM;
297                         break;
298                 }
299                 pList->uItem = sList.uItem;
300                 pBSS = &(pMgmt->sBSSList[0]);
301                 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
302                         pBSS = &(pMgmt->sBSSList[jj]);
303                         if (pBSS->bActive) {
304                                 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
305                                 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
306                                 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
307                                 RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
308                                 pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm;
309                                 /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */
310                                 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
311                                 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
312                                 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
313                                 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
314                                 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
315                                         pList->sBSSIDList[ii].byNetType = INFRA;
316                                 } else {
317                                         pList->sBSSIDList[ii].byNetType = ADHOC;
318                                 }
319                                 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
320                                         pList->sBSSIDList[ii].bWEPOn = TRUE;
321                                 } else {
322                                         pList->sBSSIDList[ii].bWEPOn = FALSE;
323                                 }
324                                 ii++;
325                                 if (ii >= pList->uItem)
326                                         break;
327                         }
328                 }
329
330                 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
331                         result = -EFAULT;
332                         break;
333                 }
334                 kfree(pList);
335                 pReq->wResult = 0;
336                 break;
337
338         case WLAN_CMD_GET_MIB:
339                 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
340                         result = -EFAULT;
341                         break;
342                 }
343                 break;
344
345         case WLAN_CMD_GET_STAT:
346                 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
347                         result = -EFAULT;
348                         break;
349                 }
350                 break;
351         case WLAN_CMD_STOP_MAC:
352                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
353                 /* Todo xxxxxx */
354                 netif_stop_queue(pDevice->dev);
355                 spin_lock_irq(&pDevice->lock);
356                 if (pDevice->bRadioOff == FALSE) {
357                         CARDbRadioPowerOff(pDevice);
358                 }
359                 pDevice->bLinkPass = FALSE;
360                 ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
361                 memset(pMgmt->abyCurrBSSID, 0, 6);
362                 pMgmt->eCurrState = WMAC_STATE_IDLE;
363                 /* del_timer(&pDevice->sTimerCommand); */
364                 /* del_timer(&pMgmt->sTimerSecondCallback); */
365                 pDevice->bCmdRunning = FALSE;
366                 spin_unlock_irq(&pDevice->lock);
367                 break;
368
369         case WLAN_CMD_START_MAC:
370                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
371                 /* Todo xxxxxxx */
372                 if (pDevice->bRadioOff == TRUE)
373                         CARDbRadioPowerOn(pDevice);
374                 break;
375
376         case WLAN_CMD_SET_HOSTAPD:
377                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
378
379                 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
380                         result = -EFAULT;
381                         break;
382                 }
383                 if (sValue.dwValue == 1) {
384                         if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0) {
385                                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
386                         } else {
387                                 result = -EFAULT;
388                                 break;
389                         }
390                 } else {
391                         vt6656_hostap_set_hostapd(pDevice, 0, 1);
392                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
393                 }
394                 break;
395
396         case WLAN_CMD_SET_HOSTAPD_STA:
397                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
398                 break;
399
400         case WLAN_CMD_SET_802_1X:
401                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
402                 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
403                         result = -EFAULT;
404                         break;
405                 }
406
407                 if (sValue.dwValue == 1) {
408                         pDevice->bEnable8021x = TRUE;
409                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
410                 } else {
411                         pDevice->bEnable8021x = FALSE;
412                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
413                 }
414                 break;
415
416         case WLAN_CMD_SET_HOST_WEP:
417                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
418                 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
419                         result = -EFAULT;
420                         break;
421                 }
422
423                 if (sValue.dwValue == 1) {
424                         pDevice->bEnableHostWEP = TRUE;
425                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
426                 } else {
427                         pDevice->bEnableHostWEP = FALSE;
428                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
429                 }
430                 break;
431
432         case WLAN_CMD_SET_WPA:
433                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
434
435                 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
436                         result = -EFAULT;
437                         break;
438                 }
439                 if (sValue.dwValue == 1) {
440                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
441                         memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr,
442                                ETH_ALEN);
443                         pDevice->bWPADEVUp = TRUE;
444                 } else {
445                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
446                         pDevice->bWPADEVUp = FALSE;
447                 }
448                 break;
449
450         case WLAN_CMD_AP_START:
451                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
452                 if (pDevice->bRadioOff == TRUE) {
453                         CARDbRadioPowerOn(pDevice);
454                         add_timer(&pMgmt->sTimerSecondCallback);
455                 }
456                 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
457                         result = -EFAULT;
458                         break;
459                 }
460
461                 if (sStartAPCmd.wBSSType == AP) {
462                         pMgmt->eConfigMode = WMAC_CONFIG_AP;
463                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
464                 } else {
465                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
466                         result = -EFAULT;
467                         break;
468                 }
469
470                 if (sStartAPCmd.wBBPType == PHY80211g) {
471                         pMgmt->byAPBBType = PHY_TYPE_11G;
472                 } else if (sStartAPCmd.wBBPType == PHY80211a) {
473                         pMgmt->byAPBBType = PHY_TYPE_11A;
474                 } else {
475                         pMgmt->byAPBBType = PHY_TYPE_11B;
476                 }
477
478                 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
479                 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
480                 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
481
482                 if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))
483                         pDevice->uChannel = sStartAPCmd.uChannel;
484
485                 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
486                         pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
487                 else
488                         pMgmt->wIBSSBeaconPeriod = 100;
489
490                 if (sStartAPCmd.bShareKeyAuth == TRUE) {
491                         pMgmt->bShareKeyAlgorithm = TRUE;
492                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
493                 } else {
494                         pMgmt->bShareKeyAlgorithm = FALSE;
495                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
496                 }
497                 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
498
499                 if (sStartAPCmd.byBasicRate & BIT3) {
500                         pMgmt->abyIBSSSuppRates[2] |= BIT7;
501                         pMgmt->abyIBSSSuppRates[3] |= BIT7;
502                         pMgmt->abyIBSSSuppRates[4] |= BIT7;
503                         pMgmt->abyIBSSSuppRates[5] |= BIT7;
504                 } else if (sStartAPCmd.byBasicRate & BIT2) {
505                         pMgmt->abyIBSSSuppRates[2] |= BIT7;
506                         pMgmt->abyIBSSSuppRates[3] |= BIT7;
507                         pMgmt->abyIBSSSuppRates[4] |= BIT7;
508                 } else if (sStartAPCmd.byBasicRate & BIT1) {
509                         pMgmt->abyIBSSSuppRates[2] |= BIT7;
510                         pMgmt->abyIBSSSuppRates[3] |= BIT7;
511                 } else if (sStartAPCmd.byBasicRate & BIT1) {
512                         pMgmt->abyIBSSSuppRates[2] |= BIT7;
513                 } else {
514                         /* default 1,2M */
515                         pMgmt->abyIBSSSuppRates[2] |= BIT7;
516                         pMgmt->abyIBSSSuppRates[3] |= BIT7;
517                 }
518
519                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
520                         pMgmt->abyIBSSSuppRates[2],
521                         pMgmt->abyIBSSSuppRates[3],
522                         pMgmt->abyIBSSSuppRates[4],
523                         pMgmt->abyIBSSSuppRates[5]);
524
525                 netif_stop_queue(pDevice->dev);
526                 spin_lock_irq(&pDevice->lock);
527                 bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
528                 spin_unlock_irq(&pDevice->lock);
529                 break;
530
531         case WLAN_CMD_GET_NODE_CNT:
532                 cbListCount = 0;
533                 pNode = &(pMgmt->sNodeDBTable[0]);
534                 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
535                         pNode = &(pMgmt->sNodeDBTable[ii]);
536                         if (!pNode->bActive)
537                                 continue;
538                         cbListCount++;
539                 }
540
541                 sNodeList.uItem = cbListCount;
542                 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
543                         result = -EFAULT;
544                         break;
545                 }
546                 pReq->wResult = 0;
547                 break;
548
549         case WLAN_CMD_GET_NODE_LIST:
550                 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
551                         result = -EFAULT;
552                         break;
553                 }
554                 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
555                 if (pNodeList == NULL) {
556                         result = -ENOMEM;
557                         break;
558                 }
559                 pNodeList->uItem = sNodeList.uItem;
560                 pNode = &(pMgmt->sNodeDBTable[0]);
561                 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
562                         pNode = &(pMgmt->sNodeDBTable[ii]);
563                         if (pNode->bActive) {
564                                 pNodeList->sNodeList[jj].wAID = pNode->wAID;
565                                 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
566                                 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
567                                 pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;
568                                 pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;
569                                 pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;
570                                 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
571                                 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
572                                 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
573                                 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
574                                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
575                                         pNodeList->sNodeList[jj].abyWepKey[0],
576                                         pNodeList->sNodeList[jj].abyWepKey[1],
577                                         pNodeList->sNodeList[jj].abyWepKey[2],
578                                         pNodeList->sNodeList[jj].abyWepKey[3],
579                                         pNodeList->sNodeList[jj].abyWepKey[4]);
580                                 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
581                                 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
582                                 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
583                                 pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;
584                                 jj++;
585                                 if (jj >= pNodeList->uItem)
586                                         break;
587                         }
588                 }
589                 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
590                         result = -EFAULT;
591                         break;
592                 }
593                 kfree(pNodeList);
594                 pReq->wResult = 0;
595                 break;
596
597         case 0xFF:
598                 memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
599                 wpa_Result.proto = 0;
600                 wpa_Result.key_mgmt = 0;
601                 wpa_Result.eap_type = 0;
602                 wpa_Result.authenticated = FALSE;
603                 pDevice->fWPA_Authened = FALSE;
604                 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
605                         result = -EFAULT;
606                         break;
607                 }
608                 /* for some AP maybe good authenticate */
609                 if (wpa_Result.key_mgmt == 0x20)
610                         pMgmt->Cisco_cckm = 1;
611                 else
612                         pMgmt->Cisco_cckm = 0;
613
614                 if (wpa_Result.authenticated == TRUE) {
615                         {
616                                 union iwreq_data wrqu;
617
618                                 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
619                                 memset(&wrqu, 0, sizeof(wrqu));
620                                 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
621                                 wrqu.data.length = pItemSSID->len;
622                                 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
623                         }
624
625                         pDevice->fWPA_Authened = TRUE; /* is successful peer to wpa_Result.authenticated? */
626                 }
627
628                 pReq->wResult = 0;
629                 break;
630
631         default:
632                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
633         }
634
635         return result;
636 }