pararoamingproc.c

来自「marvell8385 GSPI开发驱动」· C语言 代码 · 共 1,981 行 · 第 1/5 页

C
1,981
字号
						|| (!priv.bProfileSetWiFiConnected) 
						|| (!priv.bFastAutoRoaming))
				{

					if(!priv.bProfileSetWiFiConnected)
					{
						priv.bProfileSetWiFiConnected = TRUE;
					}
//#ifdef DEBUG_PARA_ROAMING_PRINT
					RETAILMSG(1,(TEXT("AutoRoamingThread:Indicate the NDIS that media is CONNECTED!\n")));
//#endif
					//TODO:
					//If necessary, notify other module:
					//enter into another net and link up
					priv.bAddedPrelistByPRM = RMM_ADDING_PREFERLIST;	
#ifdef PARA_WPA_1X
					if(HandOffhandlerRetCode!=HANDOFF_HAD_POSTED_LINK_UP){
#endif
					ED_PostMessage(TEXT("PRM"), PRM_LINKUP, 1, priv.ProfileAllList.CurrentProfileIndex);
#if 0
					wlan_RMMSetRetryPRMLinkupStatusTimer();
#endif
#ifdef PARA_WPA_1X
					}
					else
					{
						ED_PostMessage(TEXT("PRM"), PRM_LINKUP, 3, priv.ProfileAllList.CurrentProfileIndex);
					}
#endif

#ifdef CONFIG_WLAN_PMU
					wlan_PMUMsgRMMLinkStatus (0);
#endif		
				}
				else
				{
//#ifdef DEBUG_PARA_ROAMING_PRINT
					RETAILMSG(1,(TEXT("AutoRoamingThread:Indicate other module: still at local net and link up!\n priv.bProfileSetWiFiConnected = %d\n"),priv.bProfileSetWiFiConnected));
//#endif
					//(1) Notify other module: still at local net and link up
					priv.bAddedPrelistByPRM = RMM_ADD_PREFERLIST_SUCCESS;
		#ifdef PARA_WPA_1X
					if(HandOffhandlerRetCode!=HANDOFF_HAD_POSTED_LINK_UP)
		#endif
					ED_PostMessage(TEXT("PRM"), PRM_LINKUP, 0, priv.ProfileAllList.CurrentProfileIndex);
#ifdef CONFIG_WLAN_PMU
                                wlan_PMUMsgRMMLinkStatus (0);
#endif

				}

#ifdef CONFIG_VERTICAL_HANDOFF
				/*start timer to get beacon's rssi periodicly!*/
				NdisMSetTimer(&priv.GetBeaconRSSITimer, BEACON_RSSI_LISTEN_INTERVAL);      
				priv.bGetBeaconRSSITimerIsSet= TRUE;
#endif	

				//Wake up OID_SET_SSID thread...!
				/*if(priv.bOID_SET_SSID)
				{
					// indicate the NDIS SetInformation OID_802_11_SSID is successful ~!
					//NdisMSetInformationComplete(Adapter->MrvDrvAdapterHdl,
			          	//								NDIS_STATUS_SUCCESS);				
					SetEvent(priv.hOIDSetSSIDFinishedEvent);			
				}*/
#ifdef DEBUG_PARA_ROAMING_PRINT
				ParaPrintFile("\n[AutoRoamingThread]ED_PostMessage--->PRM_LINKUP!!!goto roaming_finished....\n");
#endif				
				goto roaming_finished;
			}
			else
			{//roaming failed
retry_roaming:
#ifdef DEBUG_PARA_ROAMING_PRINT
				ParaPrintFile("\n[AutoRoamingThread]------retry_roaming!!!\n");
#endif
				if(priv.bFastAutoRoaming)
				{
					priv.bAddedPrelistByPRM = RMM_ADD_PREFERLIST_SUCCESS;
				}
				else
				{
                    		priv.bAddedPrelistByPRM = RMM_ADD_PREFERLIST_FAILED;	
                    	}
#if 0
				//Notify profile manager module: WZC preferlist should be clear!
				ED_PostMessage(TEXT("PRM"), PRM_CLR_WZC_PREFERLIST, 0, 0);
#endif			
				//roaming process should be stop or not?(roaming is timeout?)  
				if(!priv.bStopRoaming)
				{
                    		if(iSearchRst >= 0 && iSearchRst <MRVDRV_MAX_BSSID_LIST)
					{
						if(priv.bProcessedHandOff)
						{
							priv.bProcessedHandOff = FALSE;
							rmm_AddBlackBSSIDList(Adapter,Adapter->PSBSSIDList[iSearchRst], priv.HandoffSSID);
						}
					}
					//Clear auto-roaming flag 
					priv.bAutoRoamingInProcess = FALSE;
#ifdef DEBUG_PARA_ROAMING_PRINT
					ParaPrintFile("\n[AutoRoamingThread]roaming is NOT timeout,so goto restart_roaming....\n");
#endif					
					goto restart_roaming;	
				}
				else
				{
					priv.bStopRoaming = FALSE;
#ifdef CONFIG_VERTICAL_HANDOFF
					if(priv.bVerticalHandoffEnabled)
					{
						/*Post message to auto-handoff manager module(AHO) that WiFi is unavailable!*/
						ED_PostMessage(EXDATNAME_AHO, AHO_WIFI_UNAVAILABLE, 0, 0);
						RETAILMSG(1,(TEXT("\r\nVerticalHandoff :post message that WiFi is linklost,should ROVE OUT WiFi !!!!!!!!!!!!!\r\n")));
					}
#endif
					/*WiFi is still connect with the current AP,even if its signal strength is too weak,
					/*we should do NOTHING here and quit auto-roaming process right now. 
					/*Because auto-roaming process can be also triggered by the real link-lost event lately,
					/*which is produced by  Marvell's FW.
					*/
					if(Adapter->MediaConnectStatus == NdisMediaStateConnected)
					{
						//Stop the data busy retry-roaming timer
						if (priv.bDataBusyRetryRoamingTimerIsSet)
						{   
							NdisMCancelTimer(&priv.DataBusyRetryRoamingTimer, &timerStatus);
							priv.bDataBusyRetryRoamingTimerIsSet = FALSE;
						}
						rmm_CleanBlackBssidList(Adapter);
#ifdef DEBUG_PARA_ROAMING_PRINT
						ParaPrintFile("\n[AutoRoamingThread]roaming is timeout or stopped,but still connected,so goto roaming_finished....\n");
#endif						
						goto roaming_finished;

					}
					
#ifdef CONFIG_WLAN_PMU
					if(wlan_PMUCheckWlanAppState () != 0)
#endif                        
					{
						//Stop the data busy retry-roaming timer
						if (priv.bDataBusyRetryRoamingTimerIsSet)
						{   
							NdisMCancelTimer(&priv.DataBusyRetryRoamingTimer, &timerStatus);
							priv.bDataBusyRetryRoamingTimerIsSet = FALSE;
						}					
						if(!priv.bManualRoamingInProcess)
						{
							//Start data busy retry-roaming timer
							NdisMCancelTimer(&priv.DataBusyRetryRoamingTimer, &timerStatus);
							NdisMSetTimer(&priv.DataBusyRetryRoamingTimer, 
							        			REROAMING_INTERVAL_STILL_IN_TRANSACTION);
							priv.bDataBusyRetryRoamingTimerIsSet=TRUE;			
						}
					
					}
					/*TODO:
					/*Notify other module: WLAN is link down!
					*/
#if	0				
					//Do DEAUTHENTICATE and wait until finished
					if(Adapter->MediaConnectStatus == NdisMediaStateDisconnected && priv.bProcessedHandOff == TRUE)
                                {
						priv.bProcessedHandOff = FALSE;
						ResetEvent(priv.hDeauthFinishedEvent);
						
						PrepareAndSendCommand(
						      Adapter,
						      HostCmd_CMD_802_11_DEAUTHENTICATE,
						      0,
						      HostCmd_OPTION_USE_INT,
						      (NDIS_OID)0,
						      HostCmd_PENDING_ON_NONE,
						      0,
						      FALSE,
						      NULL,
						      NULL,
						      NULL,
						      NULL);
						      
						//wait for 1000 ms
						waitStatus = WaitForSingleObject(priv.hDeauthFinishedEvent, 100);
						if (WAIT_OBJECT_0 != waitStatus)
						{
							RETAILMSG(1,(TEXT("call WaitFor hDeauthFinishedEvent Fail : \n")));
						}
					}
#endif
//#ifdef DEBUG_PARA_ROAMING_PRINT
					RETAILMSG(1,(TEXT("AutoRoamingThread:Indicate the NDIS that media is DISCONNECTED!\n")));
//#endif
					// indicate the NDIS the media is disconnected!
					NdisMIndicateStatus(
							Adapter->MrvDrvAdapterHdl,
							NDIS_STATUS_MEDIA_DISCONNECT,
							(PVOID)NULL,
							0);
					NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
#ifdef CONFIG_WLAN_PMU
                                wlan_PMUMsgRMMLinkStatus (1);
#endif
					priv.bAddedPrelistByPRM = RMM_ADD_PREFERLIST_FAILED;	
#ifdef DEBUG_PARA_ROAMING_PRINT
					ParaPrintFile("\n[AutoRoamingThread]ED_PostMessage--->PRM_LINKDOWN!!!\n");
#endif
					ED_PostMessage(TEXT("PRM"), PRM_LINKDOWN, 0, 0);
#if 0
                                wlan_RMMCancelRetryPRMLinkupStatusTimer();
#endif
                                rmm_CleanBlackBssidList(Adapter);

					//Wake up OID_SET_SSID thread...!
					/*if(priv.bOID_SET_SSID)
					{
						// indicate the NDIS SetInformation OID_802_11_SSID is failed ~!
						//NdisMSetInformationComplete(Adapter->MrvDrvAdapterHdl,
				          	//								NDIS_STATUS_FAILURE);
						SetEvent(priv.hOIDSetSSIDFinishedEvent);
					}*/
										
				}
			}
roaming_finished:
#ifdef DEBUG_PARA_ROAMING_PRINT
			ParaPrintFile("\n[AutoRoamingThread]------roaming_finished!!!\n");
#endif
			//Clear auto-roaming flag 
			priv.bAutoRoamingInProcess = FALSE;

			priv.bStopRoaming = FALSE;
			
			//Stop the auto-roaming timer
			if (priv.bAutoRoamingTimerIsSet)
			{   
				NdisMCancelTimer(&priv.AutoRoamingTimer, &timerStatus);
				priv.bAutoRoamingTimerIsSet = FALSE;
			}
#ifdef CONFIG_VERTICAL_HANDOFF
			if(priv.bVerticalHandoffEnabled && priv.bDataBusyRetryRoamingTimerIsSet)
			{
				RETAILMSG(1,(TEXT("AutoRoamingThread:roaming failed,databusy timer is turn on even after vertical-handoff from WiFi to GSM!!\n")));
			}
			else
			{
#endif
				//Stop the data busy retry-roaming timer
#ifdef CONFIG_WLAN_PMU
			if ((priv.bDataBusyRetryRoamingTimerIsSet) && (wlan_PMUCheckWlanAppState() == 0))
#else
			if (priv.bDataBusyRetryRoamingTimerIsSet)
#endif
			{   
				NdisMCancelTimer(&priv.DataBusyRetryRoamingTimer, &timerStatus);
				priv.bDataBusyRetryRoamingTimerIsSet = FALSE;
			}	
#ifdef CONFIG_VERTICAL_HANDOFF
			}
#endif
		}
		
	}
	
}




void ManualRoamingThread(PVOID pContext)
{
	DWORD         waitStatus,dwWifi;
	BOOLEAN		timerStatus;
	int 			iSearchRst;
	int			iProfilesGotStatus;
	ULONG  		i;
	UCHAR		ucAttemptedProfileIdx;
	BOOLEAN		bRetryAutoRoaming;
	NDIS_802_11_SSID TopPriorityHandoffSSID;

	
	PMRVDRV_ADAPTER   Adapter = priv.pAdapter;
#ifdef PARA_WPA_1X
	int HandOffhandlerRetCode=0;
#endif
	CeSetThreadPriority(GetCurrentThread(), 150); 
	
	for (;;)
	{
		//wait until ManualRoamingEvent trigger happenned!
		ResetEvent(priv.hManualRoamingEvent);
		waitStatus = WaitForSingleObject(priv.hManualRoamingEvent, INFINITE);
		if (WAIT_OBJECT_0 != waitStatus)
		{
			RETAILMSG(1,(TEXT("ManualRoaming call WaitFor ManualRoamingEvent Fail : \n")));
			DBGPRINT(DBG_ALL,("ManualRoaming call WaitFor ManualRoamingEvent Fail : \n"));
			return;
		}
#ifdef CONFIG_WLAN_PMU
              if(wlan_PMUCardOnOffStatus() == 0)
              {
		    ED_PostMessage(TEXT("WMG"), WMG_WLAN_LINK_DOWN, 0, 0);
#ifdef SIP_ACCOUNT_DYNAMIC_ALLOC
		    ED_PostMessage(TEXT("SAF"), SAF_WLAN_LINK_DOWN, 0, 0);
#endif
                  continue;
              }
#endif              
#ifdef DEBUG_PARA_ROAMING_PRINT
		RETAILMSG(1,(TEXT("Enter ManualRoamingThread!...\n")));
		ParaPrintFile("\nEnter ManualRoamingThread!...\n");
#endif
DBGPRINT(DBG_ALL,(TEXT("Enter ManualRoamingThread!...\n")));

    		priv.bAddedPrelistByPRM = RMM_ADD_PREFERLIST_FAILED;	
#if 0
		//Notify profile manager module: WZC preferlist should be clear!
		ED_PostMessage(TEXT("PRM"), PRM_CLR_WZC_PREFERLIST, 0, 0);
#endif		
		EnterCriticalSection(&priv.ManualRoamingCriticalSection);

		/*store the previous connected AP's SSID and BSSID*/
		NdisMoveMemory( &(Adapter->PreviousSSID), &(Adapter->CurrentSSID), 
		              sizeof(NDIS_802_11_SSID));
		        
		NdisMoveMemory( Adapter->PreviousBSSID, Adapter->CurrentBSSID, 
		              MRVDRV_ETH_ADDR_LEN);

		/*store the previous connected profile's index*/
		priv.ProfileAllList.PreviousProfileIndex = priv.ProfileAllList.CurrentProfileIndex;
		
		/* Set the  InfrastructureMode */
		Adapter->InfrastructureMode = Ndis802_11Infrastructure;

		Adapter->LinkSpeed = MRVDRV_LINK_SPEED_1mbps;	
		
		Adapter->AdHocCreated = FALSE;   
		
		LeaveCriticalSection(&priv.ManualRoamingCriticalSection);

		bRetryAutoRoaming = FALSE;

	

		//Start auto-roaming only if manual-roaming or auto-roaming have NOT happenned before!
		if(!priv.bManualRoamingInProcess)
		{
			//Set manual-roaming flag
			priv.bManualRoamingInProcess = TRUE;
#ifdef CONFIG_WLAN_PMU
                     wlan_ManualRoamingBusy();
#endif
			priv.bStopRoaming = FALSE;
			//Stop the auto-roaming timer
			if (priv.bAutoRoamingTimerIsSet)
			{   
				NdisMCancelTimer(&priv.AutoRoamingTimer, &timerStatus);
				priv.bAutoRoamingTimerIsSet = FALSE;
			}

			//Stop the data busy retry-roaming timer
			if (priv.bDataBusyRetryRoamingTimerIsSet)
			{   
				NdisMCancelTimer(&priv.DataBusyRetryRoamingTimer, &timerStatus);
				priv.bDataBusyRetryRoamingTimerIsSet = FALSE;
			}

#ifdef CONFIG_VERTICAL_HANDOFF
			//Stop timer for get beacon's rssi periodically
			if(priv.bGetBeaconRSSITimerIsSet)
			{
				NdisMCancelTimer(&priv.GetBeaconRSSITimer, &timerStatus);
				priv.bGetBeaconRSSITimerIsSet = FALSE;
			}
#endif
		
			/*TODO:
			/*Display profiles got from PROFILE MANAGER,
			/*Adjudge received profiles correct or not?
			/*If profiles is error,just de-auth and do NOTHING anymore.
			*/
			iProfilesGotStatus = CheckProfiles(&priv);
			if(iProfilesGotStatus < 0)//profiles error!
			{
				//Set profile but WiFi not connected~!
				priv.bProfileSetWiFiConnected = FALSE;

				if((Adapter->MediaConnectStatus == NdisMediaStateConnected)
					&& (!(NdisEqualMemory(Adapter->NullBSSID, 
							Adapter->CurrentBSSID,MRVDRV_ETH_ADDR_LEN))))
				{
					//Do DEAUTHENTICATE and wait until finished
					ResetEvent(priv.hDeauthFinishedEvent);	
					
					PrepareAndSendCommand(
					      Adapter,
					      HostCmd_CMD_802_11_DEAUTHENTICATE,

⌨️ 快捷键说明

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