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

📄 connect.c

📁 华硕无线网卡 167G linux 驱动
💻 C
📖 第 1 页 / 共 4 页
字号:
			/*	==========================================================================	Description:	==========================================================================*/VOID CntlWaitAssocProc(	IN PRT2570ADAPTER pAd, 	IN MLME_QUEUE_ELEM *Elem) {	USHORT		Reason;	if (Elem->MsgType == MT2_ASSOC_CONF) 	{		memcpy(&Reason, Elem->Msg, sizeof(USHORT));		if (Reason == MLME_SUCCESS) 		{			DBGPRINT(RT_DEBUG_TRACE, "CNTL - Association successful on BSS #%d\n",pAd->Mlme.CntlAux.BssIdx);//			RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x7e);//steven:for test			LinkUp(pAd, BSS_INFRA);			if (pAd->Mlme.CntlAux.CurrReqIsFromNdis)			{				NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS);			}			pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;			RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test		} 		else 		{			// not success, try next BSS			DBGPRINT(RT_DEBUG_TRACE, "CNTL - Association fails on BSS #%d\n",pAd->Mlme.CntlAux.BssIdx);//			  pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;//steven:for test			pAd->Mlme.CntlAux.BssIdx++;//			RTUSBWriteMACRegister(pAd, TXRX_CSR2, 0x7e);//steven:for test			IterateOnBssTab(pAd);		}	}}/*	==========================================================================	Description:	==========================================================================*/VOID CntlWaitReassocProc(	IN PRT2570ADAPTER pAd, 	IN MLME_QUEUE_ELEM *Elem) {	USHORT		Result;	if (Elem->MsgType == MT2_REASSOC_CONF) 	{		memcpy(&Result, Elem->Msg, sizeof(USHORT));		if (Result == MLME_SUCCESS) 		{			BSS_ENTRY *pBss = &pAd->Mlme.CntlAux.RoamTab.BssEntry[pAd->Mlme.CntlAux.RoamIdx];			// COPY_MAC_ADDR(&pAd->PortCfg.Bssid, &pBss->Bssid);			// AsicSetBssid(pAd, &pAd->PortCfg.Bssid);						// The following steps are supposed to be done after JOIN in normal procedure			// But since this RE-ASSOC skips the JOIN procedure, we have to do it after			// RE-ASSOC succeeds. If RE-ASSOC fails, then stay at original AP without any change			pAd->PortCfg.BeaconPeriod = pBss->BeaconPeriod;			pAd->PortCfg.Channel = pBss->Channel;			// The security setting should always follow upper layer definition, not from frame			//pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo);			pAd->PortCfg.SupportedRatesLen = pBss->RatesLen;			memcpy(pAd->PortCfg.SupportedRates, pBss->Rates, pBss->RatesLen);			// Check for 802.11g information, if 802.11 b /g mixed mode.			pAd->PortCfg.CapabilityInfo = pBss->CapabilityInfo;			pAd->PortCfg.CfpPeriod = pBss->CfpPeriod;			pAd->PortCfg.CfpMaxDuration = pBss->CfpMaxDuration;			pAd->PortCfg.CfpDurRemain = pBss->CfpDurRemaining;			pAd->PortCfg.CfpCount = pBss->CfpCount;			// 			// NDIS requires a new Link UP indication but no Link Down for RE-ASSOC			//			DBGPRINT(RT_DEBUG_TRACE, "CNTL - Re-assocition successful on BSS #%d\n", pAd->Mlme.CntlAux.RoamIdx);			LinkUp(pAd, BSS_INFRA);			pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;						RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REASSOC_IN_PROGRESS);//steven:for test		} 		else 		{			// reassoc failed, try to pick next BSS in the BSS Table			DBGPRINT(RT_DEBUG_TRACE, "CNTL - Re-assocition fails on BSS #%d\n", pAd->Mlme.CntlAux.RoamIdx);			pAd->Mlme.CntlAux.RoamIdx++;			IterateOnBssTab2(pAd);		}	}}			/*	==========================================================================	Description:	==========================================================================*/VOID LinkUp(	IN PRT2570ADAPTER pAd,	IN UCHAR BssType) {	ULONG	Now;	UCHAR			buffer[22];		DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! LINK UP !!!\n");	MlmeUpdateTxRates(pAd, TRUE);	RTUSBMultiReadMAC(pAd, STA_CSR0, buffer, 22);	memcpy(&pAd->Mlme.PrevWlanCounters, &pAd->WlanCounters, sizeof(COUNTER_802_11));	memset(&pAd->DrsCounters, 0, sizeof(COUNTER_DRS));	Now = jiffies;	pAd->PortCfg.LastBeaconRxTime = Now;   // last RX timestamp		if ((pAd->PortCfg.WindowsTxPreamble != Rt802_11PreambleLong) &&		CAP_IS_SHORT_PREAMBLE_ON(pAd->PortCfg.CapabilityInfo))	{		DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! Set to short preamble!!!\n");		MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);	}		pAd->PortCfg.BssType = BssType;	if (BssType == BSS_INDEP)	{//		USHORT SentBeaconsCount, ReceivedBeaconsCount;//		RTUSBReadMACRegister(pAd, STA_CSR5, &SentBeaconsCount);//		RTUSBReadMACRegister(pAd, STA_CSR10, &ReceivedBeaconsCount);		pAd->PortCfg.Mibss = TRUE;		pAd->PortCfg.Massoc = FALSE;		AsicEnableIbssSync(pAd);		#ifdef	SINGLE_ADHOC_LINKUP		// Although this did not follow microsoft's recommendation.		//Change based on customer's request		pAd->MediaState = NdisMediaStateConnected;		NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_CONNECT, (PVOID)NULL, 0);		NdisMIndicateStatusComplete(pAd->AdapterHandle);#endif	}	else // BSS_INFRA	{            // need to check		//InterlockedExchange(&(pAd->PortCfg.DataPacketsFromAP), 0);		pAd->PortCfg.Massoc = TRUE;		pAd->PortCfg.Mibss = FALSE;		// NOTE:		// the decision of using "short slot time" or not may change dynamically due to		// new STA association to the AP. so we have to decide that upon parsing BEACON, not here		// NOTE:		// the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically		// due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here				ComposePsPoll(pAd);		ComposeNullFrame(pAd);		AsicEnableBssSync(pAd);		if (pAd->PortCfg.EnableTxBurst)		{			//Set CWmin/CWmax to 0.			RTUSBWriteMACRegister(pAd, MAC_CSR22, 0x100);		}		else		{			RTUSBWriteMACRegister(pAd, MAC_CSR22, 0x53);		}			// only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode		// should wait until at least 2 active nodes in this BSSID.		pAd->MediaState = NdisMediaStateConnected;		NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_CONNECT, (PVOID)NULL, 0);		NdisMIndicateStatusComplete(pAd->AdapterHandle);	}	DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_CONNECT Event B!\n");	if ((pAd->PortCfg.LedMode != LED_MODE_SINGLE)&&(pAd->PortCfg.LedMode != LED_MODE_TXRX_ACTIVITY))	{		ASIC_LED_ACT_ON(pAd);	}	if (pAd->PortCfg.LedMode == LED_MODE_ALPHA){		pAd->PortCfg.LedCntl.fSiteSurvey = FALSE;		pAd->PortCfg.LedCntl.fLinkUp = TRUE;	}		AsicSetSlotTime(pAd, FALSE);	pAd->Mlme.PeriodicRound = 0;	// Reset config flag	pAd->bConfigChanged = FALSE;	// Update extra information to link is up	pAd->ExtraInfo = GENERAL_LINK_UP;	pAd->PortCfg.WpaState = SS_START;	RTUSBKickBulkOut(pAd);}/*	==========================================================================	Description:	==========================================================================*/VOID LinkDown(	IN PRT2570ADAPTER pAd) {	DBGPRINT(RT_DEBUG_TRACE, "CNTL - !!! LINK DOWN !!!\n");	if (ADHOC_ON(pAd))		// Adhoc mode link down	{		pAd->PortCfg.Mibss = FALSE;#ifdef	SINGLE_ADHOC_LINKUP		pAd->MediaState = NdisMediaStateDisconnected;		NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0);		NdisMIndicateStatusComplete(pAd->AdapterHandle);		// clean up previous SCAN result, add current BSS back to table if any		BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid));#else		if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))		{			pAd->MediaState = NdisMediaStateDisconnected;			NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)NULL, 0);			NdisMIndicateStatusComplete(pAd->AdapterHandle);			// clean up previous SCAN result, add current BSS back to table if any			BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid));		}#endif			}	else					// Infra structure mode	{		pAd->PortCfg.Massoc = FALSE;		pAd->MediaState = NdisMediaStateDisconnected;		DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event A!\n");		BssTableDeleteEntry(&pAd->PortCfg.BssTab, &(pAd->PortCfg.Bssid));		// restore back to - 		//		1. long slot (20 us) or short slot (9 us) time		//		2. turn on/off RTS/CTS and/or CTS-to-self protection		//		3. short preamble		if (pAd->PortCfg.BGProtectionInUsed == TRUE)		{			pAd->PortCfg.BGProtectionInUsed = FALSE;			DBGPRINT(RT_DEBUG_TRACE, "Link down - turn off B/G protection\n");		}		if (pAd->PortCfg.Pss == PWR_SAVE)		{			RTUSBWriteMACRegister(pAd, MAC_CSR1, 1);			RTUSBWriteMACRegister(pAd, MAC_CSR1, 4);			pAd->PortCfg.Pss = PWR_ACTIVE;		}	}		AsicSetSlotTime(pAd, FALSE);	RTUSBWriteMACRegister(pAd, MAC_CSR22, 0x53);	AsicRestoreBbpSensibility(pAd);		if (pAd->PortCfg.WindowsTxPreamble == Rt802_11PreambleShort)		MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);	else		MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);	if ((pAd->PortCfg.LedMode != LED_MODE_SINGLE) && (pAd->PortCfg.LedMode != LED_MODE_ASUS))	{		ASIC_LED_ACT_OFF(pAd);	}	else if ((pAd->PortCfg.LedMode == LED_MODE_ASUS) && (pAd->PortCfg.bRadio == TRUE))	{		RTUSBWriteMACRegister(pAd, MAC_CSR20, 0x0002);	}	AsicDisableSync(pAd);	pAd->Mlme.PeriodicRound = 0;	pAd->ScanAllowed = TRUE;	// Remove PortCfg Information after link down	memset(&(pAd->PortCfg.Bssid), 0, MAC_ADDR_LEN);		// Reset WPA-PSK state. Only reset when supplicant enabled	if (pAd->PortCfg.WpaState != SS_NOTUSE)	{		pAd->PortCfg.WpaState = SS_START;		// Clear Replay counter		memset(pAd->PortCfg.ReplayCounter, 0, 8);	}	// Remove all WPA keys after link down	RTMPWPARemoveAllKeys(pAd);	// 802.1x port control	pAd->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;	pAd->PortCfg.MicErrCnt = 0;	if (pAd->PortCfg.LedMode == LED_MODE_ALPHA)		pAd->PortCfg.LedCntl.fLinkUp = FALSE;	// Update extra information to link is up	pAd->ExtraInfo = GENERAL_LINK_DOWN;	// Start STA supplicant state machine	//pAd->PortCfg.WpaState = SS_NOTUSE;}/*	==========================================================================	Description:	==========================================================================*/VOID MlmeCntlConfirm(	IN PRT2570ADAPTER pAd, 	IN ULONG MsgType, 	IN USHORT Msg) {	MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(USHORT), &Msg);}/*	==========================================================================	Description:	==========================================================================*/VOID IterateOnBssTab(	IN PRT2570ADAPTER pAd) {	MLME_START_REQ_STRUCT	StartReq;	MLME_JOIN_REQ_STRUCT	JoinReq;	ULONG					BssIdx;	BssIdx = pAd->Mlme.CntlAux.BssIdx;	if (BssIdx < pAd->Mlme.CntlAux.SsidBssTab.BssNr) 	{		if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS))			RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_JOIN_IN_PROGRESS);//steven:for test		DBGPRINT(RT_DEBUG_TRACE, "CNTL - Trying BSSID %02x:%02x:%02x:%02x:%02x:%02x ...\n", 			pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[0],			pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[1],			pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[2],			pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[3],			pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[4],			pAd->Mlme.CntlAux.SsidBssTab.BssEntry[BssIdx].Bssid.Octet[5]);		JoinParmFill(pAd, &JoinReq, BssIdx);		MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ, sizeof(MLME_JOIN_REQ_STRUCT),					&JoinReq);		pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;	}	else if (pAd->PortCfg.BssType == BSS_INDEP)	{		DBGPRINT(RT_DEBUG_TRACE, "CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",pAd->Mlme.CntlAux.Ssid);		StartParmFill(pAd, &StartReq, pAd->Mlme.CntlAux.Ssid, (UCHAR)pAd->Mlme.CntlAux.SsidLen);		MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq);		pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;	}	else // no more BSS	{		if (pAd->Mlme.CntlAux.CurrReqIsFromNdis)		{			DBGPRINT(RT_DEBUG_TRACE, "CNTL - All BSS fail; reply NDIS_STATUS_NOT_ACCEPTED\n");			NdisMSetInformationComplete(pAd->AdapterHandle, NDIS_STATUS_SUCCESS);

⌨️ 快捷键说明

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