Merge tag 'ktest-v3.5-spelling' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / drivers / staging / vt6655 / 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 "rf.h"
40
41 static int msglevel = MSG_LEVEL_INFO;
42
43 #ifdef WPA_SM_Transtatus
44 SWPAResult wpa_Result;
45 #endif
46
47 int private_ioctl(PSDevice pDevice, struct ifreq *rq)
48 {
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;
73
74 pReq->wResult = 0;
75
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;
82 }
83
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);
90 }
91
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;
99 }
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);
105
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;
112
113 case WLAN_CMD_ZONETYPE_SET:
114 /* mike add :cann't support. */
115 result = -EOPNOTSUPP;
116 break;
117
118 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
119 result = -EFAULT;
120 break;
121 }
122
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");
134 }
135 } else {
136 /* read zonetype */
137 unsigned char zonetype = 0;
138
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;
149 }
150 if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
151 result = -EFAULT;
152 break;
153 }
154 }
155 break;
156
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;
165 }
166
167 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
168 result = -EFAULT;
169 break;
170 }
171
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");
183 }
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");
192 }
193
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");
200 }
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;
209
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;
216 }
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;
223 }
224
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;
231
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);
240 }
241 }
242 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
243 pDevice->bTransmitKey = true;
244 pDevice->bEncryptionEnable = true;
245 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
246 break;
247
248 case WLAN_CMD_GET_LINK:
249 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n");
250
251 memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
252
253 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
254 sLinkStatus.wBSSType = ADHOC;
255 else
256 sLinkStatus.wBSSType = INFRA;
257
258 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
259 sLinkStatus.byState = ADHOC_JOINTED;
260 else
261 sLinkStatus.byState = ADHOC_STARTED;
262
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;
274 }
275 if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
276 result = -EFAULT;
277 break;
278 }
279 break;
280
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++;
289 }
290 sList.uItem = cbListCount;
291 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
292 result = -EFAULT;
293 break;
294 }
295 pReq->wResult = 0;
296 break;
297
298 case WLAN_CMD_GET_LIST:
299 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
300 result = -EFAULT;
301 break;
302 }
303 if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) {
304 result = -EINVAL;
305 break;
306 }
307 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
308 if (pList == NULL) {
309 result = -ENOMEM;
310 break;
311 }
312 pList->uItem = sList.uItem;
313 pBSS = &(pMgmt->sBSSList[0]);
314 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
315 pBSS = &(pMgmt->sBSSList[jj]);
316 if (pBSS->bActive) {
317 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
318 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
319 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
320 /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */
321 RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
322 pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
323 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
324 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
325 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
326 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
327 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo))
328 pList->sBSSIDList[ii].byNetType = INFRA;
329 else
330 pList->sBSSIDList[ii].byNetType = ADHOC;
331
332 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo))
333 pList->sBSSIDList[ii].bWEPOn = true;
334 else
335 pList->sBSSIDList[ii].bWEPOn = false;
336
337 ii++;
338 if (ii >= pList->uItem)
339 break;
340 }
341 }
342
343 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
344 result = -EFAULT;
345 break;
346 }
347 kfree(pList);
348 pReq->wResult = 0;
349 break;
350
351 case WLAN_CMD_GET_MIB:
352 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
353 result = -EFAULT;
354 break;
355 }
356 break;
357
358 case WLAN_CMD_GET_STAT:
359 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
360 result = -EFAULT;
361 break;
362 }
363 break;
364
365 case WLAN_CMD_STOP_MAC:
366 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
367 netif_stop_queue(pDevice->dev);
368
369 spin_lock_irq(&pDevice->lock);
370 if (pDevice->bRadioOff == false)
371 CARDbRadioPowerOff(pDevice);
372
373 pDevice->bLinkPass = false;
374 memset(pMgmt->abyCurrBSSID, 0, 6);
375 pMgmt->eCurrState = WMAC_STATE_IDLE;
376 del_timer(&pDevice->sTimerCommand);
377 del_timer(&pMgmt->sTimerSecondCallback);
378 pDevice->bCmdRunning = false;
379 pDevice->bMACSuspend = true;
380 MACvIntDisable(pDevice->PortOffset);
381 spin_unlock_irq(&pDevice->lock);
382 break;
383
384 case WLAN_CMD_START_MAC:
385 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
386
387 if (pDevice->bMACSuspend == true) {
388 if (pDevice->bRadioOff == true)
389 CARDbRadioPowerOn(pDevice);
390 vMgrTimerInit(pDevice);
391 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
392 add_timer(&pMgmt->sTimerSecondCallback);
393 pDevice->bMACSuspend = false;
394 }
395 break;
396
397 case WLAN_CMD_SET_HOSTAPD:
398 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
399
400 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
401 result = -EFAULT;
402 break;
403 }
404 if (sValue.dwValue == 1) {
405 if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) {
406 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
407 } else {
408 result = -EFAULT;
409 break;
410 }
411 } else {
412 vt6655_hostap_set_hostapd(pDevice, 0, 1);
413 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
414 }
415 break;
416
417 case WLAN_CMD_SET_HOSTAPD_STA:
418 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
419 break;
420
421 case WLAN_CMD_SET_802_1X:
422 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
423 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
424 result = -EFAULT;
425 break;
426 }
427
428 if (sValue.dwValue == 1) {
429 pDevice->bEnable8021x = true;
430 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
431 } else {
432 pDevice->bEnable8021x = false;
433 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
434 }
435 break;
436
437 case WLAN_CMD_SET_HOST_WEP:
438 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
439 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
440 result = -EFAULT;
441 break;
442 }
443
444 if (sValue.dwValue == 1) {
445 pDevice->bEnableHostWEP = true;
446 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
447 } else {
448 pDevice->bEnableHostWEP = false;
449 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
450 }
451 break;
452
453 case WLAN_CMD_SET_WPA:
454 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
455
456 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
457 result = -EFAULT;
458 break;
459 }
460 if (sValue.dwValue == 1) {
461 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
462 memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN);
463 pDevice->bWPADEVUp = true;
464 } else {
465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
466 pDevice->bWPADEVUp = false;
467 }
468 break;
469
470 case WLAN_CMD_AP_START:
471 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
472 if (pDevice->bRadioOff == true) {
473 CARDbRadioPowerOn(pDevice);
474 vMgrTimerInit(pDevice);
475 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
476 add_timer(&pMgmt->sTimerSecondCallback);
477 }
478 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
479 result = -EFAULT;
480 break;
481 }
482
483 if (sStartAPCmd.wBSSType == AP) {
484 pMgmt->eConfigMode = WMAC_CONFIG_AP;
485 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
486 } else {
487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
488 result = -EFAULT;
489 break;
490 }
491
492 if (sStartAPCmd.wBBPType == PHY80211g)
493 pMgmt->byAPBBType = PHY_TYPE_11G;
494 else if (sStartAPCmd.wBBPType == PHY80211a)
495 pMgmt->byAPBBType = PHY_TYPE_11A;
496 else
497 pMgmt->byAPBBType = PHY_TYPE_11B;
498
499 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
500 if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
501 return -EINVAL;
502 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
503 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
504
505 if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))
506 pDevice->uChannel = sStartAPCmd.uChannel;
507
508 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
509 pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
510 else
511 pMgmt->wIBSSBeaconPeriod = 100;
512
513 if (sStartAPCmd.bShareKeyAuth == true) {
514 pMgmt->bShareKeyAlgorithm = true;
515 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
516 } else {
517 pMgmt->bShareKeyAlgorithm = false;
518 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
519 }
520 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
521
522 if (sStartAPCmd.byBasicRate & BIT3) {
523 pMgmt->abyIBSSSuppRates[2] |= BIT7;
524 pMgmt->abyIBSSSuppRates[3] |= BIT7;
525 pMgmt->abyIBSSSuppRates[4] |= BIT7;
526 pMgmt->abyIBSSSuppRates[5] |= BIT7;
527 } else if (sStartAPCmd.byBasicRate & BIT2) {
528 pMgmt->abyIBSSSuppRates[2] |= BIT7;
529 pMgmt->abyIBSSSuppRates[3] |= BIT7;
530 pMgmt->abyIBSSSuppRates[4] |= BIT7;
531 } else if (sStartAPCmd.byBasicRate & BIT1) {
532 pMgmt->abyIBSSSuppRates[2] |= BIT7;
533 pMgmt->abyIBSSSuppRates[3] |= BIT7;
534 } else if (sStartAPCmd.byBasicRate & BIT1) {
535 pMgmt->abyIBSSSuppRates[2] |= BIT7;
536 } else {
537 /* default 1,2M */
538 pMgmt->abyIBSSSuppRates[2] |= BIT7;
539 pMgmt->abyIBSSSuppRates[3] |= BIT7;
540 }
541
542 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
543 pMgmt->abyIBSSSuppRates[2],
544 pMgmt->abyIBSSSuppRates[3],
545 pMgmt->abyIBSSSuppRates[4],
546 pMgmt->abyIBSSSuppRates[5]);
547
548 netif_stop_queue(pDevice->dev);
549 spin_lock_irq(&pDevice->lock);
550 bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
551 spin_unlock_irq(&pDevice->lock);
552 break;
553
554 case WLAN_CMD_GET_NODE_CNT:
555 cbListCount = 0;
556 pNode = &(pMgmt->sNodeDBTable[0]);
557 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
558 pNode = &(pMgmt->sNodeDBTable[ii]);
559 if (!pNode->bActive)
560 continue;
561 cbListCount++;
562 }
563
564 sNodeList.uItem = cbListCount;
565 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
566 result = -EFAULT;
567 break;
568 }
569 pReq->wResult = 0;
570 break;
571
572 case WLAN_CMD_GET_NODE_LIST:
573 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
574 result = -EFAULT;
575 break;
576 }
577 if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) {
578 result = -EINVAL;
579 break;
580 }
581 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
582 if (pNodeList == NULL) {
583 result = -ENOMEM;
584 break;
585 }
586 pNodeList->uItem = sNodeList.uItem;
587 pNode = &(pMgmt->sNodeDBTable[0]);
588 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
589 pNode = &(pMgmt->sNodeDBTable[ii]);
590 if (pNode->bActive) {
591 pNodeList->sNodeList[jj].wAID = pNode->wAID;
592 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
593 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
594 pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount;
595 pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt;
596 pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags;
597 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
598 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
599 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
600 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
601 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
602 pNodeList->sNodeList[jj].abyWepKey[0],
603 pNodeList->sNodeList[jj].abyWepKey[1],
604 pNodeList->sNodeList[jj].abyWepKey[2],
605 pNodeList->sNodeList[jj].abyWepKey[3],
606 pNodeList->sNodeList[jj].abyWepKey[4]);
607 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
608 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
609 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
610 pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio;
611 jj++;
612 if (jj >= pNodeList->uItem)
613 break;
614 }
615 }
616 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
617 result = -EFAULT;
618 break;
619 }
620 kfree(pNodeList);
621 pReq->wResult = 0;
622 break;
623
624 #ifdef WPA_SM_Transtatus
625 case 0xFF:
626 memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
627 wpa_Result.proto = 0;
628 wpa_Result.key_mgmt = 0;
629 wpa_Result.eap_type = 0;
630 wpa_Result.authenticated = false;
631 pDevice->fWPA_Authened = false;
632 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
633 result = -EFAULT;
634 break;
635 }
636
637 if (wpa_Result.authenticated == true) {
638 #ifdef SndEvt_ToAPI
639 {
640 union iwreq_data wrqu;
641
642 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
643
644 memset(&wrqu, 0, sizeof(wrqu));
645 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
646 wrqu.data.length = pItemSSID->len;
647 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
648 }
649 #endif
650 pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */
651 }
652 pReq->wResult = 0;
653 break;
654 #endif
655
656 default:
657 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
658 }
659
660 return result;
661 }
This page took 0.050387 seconds and 5 git commands to generate.