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

assoc.c

RT73无线网络芯片最新linux下驱动 支持到linux2.6.24 并向下兼容
C
第 1 页 / 共 4 页
字号:
        wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);    } #endif#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT					if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli		wext_notify_event_assoc(pAd, SIOCGIWAP, FALSE);#endif // NATIVE_WPA_SUPPLICANT_SUPPORT    pAd->PortCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;    COPY_MAC_ADDR(pAd->PortCfg.DisassocSta, pDisassocReq->Addr);    RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout);        pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;}#ifdef RALINK_WPA_SUPPLICANT_SUPPORT#ifdef DBGstatic void _rtmp_hexdump(int level, const char *title, const u8 *buf,			 size_t len, int show){	size_t i;	if (level < RTDebugLevel)		return;	printk("%s - hexdump(len=%lu):", title, (unsigned long) len);	if (show) {		for (i = 0; i < len; i++)			printk(" %02x", buf[i]);	} else {		printk(" [REMOVED]");	}	printk("\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	NdisMoveMemory(buf, &pAd->PortCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));	// Second add ReqVarIEs	NdisMoveMemory(buf + sizeof(NDIS_802_11_ASSOCIATION_INFORMATION), pAd->PortCfg.ReqVarIEs, pAd->PortCfg.ReqVarIELen);	// Third add ResVarIEs	NdisMoveMemory(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");		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");		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, "%c", ies[i]);    p += sprintf(p, "\0");	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");		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, "%c", ies[i]);	p += sprintf(p, "\0");    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    kfree(wpa_assoc_info_req);	kfree(wpa_assoc_info_resp);	kfree(assoc_info);	return;}#endif/*    ==========================================================================    Description:        peer sends assoc rsp back    Parameters:        Elme - MLME message containing the received frame    ========================================================================== */VOID PeerAssocRspAction(    IN PRTMP_ADAPTER pAd,     IN MLME_QUEUE_ELEM *Elem) {    USHORT        CapabilityInfo, Status, Aid;    UCHAR         SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;    UCHAR         ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;    UCHAR         Addr2[MAC_ADDR_LEN];	EDCA_PARM     EdcaParm;	BOOLEAN       TimerCancelled;#ifdef RALINK_WPA_SUPPLICANT_SUPPORT    union iwreq_data wrqu;#endif    if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &EdcaParm))    {        // The frame is for me ?        if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))         {            DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status);		            RTMPCancelTimer(&pAd->MlmeAux.AssocTimer,&TimerCancelled);            if(Status == MLME_SUCCESS)             {                //				// There may some packets will be drop, if we haven't set the BSS type!				// For example: EAPOL packet and the case of WHQL lost Packets.				// Since this may some delays to set those variables at LinkUp(..) on this (Mlme) thread. 				// 				// This is a trick, set the BSS type here.				//				if (pAd->PortCfg.BssType == BSS_INFRA)				{					OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);				}                // go to procedure listed on page 376                AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, &EdcaParm);  	#ifdef RALINK_WPA_SUPPLICANT_SUPPORT                if (pAd->PortCfg.WPA_Supplicant == TRUE) {                    // collect associate info                     link_status_handler(pAd);                    //send associnfo event to wpa_supplicant                    memset(&wrqu, 0, sizeof(wrqu));                    wrqu.data.flags = RT_ASSOC_EVENT_FLAG;                    wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);                }#endif#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT				// collect associate info and notify the wpa_supplicant. 				if (pAd->PortCfg.bNativeWpa == TRUE)  // add by johnli					wext_notify_event_assoc(pAd, SIOCGIWAP, TRUE);#endif // NATIVE_WPA_SUPPLICANT_SUPPORT            } 			            pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;            MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);        }     }    else    {        DBGPRINT(RT_DEBUG_TRACE, "ASSOC - PeerAssocRspAction() sanity check fail\n");    }}/*    ==========================================================================    Description:        peer sends reassoc rsp    Parametrs:        Elem - MLME message cntaining the received frame    ========================================================================== */VOID PeerReassocRspAction(    IN PRTMP_ADAPTER pAd,     IN MLME_QUEUE_ELEM *Elem) {    USHORT      CapabilityInfo;    USHORT      Status;    USHORT      Aid;    UCHAR       SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;    UCHAR       ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;    UCHAR       Addr2[MAC_ADDR_LEN];    EDCA_PARM   EdcaParm;	BOOLEAN     TimerCancelled;    #ifdef RALINK_WPA_SUPPLICANT_SUPPORT    union iwreq_data wrqu;#endif    if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &EdcaParm))     {        if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?

⌨️ 快捷键说明

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