staging: brcm80211: remove brcms_b_dotxstatus wrapper function
[zen-stable.git] / drivers / staging / vt6655 / ioctl.c
blob43964a5e72a98edc826a400eb8dafbcb83090231
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * File: ioctl.c
21 * Purpose: private ioctl functions
23 * Author: Lyndon Chen
25 * Date: Auguest 20, 2003
27 * Functions:
29 * Revision History:
33 #include "ioctl.h"
34 #include "iocmd.h"
35 #include "mac.h"
36 #include "card.h"
37 #include "hostap.h"
38 #include "wpactl.h"
39 #include "rf.h"
41 /*--------------------- Static Definitions -------------------------*/
43 /*--------------------- Static Classes ----------------------------*/
45 /*--------------------- Static Variables --------------------------*/
46 //static int msglevel =MSG_LEVEL_DEBUG;
47 static int msglevel =MSG_LEVEL_INFO;
49 #ifdef WPA_SM_Transtatus
50 SWPAResult wpa_Result;
51 #endif
53 /*--------------------- Static Functions --------------------------*/
55 /*--------------------- Export Variables --------------------------*/
57 int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
59 PSCmdRequest pReq = (PSCmdRequest)rq;
60 PSMgmtObject pMgmt = pDevice->pMgmt;
61 int result = 0;
62 PWLAN_IE_SSID pItemSSID;
63 SCmdBSSJoin sJoinCmd;
64 SCmdZoneTypeSet sZoneTypeCmd;
65 SCmdScan sScanCmd;
66 SCmdStartAP sStartAPCmd;
67 SCmdSetWEP sWEPCmd;
68 SCmdValue sValue;
69 SBSSIDList sList;
70 SNodeList sNodeList;
71 PSBSSIDList pList;
72 PSNodeList pNodeList;
73 unsigned int cbListCount;
74 PKnownBSS pBSS;
75 PKnownNodeDB pNode;
76 unsigned int ii, jj;
77 SCmdLinkStatus sLinkStatus;
78 unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
79 unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
80 unsigned long dwKeyIndex= 0;
81 unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
82 long ldBm;
84 pReq->wResult = 0;
86 switch (pReq->wCmdCode) {
88 case WLAN_CMD_BSS_SCAN:
90 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin \n");
91 if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
92 result = -EFAULT;
93 break;
96 pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
97 if (pItemSSID->len != 0) {
98 memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
99 memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
102 if (pDevice->bMACSuspend == true) {
103 if (pDevice->bRadioOff == true)
104 CARDbRadioPowerOn(pDevice);
105 vMgrTimerInit(pDevice);
106 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
107 add_timer(&pMgmt->sTimerSecondCallback);
108 pDevice->bMACSuspend = false;
110 spin_lock_irq(&pDevice->lock);
111 if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
112 BSSvClearBSSList((void *)pDevice, false);
113 else
114 BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
116 if (pItemSSID->len != 0)
117 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
118 else
119 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
120 spin_unlock_irq(&pDevice->lock);
121 break;
123 case WLAN_CMD_ZONETYPE_SET:
124 //mike add :cann't support.
125 result=-EOPNOTSUPP;
126 break;
128 if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
129 result = -EFAULT;
130 break;
133 if(sZoneTypeCmd.bWrite==true) {
134 //////write zonetype
135 if(sZoneTypeCmd.ZoneType == ZoneType_USA) {
136 //set to USA
137 printk("set_ZoneType:USA\n");
139 else if(sZoneTypeCmd.ZoneType == ZoneType_Japan) {
140 //set to Japan
141 printk("set_ZoneType:Japan\n");
143 else if(sZoneTypeCmd.ZoneType == ZoneType_Europe) {
144 //set to Europe
145 printk("set_ZoneType:Europe\n");
148 else {
149 ///////read zonetype
150 unsigned char zonetype=0;
153 if(zonetype == 0x00) { //USA
154 sZoneTypeCmd.ZoneType = ZoneType_USA;
156 else if(zonetype == 0x01) { //Japan
157 sZoneTypeCmd.ZoneType = ZoneType_Japan;
159 else if(zonetype == 0x02) { //Europe
160 sZoneTypeCmd.ZoneType = ZoneType_Europe;
162 else { //Unknown ZoneType
163 printk("Error:ZoneType[%x] Unknown ???\n",zonetype);
164 result = -EFAULT;
165 break;
167 if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
168 result = -EFAULT;
169 break;
173 break;
175 case WLAN_CMD_BSS_JOIN:
177 if (pDevice->bMACSuspend == true) {
178 if (pDevice->bRadioOff == true)
179 CARDbRadioPowerOn(pDevice);
180 vMgrTimerInit(pDevice);
181 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
182 add_timer(&pMgmt->sTimerSecondCallback);
183 pDevice->bMACSuspend = false;
186 if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
187 result = -EFAULT;
188 break;
191 pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
192 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
193 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
194 if (sJoinCmd.wBSSType == ADHOC) {
195 pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
196 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
198 else {
199 pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
200 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
202 if (sJoinCmd.bPSEnable == true) {
203 pDevice->ePSMode = WMAC_POWER_FAST;
204 // pDevice->ePSMode = WMAC_POWER_MAX;
205 pMgmt->wListenInterval = 2;
206 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
208 else {
209 pDevice->ePSMode = WMAC_POWER_CAM;
210 pMgmt->wListenInterval = 1;
211 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off \n");
214 if (sJoinCmd.bShareKeyAuth == true){
215 pMgmt->bShareKeyAlgorithm = true;
216 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
218 else {
219 pMgmt->bShareKeyAlgorithm = false;
220 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
222 pDevice->uChannel = sJoinCmd.uChannel;
223 netif_stop_queue(pDevice->dev);
224 spin_lock_irq(&pDevice->lock);
225 pMgmt->eCurrState = WMAC_STATE_IDLE;
226 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
227 bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
228 spin_unlock_irq(&pDevice->lock);
229 break;
231 case WLAN_CMD_SET_WEP:
232 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key. \n");
233 memset(&sWEPCmd, 0 ,sizeof(SCmdSetWEP));
234 if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
235 result = -EFAULT;
236 break;
238 if (sWEPCmd.bEnableWep != true) {
239 pDevice->bEncryptionEnable = false;
240 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
241 MACvDisableDefaultKey(pDevice->PortOffset);
242 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable. \n");
243 break;
246 for (ii = 0; ii < WLAN_WEP_NKEYS; ii ++) {
247 if (sWEPCmd.bWepKeyAvailable[ii]) {
248 if (ii == sWEPCmd.byKeyIndex)
249 //2006-1123-02,<Modify> by EinsnLiu
250 //Evaluate the "dwKeyIndex" error
251 // dwKeyIndex |= (1 << 31);
252 dwKeyIndex =ii|(1 << 31);
253 else
254 dwKeyIndex = ii;
256 KeybSetDefaultKey(&(pDevice->sKey),
257 dwKeyIndex,
258 sWEPCmd.auWepKeyLength[ii],
259 NULL,
260 (unsigned char *)&sWEPCmd.abyWepKey[ii][0],
261 KEY_CTL_WEP,
262 pDevice->PortOffset,
263 pDevice->byLocalID);
266 pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
267 pDevice->bTransmitKey = true;
268 pDevice->bEncryptionEnable = true;
269 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
271 break;
273 case WLAN_CMD_GET_LINK:
274 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status. \n");
276 memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
278 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
279 sLinkStatus.wBSSType = ADHOC;
280 else
281 sLinkStatus.wBSSType = INFRA;
283 if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
284 sLinkStatus.byState = ADHOC_JOINTED;
285 else
286 sLinkStatus.byState = ADHOC_STARTED;
288 sLinkStatus.uChannel = pMgmt->uCurrChannel;
289 if (pDevice->bLinkPass == true) {
290 sLinkStatus.bLink = true;
291 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
292 memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
293 memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
294 sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
295 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success ! \n");
297 else {
298 sLinkStatus.bLink = false;
299 sLinkStatus.uLinkRate = 0;
301 if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
302 result = -EFAULT;
303 break;
306 break;
308 case WLAN_CMD_GET_LISTLEN:
309 cbListCount = 0;
310 pBSS = &(pMgmt->sBSSList[0]);
311 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
312 pBSS = &(pMgmt->sBSSList[ii]);
313 if (!pBSS->bActive)
314 continue;
315 cbListCount++;
317 sList.uItem = cbListCount;
318 if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
319 result = -EFAULT;
320 break;
322 pReq->wResult = 0;
323 break;
325 case WLAN_CMD_GET_LIST:
326 if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
327 result = -EFAULT;
328 break;
330 pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
331 if (pList == NULL) {
332 result = -ENOMEM;
333 break;
335 pList->uItem = sList.uItem;
336 pBSS = &(pMgmt->sBSSList[0]);
337 for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
338 pBSS = &(pMgmt->sBSSList[jj]);
339 if (pBSS->bActive) {
340 pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
341 pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
342 pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
343 // pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI;
344 RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
345 pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
346 memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
347 pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
348 memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
349 memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
350 if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
351 pList->sBSSIDList[ii].byNetType = INFRA;
353 else {
354 pList->sBSSIDList[ii].byNetType = ADHOC;
356 if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
357 pList->sBSSIDList[ii].bWEPOn = true;
359 else {
360 pList->sBSSIDList[ii].bWEPOn = false;
362 ii ++;
363 if (ii >= pList->uItem)
364 break;
368 if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
369 result = -EFAULT;
370 break;
372 kfree(pList);
373 pReq->wResult = 0;
374 break;
376 case WLAN_CMD_GET_MIB:
377 if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
378 result = -EFAULT;
379 break;
381 break;
383 case WLAN_CMD_GET_STAT:
384 if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
385 result = -EFAULT;
386 break;
388 break;
389 case WLAN_CMD_STOP_MAC:
391 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
392 netif_stop_queue(pDevice->dev);
394 spin_lock_irq(&pDevice->lock);
395 if (pDevice->bRadioOff == false) {
396 CARDbRadioPowerOff(pDevice);
398 pDevice->bLinkPass = false;
399 memset(pMgmt->abyCurrBSSID, 0, 6);
400 pMgmt->eCurrState = WMAC_STATE_IDLE;
401 del_timer(&pDevice->sTimerCommand);
402 del_timer(&pMgmt->sTimerSecondCallback);
403 pDevice->bCmdRunning = false;
404 pDevice->bMACSuspend = true;
405 MACvIntDisable(pDevice->PortOffset);
406 spin_unlock_irq(&pDevice->lock);
408 break;
410 case WLAN_CMD_START_MAC:
412 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
414 if (pDevice->bMACSuspend == true) {
415 if (pDevice->bRadioOff == true)
416 CARDbRadioPowerOn(pDevice);
417 vMgrTimerInit(pDevice);
418 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
419 add_timer(&pMgmt->sTimerSecondCallback);
420 pDevice->bMACSuspend = false;
422 break;
424 case WLAN_CMD_SET_HOSTAPD:
426 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
428 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
429 result = -EFAULT;
430 break;
432 if (sValue.dwValue == 1) {
433 if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0){
434 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
436 else {
437 result = -EFAULT;
438 break;
441 else {
442 vt6655_hostap_set_hostapd(pDevice, 0, 1);
443 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
446 break;
448 case WLAN_CMD_SET_HOSTAPD_STA:
450 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
452 break;
453 case WLAN_CMD_SET_802_1X:
455 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
456 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
457 result = -EFAULT;
458 break;
461 if (sValue.dwValue == 1) {
462 pDevice->bEnable8021x = true;
463 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
465 else {
466 pDevice->bEnable8021x = false;
467 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
470 break;
473 case WLAN_CMD_SET_HOST_WEP:
475 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
476 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
477 result = -EFAULT;
478 break;
481 if (sValue.dwValue == 1) {
482 pDevice->bEnableHostWEP = true;
483 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
485 else {
486 pDevice->bEnableHostWEP = false;
487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
490 break;
492 case WLAN_CMD_SET_WPA:
493 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
495 if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
496 result = -EFAULT;
497 break;
499 if (sValue.dwValue == 1) {
500 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
501 memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN);
502 pDevice->bWPADEVUp = true;
504 else {
505 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
506 pDevice->bWPADEVUp = false;
509 break;
511 case WLAN_CMD_AP_START:
513 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
514 if (pDevice->bRadioOff == true) {
515 CARDbRadioPowerOn(pDevice);
516 vMgrTimerInit(pDevice);
517 MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
518 add_timer(&pMgmt->sTimerSecondCallback);
520 if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
521 result = -EFAULT;
522 break;
525 if (sStartAPCmd.wBSSType == AP) {
526 pMgmt->eConfigMode = WMAC_CONFIG_AP;
527 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
529 else {
530 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
531 result = -EFAULT;
532 break;
536 if (sStartAPCmd.wBBPType == PHY80211g) {
537 pMgmt->byAPBBType = PHY_TYPE_11G;
539 else if (sStartAPCmd.wBBPType == PHY80211a) {
540 pMgmt->byAPBBType = PHY_TYPE_11A;
542 else {
543 pMgmt->byAPBBType = PHY_TYPE_11B;
546 pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
547 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
548 memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
550 if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14))
551 pDevice->uChannel = sStartAPCmd.uChannel;
553 if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
554 pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
555 else
556 pMgmt->wIBSSBeaconPeriod = 100;
558 if (sStartAPCmd.bShareKeyAuth == true){
559 pMgmt->bShareKeyAlgorithm = true;
560 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
562 else {
563 pMgmt->bShareKeyAlgorithm = false;
564 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
566 memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
568 if (sStartAPCmd.byBasicRate & BIT3) {
569 pMgmt->abyIBSSSuppRates[2] |= BIT7;
570 pMgmt->abyIBSSSuppRates[3] |= BIT7;
571 pMgmt->abyIBSSSuppRates[4] |= BIT7;
572 pMgmt->abyIBSSSuppRates[5] |= BIT7;
573 }else if (sStartAPCmd.byBasicRate & BIT2) {
574 pMgmt->abyIBSSSuppRates[2] |= BIT7;
575 pMgmt->abyIBSSSuppRates[3] |= BIT7;
576 pMgmt->abyIBSSSuppRates[4] |= BIT7;
577 }else if (sStartAPCmd.byBasicRate & BIT1) {
578 pMgmt->abyIBSSSuppRates[2] |= BIT7;
579 pMgmt->abyIBSSSuppRates[3] |= BIT7;
580 }else if (sStartAPCmd.byBasicRate & BIT1) {
581 pMgmt->abyIBSSSuppRates[2] |= BIT7;
582 }else {
583 //default 1,2M
584 pMgmt->abyIBSSSuppRates[2] |= BIT7;
585 pMgmt->abyIBSSSuppRates[3] |= BIT7;
588 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n",
589 pMgmt->abyIBSSSuppRates[2],
590 pMgmt->abyIBSSSuppRates[3],
591 pMgmt->abyIBSSSuppRates[4],
592 pMgmt->abyIBSSSuppRates[5]
595 netif_stop_queue(pDevice->dev);
596 spin_lock_irq(&pDevice->lock);
597 bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
598 spin_unlock_irq(&pDevice->lock);
599 break;
601 case WLAN_CMD_GET_NODE_CNT:
603 cbListCount = 0;
604 pNode = &(pMgmt->sNodeDBTable[0]);
605 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
606 pNode = &(pMgmt->sNodeDBTable[ii]);
607 if (!pNode->bActive)
608 continue;
609 cbListCount++;
612 sNodeList.uItem = cbListCount;
613 if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
614 result = -EFAULT;
615 break;
617 pReq->wResult = 0;
618 break;
620 case WLAN_CMD_GET_NODE_LIST:
622 if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
623 result = -EFAULT;
624 break;
626 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
627 if (pNodeList == NULL) {
628 result = -ENOMEM;
629 break;
631 pNodeList->uItem = sNodeList.uItem;
632 pNode = &(pMgmt->sNodeDBTable[0]);
633 for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
634 pNode = &(pMgmt->sNodeDBTable[ii]);
635 if (pNode->bActive) {
636 pNodeList->sNodeList[jj].wAID = pNode->wAID;
637 memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
638 pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
639 pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount;
640 pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt;
641 pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags;
642 pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
643 pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
644 pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
645 memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
646 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
647 pNodeList->sNodeList[jj].abyWepKey[0],
648 pNodeList->sNodeList[jj].abyWepKey[1],
649 pNodeList->sNodeList[jj].abyWepKey[2],
650 pNodeList->sNodeList[jj].abyWepKey[3],
651 pNodeList->sNodeList[jj].abyWepKey[4]
653 pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
654 pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
655 pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
656 pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio;
657 jj ++;
658 if (jj >= pNodeList->uItem)
659 break;
662 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
663 result = -EFAULT;
664 break;
666 kfree(pNodeList);
667 pReq->wResult = 0;
668 break;
670 #ifdef WPA_SM_Transtatus
671 case 0xFF:
672 memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
673 wpa_Result.proto = 0;
674 wpa_Result.key_mgmt = 0;
675 wpa_Result.eap_type = 0;
676 wpa_Result.authenticated = false;
677 pDevice->fWPA_Authened = false;
678 if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
679 result = -EFAULT;
680 break;
683 if(wpa_Result.authenticated==true) {
684 #ifdef SndEvt_ToAPI
686 union iwreq_data wrqu;
688 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
690 memset(&wrqu, 0, sizeof(wrqu));
691 wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
692 wrqu.data.length =pItemSSID->len;
693 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
695 #endif
696 pDevice->fWPA_Authened = true; //is successful peer to wpa_Result.authenticated?
699 //printk("get private wpa_supplicant announce WPA SM\n");
700 //printk("wpa-->ifname=%s\n",wpa_Result.ifname);
701 //printk("wpa-->proto=%d\n",wpa_Result.proto);
702 //printk("wpa-->key-mgmt=%d\n",wpa_Result.key_mgmt);
703 //printk("wpa-->eap_type=%d\n",wpa_Result.eap_type);
704 //printk("wpa-->authenticated is %s\n",(wpa_Result.authenticated==true)?"true":"false");
706 pReq->wResult = 0;
707 break;
708 #endif
710 default:
711 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
714 return result;
718 void
719 vConfigWEPKey (
720 PSDevice pDevice,
721 unsigned long dwKeyIndex,
722 unsigned char *pbyKey,
723 unsigned long uKeyLength
726 int ii;
729 memset(&pDevice->abyWepKey[dwKeyIndex][0], 0, WLAN_WEPMAX_KEYLEN);
730 memcpy(&pDevice->abyWepKey[dwKeyIndex][0], pbyKey, uKeyLength);
732 pDevice->bWepKeyAvailable[dwKeyIndex] = true;
733 pDevice->auWepKeyLength[dwKeyIndex] = uKeyLength;
735 MACvSetDefaultKeyEntry(pDevice->PortOffset, uKeyLength, dwKeyIndex,
736 (unsigned long *) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID);
738 if (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported) {
739 for(ii=0; ii<MAX_GROUP_KEY; ii++) {
740 if ((pDevice->bWepKeyAvailable[ii] == true) &&
741 (pDevice->auWepKeyLength[ii] == WLAN_WEP232_KEYLEN)) {
742 pDevice->uCurrentWEPMode = TX_WEP_SW232;
743 MACvDisableDefaultKey(pDevice->PortOffset);
744 break;
747 if ((ii == MAX_GROUP_KEY) &&
748 (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported)) {
749 MACvEnableDefaultKey(pDevice->PortOffset, pDevice->byLocalID);