datacommsserver/esockserver/MobilityCoreProviders/src/mobilitymcpractivities.cpp
changeset 4 928ed51ddc43
parent 2 dee179edb159
child 13 0b0e9fce0b58
equal deleted inserted replaced
3:b6139031a239 4:928ed51ddc43
    98 	//      NOTE: This tuple doesn't actually do (b), i.e.: assumes the threshold of '1' (in 0..100 availability score range)
    98 	//      NOTE: This tuple doesn't actually do (b), i.e.: assumes the threshold of '1' (in 0..100 availability score range)
    99 	//Before awaitng for availability change or rejection by the client (TAwaitingCurrentCarrierRejectedOrAvailabilityChange), the activity
    99 	//Before awaitng for availability change or rejection by the client (TAwaitingCurrentCarrierRejectedOrAvailabilityChange), the activity
   100 	//first checks (TNoTagOrAwaitMobilityBlockedByErrorRecovery) if the availability has changed since it last checked 
   100 	//first checks (TNoTagOrAwaitMobilityBlockedByErrorRecovery) if the availability has changed since it last checked 
   101 	//(availability could have been reported amidst the previous handshake loop) 
   101 	//(availability could have been reported amidst the previous handshake loop) 
   102 	THROUGH_NODEACTIVITY_ENTRY(MobilityMCprStates::KStartMobilityHandshake, CMobilityActivity::TClearHandshakingFlag, CMobilityActivity::TNoTagOrAwaitMobilityBlockedByErrorRecovery)
   102 	THROUGH_NODEACTIVITY_ENTRY(MobilityMCprStates::KStartMobilityHandshake, CMobilityActivity::TClearHandshakingFlag, CMobilityActivity::TNoTagOrAwaitMobilityBlockedByErrorRecovery)
   103 	NODEACTIVITY_ENTRY(MobilityMCprStates::KAwaitMobility, MeshMachine::TDoNothing, CMobilityActivity::TAwaitingCurrentCarrierRejectedOrAvailabilityChange, CMobilityActivity::TNoTagOrAwaitMobilityBackwardsOnMobilityTriggerBlockedByErrorRecovery)
   103 	    NODEACTIVITY_ENTRY(MobilityMCprStates::KAwaitMobility, MeshMachine::TDoNothing, CMobilityActivity::TAwaitingCurrentCarrierRejectedOrAvailabilityChange, CMobilityActivity::TNoTagOrAwaitMobilityBackwardsOnMobilityTriggerBlockedByErrorRecovery)
   104 
   104 
   105 		//Mobility has been triggered ((a) or (b)). Start mobility handshake (set handshaking flag and inform the client about the preferred bearer) 
   105 		//Mobility has been triggered ((a) or (b)). Start mobility handshake (set handshaking flag and inform the client about the preferred bearer) 
   106 		NODEACTIVITY_ENTRY(KNoTag, CMobilityActivity::TInformMigrationAvailableAndSetHandshakingFlag, MobilityMCprStates::TAwaitingMigrationRequestedOrRejected, CMobilityActivity::TNoTagOrStartMobilityHandshakeBackwards)
   106 		NODEACTIVITY_ENTRY(KNoTag, CMobilityActivity::TInformMigrationAvailableAndSetHandshakingFlag, MobilityMCprStates::TAwaitingMigrationRequestedOrRejected, CMobilityActivity::TNoTagOrStartMobilityHandshakeBackwards)
   107 		//The client accepts the new access point. 
   107 		//The client accepts the new access point. 
   108 		//For the moment it is sufficient to use the re-connect activity, in the future we may want to
   108 		//For the moment it is sufficient to use the re-connect activity, in the future we may want to
   110 		//Should rebinding fail, the mobility activity will be set to an error mode. The error mode will be cleared if
   110 		//Should rebinding fail, the mobility activity will be set to an error mode. The error mode will be cleared if
   111 		//there are other bearers this activity can offer. If there aren't the data client will be errored.
   111 		//there are other bearers this activity can offer. If there aren't the data client will be errored.
   112 		NODEACTIVITY_ENTRY(KNoTag, CMobilityActivity::TRequestReConnect, MCprStates::TAwaitingReConnectCompleteOrError, CMobilityActivity::TNoTagOrStartMobilityHandshakeBackwards)
   112 		NODEACTIVITY_ENTRY(KNoTag, CMobilityActivity::TRequestReConnect, MCprStates::TAwaitingReConnectCompleteOrError, CMobilityActivity::TNoTagOrStartMobilityHandshakeBackwards)
   113 		//Rebinding has been successful. As far as MCPR is concerned, the mobility is finished, but the MCPR must await
   113 		//Rebinding has been successful. As far as MCPR is concerned, the mobility is finished, but the MCPR must await
   114 		//for the handshake (accept|reject) before it can offer another bearer. 
   114 		//for the handshake (accept|reject) before it can offer another bearer. 
   115 		NODEACTIVITY_ENTRY(KNoTag, CMobilityActivity::TInformMigrationCompleted, MobilityMCprStates::TAwaitingMigrationAcceptedOrRejected, MeshMachine::TTag<MobilityMCprStates::KStartMobilityHandshake|EBackward>)
   115         NODEACTIVITY_ENTRY(KNoTag, CMobilityActivity::TInformMigrationCompleted, MobilityMCprStates::TAwaitingMigrationAcceptedOrRejected, CMobilityActivity::TRejectedOrStartMobilityHandshakeBackwards)
       
   116         NODEACTIVITY_ENTRY(MobilityMCprStates::KRejected, CoreNetStates::TStopDataClients, CoreNetStates::TAwaitingDataClientsStopped, MeshMachine::TTag<MobilityMCprStates::KStartMobilityHandshake|NetStateMachine::EBackward>)
   116 NODEACTIVITY_END()
   117 NODEACTIVITY_END()
   117 }
   118 }
   118 
   119 
   119 namespace MCprConnectionStartRecoveryActivity
   120 namespace MCprConnectionStartRecoveryActivity
   120 {
   121 {
   309 	    activity.SetError(KErrNone);
   310 	    activity.SetError(KErrNone);
   310 	    }
   311 	    }
   311 	return MobilityMCprStates::KAwaitMobility;
   312 	return MobilityMCprStates::KAwaitMobility;
   312 	}
   313 	}
   313 
   314 
       
   315 
       
   316 DEFINE_SMELEMENT(CMobilityActivity::TRejectedOrStartMobilityHandshakeBackwards, NetStateMachine::MStateFork, MobilityMCprStates::TContext)
       
   317 TInt CMobilityActivity::TRejectedOrStartMobilityHandshakeBackwards::TransitionTag()
       
   318     {
       
   319 	__ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KCoreMobileMCprPanic, KPanicNoActivity));
       
   320 	CMobilityActivity& activity = static_cast<CMobilityActivity&>(*iContext.iNodeActivity);
       
   321 
       
   322 	// if rejected last ap and there's no more
       
   323 	if (iContext.iMessage.IsMessage<TCFMobilityProvider::TMigrationRejected>())
       
   324 		{
       
   325 		TBool otherSP = EFalse;
       
   326 		
       
   327 		// Find if there anymore available non rejected service providers
       
   328 		TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider));
       
   329 		__ASSERT_DEBUG(iter[0], User::Panic(KCoreMobileMCprPanic, KPanicNoServiceProvider)); //A Service Provider must exist!
       
   330 		RMetaServiceProviderInterface* rejected = static_cast<RMetaServiceProviderInterface*>(iContext.Node().ServiceProvider());
       
   331 		RMetaServiceProviderInterface* candidate = NULL;
       
   332 		
       
   333 		while ((candidate = static_cast<RMetaServiceProviderInterface*>(iter++)) != NULL)
       
   334 			{
       
   335 			if (candidate == rejected)
       
   336 				{
       
   337 				continue;
       
   338 				}
       
   339 			
       
   340 			const TAvailabilityStatus& status = candidate->AvailabilityStatus();
       
   341 			if (!status.IsKnown())
       
   342 				{
       
   343 				continue;
       
   344 				}
       
   345 
       
   346 			if (status.Score() > activity.iAvailabilityScoreTreshold)
       
   347 				{
       
   348 				otherSP=ETrue;
       
   349 				break;
       
   350 				}
       
   351 			}
       
   352 
       
   353 		if (!otherSP)
       
   354 			{
       
   355 			return MobilityMCprStates::KRejected;
       
   356 			}
       
   357 		}
       
   358 
       
   359     return MobilityMCprStates::KStartMobilityHandshake | NetStateMachine::EBackward;
       
   360     }
       
   361 
   314 DEFINE_SMELEMENT(CMobilityActivity::TSendAvailabilityRequest, NetStateMachine::MStateTransition, CMobilityActivity::TContext)
   362 DEFINE_SMELEMENT(CMobilityActivity::TSendAvailabilityRequest, NetStateMachine::MStateTransition, CMobilityActivity::TContext)
   315 void CMobilityActivity::TSendAvailabilityRequest::DoL()
   363 void CMobilityActivity::TSendAvailabilityRequest::DoL()
   316 	{
   364 	{
   317 	//Issue availability notification registration to start the availability activity on this node.
   365 	//Issue availability notification registration to start the availability activity on this node.
   318 	//NOTE: since we've requested availability from self, we are interested in any change (even available->available)
   366 	//NOTE: since we've requested availability from self, we are interested in any change (even available->available)