📄 cmm_info.c.bak
字号:
/* ************************************************************************* * Ralink Tech Inc. * 4F, No. 2 Technology 5th Rd. * Science-based Industrial Park * Hsin-chu, Taiwan, R.O.C. * * (c) Copyright 2002-2007, Ralink Technology, Inc. * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * **************************************************************************/#include "rt_config.h"/* ======================================================================== Routine Description: Remove WPA Key process Arguments: pAd Pointer to our adapter pBuf Pointer to the where the key stored Return Value: NDIS_SUCCESS Add key successfully IRQL = DISPATCH_LEVEL Note: ========================================================================*/#ifdef CONFIG_STA_SUPPORTNDIS_STATUS RTMPWPARemoveKeyProc( IN PRTMP_ADAPTER pAd, IN PVOID pBuf){ PNDIS_802_11_REMOVE_KEY pKey; ULONG KeyIdx; NDIS_STATUS Status = NDIS_STATUS_FAILURE; BOOLEAN bTxKey; // Set the key as transmit key BOOLEAN bPairwise; // Indicate the key is pairwise key BOOLEAN bKeyRSC; // indicate the receive SC set by KeyRSC value. // Otherwise, it will set by the NIC. BOOLEAN bAuthenticator; // indicate key is set by authenticator. INT i; DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n")); pKey = (PNDIS_802_11_REMOVE_KEY) pBuf; KeyIdx = pKey->KeyIndex & 0xff; // Bit 31 of Add-key, Tx Key bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE; // Bit 30 of Add-key PairwiseKey bPairwise = (pKey->KeyIndex & 0x40000000) ? TRUE : FALSE; // Bit 29 of Add-key KeyRSC bKeyRSC = (pKey->KeyIndex & 0x20000000) ? TRUE : FALSE; // Bit 28 of Add-key Authenticator bAuthenticator = (pKey->KeyIndex & 0x10000000) ? TRUE : FALSE; // 1. If bTx is TRUE, return failure information if (bTxKey == TRUE) return(NDIS_STATUS_INVALID_DATA); // 2. Check Pairwise Key if (bPairwise) { // a. If BSSID is broadcast, remove all pairwise keys. // b. If not broadcast, remove the pairwise specified by BSSID for (i = 0; i < SHARE_KEY_NUM; i++) { if (MAC_ADDR_EQUAL(pAd->SharedKey[BSS0][i].BssId, pKey->BSSID)) { DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%d)\n", i)); pAd->SharedKey[BSS0][i].KeyLen = 0; pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE; AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)i); Status = NDIS_STATUS_SUCCESS; break; } } } // 3. Group Key else { // a. If BSSID is broadcast, remove all group keys indexed // b. If BSSID matched, delete the group key indexed. DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveKeyProc(KeyIdx=%ld)\n", KeyIdx)); pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0; pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE; AsicRemoveSharedKeyEntry(pAd, BSS0, (UCHAR)KeyIdx); Status = NDIS_STATUS_SUCCESS; } return (Status);}#endif // CONFIG_STA_SUPPORT //#ifdef CONFIG_STA_SUPPORT/* ======================================================================== Routine Description: Remove All WPA Keys Arguments: pAd Pointer to our adapter Return Value: None IRQL = DISPATCH_LEVEL Note: ========================================================================*/VOID RTMPWPARemoveAllKeys( IN PRTMP_ADAPTER pAd){ UCHAR i; DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus)); // For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after // Link up. And it will be replaced if user changed it. if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA) return; // For WPA-None, there is no need to remove it, since WinXP won't set it again after // Link up. And it will be replaced if user changed it. if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) return; // set BSSID wcid entry of the Pair-wise Key table as no-security mode AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID); // set all shared key mode as no-security. for (i = 0; i < SHARE_KEY_NUM; i++) { DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i)); NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY)); AsicRemoveSharedKeyEntry(pAd, BSS0, i); }}#endif // CONFIG_STA_SUPPORT // /* ======================================================================== Routine Description: Change NIC PHY mode. Re-association may be necessary. possible settings include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED Arguments: pAd - Pointer to our adapter phymode - IRQL = PASSIVE_LEVEL IRQL = DISPATCH_LEVEL ========================================================================*/VOID RTMPSetPhyMode( IN PRTMP_ADAPTER pAd, IN ULONG phymode){ INT i;#ifdef CONFIG_STA_SUPPORT OID_SET_HT_PHYMODE HTPhymode;#endif // CONFIG_STA_SUPPORT // // the selected phymode must be supported by the RF IC encoded in E2PROM // if no change, do nothing /* bug fix if (pAd->CommonCfg.PhyMode == phymode) return; */ pAd->CommonCfg.PhyMode = (UCHAR)phymode; DBGPRINT(RT_DEBUG_TRACE,("RTMPSetPhyMode(=%d)HTPhyMode.MODE=%d, channel=%d \n", pAd->CommonCfg.PhyMode, pAd->CommonCfg.HTPhyMode.field.MODE, pAd->CommonCfg.Channel)); BuildChannelList(pAd); // sanity check user setting for (i = 0; i < pAd->ChannelListNum; i++) { if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel) break; } if (i == pAd->ChannelListNum) { pAd->CommonCfg.Channel = FirstChannel(pAd); DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel)); } NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES); NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES); NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES); switch (phymode) { case PHY_11B: pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRateLen = 4; pAd->CommonCfg.ExtRateLen = 0; pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use break; case PHY_11G: case PHY_11N: case PHY_11BG_MIXED: case PHY_11ABG_MIXED: case PHY_11ABGN_MIXED: case PHY_11BGN_MIXED: case PHY_11GN_MIXED: pAd->CommonCfg.SupRate[0] = 0x82; // 1 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[1] = 0x84; // 2 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[2] = 0x8B; // 5.5 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[3] = 0x96; // 11 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[4] = 0x12; // 9 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[5] = 0x24; // 18 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[6] = 0x48; // 36 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRateLen = 8; pAd->CommonCfg.ExtRate[0] = 0x0C; // 6 mbps, in units of 0.5 Mbps pAd->CommonCfg.ExtRate[1] = 0x18; // 12 mbps, in units of 0.5 Mbps pAd->CommonCfg.ExtRate[2] = 0x30; // 24 mbps, in units of 0.5 Mbps pAd->CommonCfg.ExtRate[3] = 0x60; // 48 mbps, in units of 0.5 Mbps pAd->CommonCfg.ExtRateLen = 4; pAd->CommonCfg.DesireRate[0] = 2; // 1 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[1] = 4; // 2 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[2] = 11; // 5.5 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[3] = 22; // 11 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[4] = 12; // 6 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[5] = 18; // 9 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[6] = 24; // 12 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[7] = 36; // 18 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[8] = 48; // 24 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[9] = 72; // 36 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[10] = 96; // 48 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[11] = 108; // 54 mbps, in units of 0.5 Mbps break; case PHY_11A: case PHY_11AN_MIXED: case PHY_11AGN_MIXED: pAd->CommonCfg.SupRate[0] = 0x8C; // 6 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[1] = 0x12; // 9 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[2] = 0x98; // 12 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[3] = 0x24; // 18 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[4] = 0xb0; // 24 mbps, in units of 0.5 Mbps, basic rate pAd->CommonCfg.SupRate[5] = 0x48; // 36 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[6] = 0x60; // 48 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRate[7] = 0x6c; // 54 mbps, in units of 0.5 Mbps pAd->CommonCfg.SupRateLen = 8; pAd->CommonCfg.ExtRateLen = 0; pAd->CommonCfg.DesireRate[0] = 12; // 6 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[1] = 18; // 9 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[2] = 24; // 12 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[3] = 36; // 18 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[4] = 48; // 24 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[5] = 72; // 36 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[6] = 96; // 48 mbps, in units of 0.5 Mbps pAd->CommonCfg.DesireRate[7] = 108; // 54 mbps, in units of 0.5 Mbps pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use break; default: break; }#ifdef CONFIG_STA_SUPPORT HTPhymode.PhyMode = pAd->CommonCfg.PhyMode; HTPhymode.TransmitNo = (UCHAR)pAd->Antenna.field.TxPath; HTPhymode.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE; HTPhymode.ExtOffset = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA; HTPhymode.MCS = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.MCS; HTPhymode.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW; HTPhymode.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC; HTPhymode.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI; pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel; if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) RTMPSetHT(pAd, &HTPhymode); #endif // CONFIG_STA_SUPPORT // MlmeUpdateTxRates(pAd, FALSE); MlmeUpdateHtTxRates(pAd, 0xff); //AsicSetSlotTime(pAd, TRUE); //FALSE); pAd->CommonCfg.BandState = UNKNOWN_BAND; // MakeIbssBeacon(pAd); // supported rates may change}/* ======================================================================== Routine Description: Caller ensures we has 802.11n support. Calls at setting HT from AP/STASetinformation Arguments: pAd - Pointer to our adapter phymode - ========================================================================*/VOID RTMPSetHT( IN PRTMP_ADAPTER pAd, IN OID_SET_HT_PHYMODE *pHTPhyMode){ //ULONG *pmcs; ULONG Value; UCHAR BBPValue = 0; UCHAR BBP3Value = 0; UCHAR TxStream = pAd->CommonCfg.TxStream; UCHAR RxStream = pAd->CommonCfg.RxStream; // Don't zero supportedHyPhy structure. RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability)); RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo)); RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset, sizeof(pAd->CommonCfg.NewExtChanOffset)); RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy, sizeof(pAd->CommonCfg.DesiredHtPhy)); pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1; if (pAd->CommonCfg.bRdg) { pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1; } pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3; pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3; DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT -(RxBAWinLimit= %d), (MaxRAmpduFactor=%d)...\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit, pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor)); pAd->CommonCfg.DesiredHtPhy.bHtEnable = TRUE; // Mimo power save, A-MSDU size, pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize; pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode; pAd->CommonCfg.DesiredHtPhy.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize; pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode; pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity; DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT-----> AMsduSize = %d (MimoPs = %d) (RxBAWinLimit = %d) \n", pAd->CommonCfg.DesiredHtPhy.AmsduSize, pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs, pAd->CommonCfg.BACapability.field.RxBAWinLimit)); DBGPRINT(RT_DEBUG_TRACE, (" RTMPSetHT<---BW = %d, STBC = %d, SHORTGI = %d,>MCS = %d,ExtOffset = %d \n", pHTPhyMode->BW,pHTPhyMode->STBC,pHTPhyMode->SHORTGI,pHTPhyMode->MCS,pHTPhyMode->ExtOffset)); if(pHTPhyMode->HtMode == HTMODE_GF) { pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1; pAd->CommonCfg.DesiredHtPhy.GF = 1; } else pAd->CommonCfg.DesiredHtPhy.GF = 0; // Support in 40-MHz //pAd->CommonCfg.DesiredHtPhy.MCSSet[4]= 0x1; // Set desired rate according to GUI setting, SUpported switch (TxStream /*pHTPhyMode->TransmitNo*/) { case 1: if (pHTPhyMode->MCS == MCS_AUTO) { pAd->CommonCfg.DesiredHtPhy.MCSSet[0]= 0xff; pAd->CommonCfg.DesiredHtPhy.MCSSet[1]= 0x00; } else { pAd->CommonCfg.DesiredHtPhy.MCSSet[0]= 1<<pHTPhyMode->MCS; pAd->CommonCfg.DesiredHtPhy.MCSSet[1]= 0x00; } //pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff; //pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -