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