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

📄 connect.c

📁 ralink最新rt3070 usb wifi 无线网卡驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);            DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));		}			    DBGPRINT(RT_DEBUG_TRACE, ("!!! 20MHz LINK UP !!! \n" ));    }	RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);	//	// Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission	//	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n", 		BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));#ifdef DOT11_N_SUPPORT	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Density =%d, )\n", pAd->MacTab.Content[BSSID_WCID].MpduDensity));#endif // DOT11_N_SUPPORT //		AsicSetBssid(pAd, pAd->CommonCfg.Bssid);			AsicSetSlotTime(pAd, TRUE);	AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);	// Call this for RTS protectionfor legacy rate, we will always enable RTS threshold, but normally it will not hit	AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE, FALSE);#ifdef DOT11_N_SUPPORT	if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))	{		// Update HT protectionfor based on AP's operating mode.    	if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)    	{    		AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode,  ALLN_SETPROTECT, FALSE, TRUE);    	}    	else   			AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode,  ALLN_SETPROTECT, FALSE, FALSE);	}#endif // DOT11_N_SUPPORT //	NdisZeroMemory(&pAd->DrsCounters, sizeof(COUNTER_DRS));	NdisGetSystemUpTime(&Now);	pAd->StaCfg.LastBeaconRxTime = Now;   // last RX timestamp	if ((pAd->CommonCfg.TxPreamble != Rt802_11PreambleLong) &&		CAP_IS_SHORT_PREAMBLE_ON(pAd->StaActive.CapabilityInfo))	{		MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);	}	OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED); 	if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE)	{#ifdef DFS_SUPPORT		RadarDetectionStop(pAd);#endif // DFS_SUPPORT //	}	pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;		if (BssType == BSS_ADHOC)	{		MakeIbssBeacon(pAd);		if ((pAd->CommonCfg.Channel > 14)			&& (pAd->CommonCfg.bIEEE80211H == 1)			&& RadarChannelCheck(pAd, pAd->CommonCfg.Channel))		{			; //Do nothing		}		else		{			AsicEnableIbssSync(pAd);		}				// In ad hoc mode, use MAC table from index 1. 		// p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here.		RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00);		RTMP_IO_WRITE32(pAd, 0x1808, 0x00);		// If WEP is enabled, add key material and cipherAlg into Asic		// Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)        		if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)		{						PUCHAR	Key; 						UCHAR 	CipherAlg;						for (idx=0; idx < SHARE_KEY_NUM; idx++)        	{				CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;    			Key = pAd->SharedKey[BSS0][idx].Key;							if (pAd->SharedKey[BSS0][idx].KeyLen > 0)				{					// Set key material and cipherAlg to Asic    				AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);						                                        if (idx == pAd->StaCfg.DefaultKeyId)					{						// Update WCID attribute table and IVEIV table for this group key table  						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);					}				}	                			}    		   		  		   							}				// If WPANone is enabled, add key material and cipherAlg into Asic 		// Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)		else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)		{			pAd->StaCfg.DefaultKeyId = 0;	// always be zero		            NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));  							pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;			NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);                        if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)            {    			NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);    			NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_TXMICK);            }			// Decide its ChiperAlg			if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)				pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;			else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)				pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;			else            {                         DBGPRINT(RT_DEBUG_TRACE, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd->StaCfg.PairCipher));				pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;            }					// Set key material and cipherAlg to Asic			AsicAddSharedKeyEntry(pAd, 								  BSS0, 								  0, 								  pAd->SharedKey[BSS0][0].CipherAlg, 								  pAd->SharedKey[BSS0][0].Key, 								  pAd->SharedKey[BSS0][0].TxMic, 								  pAd->SharedKey[BSS0][0].RxMic);	            // Update WCID attribute table and IVEIV table for this group key table  			RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pAd->SharedKey[BSS0][0].CipherAlg, NULL);            		}			}	else // BSS_INFRA	{		// Check the new SSID with last SSID		while (Cancelled == TRUE)		{			if (pAd->CommonCfg.LastSsidLen == pAd->CommonCfg.SsidLen)			{				if (RTMPCompareMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid, pAd->CommonCfg.LastSsidLen) == 0)				{					// Link to the old one no linkdown is required.					break;				}			}			// Send link down event before set to link up			pAd->IndicateMediaState = NdisMediaStateDisconnected;			RTMP_IndicateMediaState(pAd);            pAd->ExtraInfo = GENERAL_LINK_DOWN;			DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));			break;		}		//		// On WPA mode, Remove All Keys if not connect to the last BSSID		// Key will be set after 4-way handshake.		//		if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))		{			ULONG 		IV;						// Remove all WPA keys 			RTMPWPARemoveAllKeys(pAd);			pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;						pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;						// Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP			// If IV related values are too large in GroupMsg2, AP would ignore this message.			IV = 0;			IV |= (pAd->StaCfg.DefaultKeyId << 30);				AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);		}		// 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);		// Add BSSID to WCID search table		AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);				NdisAcquireSpinLock(&pAd->MacTabLock);		// add this BSSID entry into HASH table		{			UCHAR HashIdx;						//pEntry = &pAd->MacTab.Content[BSSID_WCID];			HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid);			if (pAd->MacTab.Hash[HashIdx] == NULL)			{				pAd->MacTab.Hash[HashIdx] = pEntry;			}			else			{				pCurrEntry = pAd->MacTab.Hash[HashIdx];				while (pCurrEntry->pNext != NULL)					pCurrEntry = pCurrEntry->pNext;				pCurrEntry->pNext = pEntry;			}		}		NdisReleaseSpinLock(&pAd->MacTabLock);				// If WEP is enabled, add paiewise and shared key#ifdef WPA_SUPPLICANT_SUPPORT        if (((pAd->StaCfg.WpaSupplicantUP)&&             (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)&&             (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) ||            ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)&&              (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)))#else		if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)#endif // WPA_SUPPLICANT_SUPPORT //            		{						PUCHAR	Key; 						UCHAR 	CipherAlg;						for (idx=0; idx < SHARE_KEY_NUM; idx++)        	{				CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;    			Key = pAd->SharedKey[BSS0][idx].Key;							if (pAd->SharedKey[BSS0][idx].KeyLen > 0)				{					// Set key material and cipherAlg to Asic    				AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);						if (idx == pAd->StaCfg.DefaultKeyId)					{						// Assign group key info  						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);						// Assign pairwise key info						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);						}				}				}    		   		  		   							}		// only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode		// should wait until at least 2 active nodes in this BSSID.		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);         // For GUI ++		if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)		{			pAd->IndicateMediaState = NdisMediaStateConnected;			pAd->ExtraInfo = GENERAL_LINK_UP;			RTMP_IndicateMediaState(pAd);		}        // --		// Add BSSID in my MAC Table.        NdisAcquireSpinLock(&pAd->MacTabLock);		RTMPMoveMemory(pAd->MacTab.Content[BSSID_WCID].Addr, pAd->CommonCfg.Bssid, MAC_ADDR_LEN);		pAd->MacTab.Content[BSSID_WCID].Aid = BSSID_WCID;		pAd->MacTab.Content[BSSID_WCID].pAd = pAd;		pAd->MacTab.Content[BSSID_WCID].ValidAsCLI = TRUE;	//Although this is bssid..still set ValidAsCl		pAd->MacTab.Size = 1;	// infra mode always set MACtab size =1.		pAd->MacTab.Content[BSSID_WCID].Sst = SST_ASSOC;		pAd->MacTab.Content[BSSID_WCID].AuthState = SST_ASSOC;		pAd->MacTab.Content[BSSID_WCID].AuthMode = pAd->StaCfg.AuthMode;		pAd->MacTab.Content[BSSID_WCID].WepStatus = pAd->StaCfg.WepStatus;        NdisReleaseSpinLock(&pAd->MacTabLock);		DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!!  ClientStatusFlags=%lx)\n", 			pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));		MlmeUpdateTxRates(pAd, TRUE, BSS0);#ifdef DOT11_N_SUPPORT		MlmeUpdateHtTxRates(pAd, BSS0);		DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !! (StaActive.bHtEnable =%d, )\n", pAd->StaActive.SupportedPhyInfo.bHtEnable));#endif // DOT11_N_SUPPORT //		//		// Report Adjacent AP report.		//#ifdef LEAP_SUPPORT		CCXAdjacentAPReport(pAd);#endif // LEAP_SUPPORT //		if (pAd->CommonCfg.bAggregationCapable)		{			if ((pAd->CommonCfg.bPiggyBackCapable) && (pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)			{				OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);				OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);                RTMPSetPiggyBack(pAd, TRUE);				DBGPRINT(RT_DEBUG_TRACE, ("Turn on Piggy-Back\n"));			}			else if (pAd->MlmeAux.APRalinkIe & 0x00000001)			{				OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);			}		}				if (pAd->MlmeAux.APRalinkIe != 0x0)		{#ifdef DOT11_N_SUPPORT					if (CLIENT_STATUS_TEST_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RDG_CAPABLE))			{				AsicEnableRDG(pAd);			}#endif // DOT11_N_SUPPORT //			OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);			CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);		}		else		{			OPSTATUS_CLEAR_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);			CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RALINK_CHIPSET);		}	}#ifdef DOT11_N_SUPPORT	DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n", pAd->CommonCfg.BACapability.word, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));#endif // DOT11_N_SUPPORT //	// Set LED	RTMPSetLED(pAd, LED_LINK_UP);		pAd->Mlme.PeriodicRound = 0;	pAd->Mlme.OneSecPeriodicRound = 0;	pAd->bConfigChanged = FALSE;        // Reset config flag	pAd->ExtraInfo = GENERAL_LINK_UP;   // Update extra information to link is up	// Set asic auto fall back	{		PUCHAR					pTable;		UCHAR					TableSize = 0;				MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID], &pTable, &TableSize, &pAd->CommonCfg.TxRateIndex);		AsicUpdateAutoFallBackTable(pAd, pTable);	}		NdisAcquireSpinLock(&pAd->MacTabLock);    pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word;    pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word;	if (pAd->StaCfg.bAutoTxRateSwitch == FALSE)	{		pEntry->bAutoTxRateSwitch = F

⌨️ 快捷键说明

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