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

📄 connect.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
		}				// 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 = 1;			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);				// 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);						pEntry->Aid = BSSID_WCID;						// 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);		}		else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||				 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))		{#ifdef WPA_SUPPLICANT_SUPPORT			if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)#endif // WPA_SUPPLICANT_SUPPORT //				RTMPSetTimer(&pAd->Mlme.LinkDownTimer, LINK_DOWN_TIMEOUT);		}        // --		// Add BSSID in my MAC Table.        NdisAcquireSpinLock(&pAd->MacTabLock);		// add this MAC entry into HASH table		if (pEntry)		{			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;			}		}		RTMPMoveMemory(pEntry->Addr, pAd->CommonCfg.Bssid, MAC_ADDR_LEN);		pEntry->Aid = BSSID_WCID;		pEntry->pAd = pAd;		pEntry->ValidAsCLI = TRUE;	//Although this is bssid..still set ValidAsCl		pAd->MacTab.Size = 1;	// infra mode always set MACtab size =1.		pEntry->Sst = SST_ASSOC;		pEntry->AuthState = SST_ASSOC;		pEntry->AuthMode = pAd->StaCfg.AuthMode;		pEntry->WepStatus = pAd->StaCfg.WepStatus;		if (pEntry->AuthMode < Ndis802_11AuthModeWPA)		{			pEntry->WpaState = AS_NOTUSE;			pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;		}		else		{			pEntry->WpaState = AS_PTKSTART;			pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;		}        	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 //		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 = FALSE;#ifdef DOT11_N_SUPPORT		if (pEntry->HTPhyMode.field.MCS == 32)			pEntry->HTPhyMode.field.ShortGI = GI_800;		if ((pEntry->HTPhyMode.field.MCS > MCS_7) || (pEntry->HTPhyMode.field.MCS == 32))			pEntry->HTPhyMode.field.STBC = STBC_NONE;#endif // DOT11_N_SUPPORT //		// If the legacy mode is set, overwrite the transmit setting of this entry.  		if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM)			RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);	}	else		pEntry->bAutoTxRateSwitch = TRUE;	NdisReleaseSpinLock(&pAd->MacTabLock);	//  Let Link Status Page display first initial rate.	pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);	// Select DAC according to HT or Legacy	if (pAd->StaActive.SupportedPhyInfo.MCSSet[0] != 0x00)	{		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);		Value &= (~0x18);		if (pAd->Antenna.field.TxPath == 2)		{		    Value |= 0x10;		}		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);	}	else	{		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);		Value &= (~0x18);		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);	}#ifdef DOT11_N_SUPPORT	if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) 	{	}	else if (pEntry->MaxRAmpduFactor == 0)	{	    // If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0.	    // Because our Init value is 1 at MACRegTable.		RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff);	}#endif // DOT11_N_SUPPORT //	// Patch for Marvel AP to gain high throughput	// Need to set as following,	// 1. Set txop in register-EDCA_AC0_CFG as 0x60	// 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero	// 3. PBF_MAX_PCNT as 0x1F3FBF9F	// 4. kick per two packets when dequeue	// 	// Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable	//	// if 1. Legacy AP WMM on,  or 2. 11n AP, AMPDU disable.  Force turn off burst no matter what bEnableTxBurst is.#ifdef DOT11_N_SUPPORT	if (!((pAd->CommonCfg.RxStream == 1)&&(pAd->CommonCfg.TxStream == 1)) &&		(pAd->StaCfg.bForceTxBurst == FALSE) &&		(((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))			|| ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE))))	{		RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);		Data  &= 0xFFFFFF00;		RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);		RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);		DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n"));	}	else#endif // DOT11_N_SUPPORT //	if (pAd->CommonCfg.bEnableTxBurst)	{		RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);		Data  &= 0xFFFFFF00;		Data  |= 0x60;		RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);		pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = TRUE;		RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3FBF9F);		DBGPRINT(RT_DEBUG_TRACE, ("Txburst 2\n"));	}	else	{		RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);		Data  &= 0xFFFFFF00;		RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);		RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);		DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n"));	}	#ifdef DOT11_N_SUPPORT		// Re-check to turn on TX burst or not.	if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) && ((STA_WEP_ON(pAd))||(STA_TKIP_ON(pAd))))	{		pAd->CommonCfg.IOTestParm.bNextDisableRxBA = TRUE;		if (pAd->CommonCfg.bEnableTxBurst)		{		    UINT32 MACValue = 0;			// Force disable  TXOP value in this case. The same action in MLMEUpdateProtect too.			// I did

⌨️ 快捷键说明

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