···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- *2020- * File: wpactl.c2121- *2222- * Purpose: handle wpa supplicant ioctl input/out functions2323- *2424- * Author: Lyndon Chen2525- *2626- * Date: Oct. 20, 20032727- *2828- * Functions:2929- *3030- * Revision History:3131- *3232- */3333-3434-#include "wpactl.h"3535-#include "key.h"3636-#include "mac.h"3737-#include "device.h"3838-#include "wmgr.h"3939-#include "iocmd.h"4040-#include "iowpa.h"4141-#include "rf.h"4242-4343-/*--------------------- Static Definitions -------------------------*/4444-4545-#define VIAWGET_WPA_MAX_BUF_SIZE 10244646-4747-static const int frequency_list[] = {4848- 2412, 2417, 2422, 2427, 2432, 2437, 2442,4949- 2447, 2452, 2457, 2462, 2467, 2472, 24845050-};5151-/*--------------------- Static Classes ----------------------------*/5252-5353-/*--------------------- Static Functions --------------------------*/5454-5555-/*--------------------- Export Variables --------------------------*/5656-static void wpadev_setup(struct net_device *dev)5757-{5858- dev->type = ARPHRD_IEEE80211;5959- dev->hard_header_len = ETH_HLEN;6060- dev->mtu = 2048;6161- dev->addr_len = ETH_ALEN;6262- dev->tx_queue_len = 1000;6363-6464- memset(dev->broadcast, 0xFF, ETH_ALEN);6565-6666- dev->flags = IFF_BROADCAST|IFF_MULTICAST;6767-}6868-6969-/*7070- * Description:7171- * register netdev for wpa supplicant daemon7272- *7373- * Parameters:7474- * In:7575- * pDevice -7676- * enable -7777- * Out:7878- *7979- * Return Value:8080- *8181- */8282-8383-static int wpa_init_wpadev(struct vnt_private *pDevice)8484-{8585- struct vnt_private *wpadev_priv;8686- struct net_device *dev = pDevice->dev;8787- int ret = 0;8888-8989- pDevice->wpadev = alloc_netdev(sizeof(*wpadev_priv), "vntwpa",9090- NET_NAME_UNKNOWN, wpadev_setup);9191- if (pDevice->wpadev == NULL)9292- return -ENOMEM;9393-9494- wpadev_priv = netdev_priv(pDevice->wpadev);9595- *wpadev_priv = *pDevice;9696- eth_hw_addr_inherit(pDevice->wpadev, dev);9797- pDevice->wpadev->base_addr = dev->base_addr;9898- pDevice->wpadev->irq = dev->irq;9999- pDevice->wpadev->mem_start = dev->mem_start;100100- pDevice->wpadev->mem_end = dev->mem_end;101101- ret = register_netdev(pDevice->wpadev);102102- if (ret) {103103- pr_debug("%s: register_netdev(WPA) failed!\n", dev->name);104104- free_netdev(pDevice->wpadev);105105- return -1;106106- }107107-108108- if (pDevice->skb == NULL) {109109- pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);110110- if (pDevice->skb == NULL)111111- return -ENOMEM;112112- }113113-114114- pr_debug("%s: Registered netdev %s for WPA management\n",115115- dev->name, pDevice->wpadev->name);116116-117117- return 0;118118-}119119-120120-/*121121- * Description:122122- * unregister net_device (wpadev)123123- *124124- * Parameters:125125- * In:126126- * pDevice -127127- * Out:128128- *129129- * Return Value:130130- *131131- */132132-133133-static int wpa_release_wpadev(struct vnt_private *pDevice)134134-{135135- if (pDevice->skb) {136136- dev_kfree_skb(pDevice->skb);137137- pDevice->skb = NULL;138138- }139139-140140- if (pDevice->wpadev) {141141- pr_debug("%s: Netdevice %s unregistered\n",142142- pDevice->dev->name, pDevice->wpadev->name);143143- unregister_netdev(pDevice->wpadev);144144- free_netdev(pDevice->wpadev);145145- pDevice->wpadev = NULL;146146- }147147-148148- return 0;149149-}150150-151151-/*152152- * Description:153153- * Set enable/disable dev for wpa supplicant daemon154154- *155155- * Parameters:156156- * In:157157- * pDevice -158158- * val -159159- * Out:160160- *161161- * Return Value:162162- *163163- */164164-165165-int wpa_set_wpadev(struct vnt_private *pDevice, int val)166166-{167167- if (val)168168- return wpa_init_wpadev(pDevice);169169- else170170- return wpa_release_wpadev(pDevice);171171-}172172-173173-/*174174- * Description:175175- * Set WPA algorithm & keys176176- *177177- * Parameters:178178- * In:179179- * pDevice -180180- * param -181181- * Out:182182- *183183- * Return Value:184184- *185185- */186186-187187-int wpa_set_keys(struct vnt_private *pDevice, void *ctx,188188- bool fcpfkernel) __must_hold(&pDevice->lock)189189-{190190- struct viawget_wpa_param *param = ctx;191191- PSMgmtObject pMgmt = pDevice->pMgmt;192192- unsigned long dwKeyIndex = 0;193193- unsigned char abyKey[MAX_KEY_LEN];194194- unsigned char abySeq[MAX_KEY_LEN];195195- u64 KeyRSC;196196- unsigned char byKeyDecMode = KEY_CTL_WEP;197197- int ret = 0;198198- int uu, ii;199199-200200- if (param->u.wpa_key.alg_name > WPA_ALG_CCMP ||201201- param->u.wpa_key.key_len > MAX_KEY_LEN ||202202- param->u.wpa_key.seq_len > MAX_KEY_LEN)203203- return -EINVAL;204204-205205- pr_debug("param->u.wpa_key.alg_name = %d\n", param->u.wpa_key.alg_name);206206- if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {207207- pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;208208- pDevice->bEncryptionEnable = false;209209- pDevice->byKeyIndex = 0;210210- pDevice->bTransmitKey = false;211211- KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset);212212- for (uu = 0; uu < MAX_KEY_TABLE; uu++)213213- MACvDisableKeyEntry(pDevice->PortOffset, uu);214214-215215- return ret;216216- }217217-218218- if (param->u.wpa_key.key && fcpfkernel) {219219- memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len);220220- } else {221221- spin_unlock_irq(&pDevice->lock);222222- if (param->u.wpa_key.key &&223223- copy_from_user(&abyKey[0],224224- (void __user *)param->u.wpa_key.key,225225- param->u.wpa_key.key_len)) {226226- spin_lock_irq(&pDevice->lock);227227- return -EINVAL;228228- }229229- spin_lock_irq(&pDevice->lock);230230- }231231-232232- dwKeyIndex = (unsigned long)(param->u.wpa_key.key_index);233233-234234- if (param->u.wpa_key.alg_name == WPA_ALG_WEP) {235235- if (dwKeyIndex > 3) {236236- return -EINVAL;237237- } else {238238- if (param->u.wpa_key.set_tx) {239239- pDevice->byKeyIndex = (unsigned char)dwKeyIndex;240240- pDevice->bTransmitKey = true;241241- dwKeyIndex |= (1 << 31);242242- }243243- KeybSetDefaultKey(&(pDevice->sKey),244244- dwKeyIndex & ~(BIT30 | USE_KEYRSC),245245- param->u.wpa_key.key_len,246246- NULL,247247- abyKey,248248- KEY_CTL_WEP,249249- pDevice->PortOffset,250250- pDevice->byLocalID);251251-252252- }253253- pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;254254- pDevice->bEncryptionEnable = true;255255- return ret;256256- }257257-258258- if (param->u.wpa_key.seq && fcpfkernel) {259259- memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len);260260- } else {261261- spin_unlock_irq(&pDevice->lock);262262- if (param->u.wpa_key.seq &&263263- copy_from_user(&abySeq[0],264264- (void __user *)param->u.wpa_key.seq,265265- param->u.wpa_key.seq_len)) {266266- spin_lock_irq(&pDevice->lock);267267- return -EINVAL;268268- }269269- spin_lock_irq(&pDevice->lock);270270- }271271-272272- if (param->u.wpa_key.seq_len > 0) {273273- for (ii = 0; ii < param->u.wpa_key.seq_len; ii++) {274274- if (ii < 4)275275- KeyRSC |= (u64)(abySeq[ii] << (ii * 8));276276- else277277- KeyRSC |= (u64)(abySeq[ii] << ((ii-4) * 8));278278- }279279- dwKeyIndex |= 1 << 29;280280- }281281-282282- if (param->u.wpa_key.key_index >= MAX_GROUP_KEY) {283283- pr_debug("return dwKeyIndex > 3\n");284284- return -EINVAL;285285- }286286-287287- if (param->u.wpa_key.alg_name == WPA_ALG_TKIP)288288- pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;289289-290290- if (param->u.wpa_key.alg_name == WPA_ALG_CCMP)291291- pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;292292-293293- if (param->u.wpa_key.set_tx)294294- dwKeyIndex |= (1 << 31);295295-296296- if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)297297- byKeyDecMode = KEY_CTL_CCMP;298298- else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled)299299- byKeyDecMode = KEY_CTL_TKIP;300300- else301301- byKeyDecMode = KEY_CTL_WEP;302302-303303- /* Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled */304304- if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) {305305- if (param->u.wpa_key.key_len == MAX_KEY_LEN)306306- byKeyDecMode = KEY_CTL_TKIP;307307- else if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN)308308- byKeyDecMode = KEY_CTL_WEP;309309- else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN)310310- byKeyDecMode = KEY_CTL_WEP;311311- } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {312312- if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN)313313- byKeyDecMode = KEY_CTL_WEP;314314- else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN)315315- byKeyDecMode = KEY_CTL_WEP;316316- }317317-318318- /* Check TKIP key length */319319- if ((byKeyDecMode == KEY_CTL_TKIP) &&320320- (param->u.wpa_key.key_len != MAX_KEY_LEN)) {321321- /* TKIP Key must be 256 bits */322322- pr_debug("return- TKIP Key must be 256 bits!\n");323323- return -EINVAL;324324- }325325- /* Check AES key length */326326- if ((byKeyDecMode == KEY_CTL_CCMP) &&327327- (param->u.wpa_key.key_len != AES_KEY_LEN)) {328328- /* AES Key must be 128 bits */329329- return -EINVAL;330330- }331331-332332- /* spin_lock_irq(&pDevice->lock); */333333- if (is_broadcast_ether_addr(¶m->addr[0]) || (param->addr == NULL)) {334334- /* If is_broadcast_ether_addr, set the key as every key entry's group key. */335335- pr_debug("Groupe Key Assign\n");336336-337337- if (KeybSetAllGroupKey(&(pDevice->sKey),338338- dwKeyIndex,339339- param->u.wpa_key.key_len,340340- (u64 *) &KeyRSC,341341- (unsigned char *)abyKey,342342- byKeyDecMode,343343- pDevice->PortOffset,344344- pDevice->byLocalID) &&345345- KeybSetDefaultKey(&(pDevice->sKey),346346- dwKeyIndex,347347- param->u.wpa_key.key_len,348348- (u64 *) &KeyRSC,349349- (unsigned char *)abyKey,350350- byKeyDecMode,351351- pDevice->PortOffset,352352- pDevice->byLocalID)) {353353- pr_debug("GROUP Key Assign\n");354354-355355- } else {356356- return -EINVAL;357357- }358358-359359- } else {360360- pr_debug("Pairwise Key Assign\n");361361- /* BSSID not 0xffffffffffff */362362- /* Pairwise Key can't be WEP */363363- if (byKeyDecMode == KEY_CTL_WEP) {364364- pr_debug("Pairwise Key can't be WEP\n");365365- return -EINVAL;366366- }367367-368368- dwKeyIndex |= (1 << 30); /* set pairwise key */369369- if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA)370370- return -EINVAL;371371-372372- if (KeybSetKey(&(pDevice->sKey),373373- ¶m->addr[0],374374- dwKeyIndex,375375- param->u.wpa_key.key_len,376376- (u64 *) &KeyRSC,377377- (unsigned char *)abyKey,378378- byKeyDecMode,379379- pDevice->PortOffset,380380- pDevice->byLocalID)) {381381- pr_debug("Pairwise Key Set\n");382382-383383- } else {384384- /* Key Table Full */385385- return -EINVAL;386386- }387387- } /* BSSID not 0xffffffffffff */388388- if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) {389389- pDevice->byKeyIndex = (unsigned char)param->u.wpa_key.key_index;390390- pDevice->bTransmitKey = true;391391- }392392- pDevice->bEncryptionEnable = true;393393-394394- return ret;395395-}396396-397397-/*398398- * Description:399399- * enable wpa auth & mode400400- *401401- * Parameters:402402- * In:403403- * pDevice -404404- * param -405405- * Out:406406- *407407- * Return Value:408408- *409409- */410410-411411-static int wpa_set_wpa(struct vnt_private *pDevice,412412- struct viawget_wpa_param *param)413413-{414414- PSMgmtObject pMgmt = pDevice->pMgmt;415415-416416- pMgmt->eAuthenMode = WMAC_AUTH_OPEN;417417- pMgmt->bShareKeyAlgorithm = false;418418-419419- return 0;420420-}421421-422422-/*423423- * Description:424424- * set disassociate425425- *426426- * Parameters:427427- * In:428428- * pDevice -429429- * param -430430- * Out:431431- *432432- * Return Value:433433- *434434- */435435-436436-static int wpa_set_disassociate(struct vnt_private *pDevice,437437- struct viawget_wpa_param *param)438438-{439439- PSMgmtObject pMgmt = pDevice->pMgmt;440440-441441- spin_lock_irq(&pDevice->lock);442442- if (pDevice->bLinkPass) {443443- if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6))444444- bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);445445- }446446- spin_unlock_irq(&pDevice->lock);447447-448448- return 0;449449-}450450-451451-/*452452- * Description:453453- * enable scan process454454- *455455- * Parameters:456456- * In:457457- * pDevice -458458- * param -459459- * Out:460460- *461461- * Return Value:462462- *463463- */464464-465465-static int wpa_set_scan(struct vnt_private *pDevice,466466- struct viawget_wpa_param *param)467467-{468468- spin_lock_irq(&pDevice->lock);469469- BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);470470- bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);471471- spin_unlock_irq(&pDevice->lock);472472-473473- return 0;474474-}475475-476476-/*477477- * Description:478478- * get bssid479479- *480480- * Parameters:481481- * In:482482- * pDevice -483483- * param -484484- * Out:485485- *486486- * Return Value:487487- *488488- */489489-490490-static int wpa_get_bssid(struct vnt_private *pDevice,491491- struct viawget_wpa_param *param)492492-{493493- PSMgmtObject pMgmt = pDevice->pMgmt;494494-495495- memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6);496496-497497- return 0;498498-}499499-500500-/*501501- * Description:502502- * get bssid503503- *504504- * Parameters:505505- * In:506506- * pDevice -507507- * param -508508- * Out:509509- *510510- * Return Value:511511- *512512- */513513-514514-static int wpa_get_ssid(struct vnt_private *pDevice,515515- struct viawget_wpa_param *param)516516-{517517- PSMgmtObject pMgmt = pDevice->pMgmt;518518- PWLAN_IE_SSID pItemSSID;519519-520520- pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;521521-522522- memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len);523523- param->u.wpa_associate.ssid_len = pItemSSID->len;524524-525525- return 0;526526-}527527-528528-/*529529- * Description:530530- * get scan results531531- *532532- * Parameters:533533- * In:534534- * pDevice -535535- * param -536536- * Out:537537- *538538- * Return Value:539539- *540540- */541541-542542-static int wpa_get_scan(struct vnt_private *pDevice,543543- struct viawget_wpa_param *param)544544-{545545- struct viawget_scan_result *scan_buf;546546- PSMgmtObject pMgmt = pDevice->pMgmt;547547- PWLAN_IE_SSID pItemSSID;548548- PKnownBSS pBSS;549549- unsigned char *pBuf;550550- int ret = 0;551551- u16 count = 0;552552- u16 ii, jj;553553- unsigned char *ptempBSS;554554-555555- ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC);556556-557557- if (ptempBSS == NULL) {558558- pr_err("bubble sort kmalloc memory fail@@@\n");559559-560560- ret = -ENOMEM;561561-562562- return ret;563563-564564- }565565-566566- for (ii = 0; ii < MAX_BSS_NUM; ii++) {567567- for (jj = 0; jj < MAX_BSS_NUM - ii - 1; jj++) {568568- if ((pMgmt->sBSSList[jj].bActive != true) ||569569-570570- ((pMgmt->sBSSList[jj].uRSSI > pMgmt->sBSSList[jj + 1].uRSSI) && (pMgmt->sBSSList[jj + 1].bActive != false))) {571571- memcpy(ptempBSS, &pMgmt->sBSSList[jj], sizeof(KnownBSS));572572-573573- memcpy(&pMgmt->sBSSList[jj], &pMgmt->sBSSList[jj + 1], sizeof(KnownBSS));574574-575575- memcpy(&pMgmt->sBSSList[jj + 1], ptempBSS, sizeof(KnownBSS));576576-577577- }578578-579579- }580580-581581- }582582-583583- kfree(ptempBSS);584584-585585-//******mike:bubble sort by stronger RSSI*****//586586-587587- count = 0;588588- pBSS = &(pMgmt->sBSSList[0]);589589- for (ii = 0; ii < MAX_BSS_NUM; ii++) {590590- pBSS = &(pMgmt->sBSSList[ii]);591591- if (!pBSS->bActive)592592- continue;593593- count++;594594- }595595-596596- pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC);597597-598598- if (pBuf == NULL) {599599- ret = -ENOMEM;600600- return ret;601601- }602602- scan_buf = (struct viawget_scan_result *)pBuf;603603- pBSS = &(pMgmt->sBSSList[0]);604604- for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) {605605- pBSS = &(pMgmt->sBSSList[ii]);606606- if (pBSS->bActive) {607607- if (jj >= count)608608- break;609609- memcpy(scan_buf->bssid, pBSS->abyBSSID, WLAN_BSSID_LEN);610610- pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;611611- memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len);612612- scan_buf->ssid_len = pItemSSID->len;613613- scan_buf->freq = frequency_list[pBSS->uChannel-1];614614- scan_buf->caps = pBSS->wCapInfo;615615-616616- if (pBSS->wWPALen != 0) {617617- scan_buf->wpa_ie_len = pBSS->wWPALen;618618- memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen);619619- }620620- if (pBSS->wRSNLen != 0) {621621- scan_buf->rsn_ie_len = pBSS->wRSNLen;622622- memcpy(scan_buf->rsn_ie, pBSS->byRSNIE, pBSS->wRSNLen);623623- }624624- scan_buf = (struct viawget_scan_result *)((unsigned char *)scan_buf + sizeof(struct viawget_scan_result));625625- jj++;626626- }627627- }628628-629629- if (jj < count)630630- count = jj;631631-632632- if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count))633633- ret = -EFAULT;634634-635635- param->u.scan_results.scan_count = count;636636- pr_debug(" param->u.scan_results.scan_count = %d\n", count);637637-638638- kfree(pBuf);639639- return ret;640640-}641641-642642-/*643643- * Description:644644- * set associate with AP645645- *646646- * Parameters:647647- * In:648648- * pDevice -649649- * param -650650- * Out:651651- *652652- * Return Value:653653- *654654- */655655-656656-static int wpa_set_associate(struct vnt_private *pDevice,657657- struct viawget_wpa_param *param)658658-{659659- PSMgmtObject pMgmt = pDevice->pMgmt;660660- PWLAN_IE_SSID pItemSSID;661661- unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};662662- unsigned char abyWPAIE[64];663663- bool bWepEnabled = false;664664-665665- /* set key type & algorithm */666666- pr_debug("pairwise_suite = %d\n",667667- param->u.wpa_associate.pairwise_suite);668668- pr_debug("group_suite = %d\n", param->u.wpa_associate.group_suite);669669- pr_debug("key_mgmt_suite = %d\n",670670- param->u.wpa_associate.key_mgmt_suite);671671- pr_debug("auth_alg = %d\n", param->u.wpa_associate.auth_alg);672672- pr_debug("mode = %d\n", param->u.wpa_associate.mode);673673- pr_debug("wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len);674674-675675- if (param->u.wpa_associate.wpa_ie_len) {676676- if (!param->u.wpa_associate.wpa_ie)677677- return -EINVAL;678678- if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE))679679- return -EINVAL;680680- if (copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, param->u.wpa_associate.wpa_ie_len))681681- return -EFAULT;682682- }683683-684684- if (param->u.wpa_associate.mode == 1)685685- pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;686686- else687687- pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;688688- /* set ssid */689689- memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);690690- pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;691691- pItemSSID->byElementID = WLAN_EID_SSID;692692- pItemSSID->len = param->u.wpa_associate.ssid_len;693693- memcpy(pItemSSID->abySSID, param->u.wpa_associate.ssid, pItemSSID->len);694694- /* set bssid */695695- if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0)696696- memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6);697697- else698698- bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID);699699-700700- if (param->u.wpa_associate.wpa_ie_len == 0) {701701- if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY)702702- pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY;703703- else704704- pMgmt->eAuthenMode = WMAC_AUTH_OPEN;705705- } else if (abyWPAIE[0] == RSN_INFO_ELEM) {706706- if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK)707707- pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;708708- else709709- pMgmt->eAuthenMode = WMAC_AUTH_WPA2;710710- } else {711711- if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_WPA_NONE)712712- pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;713713- else if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK)714714- pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;715715- else716716- pMgmt->eAuthenMode = WMAC_AUTH_WPA;717717- }718718-719719- switch (param->u.wpa_associate.pairwise_suite) {720720- case CIPHER_CCMP:721721- pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;722722- break;723723- case CIPHER_TKIP:724724- pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;725725- break;726726- case CIPHER_WEP40:727727- case CIPHER_WEP104:728728- pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;729729- bWepEnabled = true;730730- break;731731- case CIPHER_NONE:732732- if (param->u.wpa_associate.group_suite == CIPHER_CCMP)733733- pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;734734- else735735- pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;736736- break;737737- default:738738- pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;739739- }740740-741741-//DavidWang add for WPA_supplicant support open/share mode742742-743743- if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) {744744- pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;745745- pMgmt->bShareKeyAlgorithm = true;746746- } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) {747747- if (!bWepEnabled) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;748748- else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;749749- }750750-//mike save old encryption status751751- pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus;752752-753753- if (pDevice->eEncryptionStatus != Ndis802_11EncryptionDisabled)754754- pDevice->bEncryptionEnable = true;755755- else756756- pDevice->bEncryptionEnable = false;757757- if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) ||758758- ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && bWepEnabled))) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP759759- KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);760760- spin_lock_irq(&pDevice->lock);761761- pDevice->bLinkPass = false;762762- memset(pMgmt->abyCurrBSSID, 0, 6);763763- pMgmt->eCurrState = WMAC_STATE_IDLE;764764- netif_stop_queue(pDevice->dev);765765- //20080701-02,<Add> by Mike Liu766766-/*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/767767- {768768- PKnownBSS pCurr = NULL;769769-770770- pCurr = BSSpSearchBSSList(pDevice,771771- pMgmt->abyDesireBSSID,772772- pMgmt->abyDesireSSID,773773- pMgmt->eConfigPHYMode774774-);775775-776776- if (pCurr == NULL) {777777- pr_debug("wpa_set_associate---->hidden mode site survey before associate.......\n");778778- bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);779779- }780780- }781781-/****************************************************************/782782- bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);783783- spin_unlock_irq(&pDevice->lock);784784-785785- return 0;786786-}787787-788788-/*789789- * Description:790790- * wpa_ioctl main function supported for wpa supplicant791791- *792792- * Parameters:793793- * In:794794- * pDevice -795795- * iw_point -796796- * Out:797797- *798798- * Return Value:799799- *800800- */801801-802802-int wpa_ioctl(struct vnt_private *pDevice, struct iw_point *p)803803-{804804- struct viawget_wpa_param *param;805805- int ret = 0;806806- int wpa_ioctl = 0;807807-808808- if (p->length < sizeof(struct viawget_wpa_param) ||809809- p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer)810810- return -EINVAL;811811-812812- param = kmalloc((int)p->length, GFP_KERNEL);813813- if (param == NULL)814814- return -ENOMEM;815815-816816- if (copy_from_user(param, p->pointer, p->length)) {817817- ret = -EFAULT;818818- goto out;819819- }820820-821821- switch (param->cmd) {822822- case VIAWGET_SET_WPA:823823- ret = wpa_set_wpa(pDevice, param);824824- pr_debug("VIAWGET_SET_WPA\n");825825- break;826826-827827- case VIAWGET_SET_KEY:828828- pr_debug("VIAWGET_SET_KEY\n");829829- spin_lock_irq(&pDevice->lock);830830- ret = wpa_set_keys(pDevice, param, false);831831- spin_unlock_irq(&pDevice->lock);832832- break;833833-834834- case VIAWGET_SET_SCAN:835835- pr_debug("VIAWGET_SET_SCAN\n");836836- ret = wpa_set_scan(pDevice, param);837837- break;838838-839839- case VIAWGET_GET_SCAN:840840- pr_debug("VIAWGET_GET_SCAN\n");841841- ret = wpa_get_scan(pDevice, param);842842- wpa_ioctl = 1;843843- break;844844-845845- case VIAWGET_GET_SSID:846846- pr_debug("VIAWGET_GET_SSID\n");847847- ret = wpa_get_ssid(pDevice, param);848848- wpa_ioctl = 1;849849- break;850850-851851- case VIAWGET_GET_BSSID:852852- pr_debug("VIAWGET_GET_BSSID\n");853853- ret = wpa_get_bssid(pDevice, param);854854- wpa_ioctl = 1;855855- break;856856-857857- case VIAWGET_SET_ASSOCIATE:858858- pr_debug("VIAWGET_SET_ASSOCIATE\n");859859- ret = wpa_set_associate(pDevice, param);860860- break;861861-862862- case VIAWGET_SET_DISASSOCIATE:863863- pr_debug("VIAWGET_SET_DISASSOCIATE\n");864864- ret = wpa_set_disassociate(pDevice, param);865865- break;866866-867867- case VIAWGET_SET_DROP_UNENCRYPT:868868- pr_debug("VIAWGET_SET_DROP_UNENCRYPT\n");869869- break;870870-871871- case VIAWGET_SET_DEAUTHENTICATE:872872- pr_debug("VIAWGET_SET_DEAUTHENTICATE\n");873873- break;874874-875875- default:876876- pr_debug("wpa_ioctl: unknown cmd=%d\n",877877- param->cmd);878878- ret = -EOPNOTSUPP;879879- goto out;880880- }881881-882882- if ((ret == 0) && wpa_ioctl) {883883- if (copy_to_user(p->pointer, param, p->length)) {884884- ret = -EFAULT;885885- goto out;886886- }887887- }888888-889889-out:890890- kfree(param);891891-892892- return ret;893893-}
-64
drivers/staging/vt6655/wpactl.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: wpactl.h2020- *2121- * Purpose:2222- *2323- * Author: Lyndon Chen2424- *2525- * Date: March 1, 20052626- *2727- */2828-2929-#ifndef __WPACTL_H__3030-#define __WPACTL_H__3131-3232-#include "device.h"3333-#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT3434-#include "iowpa.h"3535-#endif3636-3737-/*--------------------- Export Definitions -------------------------*/3838-3939-//WPA related4040-4141-enum wpa_alg { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP };4242-enum wpa_cipher { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,4343- CIPHER_WEP104 };4444-enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_CCKM, KEY_MGMT_PSK, KEY_MGMT_NONE,4545- KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE };4646-4747-#define AUTH_ALG_OPEN_SYSTEM 0x014848-#define AUTH_ALG_SHARED_KEY 0x024949-#define AUTH_ALG_LEAP 0x045050-5151-#define GENERIC_INFO_ELEM 0xdd5252-#define RSN_INFO_ELEM 0x305353-5454-/*--------------------- Export Classes ----------------------------*/5555-5656-/*--------------------- Export Variables --------------------------*/5757-5858-/*--------------------- Export Functions --------------------------*/5959-6060-int wpa_set_wpadev(struct vnt_private *, int val);6161-int wpa_ioctl(struct vnt_private *, struct iw_point *p);6262-int wpa_set_keys(struct vnt_private *, void *ctx, bool fcpfkernel);6363-6464-#endif // __WPACL_H__