···11-/*22- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.33- * All rights reserved.44- *55- * This program is free software; you can redistribute it and/or modify66- * it under the terms of the GNU General Public License as published by77- * the Free Software Foundation; either version 2 of the License, or88- * (at your option) any later version.99- *1010- * This program is distributed in the hope that it will be useful,1111- * but WITHOUT ANY WARRANTY; without even the implied warranty of1212- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313- * GNU General Public License for more details.1414- *1515- * You should have received a copy of the GNU General Public License along1616- * with this program; if not, write to the Free Software Foundation, Inc.,1717- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.1818- *1919- * File: ioctl.c2020- *2121- * Purpose: private ioctl functions2222- *2323- * Author: Lyndon Chen2424- *2525- * Date: Auguest 20, 20032626- *2727- * Functions:2828- *2929- * Revision History:3030- *3131- */3232-3333-#include "ioctl.h"3434-#include "iocmd.h"3535-#include "mac.h"3636-#include "card.h"3737-#include "hostap.h"3838-#include "wpactl.h"3939-#include "control.h"4040-#include "rndis.h"4141-#include "rf.h"4242-4343-SWPAResult wpa_Result;4444-static int msglevel = MSG_LEVEL_INFO;4545-4646-int private_ioctl(PSDevice pDevice, struct ifreq *rq)4747-{4848-4949- PSCmdRequest pReq = (PSCmdRequest)rq;5050- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);5151- int result = 0;5252- PWLAN_IE_SSID pItemSSID;5353- SCmdBSSJoin sJoinCmd;5454- SCmdZoneTypeSet sZoneTypeCmd;5555- SCmdScan sScanCmd;5656- SCmdStartAP sStartAPCmd;5757- SCmdSetWEP sWEPCmd;5858- SCmdValue sValue;5959- SBSSIDList sList;6060- SNodeList sNodeList;6161- PSBSSIDList pList;6262- PSNodeList pNodeList;6363- unsigned int cbListCount;6464- PKnownBSS pBSS;6565- PKnownNodeDB pNode;6666- unsigned int ii, jj;6767- SCmdLinkStatus sLinkStatus;6868- BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};6969- BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};7070- DWORD dwKeyIndex = 0;7171- BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];7272- signed long ldBm;7373-7474- pReq->wResult = 0;7575-7676- switch (pReq->wCmdCode) {7777- case WLAN_CMD_BSS_SCAN:7878- if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {7979- result = -EFAULT;8080- break;8181- }8282-8383- pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;8484- if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)8585- return -EINVAL;8686- if (pItemSSID->len != 0) {8787- memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);8888- memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);8989- }9090- spin_lock_irq(&pDevice->lock);9191-9292- if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)9393- BSSvClearBSSList(pDevice, FALSE);9494- else9595- BSSvClearBSSList(pDevice, pDevice->bLinkPass);9696-9797- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");9898-9999- if (pItemSSID->len != 0)100100- bScheduleCommand(pDevice, WLAN_CMD_BSSID_SCAN,101101- abyScanSSID);102102- else103103- bScheduleCommand(pDevice, WLAN_CMD_BSSID_SCAN, NULL);104104-105105- spin_unlock_irq(&pDevice->lock);106106- break;107107-108108- case WLAN_CMD_ZONETYPE_SET:109109- result = -EOPNOTSUPP;110110- break;111111-112112- if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {113113- result = -EFAULT;114114- break;115115- }116116-117117- if (sZoneTypeCmd.bWrite == TRUE) {118118- /* write zonetype */119119- if (sZoneTypeCmd.ZoneType == ZoneType_USA) {120120- /* set to USA */121121- printk("set_ZoneType:USA\n");122122- } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) {123123- /* set to Japan */124124- printk("set_ZoneType:Japan\n");125125- } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) {126126- /* set to Europe */127127- printk("set_ZoneType:Europe\n");128128- }129129- } else {130130- /* read zonetype */131131- BYTE zonetype = 0;132132-133133- if (zonetype == 0x00) { /* USA */134134- sZoneTypeCmd.ZoneType = ZoneType_USA;135135- } else if (zonetype == 0x01) { /* Japan */136136- sZoneTypeCmd.ZoneType = ZoneType_Japan;137137- } else if (zonetype == 0x02) { /* Europe */138138- sZoneTypeCmd.ZoneType = ZoneType_Europe;139139- } else { /* Unknown ZoneType */140140- printk("Error:ZoneType[%x] Unknown ???\n", zonetype);141141- result = -EFAULT;142142- break;143143- }144144-145145- if (copy_to_user(pReq->data, &sZoneTypeCmd,146146- sizeof(SCmdZoneTypeSet))) {147147- result = -EFAULT;148148- break;149149- }150150- }151151- break;152152-153153- case WLAN_CMD_BSS_JOIN:154154- if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {155155- result = -EFAULT;156156- break;157157- }158158-159159- pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;160160- if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)161161- return -EINVAL;162162- memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);163163- memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);164164- if (sJoinCmd.wBSSType == ADHOC) {165165- pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;166166- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");167167- } else {168168- pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;169169- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");170170- }171171- if (sJoinCmd.bPSEnable == TRUE) {172172- pDevice->ePSMode = WMAC_POWER_FAST;173173- pMgmt->wListenInterval = 2;174174- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");175175- } else {176176- pDevice->ePSMode = WMAC_POWER_CAM;177177- pMgmt->wListenInterval = 1;178178- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n");179179- }180180-181181- if (sJoinCmd.bShareKeyAuth == TRUE) {182182- pMgmt->bShareKeyAlgorithm = TRUE;183183- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");184184- } else {185185- pMgmt->bShareKeyAlgorithm = FALSE;186186- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");187187- }188188-189189- pDevice->uChannel = sJoinCmd.uChannel;190190- netif_stop_queue(pDevice->dev);191191- spin_lock_irq(&pDevice->lock);192192- pMgmt->eCurrState = WMAC_STATE_IDLE;193193- bScheduleCommand(pDevice, WLAN_CMD_BSSID_SCAN,194194- pMgmt->abyDesireSSID);195195- bScheduleCommand(pDevice, WLAN_CMD_SSID, NULL);196196- spin_unlock_irq(&pDevice->lock);197197- break;198198-199199- case WLAN_CMD_SET_WEP:200200- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n");201201- memset(&sWEPCmd, 0, sizeof(SCmdSetWEP));202202- if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {203203- result = -EFAULT;204204- break;205205- }206206- if (sWEPCmd.bEnableWep != TRUE) {207207- int uu;208208-209209- pDevice->bEncryptionEnable = FALSE;210210- pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;211211- spin_lock_irq(&pDevice->lock);212212- for (uu = 0; uu < MAX_KEY_TABLE; uu++)213213- MACvDisableKeyEntry(pDevice, uu);214214- spin_unlock_irq(&pDevice->lock);215215- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n");216216- break;217217- }218218-219219- for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) {220220- if (sWEPCmd.bWepKeyAvailable[ii]) {221221- if (ii == sWEPCmd.byKeyIndex)222222- dwKeyIndex = ii | (1 << 31);223223- else224224- dwKeyIndex = ii;225225- spin_lock_irq(&pDevice->lock);226226- KeybSetDefaultKey(pDevice, &(pDevice->sKey),227227- dwKeyIndex,228228- sWEPCmd.auWepKeyLength[ii],229229- NULL,230230- (PBYTE)&sWEPCmd.abyWepKey[ii][0],231231- KEY_CTL_WEP);232232- spin_unlock_irq(&pDevice->lock);233233- }234234- }235235- pDevice->byKeyIndex = sWEPCmd.byKeyIndex;236236- pDevice->bTransmitKey = TRUE;237237- pDevice->bEncryptionEnable = TRUE;238238- pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;239239- break;240240-241241- case WLAN_CMD_GET_LINK:242242- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n");243243-244244- memset(sLinkStatus.abySSID, 0, WLAN_SSID_MAXLEN + 1);245245-246246- if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)247247- sLinkStatus.wBSSType = ADHOC;248248- else249249- sLinkStatus.wBSSType = INFRA;250250-251251- if (pMgmt->eCurrState == WMAC_STATE_JOINTED)252252- sLinkStatus.byState = ADHOC_JOINTED;253253- else254254- sLinkStatus.byState = ADHOC_STARTED;255255-256256- sLinkStatus.uChannel = pMgmt->uCurrChannel;257257- if (pDevice->bLinkPass == TRUE) {258258- sLinkStatus.bLink = TRUE;259259- pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;260260- memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);261261- memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);262262- sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;263263- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Link Success!\n");264264- } else {265265- sLinkStatus.bLink = FALSE;266266- sLinkStatus.uLinkRate = 0;267267- }268268- if (copy_to_user(pReq->data, &sLinkStatus,269269- sizeof(SCmdLinkStatus))) {270270- result = -EFAULT;271271- break;272272- }273273- break;274274-275275- case WLAN_CMD_GET_LISTLEN:276276- cbListCount = 0;277277- pBSS = &(pMgmt->sBSSList[0]);278278- for (ii = 0; ii < MAX_BSS_NUM; ii++) {279279- pBSS = &(pMgmt->sBSSList[ii]);280280- if (!pBSS->bActive)281281- continue;282282- cbListCount++;283283- }284284- sList.uItem = cbListCount;285285- if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {286286- result = -EFAULT;287287- break;288288- }289289- pReq->wResult = 0;290290- break;291291-292292- case WLAN_CMD_GET_LIST:293293- if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {294294- result = -EFAULT;295295- break;296296- }297297- if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) {298298- result = -EINVAL;299299- break;300300- }301301- pList = kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), GFP_ATOMIC);302302- if (pList == NULL) {303303- result = -ENOMEM;304304- break;305305- }306306- pList->uItem = sList.uItem;307307- pBSS = &(pMgmt->sBSSList[0]);308308- for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {309309- pBSS = &(pMgmt->sBSSList[jj]);310310- if (pBSS->bActive) {311311- pList->sBSSIDList[ii].uChannel = pBSS->uChannel;312312- pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;313313- pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;314314- RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);315315- pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;316316- /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */317317- memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);318318- pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;319319- memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);320320- memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);321321- if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {322322- pList->sBSSIDList[ii].byNetType = INFRA;323323- } else {324324- pList->sBSSIDList[ii].byNetType = ADHOC;325325- }326326- if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {327327- pList->sBSSIDList[ii].bWEPOn = TRUE;328328- } else {329329- pList->sBSSIDList[ii].bWEPOn = FALSE;330330- }331331- ii++;332332- if (ii >= pList->uItem)333333- break;334334- }335335- }336336-337337- if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {338338- result = -EFAULT;339339- break;340340- }341341- kfree(pList);342342- pReq->wResult = 0;343343- break;344344-345345- case WLAN_CMD_GET_MIB:346346- if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {347347- result = -EFAULT;348348- break;349349- }350350- break;351351-352352- case WLAN_CMD_GET_STAT:353353- if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {354354- result = -EFAULT;355355- break;356356- }357357- break;358358-359359- case WLAN_CMD_STOP_MAC:360360- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");361361- /* Todo xxxxxx */362362- netif_stop_queue(pDevice->dev);363363- spin_lock_irq(&pDevice->lock);364364- if (pDevice->bRadioOff == FALSE) {365365- CARDbRadioPowerOff(pDevice);366366- }367367- pDevice->bLinkPass = FALSE;368368- ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);369369- memset(pMgmt->abyCurrBSSID, 0, 6);370370- pMgmt->eCurrState = WMAC_STATE_IDLE;371371- /* del_timer(&pDevice->sTimerCommand); */372372- /* del_timer(&pMgmt->sTimerSecondCallback); */373373- pDevice->bCmdRunning = FALSE;374374- spin_unlock_irq(&pDevice->lock);375375- break;376376-377377- case WLAN_CMD_START_MAC:378378- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");379379- /* Todo xxxxxxx */380380- if (pDevice->bRadioOff == TRUE)381381- CARDbRadioPowerOn(pDevice);382382- break;383383-384384- case WLAN_CMD_SET_HOSTAPD:385385- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");386386-387387- if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {388388- result = -EFAULT;389389- break;390390- }391391- if (sValue.dwValue == 1) {392392- if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0) {393393- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");394394- } else {395395- result = -EFAULT;396396- break;397397- }398398- } else {399399- vt6656_hostap_set_hostapd(pDevice, 0, 1);400400- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");401401- }402402- break;403403-404404- case WLAN_CMD_SET_HOSTAPD_STA:405405- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");406406- break;407407-408408- case WLAN_CMD_SET_802_1X:409409- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");410410- if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {411411- result = -EFAULT;412412- break;413413- }414414-415415- if (sValue.dwValue == 1) {416416- pDevice->bEnable8021x = TRUE;417417- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");418418- } else {419419- pDevice->bEnable8021x = FALSE;420420- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");421421- }422422- break;423423-424424- case WLAN_CMD_SET_HOST_WEP:425425- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");426426- if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {427427- result = -EFAULT;428428- break;429429- }430430-431431- if (sValue.dwValue == 1) {432432- pDevice->bEnableHostWEP = TRUE;433433- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");434434- } else {435435- pDevice->bEnableHostWEP = FALSE;436436- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");437437- }438438- break;439439-440440- case WLAN_CMD_SET_WPA:441441- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");442442-443443- if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {444444- result = -EFAULT;445445- break;446446- }447447- if (sValue.dwValue == 1) {448448- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");449449- memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr,450450- ETH_ALEN);451451- pDevice->bWPADEVUp = TRUE;452452- } else {453453- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");454454- pDevice->bWPADEVUp = FALSE;455455- }456456- break;457457-458458- case WLAN_CMD_AP_START:459459- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");460460- if (pDevice->bRadioOff == TRUE) {461461- CARDbRadioPowerOn(pDevice);462462- add_timer(&pMgmt->sTimerSecondCallback);463463- }464464- if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {465465- result = -EFAULT;466466- break;467467- }468468-469469- if (sStartAPCmd.wBSSType == AP) {470470- pMgmt->eConfigMode = WMAC_CONFIG_AP;471471- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");472472- } else {473473- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");474474- result = -EFAULT;475475- break;476476- }477477-478478- if (sStartAPCmd.wBBPType == PHY80211g) {479479- pMgmt->byAPBBType = PHY_TYPE_11G;480480- } else if (sStartAPCmd.wBBPType == PHY80211a) {481481- pMgmt->byAPBBType = PHY_TYPE_11A;482482- } else {483483- pMgmt->byAPBBType = PHY_TYPE_11B;484484- }485485-486486- pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;487487- if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)488488- return -EINVAL;489489- memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);490490- memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);491491-492492- if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))493493- pDevice->uChannel = sStartAPCmd.uChannel;494494-495495- if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))496496- pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;497497- else498498- pMgmt->wIBSSBeaconPeriod = 100;499499-500500- if (sStartAPCmd.bShareKeyAuth == TRUE) {501501- pMgmt->bShareKeyAlgorithm = TRUE;502502- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");503503- } else {504504- pMgmt->bShareKeyAlgorithm = FALSE;505505- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");506506- }507507- memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);508508-509509- if (sStartAPCmd.byBasicRate & BIT3) {510510- pMgmt->abyIBSSSuppRates[2] |= BIT7;511511- pMgmt->abyIBSSSuppRates[3] |= BIT7;512512- pMgmt->abyIBSSSuppRates[4] |= BIT7;513513- pMgmt->abyIBSSSuppRates[5] |= BIT7;514514- } else if (sStartAPCmd.byBasicRate & BIT2) {515515- pMgmt->abyIBSSSuppRates[2] |= BIT7;516516- pMgmt->abyIBSSSuppRates[3] |= BIT7;517517- pMgmt->abyIBSSSuppRates[4] |= BIT7;518518- } else if (sStartAPCmd.byBasicRate & BIT1) {519519- pMgmt->abyIBSSSuppRates[2] |= BIT7;520520- pMgmt->abyIBSSSuppRates[3] |= BIT7;521521- } else if (sStartAPCmd.byBasicRate & BIT1) {522522- pMgmt->abyIBSSSuppRates[2] |= BIT7;523523- } else {524524- /* default 1,2M */525525- pMgmt->abyIBSSSuppRates[2] |= BIT7;526526- pMgmt->abyIBSSSuppRates[3] |= BIT7;527527- }528528-529529- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %*ph\n",530530- 4, pMgmt->abyIBSSSuppRates + 2);531531-532532- netif_stop_queue(pDevice->dev);533533- spin_lock_irq(&pDevice->lock);534534- bScheduleCommand(pDevice, WLAN_CMD_RUN_AP, NULL);535535- spin_unlock_irq(&pDevice->lock);536536- break;537537-538538- case WLAN_CMD_GET_NODE_CNT:539539- cbListCount = 0;540540- pNode = &(pMgmt->sNodeDBTable[0]);541541- for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {542542- pNode = &(pMgmt->sNodeDBTable[ii]);543543- if (!pNode->bActive)544544- continue;545545- cbListCount++;546546- }547547-548548- sNodeList.uItem = cbListCount;549549- if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {550550- result = -EFAULT;551551- break;552552- }553553- pReq->wResult = 0;554554- break;555555-556556- case WLAN_CMD_GET_NODE_LIST:557557- if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {558558- result = -EFAULT;559559- break;560560- }561561- if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) {562562- result = -ENOMEM;563563- break;564564- }565565- pNodeList = kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), GFP_ATOMIC);566566- if (pNodeList == NULL) {567567- result = -ENOMEM;568568- break;569569- }570570- pNodeList->uItem = sNodeList.uItem;571571- pNode = &(pMgmt->sNodeDBTable[0]);572572- for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {573573- pNode = &(pMgmt->sNodeDBTable[ii]);574574- if (pNode->bActive) {575575- pNodeList->sNodeList[jj].wAID = pNode->wAID;576576- memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);577577- pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;578578- pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;579579- pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;580580- pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;581581- pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;582582- pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;583583- pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;584584- memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);585585- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",586586- pNodeList->sNodeList[jj].abyWepKey[0],587587- pNodeList->sNodeList[jj].abyWepKey[1],588588- pNodeList->sNodeList[jj].abyWepKey[2],589589- pNodeList->sNodeList[jj].abyWepKey[3],590590- pNodeList->sNodeList[jj].abyWepKey[4]);591591- pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;592592- pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;593593- pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;594594- pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;595595- jj++;596596- if (jj >= pNodeList->uItem)597597- break;598598- }599599- }600600- if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {601601- kfree(pNodeList);602602- result = -EFAULT;603603- break;604604- }605605- kfree(pNodeList);606606- pReq->wResult = 0;607607- break;608608-609609- case 0xFF:610610- memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));611611- wpa_Result.proto = 0;612612- wpa_Result.key_mgmt = 0;613613- wpa_Result.eap_type = 0;614614- wpa_Result.authenticated = FALSE;615615- pDevice->fWPA_Authened = FALSE;616616- if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {617617- result = -EFAULT;618618- break;619619- }620620- /* for some AP's maybe a good authentication */621621- if (wpa_Result.key_mgmt == 0x20)622622- pMgmt->Cisco_cckm = 1;623623- else624624- pMgmt->Cisco_cckm = 0;625625-626626- if (wpa_Result.authenticated == TRUE) {627627- {628628- union iwreq_data wrqu;629629-630630- pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;631631- memset(&wrqu, 0, sizeof(wrqu));632632- wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;633633- wrqu.data.length = pItemSSID->len;634634- wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);635635- }636636-637637- pDevice->fWPA_Authened = TRUE; /* is successful peer to wpa_Result.authenticated? */638638- }639639-640640- pReq->wResult = 0;641641- break;642642-643643- default:644644- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not supported..\n");645645- }646646-647647- return result;648648-}
-54
drivers/staging/vt6656/ioctl.h
···11-/*22- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.33- * All rights reserved.44- *55- * This program is free software; you can redistribute it and/or modify66- * it under the terms of the GNU General Public License as published by77- * the Free Software Foundation; either version 2 of the License, or88- * (at your option) any later version.99- *1010- * This program is distributed in the hope that it will be useful,1111- * but WITHOUT ANY WARRANTY; without even the implied warranty of1212- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313- * GNU General Public License for more details.1414- *1515- * You should have received a copy of the GNU General Public License along1616- * with this program; if not, write to the Free Software Foundation, Inc.,1717- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.1818- *1919- * File: hostap.h2020- *2121- * Purpose:2222- *2323- * Author: Lyndon Chen2424- *2525- * Date: May 21, 20032626- *2727- */2828-2929-#ifndef __IOCTL_H__3030-#define __IOCTL_H__3131-3232-#include "device.h"3333-3434-/*--------------------- Export Definitions -------------------------*/3535-3636-3737-/*--------------------- Export Classes ----------------------------*/3838-3939-/*--------------------- Export Variables --------------------------*/4040-4141-/*--------------------- Export Functions --------------------------*/4242-4343-int private_ioctl(PSDevice pDevice, struct ifreq *rq);4444-4545-/*4646-void vConfigWEPKey (4747- PSDevice pDevice,4848- DWORD dwKeyIndex,4949- PBYTE pbyKey,5050- unsigned long uKeyLength5151- );5252-*/5353-5454-#endif /* __IOCTL_H__ */