⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mlme.c.bak

📁 Linux下的RT系列无线网卡驱动,可以直接在x86平台上编译
💻 BAK
📖 第 1 页 / 共 5 页
字号:
/* ************************************************************************* * 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.             *  *                                                                       *  ************************************************************************* 	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   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_SUPPORTUCHAR	PRE_N_HT_OUI[]	= {0x00, 0x90, 0x4c};#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, 20,    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,};UCHAR 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)    0x09, 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, 0x21,  5, 10, 25,    0x06, 0x21,  6,  8, 14,    0x07, 0x21,  7,  8, 14,    0x08, 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)    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, 12,  15, 20,    0x06, 0x20, 13,  8, 20,    0x07, 0x20, 14,  8, 20,    0x08, 0x20, 15,  8, 25,    0x09, 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)    0x0d, 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,101,	//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, 14,    0x0b, 0x21,  7,  8, 14,	0x0c, 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)    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, 15, 50,    0x04, 0x21,  4, 15, 30,    0x05, 0x20, 12, 15, 20,    0x06, 0x20, 13,  8, 20,    0x07, 0x20, 14,  8, 20,    0x08, 0x20, 15,  8, 25,    0x09, 0x22, 15,  8, 25,};PUCHAR ReasonString[] = {	/* 0  */	 "Reserved",	/* 1  */	 "Unspecified Reason",	/* 2  */	 "Previous Auth no longer valid",	/* 3  */	 "STA is leaving / has left",	/* 4  */	 "DIS-ASSOC due to inactivity",	/* 5  */	 "AP unable to hanle all associations",	/* 6  */	 "class 2 error",	/* 7  */	 "class 3 error",	/* 8  */	 "STA is leaving / has left",	/* 9  */	 "require auth before assoc/re-assoc",	/* 10 */	 "Reserved",	/* 11 */	 "Reserved",	/* 12 */	 "Reserved",	/* 13 */	 "invalid IE",	/* 14 */	 "MIC error",	/* 15 */	 "4-way handshake timeout",	/* 16 */	 "2-way (group key) handshake timeout",	/* 17 */	 "4-way handshake IE diff among AssosReq/Rsp/Beacon",	/* 18 */};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 MULTICAST_ADDR[MAC_ADDR_LEN] = {0x1,  0x00, 0x00, 0x00, 0x00, 0x00};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;UCHAR  HtCapIe = IE_HT_CAP;UCHAR  AddHtInfoIe = IE_ADD_HT;UCHAR  NewExtChanIe = IE_NEW_EXT_CHA_OFFSET;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;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};// Reset the RFIC setting to new series    RTMP_RF_REGS RF2850RegTable[] = {//		ch	 R1 		 R2 		 R3(TX0~4=0) R4		{1,  0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b},		{2,  0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f},		{3,  0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b},		{4,  0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f},		{5,  0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b},		{6,  0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f},		{7,  0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b},		{8,  0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f},		{9,  0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b},		{10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f},		{11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b},		{12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f},		{13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b},		{14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193},		// 802.11 UNI / HyperLan 2		{36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3},		{38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193},		{40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183},		{44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3},		{46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b},		{48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b},		{52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193},		{54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3},		{56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b},		{60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183},		{62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193},		{64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3}, // Plugfest#4, Day4, change RFR3 left4th 9->5.		// 802.11 HyperLan 2		{100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783},		{102, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed793},		{104, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed1a3},		{108, 0x98402ecc, 0x984c0a32, 0x98178a55, 0x980ed193},		{110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183},		{112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b},		{116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3},		{118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193},		{120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183},		{124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193},		{126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1bb},		{128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3},		{132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b},		{134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193},		{136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b},		{140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183},		// 802.11 UNII		{149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7},		{151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187},		{153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f},		{157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f},		{159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7},		{161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187},		{165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197},		// Japan		{184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b},		{188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13},		{192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b},		{196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23},		{208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13},		{212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b},		{216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23},		// still lack of MMAC(Japan) ch 34,38,42,46};UCHAR	NUM_OF_2850_CHNL = (sizeof(RF2850RegTable) / sizeof(RTMP_RF_REGS));/*	==========================================================================	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		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);		WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc);		AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);				// 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 //				ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine, pAd->Mlme.ActFunc);		// Init mlme periodic timer		RTMPInitTimer(pAd, &pAd->Mlme.PeriodicTimer, GET_TIMER_FUNCTION(MlmePeriodicExec), pAd, TRUE);		// Set mlme periodic timer		RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);#ifdef CONFIG_STA_SUPPORT		// Init timer to report link down event		RTMPInitTimer(pAd, &pAd->Mlme.LinkDownTimer, GET_TIMER_FUNCTION(LinkDownExec), pAd, FALSE);		#endif // CONFIG_STA_SUPPORT //

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -