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

📄 wlan_cmdresp.c

📁 marvell cf wifi driver source code CF-8385-linux-x86-5.0.4.p0-132-src.rar
💻 C
📖 第 1 页 / 共 5 页
字号:
	// Parse RSSI array
	for (j = 0; i < Adapter->ulNumOfBSSIDs; j++,i++) {
		Adapter->BSSIDList[i].Rssi =
			(LONG) (scan->RSSI[j]) + 
			MRVDRV_RSSI_DEFAULT_NOISE_VALUE;
#ifdef MULTI_BANDS
		Adapter->BSSIDList[i].bss_band = Adapter->cur_region_channel->Band;
#endif
	}
#endif /*TLV_SCAN*/

#ifdef TLV_SCAN
	for (j = 0; j < scan->NumberOfSets; j++, i++) {
#ifdef MULTI_BANDS
#ifdef BG_SCAN
	    if (priv->adapter->bgScanConfig->Enable) {
		// remove this after f/w add band info. in scan response
		MrvlIEtypes_ChanListParamSet_t	*chanList;
		ChanScanParamSet_t		*chanScan = NULL;
		u8				band = BAND_G;	

		chanList = (MrvlIEtypes_ChanListParamSet_t *)((u8 *)Adapter->bgScanConfig + 
					sizeof(HostCmd_DS_802_11_BG_SCAN_CONFIG));
		while (!chanScan &&
			((u8 *)chanList < (u8 *)Adapter->bgScanConfig + Adapter->bgScanConfigSize)) {
			PRINTK("Header type=%#x  len=%d\n",chanList->Header.Type,chanList->Header.Len);
			if (chanList->Header.Type == TLV_TYPE_CHANLIST) {
				chanScan = chanList->ChanScanParam;
				break;
			} else {
				chanList = (MrvlIEtypes_ChanListParamSet_t *)
					((u8 *)chanList + chanList->Header.Len + sizeof(chanList->Header));
			}
		}

		if (chanScan) {
			PRINTK("radio_type=%#x  chan=%#x\n",chanScan->RadioType,chanScan->ChanNumber);
			if (chanScan->RadioType == HostCmd_SCAN_RADIO_TYPE_A)
				band = BAND_A;
			else
				band = BAND_G;
		} else {
			printk("Cannot find valid radio_type/channel info. in channel list\n");
		}

 		Adapter->BSSIDList[i].bss_band = band;
	    } else {
#endif /* BG_SCAN */
 		Adapter->BSSIDList[i].bss_band = Adapter->cur_region_channel->Band;
#ifdef BG_SCAN
	    }
#endif /* BG_SCAN */
#endif /* MULTI_BANDS */
	}
#endif /*TLV_SCAN*/

	PRINTK1("Scan Results: number of BSSID: %d\n", Adapter->ulNumOfBSSIDs);
    
#if DEBUG
#ifdef PROGRESSIVE_SCAN
	if (Adapter->ScanChannelsLeft <= 0) {
#endif
		for (i = 0; i < Adapter->ulNumOfBSSIDs; i++) {
			PRINTK1("%2d:%32s-%02x:%02x:%02x:%02x:%02x:%02x "
					"RSSI=%d SR=%x\n", i,
					Adapter->BSSIDList[i].Ssid.Ssid,
					Adapter->BSSIDList[i].MacAddress[0],
					Adapter->BSSIDList[i].MacAddress[1],
					Adapter->BSSIDList[i].MacAddress[2],
					Adapter->BSSIDList[i].MacAddress[3],
					Adapter->BSSIDList[i].MacAddress[4],
					Adapter->BSSIDList[i].MacAddress[5],
					(int) Adapter->BSSIDList[i].Rssi,
					Adapter->
					BSSIDList[i].SupportedRates[i]);
		}

#ifdef PROGRESSIVE_SCAN
	}
#endif
#endif

  discard_bad_ssid(Adapter);

	// if currently connected to an AP or an Ad Hoc network
	if (Adapter->CurBssParams.ssid.SsidLength != 0 &&
			Adapter->CurBssParams.ssid.Ssid[0] > 0x20) {
		// try to find the current SSID in the new scan list
		for (i = 0; i < Adapter->ulNumOfBSSIDs; i++) {
			if (!SSIDcmp(&Adapter->BSSIDList[i].Ssid,
						&Adapter->CurBssParams.ssid) &&
					!memcmp(Adapter->CurrentBSSID,
						Adapter->BSSIDList[i].
						MacAddress,
						MRVDRV_ETH_ADDR_LEN)) {
				break;
			}
		}
		
		// if we found matching SSID, update the index
		if (i < Adapter->ulNumOfBSSIDs) {
			// Set the attempted BSSID Index to current
			Adapter->ulCurrentBSSIDIndex = i;
			// Set the new BSSID (AP's MAC address) to current
			// BSSID
			memcpy(Adapter->CurrentBSSID,
					&(Adapter->BSSIDList[Adapter->
					ulCurrentBSSIDIndex].MacAddress),
					MRVDRV_ETH_ADDR_LEN);
			
			// Make a copy of current BSSID descriptor
			memcpy(&Adapter->CurrentBSSIDDescriptor,
					&Adapter->BSSIDList[Adapter->
					ulCurrentBSSIDIndex],
					sizeof(WLAN_802_11_BSSID));
			// Set the new configuration to the current config
			memcpy(&Adapter->CurrentConfiguration,
					&Adapter->BSSIDList[Adapter->
					ulCurrentBSSIDIndex].Configuration, 
					sizeof(WLAN_802_11_CONFIGURATION));
		}
		// if the current associated SSID is not contained in the
		// list, append it
		else {
#ifdef PROGRESSIVE_SCAN
			if (Adapter->ScanChannelsLeft == 0) {
#endif
				AppendCurrentSSID(priv, i);
#ifdef PROGRESSIVE_SCAN				
			}
#endif
		}
	}

	PRINTK1("HWAC - Scanned %2d APs\n", Adapter->ulNumOfBSSIDs);

	LEAVE();
	return 0;
}

static int wlan_ret_mac_control(wlan_private * priv, HostCmd_DS_COMMAND * resp)
{
	return 0;
}

static int wlan_ret_802_11_associate(wlan_private * priv, 
		HostCmd_DS_COMMAND * resp)
{
	HostCmd_DS_802_11_ASSOCIATE_RSP	*rasst = &resp->params.associatersp;
	wlan_adapter			*Adapter = priv->adapter;
	union iwreq_data		wrqu;
	u16				ResultCode = wlan_le16_to_cpu(rasst->ResultCode);

	ENTER();

	Adapter->bIsAssociationInProgress = FALSE;

    // if there is a reset pending
    if (Adapter->bIsPendingReset == TRUE) 
    {
		Adapter->bIsPendingReset = FALSE;
		
		PRINTK1("HWAC - Sending ResetComplete\n");
		Adapter->HardwareStatus = WlanHardwareStatusReady;
		
		SetMacPacketFilter(priv);
    }
    
    // if association result code != 0, will return Failure later
    if (ResultCode)
    {
		PRINTK1("HWAC - Association Failed, code = %d\n", rasst->ResultCode);
		if (Adapter->MediaConnectStatus == WlanMediaStateConnected) 
        {
			MacEventDisconnected(priv);
		}
	
		ResetSingleTxDoneAck(priv);

#ifdef WPA  
        if (ResultCode == HostCmd_Assoc_RESULT_AUTH_REFUSED)
        {
            send_iwevcustom_event(priv, "BAD-AUTH.indication ");
        }
#endif
		return 0;
	}

#if defined(WPA) || defined(SAVE_ASSOC_RSP)
    {
		//copy the association result info to the 
		//ASSOCIATION_INFO buffer
		PWLAN_802_11_ASSOCIATION_INFORMATION pInfo;
        int buflen;
	
		pInfo = (PWLAN_802_11_ASSOCIATION_INFORMATION)
			Adapter->AssocInfoBuffer;

		//only currently copy the fixed IE
		//Todo : copy the entire IE once it is available
		memcpy(&pInfo->ResponseFixedIEs.Capabilities, 
				&rasst->CapInfo, sizeof(rasst->CapInfo));
		pInfo->ResponseFixedIEs.StatusCode =
			ResultCode;
		pInfo->ResponseFixedIEs.AssociationId =
			wlan_le16_to_cpu(rasst->AssociationID);
		pInfo->AvailableResponseFixedIEs |=
				WLAN_802_11_AI_RESFI_CAPABILITIES;
		pInfo->AvailableResponseFixedIEs |=
				WLAN_802_11_AI_RESFI_STATUSCODE;
		pInfo->AvailableResponseFixedIEs |=
				WLAN_802_11_AI_RESFI_ASSOCIATIONID;
		pInfo->OffsetResponseIEs = pInfo->OffsetRequestIEs + 
				pInfo->RequestIELength;
		pInfo->ResponseIELength = wlan_le16_to_cpu(rasst->IELength);
        buflen = sizeof(Adapter->AssocInfoBuffer) - pInfo->OffsetResponseIEs;

#ifdef NEW_ASSOCIATION_RSP
		memmove((u8*)pInfo + pInfo->OffsetResponseIEs, 
				(u8*)&rasst->RateID, 
                MIN(buflen, wlan_le16_to_cpu(rasst->IELength)));
#else
		memmove((u8*)pInfo + pInfo->OffsetResponseIEs, 
				rasst->IE,
                MIN(buflen, wlan_le16_to_cpu(rasst->IELength)));
#endif
		PRINTK1("Association Result IE: CapInfo = 0x%x,"
				"StatusCode = 0x%x,AssociationID = 0x%x\n",
				pInfo->ResponseFixedIEs.Capabilities,
				pInfo->ResponseFixedIEs.StatusCode,
				pInfo->ResponseFixedIEs.AssociationId);
	}
#endif	// #if defined(WPA) || defined(SAVE_ASSOC_RSP)
	
	HEXDUMP("Association response:", 
			(void*)rasst, sizeof(HostCmd_DS_802_11_ASSOCIATE_RSP));
	
	// Send a Media Connected event, according to the Spec
	Adapter->MediaConnectStatus = WlanMediaStateConnected;
	Adapter->LinkSpeed = MRVDRV_LINK_SPEED_11mbps;
	
	// Set the attempted BSSID Index to current
	Adapter->ulCurrentBSSIDIndex = Adapter->ulAttemptedBSSIDIndex;
	
	PRINTK1("Associated BSSIDList[%d]=%s\n", Adapter->ulCurrentBSSIDIndex,
			Adapter->BSSIDList[Adapter->
			ulCurrentBSSIDIndex].Ssid.Ssid);
	
	// Set the new SSID to current SSID
	memcpy(&Adapter->CurBssParams.ssid, &Adapter->
			BSSIDList[Adapter-> ulCurrentBSSIDIndex].Ssid,
			sizeof(WLAN_802_11_SSID));
	
	// Set the new BSSID (AP's MAC address) to current BSSID
	memcpy(Adapter->CurrentBSSID, &Adapter->BSSIDList
			[Adapter->ulCurrentBSSIDIndex].MacAddress,
			MRVDRV_ETH_ADDR_LEN);
	
	// Make a copy of current BSSID descriptor
	memcpy(&Adapter->CurrentBSSIDDescriptor,
			&Adapter->BSSIDList[Adapter->ulCurrentBSSIDIndex],
			sizeof(WLAN_802_11_BSSID));

	/* Copy associate'd bssid into Current BSS State struct */
	memcpy(&Adapter->CurBssParams.bssid, 
			&Adapter->BSSIDList[Adapter->ulCurrentBSSIDIndex],
			sizeof(WLAN_802_11_BSSID));
	
#ifdef WMM
	if (Adapter->BSSIDList[Adapter->
			ulCurrentBSSIDIndex].Wmm_IE[0] == WMM_IE)
		Adapter->CurBssParams.wmm_enabled = TRUE;
	else
		Adapter->CurBssParams.wmm_enabled = FALSE;

	if (Adapter->wmm.required && Adapter->CurBssParams.wmm_enabled)
		Adapter->wmm.enabled = TRUE;
	else
		Adapter->wmm.enabled = FALSE;
#endif /* WMM */

#ifdef WMM_UAPSD
	Adapter->CurBssParams.wmm_uapsd_enabled = FALSE;

	if (Adapter->wmm.enabled == TRUE)
	{
		if(Adapter->BSSIDList[Adapter->ulCurrentBSSIDIndex].Wmm_IE[8] & 0x80)
		Adapter->CurBssParams.wmm_uapsd_enabled = TRUE;
	}
#endif

	if (Adapter->ulCurrentBSSIDIndex < MRVDRV_MAX_BSSID_LIST) {
		// Set the new configuration to the current config
		memcpy(&Adapter->CurrentConfiguration,
				&Adapter->BSSIDList[Adapter->
				ulCurrentBSSIDIndex].
				Configuration, 
				sizeof(WLAN_802_11_CONFIGURATION));
	}
	
	// if the periodic timer is on, cancel it
	if (Adapter->TimerIsSet == TRUE) {
		CancelTimer(&Adapter->MrvDrvTimer);
		Adapter->TimerIsSet = FALSE;
	}
	
	// Association causes the MAC to lose the flag such as
	// promiscuous mode on, need to set the flag again
	if (Adapter->CurBssParams.ssid.Ssid[0] == '\0' ||
			!Adapter->CurBssParams.ssid.SsidLength) {
		memcpy(&Adapter->CurBssParams.ssid, &Adapter->PreviousSSID,
				sizeof(WLAN_802_11_SSID));
	
		memcpy(&Adapter->CurrentBSSID, &Adapter->PreviousBSSID,
				ETH_ALEN);
	}	
	
	PRINTK1("Value of the mac controller-> %x\n",
			Adapter->CurrentPacketFilter);
	
	Adapter->MediaConnectStatus = WlanMediaStateConnected;
	
#ifdef WPA
	if (Adapter->SecInfo.WPAEnabled
#ifdef WPA2
		|| Adapter->SecInfo.WPA2Enabled
#endif
	)
		Adapter->IsGTK_SET = FALSE;
#endif
	
	// Do NOT SetMacPacketFilter after association 7/23/04
	// SetMacPacketFilter(priv);
	
	// Adapter->RxDataSNR = Adapter->RxDataNF = 0;
	Adapter->SNR[TYPE_RXPD][TYPE_AVG] = 
		Adapter->NF[TYPE_RXPD][TYPE_AVG] = 0;

	/* Remove: AvgPacketCount not used anywhere ??? */
	Adapter->AvgPacketCount = 0;

#ifdef WMM
	/* Don't enable carrier until we get the WMM_GET_STATUS event */
	if (Adapter->wmm.enabled)
		sendWMMStatusChangeCmd(priv);
	else
#endif /* WMM */
		netif_carrier_on(priv->wlan_dev.netdev);
	
	PRINTK1("HWAC - Associated \n");

	memcpy(wrqu.ap_addr.sa_data, Adapter->CurrentBSSID, ETH_ALEN);
	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
	wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL); 

	LEAVE();
	return 0;
}

static int wlan_ret_802_11_disassociate(wlan_private * priv, 
		HostCmd_DS_COMMAND * resp)
{
	ENTER();
	
	MacEventDisconnected(priv);
	
	LEAVE();
	return 0;
}

static int wlan_ret_802_11_ad_hoc_stop(wlan_private * priv, 
		HostCmd_DS_COMMAND * resp)
{
	ENTER();
	
	MacEventDisconnected(priv);
	
	LEAVE();
	return 0;
}

static int wlan_ret_802_11_set_wep(wlan_private * priv, 
		HostCmd_DS_COMMAND * resp)
{
	/*
	 * Nothing to be done here 
	 */
	return 0;
}

static int wlan_ret_802_11_ad_hoc_start(wlan_private * priv, 
		HostCmd_DS_COMMAND * resp)
{
	int				ret = 0;
	wlan_adapter			*Adapter = priv->adapter;
	u16				Command = wlan_le16_to_cpu(resp->Command);
	HostCmd_DS_802_11_AD_HOC_RESULT	*pAdHocResult = &resp->params.result;
	u16				Result = wlan_le16_to_cpu(resp->Result);
	union iwreq_data		wrqu;


	ENTER();

	PRINTK1("Size = %d\n", wlan_le16_to_cpu(resp->Size));
	PRINTK1("Command = %x\n", Command);
	PRINTK1("Result = %x\n", Result);

	Adapter->bIsAssociationInProgress = FALSE;

	// Send the setmacfilter here 
	// if there is a reset pending
	if (Adapter->bIsPendingReset == TRUE) {
		Adapter->bIsPendingReset = FALSE;
		PRINTK1("HWAC - Sending ResetComplete\n");
		Adapter->HardwareStatus = WlanHardwareStatusReady;
		SetMacPacketFilter(priv);
	}

	// Join result code 0 --> SUCCESS
	// if join result code != 0, will return Failure later
	if (Result) {
		PRINTK1("HWAC Join or Start Command Failed\n");
		if (Adapter->MediaConnectStatus == WlanMediaStateConnected) {
			MacEventDisconnected(priv);
		}

		if (Command == HostCmd_RET_802_11_AD_HOC_JOIN) {
			Adapter->m_NumAssociationAttemp++;
			if (Adapter->m_NumAssociationAttemp >= 2) {
				// do not attemp any more
				return 0;
			}

			ret = PrepareAndSendCommand(priv,
					HostCmd_CMD_802_11_AD_HOC_JOIN, 0,
					HostCmd_OPTION_USE_INT, (WLAN_OID) 0,
					HostCmd_PENDING_ON_CMD,
					&(Adapter->AttemptedSSIDBeforeScan));

			if (ret) {
				LEAVE();
				return ret;
			}
		}
		// If it's a START command and it fails, 
		// remove the entry on BSSIDList
		else if (Command == HostCmd_RET_802_11_AD_HOC_START) {
			memset(&(Adapter->BSSIDList[Adapter->
						ulAttemptedBSSIDIndex]), 0,
					sizeof(WLAN_802_11_BSSID));

⌨️ 快捷键说明

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