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