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

📄 assoc.c

📁 r73模块的无线网卡在Linux下的驱动程序
💻 C
📖 第 1 页 / 共 3 页
字号:
							  END_OF_ARGS);			FrameLen += TmpLen;		}#endif		MiniportMMRequest(pAd, pOutBuffer, FrameLen);		RTMPSetTimer(pAd, &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;	// 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);		// 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, pOutBuffer, FrameLen);		RTMPSetTimer(pAd, &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;    USHORT                Status;    USHORT                NStatus;#if 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");        Status = MLME_FAIL_NO_RESOURCE;        MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);        return;    }    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, 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);#if 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;        wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);    }#endif    pAd->PortCfg.DisassocReason = pDisassocReq->Reason;    COPY_MAC_ADDR(pAd->PortCfg.DisassocSta, pDisassocReq->Addr);	Status = MLME_SUCCESS;	MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);}#if WPA_SUPPLICANT_SUPPORT#ifdef DBGstatic void _rtmp_hexdump(int level, const char *title, const u8 *buf,			 size_t len, int show){	size_t i;	DBGPRINT(level, "%s - hexdump(len=%lu):", title, (unsigned long)len);	if (show) {		for (i = 0; i < len; i++)			DBGPRINT_RAW(level, " %02x", buf[i]);	} else {		DBGPRINT_RAW(level, " [REMOVED]");	}	DBGPRINT_RAW(level, "\n");}void rtmp_hexdump(int level, const char *title, const u8 *buf, size_t len){	_rtmp_hexdump(level, title, buf, len, 1);}#endifNDIS_STATUS miniport_query_info(     IN PRTMP_ADAPTER pAd,     IN USHORT oid,     OUT void *buf,     OUT ULONG bufsize){    // First add AssocInfo	memcpy(buf, &pAd->PortCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));	// Second add ReqVarIEs	memcpy(buf + sizeof(NDIS_802_11_ASSOCIATION_INFORMATION), pAd->PortCfg.ReqVarIEs, pAd->PortCfg.ReqVarIELen);	// Third add ResVarIEs	memcpy(buf + sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->PortCfg.ReqVarIELen, pAd->PortCfg.ResVarIEs, pAd->PortCfg.ResVarIELen);	return 0;}VOID link_status_handler(    IN PRTMP_ADAPTER pAd){	NDIS_802_11_ASSOCIATION_INFORMATION *ndis_assoc_info;	unsigned char *wpa_assoc_info_req, *wpa_assoc_info_resp, *ies;	unsigned char *p;	int i;	unsigned char *assoc_info;	union iwreq_data wrqu;	NDIS_STATUS res;	const int assoc_size = sizeof(*ndis_assoc_info) + IW_CUSTOM_MAX;	assoc_info = kmalloc(assoc_size, MEM_ALLOC_FLAG);	if (!assoc_info) {              DBGPRINT(RT_DEBUG_TRACE, "couldn't allocate memory\n");		return;	}	memset(assoc_info, 0, assoc_size);	ndis_assoc_info = (NDIS_802_11_ASSOCIATION_INFORMATION *)assoc_info;	res = miniport_query_info(pAd, OID_802_11_ASSOCIATION_INFORMATION,				  assoc_info, assoc_size);	if (res) {		DBGPRINT(RT_DEBUG_TRACE, "query assoc_info failed\n");		if(assoc_info != NULL){			kfree(assoc_info);		}		return;	}	/*	 * TODO: backwards compatibility would require that IWEVCUSTOM	 * is sent even if WIRELESS_EXT > 17. This version does not do	 * this in order to allow wpa_supplicant to be tested with	 * WE-18.	 */#ifdef DBG	rtmp_hexdump(RT_DEBUG_TRACE, "ASSOCINFO", (const u8 *) ndis_assoc_info,		    sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));#endif    wpa_assoc_info_req = kmalloc(IW_CUSTOM_MAX, MEM_ALLOC_FLAG);	if (!wpa_assoc_info_req) {		DBGPRINT(RT_DEBUG_TRACE, "couldn't allocate memory\n");		//kfree(wpa_assoc_info_req);//Thomas		return;	}    //send ReqIEs    memset(wpa_assoc_info_req, 0, IW_CUSTOM_MAX);	p = wpa_assoc_info_req;	p += sprintf(p, "ASSOCINFO(ReqIEs=");	ies = ((char *)ndis_assoc_info) +		ndis_assoc_info->OffsetRequestIEs;	for (i = 0; i < ndis_assoc_info->RequestIELength; i++)		p += sprintf(p, "%02x", ies[i]);	memset(&wrqu, 0, sizeof(wrqu));    wrqu.data.length = p - wpa_assoc_info_req;	wrqu.data.flags = RT_REQIE_EVENT_FLAG;	DBGPRINT(RT_DEBUG_TRACE, "adding %d bytes\n", wrqu.data.length);	wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, wpa_assoc_info_req);    wpa_assoc_info_resp = kmalloc(IW_CUSTOM_MAX, MEM_ALLOC_FLAG);	if (!wpa_assoc_info_resp) {		DBGPRINT(RT_DEBUG_TRACE, "couldn't allocate memory\n");		//kfree(wpa_assoc_info_resp); //Thomas		return;	}    //send RespIEs	memset(wpa_assoc_info_resp, 0, IW_CUSTOM_MAX);	p = wpa_assoc_info_resp;	p += sprintf(p, " RespIEs=");	ies = ((char *)ndis_assoc_info) +		ndis_assoc_info->OffsetResponseIEs;	for (i = 0; i < ndis_assoc_info->ResponseIELength; i++)		p += sprintf(p, "%02x", ies[i]);	p += sprintf(p, ")");    memset(&wrqu, 0, sizeof(wrqu));	wrqu.data.length = p - wpa_assoc_info_resp;	wrqu.data.flags = RT_RESPIE_EVENT_FLAG;	wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, wpa_assoc_info_resp);        memset(&wrqu, 0, sizeof(wrqu));        wrqu.data.flags = RT_ASSOCINFO_EVENT_FLAG;        wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);#if 0	/* we need 28 extra bytes for the format strings */	if ((ndis_assoc_info->RequestIELength +	     ndis_assoc_info->ResponseIELength + 28) > IW_CUSTOM_MAX) {		//WARNING("information element is too long! (%u,%u),"		//	"association information dropped",		//	ndis_assoc_info->RequestIELength,		//	ndis_assoc_info->ResponseIELength);		DBGPRINT(RT_DEBUG_TRACE, "information element is too long! "			"association information dropped\n");		kfree(assoc_info);		return;	}	wpa_assoc_info = kmalloc(IW_CUSTOM_MAX, MEM_ALLOC_FLAG);	if (!wpa_assoc_info) {		DBGPRINT(RT_DEBUG_TRACE, "couldn't allocate memory\n");		kfree(assoc_info);		return;	}	p = wpa_assoc_info;	p += sprintf(p, "ASSOCINFO(ReqIEs=");	ies = ((char *)ndis_assoc_info) +		ndis_assoc_info->OffsetRequestIEs;	for (i = 0; i < ndis_assoc_info->RequestIELength; i++)		p += sprintf(p, "%02x", ies[i]);	p += sprintf(p, " RespIEs=");	ies = ((char *)ndis_assoc_info) +		ndis_assoc_info->OffsetResponseIEs;	for (i = 0; i < ndis_assoc_info->ResponseIELength; i++)		p += sprintf(p, "%02x", ies[i]);	p += sprintf(p, ")");	memset(&wrqu, 0, sizeof(wrqu));	wrqu.data.length = p - wpa_assoc_info;	//DBGPRINT(RT_DEBUG_TRACE, "adding %d bytes\n", wrqu.data.length);	wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, wpa_assoc_info);	kfree(wpa_assoc_info);#endif	if(wpa_assoc_info_req != NULL){		kfree(wpa_assoc_info_req);	}	if(wpa_assoc_info_resp != NULL){		kfree(wpa_assoc_info_resp);	}	if(assoc_info != NULL){		kfree(assoc_info);	}	return;}#endif/*    ==========================================================================    Description:

⌨️ 快捷键说明

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