📄 mlme.c
字号:
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * 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. * * * ************************************************************************* Module Name: mlme.c Abstract: Revision History: Who When What -------- ---------- ---------------------------------------------- John Chang 2004-08-25 Modify from RT2500 code base John Chang 2004-09-06 modified for RT2600*/#include "rt_config.h"#include <stdarg.h>UCHAR CISCO_OUI[] = {0x00, 0x40, 0x96};UCHAR WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01};UCHAR RSN_OUI[] = {0x00, 0x0f, 0xac};UCHAR WAPI_OUI[] = {0x00, 0x14, 0x72};UCHAR WME_INFO_ELEM[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};UCHAR WME_PARM_ELEM[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};UCHAR Ccx2QosInfo[] = {0x00, 0x40, 0x96, 0x04};UCHAR RALINK_OUI[] = {0x00, 0x0c, 0x43};UCHAR BROADCOM_OUI[] = {0x00, 0x90, 0x4c};UCHAR WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04};#ifdef CONFIG_STA_SUPPORT#ifdef DOT11_N_SUPPORTUCHAR PRE_N_HT_OUI[] = {0x00, 0x90, 0x4c};#endif // DOT11_N_SUPPORT //#endif // CONFIG_STA_SUPPORT //UCHAR RateSwitchTable[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x11, 0x00, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 35, 45, 0x03, 0x00, 3, 20, 45, 0x04, 0x21, 0, 30, 50, 0x05, 0x21, 1, 20, 50, 0x06, 0x21, 2, 20, 50, 0x07, 0x21, 3, 15, 50, 0x08, 0x21, 4, 15, 30, 0x09, 0x21, 5, 10, 25, 0x0a, 0x21, 6, 8, 25, 0x0b, 0x21, 7, 8, 25, 0x0c, 0x20, 12, 15, 30, 0x0d, 0x20, 13, 8, 20, 0x0e, 0x20, 14, 8, 20, 0x0f, 0x20, 15, 8, 25, 0x10, 0x22, 15, 8, 25, 0x11, 0x00, 0, 0, 0, 0x12, 0x00, 0, 0, 0, 0x13, 0x00, 0, 0, 0, 0x14, 0x00, 0, 0, 0, 0x15, 0x00, 0, 0, 0, 0x16, 0x00, 0, 0, 0, 0x17, 0x00, 0, 0, 0, 0x18, 0x00, 0, 0, 0, 0x19, 0x00, 0, 0, 0, 0x1a, 0x00, 0, 0, 0, 0x1b, 0x00, 0, 0, 0, 0x1c, 0x00, 0, 0, 0, 0x1d, 0x00, 0, 0, 0, 0x1e, 0x00, 0, 0, 0, 0x1f, 0x00, 0, 0, 0,};UCHAR RateSwitchTable11B[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x04, 0x03, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 35, 45, 0x03, 0x00, 3, 20, 45,};UCHAR RateSwitchTable11BG[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0a, 0x00, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 35, 45, 0x03, 0x00, 3, 20, 45, 0x04, 0x10, 2, 20, 35, 0x05, 0x10, 3, 16, 35, 0x06, 0x10, 4, 10, 25, 0x07, 0x10, 5, 16, 25, 0x08, 0x10, 6, 10, 25, 0x09, 0x10, 7, 10, 13,};UCHAR RateSwitchTable11G[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x08, 0x00, 0, 0, 0, // Initial used item after association 0x00, 0x10, 0, 20, 101, 0x01, 0x10, 1, 20, 35, 0x02, 0x10, 2, 20, 35, 0x03, 0x10, 3, 16, 35, 0x04, 0x10, 4, 10, 25, 0x05, 0x10, 5, 16, 25, 0x06, 0x10, 6, 10, 25, 0x07, 0x10, 7, 10, 13,};#ifdef DOT11_N_SUPPORTUCHAR RateSwitchTable11N1S[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0c, 0x0a, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 25, 45, 0x03, 0x21, 0, 20, 35, 0x04, 0x21, 1, 20, 35, 0x05, 0x21, 2, 20, 35, 0x06, 0x21, 3, 15, 35, 0x07, 0x21, 4, 15, 30, 0x08, 0x21, 5, 10, 25, 0x09, 0x21, 6, 8, 14, 0x0a, 0x21, 7, 8, 14, 0x0b, 0x23, 7, 8, 14,};UCHAR RateSwitchTable11N2S[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0e, 0x0c, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 25, 45, 0x03, 0x21, 0, 20, 35, 0x04, 0x21, 1, 20, 35, 0x05, 0x21, 2, 20, 35, 0x06, 0x21, 3, 15, 35, 0x07, 0x21, 4, 15, 30, 0x08, 0x20, 11, 15, 30, 0x09, 0x20, 12, 15, 30, 0x0a, 0x20, 13, 8, 20, 0x0b, 0x20, 14, 8, 20, 0x0c, 0x20, 15, 8, 25, 0x0d, 0x22, 15, 8, 15,};UCHAR RateSwitchTable11N3S[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0b, 0x00, 0, 0, 0, // 0x0a, 0x00, 0, 0, 0, // Initial used item after association 0x00, 0x21, 0, 30, 101, 0x01, 0x21, 1, 20, 50, 0x02, 0x21, 2, 20, 50, 0x03, 0x21, 3, 15, 50, 0x04, 0x21, 4, 15, 30, 0x05, 0x20, 11, 15, 30, // Required by System-Alan @ 20080812 0x06, 0x20, 12, 15, 30, // 0x05, 0x20, 12, 15, 30, 0x07, 0x20, 13, 8, 20, // 0x06, 0x20, 13, 8, 20, 0x08, 0x20, 14, 8, 20, // 0x07, 0x20, 14, 8, 20, 0x09, 0x20, 15, 8, 25, // 0x08, 0x20, 15, 8, 25, 0x0a, 0x22, 15, 8, 25, // 0x09, 0x22, 15, 8, 25,};UCHAR RateSwitchTable11N2SForABand[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0b, 0x09, 0, 0, 0, // Initial used item after association 0x00, 0x21, 0, 30, 101, 0x01, 0x21, 1, 20, 50, 0x02, 0x21, 2, 20, 50, 0x03, 0x21, 3, 15, 50, 0x04, 0x21, 4, 15, 30, 0x05, 0x21, 5, 15, 30, 0x06, 0x20, 12, 15, 30, 0x07, 0x20, 13, 8, 20, 0x08, 0x20, 14, 8, 20, 0x09, 0x20, 15, 8, 25, 0x0a, 0x22, 15, 8, 25,};UCHAR RateSwitchTable11N3SForABand[] = { // 3*3// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0b, 0x09, 0, 0, 0, // Initial used item after association 0x00, 0x21, 0, 30, 101, 0x01, 0x21, 1, 20, 50, 0x02, 0x21, 2, 20, 50, 0x03, 0x21, 3, 15, 50, 0x04, 0x21, 4, 15, 30, 0x05, 0x21, 5, 15, 30, 0x06, 0x20, 12, 15, 30, 0x07, 0x20, 13, 8, 20, 0x08, 0x20, 14, 8, 20, 0x09, 0x20, 15, 8, 25, 0x0a, 0x22, 15, 8, 25,};UCHAR RateSwitchTable11BGN1S[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0c, 0x0a, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 25, 45, 0x03, 0x21, 0, 20, 35, 0x04, 0x21, 1, 20, 35, 0x05, 0x21, 2, 20, 35, 0x06, 0x21, 3, 15, 35, 0x07, 0x21, 4, 15, 30, 0x08, 0x21, 5, 10, 25, 0x09, 0x21, 6, 8, 14, 0x0a, 0x21, 7, 8, 14, 0x0b, 0x23, 7, 8, 14,};UCHAR RateSwitchTable11BGN2S[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0e, 0x0c, 0, 0, 0, // Initial used item after association 0x00, 0x00, 0, 40, 101, 0x01, 0x00, 1, 40, 50, 0x02, 0x00, 2, 25, 45, 0x03, 0x21, 0, 20, 35, 0x04, 0x21, 1, 20, 35, 0x05, 0x21, 2, 20, 35, 0x06, 0x21, 3, 15, 35, 0x07, 0x21, 4, 15, 30, 0x08, 0x20, 11, 15, 30, 0x09, 0x20, 12, 15, 30, 0x0a, 0x20, 13, 8, 20, 0x0b, 0x20, 14, 8, 20, 0x0c, 0x20, 15, 8, 25, 0x0d, 0x22, 15, 8, 15,};UCHAR RateSwitchTable11BGN3S[] = { // 3*3// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0a, 0x00, 0, 0, 0, // Initial used item after association 0x00, 0x21, 0, 30,101, //50 0x01, 0x21, 1, 20, 50, 0x02, 0x21, 2, 20, 50, 0x03, 0x21, 3, 20, 50, 0x04, 0x21, 4, 15, 50, 0x05, 0x20, 20, 15, 30, 0x06, 0x20, 21, 8, 20, 0x07, 0x20, 22, 8, 20, 0x08, 0x20, 23, 8, 25, 0x09, 0x22, 23, 8, 25,};UCHAR RateSwitchTable11BGN2SForABand[] = {// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0b, 0x09, 0, 0, 0, // Initial used item after association 0x00, 0x21, 0, 30,101, //50 0x01, 0x21, 1, 20, 50, 0x02, 0x21, 2, 20, 50, 0x03, 0x21, 3, 15, 50, 0x04, 0x21, 4, 15, 30, 0x05, 0x21, 5, 15, 30, 0x06, 0x20, 12, 15, 30, 0x07, 0x20, 13, 8, 20, 0x08, 0x20, 14, 8, 20, 0x09, 0x20, 15, 8, 25, 0x0a, 0x22, 15, 8, 25,};UCHAR RateSwitchTable11BGN3SForABand[] = { // 3*3// Item No. Mode Curr-MCS TrainUp TrainDown // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) 0x0c, 0x09, 0, 0, 0, // Initial used item after association 0x00, 0x21, 0, 30,101, //50 0x01, 0x21, 1, 20, 50, 0x02, 0x21, 2, 20, 50, 0x03, 0x21, 3, 15, 50, 0x04, 0x21, 4, 15, 30, 0x05, 0x21, 5, 15, 30, 0x06, 0x21, 12, 15, 30, 0x07, 0x20, 20, 15, 30, 0x08, 0x20, 21, 8, 20, 0x09, 0x20, 22, 8, 20, 0x0a, 0x20, 23, 8, 25, 0x0b, 0x22, 23, 8, 25,};#endif // DOT11_N_SUPPORT //extern UCHAR OfdmRateToRxwiMCS[];// since RT61 has better RX sensibility, we have to limit TX ACK rate not to exceed our normal data TX rate.// otherwise the WLAN peer may not be able to receive the ACK thus downgrade its data TX rateULONG BasicRateMask[12] = {0xfffff001 /* 1-Mbps */, 0xfffff003 /* 2 Mbps */, 0xfffff007 /* 5.5 */, 0xfffff00f /* 11 */, 0xfffff01f /* 6 */ , 0xfffff03f /* 9 */ , 0xfffff07f /* 12 */ , 0xfffff0ff /* 18 */, 0xfffff1ff /* 24 */ , 0xfffff3ff /* 36 */ , 0xfffff7ff /* 48 */ , 0xffffffff /* 54 */};UCHAR BROADCAST_ADDR[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than // this value, then it's quaranteed capable of operating in 36 mbps TX rate in // clean environment.// TxRate: 1 2 5.5 11 6 9 12 18 24 36 48 54 72 100CHAR RssiSafeLevelForTxRate[] ={ -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 };UCHAR RateIdToMbps[] = { 1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 72, 100};USHORT RateIdTo500Kbps[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144, 200};UCHAR SsidIe = IE_SSID;UCHAR SupRateIe = IE_SUPP_RATES;UCHAR ExtRateIe = IE_EXT_SUPP_RATES;#ifdef DOT11_N_SUPPORTUCHAR HtCapIe = IE_HT_CAP;UCHAR AddHtInfoIe = IE_ADD_HT;UCHAR NewExtChanIe = IE_SECONDARY_CH_OFFSET;#ifdef DOT11N_DRAFT3UCHAR ExtHtCapIe = IE_EXT_CAPABILITY;#endif // DOT11N_DRAFT3 //#endif // DOT11_N_SUPPORT //UCHAR ErpIe = IE_ERP;UCHAR DsIe = IE_DS_PARM;UCHAR TimIe = IE_TIM;UCHAR WpaIe = IE_WPA;UCHAR Wpa2Ie = IE_WPA2;UCHAR IbssIe = IE_IBSS_PARM;UCHAR Ccx2Ie = IE_CCX_V2;UCHAR WapiIe = IE_WAPI;extern UCHAR WPA_OUI[];UCHAR SES_OUI[] = {0x00, 0x90, 0x4c};UCHAR ZeroSsid[32] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* ========================================================================== Description: initialize the MLME task and its data structure (queue, spinlock, timer, state machines). IRQL = PASSIVE_LEVEL Return: always return NDIS_STATUS_SUCCESS ==========================================================================*/NDIS_STATUS MlmeInit( IN PRTMP_ADAPTER pAd) { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; DBGPRINT(RT_DEBUG_TRACE, ("--> MLME Initialize\n")); do { Status = MlmeQueueInit(&pAd->Mlme.Queue); if(Status != NDIS_STATUS_SUCCESS) break; pAd->Mlme.bRunning = FALSE; NdisAllocateSpinLock(&pAd->Mlme.TaskLock);#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { BssTableInit(&pAd->ScanTab); // init STA state machines AssocStateMachineInit(pAd, &pAd->Mlme.AssocMachine, pAd->Mlme.AssocFunc); AuthStateMachineInit(pAd, &pAd->Mlme.AuthMachine, pAd->Mlme.AuthFunc); AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine, pAd->Mlme.AuthRspFunc); SyncStateMachineInit(pAd, &pAd->Mlme.SyncMachine, pAd->Mlme.SyncFunc);#ifdef QOS_DLS_SUPPORT DlsStateMachineInit(pAd, &pAd->Mlme.DlsMachine, pAd->Mlme.DlsFunc);#endif // QOS_DLS_SUPPORT // // Since we are using switch/case to implement it, the init is different from the above // state machine init MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL); }#endif // CONFIG_STA_SUPPORT //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -