欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

assoc.c

RT73无线网络芯片最新linux下驱动 支持到linux2.6.24 并向下兼容
C
第 1 页 / 共 4 页
字号:
			FrameLen += tmp;		}		if (pAd->MlmeAux.APEdcaParm.bValid)		{			WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);			MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,							  9,						&WmeIe[0],							  END_OF_ARGS);			FrameLen += tmp;		}		// For WPA / WPA-PSK		if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) || 			(pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK))					{			// Copy WPA template to buffer			CipherTmpLen = sizeof(CipherWpaTemplate);			NdisMoveMemory(CipherTmp, CipherWpaTemplate, CipherTmpLen);			// Modify Group cipher			CipherTmp[11] = ((pAd->PortCfg.GroupCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4);			// Modify Pairwise cipher			CipherTmp[17] = ((pAd->PortCfg.PairCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4);			// Modify AKM			CipherTmp[23] = ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ? 0x1 : 0x2);			// Make outgoing frame			MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,							  CipherTmpLen,				&CipherTmp[0],							  END_OF_ARGS);			FrameLen += tmp;						// Append Variable IE			printk("%s(): WPA/WPAPSK, Fill the ReqVarIEs with CipherTmp!\n", __FUNCTION__);			NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, CipherTmp, CipherTmpLen);			VarIesOffset += CipherTmpLen;			// Set Variable IEs Length			pAd->PortCfg.ReqVarIELen = VarIesOffset;			pAd->PortCfg.AssocInfo.RequestIELength = VarIesOffset;			// OffsetResponseIEs follow ReqVarIE			pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;		}		// For WPA2 / WPA2-PSK		else if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) || 				 (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))		{			// Copy WPA2 template to buffer			CipherTmpLen = sizeof(CipherWpa2Template);			NdisMoveMemory(CipherTmp, CipherWpa2Template, CipherTmpLen);			// Modify Group cipher			CipherTmp[7] = ((pAd->PortCfg.GroupCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4);			// Modify Pairwise cipher			CipherTmp[13] = ((pAd->PortCfg.PairCipher == Ndis802_11Encryption2Enabled) ? 0x2 : 0x4);			// Modify AKM			CipherTmp[19] = ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) ? 0x1 : 0x2);			// Check for WPA PMK cache list			if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2)			{				// Search chched PMKID, append it if existed				for (idx = 0; idx < PMKID_NO; idx++)				{					if (NdisEqualMemory(ApAddr, &pAd->PortCfg.SavedPMK[idx].BSSID, 6))					{						FoundPMK = TRUE;						break;					}				}				if (FoundPMK)				{					// Update length within RSN IE					CipherTmp[1] += 18;					// Set PMK number					*(PUSHORT) &CipherTmp[CipherTmpLen] = 1;					NdisMoveMemory(&CipherTmp[CipherTmpLen + 2], &pAd->PortCfg.SavedPMK[idx].PMKID, 16);					CipherTmpLen += 18;				}			}			// Make outgoing frame			MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,							  CipherTmpLen,				&CipherTmp[0],							  END_OF_ARGS);			FrameLen += tmp;			// Append Variable IE			printk("%s(): WPA2/WPA2PSK fill the ReqVarIEs with CipherTmp!\n", __FUNCTION__);			NdisMoveMemory(pAd->PortCfg.ReqVarIEs + VarIesOffset, CipherTmp, CipherTmpLen);			VarIesOffset += CipherTmpLen;			// Set Variable IEs Length			pAd->PortCfg.ReqVarIELen = VarIesOffset;			pAd->PortCfg.AssocInfo.RequestIELength = VarIesOffset;			// OffsetResponseIEs follow ReqVarIE			pAd->PortCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen;					}		else		{			// Do nothing			;		}#if 0 //AGGREGATION_SUPPORT		// add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION, only when -		// 1. user enable aggregation, AND		// 2. AP annouces it's AGGREGATION-capable in BEACON		if (pAd->PortCfg.bAggregationCapable && (pAd->MlmeAux.APRalinkIe & 0x00000001))		{			ULONG TmpLen;			UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00}; 			MakeOutgoingFrame(pOutBuffer+FrameLen,			 &TmpLen,							  9,							 RalinkIe,							  END_OF_ARGS);			FrameLen += TmpLen;		}#endif				MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);		RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);		pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;	} 	else 	{		DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n");		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;		Status = MLME_INVALID_FORMAT;		MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);	}}/*	==========================================================================	Description:		mlme reassoc req handling procedure	Parameters:		Elem - 	Pre:		-# SSID  (Adapter->PortCfg.ssid[])		-# BSSID (AP address, Adapter->PortCfg.bssid)		-# Supported rates (Adapter->PortCfg.supported_rates[])		-# Supported rates length (Adapter->PortCfg.supported_rates_len)		-# Tx power (Adapter->PortCfg.tx_power)			========================================================================== */VOID MlmeReassocReqAction(	IN PRTMP_ADAPTER pAd, 	IN MLME_QUEUE_ELEM *Elem) {	UCHAR			ApAddr[6];	HEADER_802_11	ReassocHdr;		UCHAR			WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, STA_QOS_CAPABILITY};	USHORT			CapabilityInfo, ListenIntv;	ULONG			Timeout;	ULONG			FrameLen = 0;	ULONG			tmp;	PUCHAR			pOutBuffer = NULL;	USHORT			Status;	USHORT			NStatus;	BOOLEAN         TimerCancelled;		// Block all authentication request durning WPA block period	if (pAd->PortCfg.bBlockAssoc == TRUE)	{		DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Block ReAssoc request durning WPA block period!\n");		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;		Status = MLME_STATE_MACHINE_REJECT;		MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);	}		// the parameters are the same as the association	else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))	{		RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer,&TimerCancelled);		// allocate and send out ReassocReq frame		NStatus = MlmeAllocateMemory(pAd, (PVOID *)&pOutBuffer);	//Get an unused nonpaged memory		if (NStatus != NDIS_STATUS_SUCCESS)		{			DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeReassocReqAction() allocate memory failed \n");			pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;			Status = MLME_FAIL_NO_RESOURCE;			MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);			return;		}		COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);		// make frame, use bssid as the AP address??		DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Send RE-ASSOC request...\n");		MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0, ApAddr, ApAddr);		MakeOutgoingFrame(pOutBuffer,				&FrameLen,						  sizeof(HEADER_802_11),	&ReassocHdr,						  2,						&CapabilityInfo,						  2,						&ListenIntv,						  MAC_ADDR_LEN, 			ApAddr,						  1,						&SsidIe,						  1,						&pAd->MlmeAux.SsidLen, 						  pAd->MlmeAux.SsidLen, 	pAd->MlmeAux.Ssid, 						  1,						&SupRateIe,						  1,						&pAd->MlmeAux.SupRateLen,						  pAd->MlmeAux.SupRateLen,	pAd->MlmeAux.SupRate,						  END_OF_ARGS);		if (pAd->MlmeAux.ExtRateLen != 0)		{			MakeOutgoingFrame(pOutBuffer + FrameLen,		&tmp,							  1,							&ExtRateIe,							  1,							&pAd->MlmeAux.ExtRateLen,							  pAd->MlmeAux.ExtRateLen,		pAd->MlmeAux.ExtRate,														  END_OF_ARGS);			FrameLen += tmp;		}		if (pAd->MlmeAux.APEdcaParm.bValid)		{			WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);			MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,							  9,						&WmeIe[0],							  END_OF_ARGS);			FrameLen += tmp;		}#if 0 //AGGREGATION_SUPPORT		// add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION, only when -		// 1. user enable aggregation, AND		// 2. AP annouces it's AGGREGATION-capable in BEACON		if (pAd->PortCfg.bAggregationCapable && (pAd->MlmeAux.APRalinkIe & 0x00000001))		{			ULONG TmpLen;			UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00}; 			MakeOutgoingFrame(pOutBuffer+FrameLen,			 &TmpLen,							  9,							 RalinkIe,							  END_OF_ARGS);			FrameLen += TmpLen;		}#endif		MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);				RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout);		pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;	} 	else 	{		DBGPRINT(RT_DEBUG_TRACE,"ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n");		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;		Status = MLME_INVALID_FORMAT;		MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);	}}/*    ==========================================================================    Description:        Upper layer issues disassoc request    Parameters:        Elem -    ========================================================================== */VOID MlmeDisassocReqAction(    IN PRTMP_ADAPTER pAd,     IN MLME_QUEUE_ELEM *Elem) {    PMLME_DISASSOC_REQ_STRUCT pDisassocReq;    HEADER_802_11         DisassocHdr;    PCHAR                 pOutBuffer = NULL;    ULONG                 FrameLen = 0;    ULONG                 Timeout = 0;    USHORT                Status;    USHORT                NStatus;	BOOLEAN               TimerCancelled;#ifdef RALINK_WPA_SUPPLICANT_SUPPORT    union iwreq_data      wrqu;#endif        // skip sanity check    pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);    // allocate and send out DeassocReq frame    NStatus = MlmeAllocateMemory(pAd, (PVOID *)&pOutBuffer);  //Get an unused nonpaged memory    if (NStatus != NDIS_STATUS_SUCCESS)    {        DBGPRINT(RT_DEBUG_TRACE, "ASSOC - MlmeDisassocReqAction() allocate memory failed\n");        pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;        Status = MLME_FAIL_NO_RESOURCE;        MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);        return;    }    RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer,&TimerCancelled);        DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Send DISASSOC request\n");    MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr);    MakeOutgoingFrame(pOutBuffer,           &FrameLen,                       sizeof(HEADER_802_11),&DisassocHdr,                       2,                    &pDisassocReq->Reason,                       END_OF_ARGS);    MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);		// Set the control aux SSID to prevent it reconnect to old SSID	// Since calling this indicate user don't want to connect to that SSID anymore.	// 2004-11-10 can't reset this info, cause it may be the new SSID that user requests for	// pAd->MlmeAux.SsidLen = MAX_LEN_OF_SSID;	// NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);    // NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN);    #ifdef RALINK_WPA_SUPPLICANT_SUPPORT    if (pAd->PortCfg.WPA_Supplicant == TRUE) {               //send disassociate event to wpa_supplicant        memset(&wrqu, 0, sizeof(wrqu));        wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;

⌨️ 快捷键说明

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