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

📄 connect.c

📁 Linux下的RT系列无线网卡驱动,可以直接在x86平台上编译
💻 C
📖 第 1 页 / 共 5 页
字号:
			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);		}		DBGPRINT(RT_DEBUG_TRACE, ("!!!20MHz Adhoc LINK UP !!! \n" ));	}	else	{		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON);		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);	    	// Change to AP channel        if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))    	{	    		// Must using 40MHz.    		pAd->CommonCfg.BBPCurrentBW = BW_40;    		AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);    		AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);    			    		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);    		Value &= (~0x18);    		Value |= 0x10;    		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);    		    		//  RX : control channel at lower     		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);    		Value &= (~0x20);    		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);    		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);    		Data &= 0xfffffffe;    		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);    		    		if (pAd->MACVersion == 0x28600100)    		{    			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);    			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);    			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);                DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));    		}	    		DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));    	}		else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))	    {			    // Must using 40MHz.			pAd->CommonCfg.BBPCurrentBW = BW_40;			AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);		    AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);						RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);    		Value &= (~0x18);    		Value |= 0x10;			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);			    		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);    		Data |= 0x1;    		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);						RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);		    Value |= (0x20);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);		    		if (pAd->MACVersion == 0x28600100)    		{    			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);    			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);    			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);    			    DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));    		}		    DBGPRINT(RT_DEBUG_TRACE, ("!!! 40MHz Upper LINK UP !!! Control Channel at UpperCentral = %d \n", pAd->CommonCfg.CentralChannel ));	    }	    else	    {		    pAd->CommonCfg.BBPCurrentBW = BW_40;			AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);			AsicLockChannel(pAd, pAd->CommonCfg.Channel);						RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);			Value &= (~0x18);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);						RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);			Data &= 0xfffffffe;			RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);						RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);			Value &= (~0x20);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);						if (pAd->MACVersion == 0x28600100)			{				RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);				RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);				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" ));	    }	}	RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x2E + GET_LNA_GAIN(pAd)));	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Infra=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n", 		BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (Density =%d, )\n", pAd->MacTab.Content[BSSID_WCID].MpduDensity));	AsicSetBssid(pAd, pAd->CommonCfg.Bssid);			AsicSetSlotTime(pAd, TRUE); //FALSE);	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);	if ((pAd->StaActive.SupportedHtPhy.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);	}	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))	{		DBGPRINT(RT_DEBUG_INFO, ("CNTL - !!! Set to short preamble!!!\n"));		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)	{		//		// We also need to cancel the LinkDownTimer, no matter it was been set or not.		// It may be set when we start an Infrastructure mode.		// And not be canceled yet then we switch to Adohc at meanwhile.		//		RTMPCancelTimer(&pAd->Mlme.LinkDownTimer, &Cancelled);		MakeIbssBeacon(pAd);		if ((pAd->CommonCfg.Channel > 14)			&& (pAd->CommonCfg.bIEEE80211H == 1)			&& RadarChannelCheck(pAd, pAd->CommonCfg.Channel))		{			; //Do nothing		}		else		{			AsicEnableIbssSync(pAd);		}		#ifdef	SINGLE_ADHOC_LINKUP		// Although this did not follow microsoft's recommendation.		//Change based on customer's request		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);         pAd->IndicateMediaState = NdisMediaStateConnected;		RTMP_IndicateMediaState();#endif		// 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	{		// First cancel linkdown timer		RTMPCancelTimer(&pAd->Mlme.LinkDownTimer, &Cancelled);		// 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();			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)/* &&			(!RTMPEqualMemory(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid, MAC_ADDR_LEN))*/)		{			// Remove all WPA keys 			RTMPWPARemoveAllKeys(pAd);			pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;					}		// 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);				// 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;			}		}		// 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 == 0)&&              (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);         pAd->IndicateMediaState = NdisMediaStateConnected;		RTMP_IndicateMediaState();		// Add BSSID in my MAC Table.

⌨️ 快捷键说明

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