telephonyprotocols/pdplayer/src/PDPSCPRStates.cpp
changeset 23 6b1d113cdff3
parent 19 1f776524b15c
child 24 6638e7f4bd8f
child 31 8ab6687fb94c
equal deleted inserted replaced
20:244d7c5f118e 23:6b1d113cdff3
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    38 #include <comms-infras/ss_api_ext.h>
    38 #include <comms-infras/ss_api_ext.h>
    39 #include <elements/nm_messages_errorrecovery.h>
    39 #include <elements/nm_messages_errorrecovery.h>
    40 #include <comms-infras/sockmes.h> // for ioctl ipc
    40 #include <comms-infras/sockmes.h> // for ioctl ipc
    41 #include <nifvar_internal.h>
    41 #include <nifvar_internal.h>
    42 #include <elements/mm_activities.h>
    42 #include <elements/mm_activities.h>
       
    43 #include <comms-infras/ss_tiermanagerutils.h>
       
    44 #include <comms-infras/connectionsettings.h>
       
    45 #include <hash.h>
       
    46 #include <e32math.h>
    43 
    47 
    44 using namespace Messages;
    48 using namespace Messages;
    45 using namespace MeshMachine;
    49 using namespace MeshMachine;
    46 using namespace ESock;
    50 using namespace ESock;
    47 using namespace NetStateMachine;
    51 using namespace NetStateMachine;
    50 using namespace ConnectionServ;
    54 using namespace ConnectionServ;
    51 
    55 
    52 #ifdef _DEBUG
    56 #ifdef _DEBUG
    53 _LIT (KPdpSCprPanic,"PpdScprPanic");
    57 _LIT (KPdpSCprPanic,"PpdScprPanic");
    54 #endif
    58 #endif
       
    59 
       
    60 const TUint8 KGenericNifChallengeSize = 8;
       
    61 const TUint KGenericNifIdLength = 1;
    55 
    62 
    56 //-=========================================================
    63 //-=========================================================
    57 //
    64 //
    58 // States
    65 // States
    59 //
    66 //
    64 //Util
    71 //Util
    65 //-=========================================================
    72 //-=========================================================
    66 DEFINE_SMELEMENT(TAwaitingPDPFSMMessage, NetStateMachine::MState, PDPSCprStates::TContext)
    73 DEFINE_SMELEMENT(TAwaitingPDPFSMMessage, NetStateMachine::MState, PDPSCprStates::TContext)
    67 TBool TAwaitingPDPFSMMessage::Accept()
    74 TBool TAwaitingPDPFSMMessage::Accept()
    68     {
    75     {
    69     return iContext.iMessage.IsMessage<TPDPFSMMessages::TPDPFSMMessage>();
    76     return iContext.iMessage.IsMessage<TPDPMessages::TPDPFSMMessage>();
    70     }
    77     }
    71 
    78 
    72 DEFINE_SMELEMENT(TNoTagOrError, NetStateMachine::MStateFork, PDPSCprStates::TContext)
    79 DEFINE_SMELEMENT(TNoTagOrError, NetStateMachine::MStateFork, PDPSCprStates::TContext)
    73 TInt TNoTagOrError::TransitionTag()
    80 TInt TNoTagOrError::TransitionTag()
    74     {
    81     {
    75     ASSERT(iContext.iNodeActivity);
    82     ASSERT(iContext.iNodeActivity);
    76     TPDPFSMMessages::TPDPFSMMessage& msg = message_cast<TPDPFSMMessages::TPDPFSMMessage>(iContext.iMessage);
    83     TPDPMessages::TPDPFSMMessage& msg = message_cast<TPDPMessages::TPDPFSMMessage>(iContext.iMessage);
    77     if (msg.iValue2 != KErrNone)
    84     if (msg.iValue2 != KErrNone)
    78         {
    85         {
    79         iContext.iNodeActivity->SetError(msg.iValue2);
    86         iContext.iNodeActivity->SetError(msg.iValue2);
    80         return KErrorTag;
    87         return KErrorTag;
    81         }
    88         }
    82     return KNoTag;
    89     return KNoTag;
    83     }
    90     }
    84 
    91 
    85 DEFINE_SMELEMENT(TNoTagOrAlreadyStarted, NetStateMachine::MStateFork, PDPSCprStates::TContext)
    92 DEFINE_SMELEMENT(TNoTagOrUserAuthenticateOrAlreadyStarted, NetStateMachine::MStateFork, PDPSCprStates::TDefContext)
    86 TInt TNoTagOrAlreadyStarted::TransitionTag()
    93 TInt TNoTagOrUserAuthenticateOrAlreadyStarted::TransitionTag()
    87     {
    94     {
    88     ASSERT(iContext.iMessage.IsMessage<TCFDataClient::TStart>());
    95     ASSERT(iContext.iMessage.IsMessage<TCFDataClient::TStart>());
    89     ASSERT(iContext.iNodeActivity);
    96     ASSERT(iContext.iNodeActivity);
    90     if (iContext.Node().iPDPFsmContextId != CPDPSubConnectionProvider::EInvalidContextId)
    97     if (iContext.Node().iPDPFsmContextId != CPDPSubConnectionProvider::EInvalidContextId)
    91         {
    98         {
    92         return CoreNetStates::KAlreadyStarted;
    99         return CoreNetStates::KAlreadyStarted;
    93         }
   100         }
       
   101 
       
   102     if (iContext.Node().PromptForAuth())
       
   103         {
       
   104         return PDPSCprStates::KUserAuthenticate;
       
   105         }
       
   106 
    94     return KNoTag;
   107     return KNoTag;
    95     }
   108     }
    96 
   109 
    97 
       
    98 TBool TAwaitingPDPFSMMessage::Accept(TInt aExtensionId)
   110 TBool TAwaitingPDPFSMMessage::Accept(TInt aExtensionId)
    99     {
   111     {
   100     TPDPFSMMessages::TPDPFSMMessage* pdpmsg = message_cast<TPDPFSMMessages::TPDPFSMMessage>(&iContext.iMessage);
   112     TPDPMessages::TPDPFSMMessage* pdpmsg = message_cast<TPDPMessages::TPDPFSMMessage>(&iContext.iMessage);
   101     if ( pdpmsg )
   113     if ( pdpmsg )
   102         {
   114         {
   103         if (pdpmsg->iValue1 == aExtensionId)
   115         if (pdpmsg->iValue1 == aExtensionId)
   104             {
   116             {
   105             return ETrue;
   117             return ETrue;
   116 
   128 
   117 DEFINE_SMELEMENT(TNoTagOrSendErrorRecoveryRequestOrError, NetStateMachine::MStateFork, PDPSCprStates::TContext)
   129 DEFINE_SMELEMENT(TNoTagOrSendErrorRecoveryRequestOrError, NetStateMachine::MStateFork, PDPSCprStates::TContext)
   118 TInt TNoTagOrSendErrorRecoveryRequestOrError::TransitionTag()
   130 TInt TNoTagOrSendErrorRecoveryRequestOrError::TransitionTag()
   119 	{
   131 	{
   120 	ASSERT(iContext.iNodeActivity);
   132 	ASSERT(iContext.iNodeActivity);
   121 	TPDPFSMMessages::TPDPFSMMessage& msg = message_cast<TPDPFSMMessages::TPDPFSMMessage>(iContext.iMessage);
   133 	TPDPMessages::TPDPFSMMessage& msg = message_cast<TPDPMessages::TPDPFSMMessage>(iContext.iMessage);
   122 	if (msg.iValue2 == KErrUmtsMaxNumOfContextExceededByNetwork ||
   134 	if (msg.iValue2 == KErrUmtsMaxNumOfContextExceededByNetwork ||
   123 	    msg.iValue2 == KErrUmtsMaxNumOfContextExceededByPhone)
   135 	    msg.iValue2 == KErrUmtsMaxNumOfContextExceededByPhone)
   124 		{
   136 		{
   125 		return KSendErrorRecoveryRequest;
   137 		return KSendErrorRecoveryRequest;
   126 		}
   138 		}
   173 
   185 
   174 //-=========================================================
   186 //-=========================================================
   175 //Provisioning
   187 //Provisioning
   176 //-=========================================================
   188 //-=========================================================
   177 DEFINE_SMELEMENT(TSelfInit, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
   189 DEFINE_SMELEMENT(TSelfInit, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
       
   190 // This is should be revisited in future releases, basic idea is that information
       
   191 // that can be modified should have a visibility that is to that node's
       
   192 // level and not further (i.e. changes here will affect this connection
       
   193 // only, not every connection that uses this MCPR)
       
   194 //      MCPR - AccessPointConfig() contains information that is used by
       
   195 //             all connections under that MCPR and is unchanging
       
   196 //       CPR - Again for all connections under that CPR and is unchanging
       
   197 //      SCPR - Connection specific information (i.e. can change and does change)
       
   198 //        DC - No point - just reads information.
       
   199 // Here we've moved basically all of the configuration information that was in
       
   200 // the MCPR [that could be moved] this is because some of it changes / is overwritten
       
   201 // with information that comes out of etel/modem.  This also has the added benefit of
       
   202 // freeing up memory in cases where the connection is torn down but the MCPR lies 
       
   203 // around for availability purposes.  In the future, this code (or something like it)
       
   204 // should be moved into the PDP.CPR when it exists.
       
   205 
       
   206 void TSelfInit::SetupProvisionCfgL(ESock::CCommsDatIapView* aIapView)
       
   207     {
       
   208     CPDPSubConnectionProvider &tNode = static_cast<CPDPSubConnectionProvider&>(iContext.Node());
       
   209     
       
   210     RMetaExtensionContainer mec;
       
   211     mec.Open(tNode.AccessPointConfig());
       
   212     CleanupClosePushL(mec);
       
   213   
       
   214     mec.AppendExtensionL(CIPConfig::NewFromGPRSOutLC(aIapView));
       
   215     CleanupStack::Pop();
       
   216 
       
   217     mec.AppendExtensionL(CBCAProvision::NewLC(aIapView));
       
   218     CleanupStack::Pop();
       
   219 
       
   220     mec.AppendExtensionL(CImsExtProvision::NewLC(aIapView));
       
   221     CleanupStack::Pop();
       
   222 
       
   223     CGPRSProvision* gprsProvision = CGPRSProvision::NewLC(aIapView);
       
   224     mec.AppendExtensionL(gprsProvision);
       
   225     CleanupStack::Pop(gprsProvision);
       
   226     
       
   227     //It's not legal for the qos defaults to be absent.
       
   228     CDefaultPacketQoSProvision* defaultQoS = NULL;
       
   229     TRAPD(ret, defaultQoS = CDefaultPacketQoSProvision::NewL(aIapView));   
       
   230     if ((KErrNone == ret) && defaultQoS)           
       
   231         {
       
   232         CleanupStack::PushL(defaultQoS);
       
   233         mec.AppendExtensionL(defaultQoS);
       
   234         CleanupStack::Pop(defaultQoS);
       
   235         }
       
   236     else
       
   237         {
       
   238         if (KErrNoMemory == ret)
       
   239             {
       
   240             User::Leave(KErrNoMemory);
       
   241             }
       
   242         else
       
   243             {
       
   244             User::Leave(KErrCorrupt);
       
   245             }          
       
   246         }    
       
   247     
       
   248     CRawIpAgentConfig* rawIpAgentConfig = CRawIpAgentConfig::NewLC(aIapView, &gprsProvision->GetScratchContextAs<TPacketDataConfigBase>());
       
   249     mec.AppendExtensionL(rawIpAgentConfig);
       
   250     CleanupStack::Pop();
       
   251 
       
   252     tNode.AccessPointConfig().Close();
       
   253     tNode.AccessPointConfig().Open(mec);
       
   254     CleanupStack::PopAndDestroy(&mec); 
       
   255     }
       
   256 
   178 void TSelfInit::DoL()
   257 void TSelfInit::DoL()
   179     {
   258     {
   180     CPDPSubConnectionProvider &tNode = static_cast<CPDPSubConnectionProvider&>(iContext.Node());
   259     CPDPSubConnectionProvider &tNode = static_cast<CPDPSubConnectionProvider&>(iContext.Node());
       
   260 
       
   261     const TProviderInfoExt* providerInfoExt = static_cast<const TProviderInfoExt*>(tNode.AccessPointConfig().FindExtension(
       
   262             STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId)));
       
   263 
       
   264     // this should always be here, however, a bit of defensive programming
       
   265     // never hurt..
       
   266     if (providerInfoExt == NULL)
       
   267         {
       
   268         User::Leave(KErrCorrupt);
       
   269         }
       
   270 
       
   271     CCommsDatIapView* iapView = CCommsDatIapView::NewLC(providerInfoExt->iProviderInfo.APId());
       
   272 
       
   273     TRAP(tNode.iProvisionFailure,SetupProvisionCfgL(iapView));
       
   274 
       
   275     // Don't want any failure here to be masked by successful configuration later on.
       
   276     // A leave here will not cause a roll back of the connection but it will show an
       
   277     // Error -> message in the SVG diagram.  The provision failure error code will 
       
   278     // cause the connection rollback.
       
   279     User::LeaveIfError(tNode.iProvisionFailure);
   181     
   280     
   182     // if the FSM interface is null, this means that we're initializing a secondary context
   281     // if the FSM interface is null, this means that we're initializing a secondary context
   183     // as this code is common for both
   282     // as this code is common for both
   184     
   283     
   185     if (tNode.iPdpFsmInterface == NULL)
   284     if (tNode.iPdpFsmInterface == NULL)
   247         // expecting a response. if there is a failure then it will be errored in 
   346         // expecting a response. if there is a failure then it will be errored in 
   248         // the next activity in the sequence, i.e. DataClientStart
   347         // the next activity in the sequence, i.e. DataClientStart
   249         TRAP(tNode.iProvisionFailure,tNode.iPdpFsmInterface->NewL(tsyProvision->iTsyName,configType));
   348         TRAP(tNode.iProvisionFailure,tNode.iPdpFsmInterface->NewL(tsyProvision->iTsyName,configType));
   250         
   349         
   251         tNode.iDefaultSCPR = static_cast<CPDPDefaultSubConnectionProvider*>(&tNode);
   350         tNode.iDefaultSCPR = static_cast<CPDPDefaultSubConnectionProvider*>(&tNode);
   252         }
   351 
       
   352         TBool promptForAuth = EFalse;
       
   353         iapView->GetBool(KCDTIdWCDMAIfPromptForAuth | KCDTIdOutgoingGprsRecord, promptForAuth);
       
   354 
       
   355         //Default SCPR executing this code, so safe to cast.
       
   356         CPDPDefaultSubConnectionProvider &tempNode = static_cast<CPDPDefaultSubConnectionProvider&>(iContext.Node());
       
   357         tempNode.SetPromptForAuth(promptForAuth);        
       
   358         }
       
   359     CleanupStack::PopAndDestroy();          // CloseIapView();
   253     }
   360     }
   254 
   361 
   255 
   362 
   256 //-=========================================================
   363 //-=========================================================
   257 //Creating context
   364 //Creating context
   446 	User::LeaveIfError(phone.GetCurrentMode(networkMode));
   553 	User::LeaveIfError(phone.GetCurrentMode(networkMode));
   447 	CleanupStack::PopAndDestroy(2); // phone, telServer
   554 	CleanupStack::PopAndDestroy(2); // phone, telServer
   448 	return (networkMode == RMobilePhone::ENetworkModeGsm);
   555 	return (networkMode == RMobilePhone::ENetworkModeGsm);
   449 	}
   556 	}
   450 
   557 
       
   558 void TCreatePrimaryPDPCtx::SetChapInformationL(RPacketContext::TProtocolConfigOptionV2& aPco)
       
   559 /*
       
   560  * This function basically checks if secure authentication is required or not.
       
   561  * If it is needed then it sets all secure authentication related information.
       
   562  */
       
   563     {
       
   564     const TProviderInfoExt* providerInfoExt = static_cast<const TProviderInfoExt*>(iContext.Node().AccessPointConfig().FindExtension(
       
   565             STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId)));
       
   566 
       
   567     if (providerInfoExt == NULL)
       
   568         {
       
   569         User::Leave(KErrCorrupt);
       
   570         }
       
   571 
       
   572     CCommsDatIapView* iapView = CCommsDatIapView::NewLC(providerInfoExt->iProviderInfo.APId());
       
   573 
       
   574     TBool isDisablePlainTextAuth = EFalse;
       
   575     iapView->GetBool(KCDTIdWCDMADisablePlainTextAuth | KCDTIdOutgoingGprsRecord, isDisablePlainTextAuth);
       
   576 
       
   577     //If user name is not available then no authentication Required.
       
   578     if (aPco.iAuthInfo.iUsername.Length() == 0)
       
   579         {
       
   580         aPco.iAuthInfo.iProtocol = RPacketContext::EProtocolNone;
       
   581         }
       
   582     else if (isDisablePlainTextAuth)  //If Disable, CHAP will be used.
       
   583         {
       
   584         if (aPco.iAuthInfo.iPassword.Length() == 0)
       
   585             {
       
   586             User::Leave(KErrArgument);      //CHAP without password?
       
   587             }
       
   588         else
       
   589             {
       
   590             aPco.iAuthInfo.iProtocol = RPacketContext::EProtocolCHAP;
       
   591             CreateChallengeAndResponseForChapL(aPco);
       
   592             }
       
   593         }
       
   594     else
       
   595         {
       
   596         aPco.iAuthInfo.iProtocol = RPacketContext::EProtocolPAP;
       
   597         }
       
   598 
       
   599     CleanupStack::PopAndDestroy();          // CloseIapView();
       
   600     }
       
   601 
       
   602 void TCreatePrimaryPDPCtx::CreateChallengeAndResponseForChapL(RPacketContext::TProtocolConfigOptionV2& aProtocolConfigOption)
       
   603 /*
       
   604  * This function basically sets the CHAP protocol authentication such as (challenge) and (response) 
       
   605  */
       
   606     {
       
   607     //Challenge
       
   608     TTime currentTime;
       
   609     currentTime.UniversalTime();
       
   610     
       
   611     TInt64 seedValue = currentTime.Int64();
       
   612 
       
   613     TUint8 challenge[KGenericNifChallengeSize] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
       
   614     
       
   615     TUint8 i=0;
       
   616     while(i < KGenericNifChallengeSize)
       
   617         {
       
   618         challenge[i] = (TUint8)(Math::Rand(seedValue)%256);
       
   619         aProtocolConfigOption.iChallenge.Append(challenge[i++]);
       
   620         }
       
   621 
       
   622     //Response
       
   623     TBuf8<KGenericNifIdLength+KCommsDbSvrMaxColumnNameLength+KGenericNifChallengeSize> message;
       
   624     message.Append(aProtocolConfigOption.iId);
       
   625     message.Append(aProtocolConfigOption.iAuthInfo.iPassword);
       
   626     message.Append(aProtocolConfigOption.iChallenge);
       
   627     
       
   628     TInt length = 1 /*iId length */ + aProtocolConfigOption.iAuthInfo.iPassword.Length() + KGenericNifChallengeSize;
       
   629 
       
   630     HBufC8* buf = HBufC8::NewL(length);
       
   631     
       
   632     CleanupStack::PushL(buf);
       
   633      
       
   634     TPtr8 ptr((TUint8*)buf->Des().Ptr(),length);
       
   635     
       
   636     ptr.Copy(message);
       
   637     
       
   638     CMD5* md5=0;
       
   639     md5 = CMD5::NewL();
       
   640     
       
   641     CleanupStack::PushL(md5);
       
   642     
       
   643     TPtrC8 Response = md5->Hash(ptr);
       
   644     
       
   645     aProtocolConfigOption.iResponse.Copy(Response);
       
   646     
       
   647     CleanupStack::PopAndDestroy(2);		//buf, md5
       
   648     }
       
   649 
   451 void TCreatePrimaryPDPCtx::DoL()
   650 void TCreatePrimaryPDPCtx::DoL()
   452     {
   651     {
   453     // if the provisionconfig failed, there is no way to inform the CPR of the failure
   652     // if the provisionconfig failed, there is no way to inform the CPR of the failure
   454     // as the framework doesn't expect a response from provisionconfig, so error here
   653     // as the framework doesn't expect a response from provisionconfig, so error here
   455     // if there was a problem so that the appropriate clean up can happen.
   654     // if there was a problem so that the appropriate clean up can happen.
   503     	}
   702     	}
   504 
   703 
   505 	const CImsExtProvision* imsprov = static_cast<const CImsExtProvision*>(
   704 	const CImsExtProvision* imsprov = static_cast<const CImsExtProvision*>(
   506 		iContext.Node().AccessPointConfig().FindExtension(STypeId::CreateSTypeId(CImsExtProvision::EUid, CImsExtProvision::ETypeId)));
   705 		iContext.Node().AccessPointConfig().FindExtension(STypeId::CreateSTypeId(CImsExtProvision::EUid, CImsExtProvision::ETypeId)));
   507 
   706 
       
   707 	TRAP_IGNORE(iContext.Node().iIsModeGsm = IsModeGsmL());
   508 
   708 
   509 	switch (gprsProvision->UmtsGprsRelease())
   709 	switch (gprsProvision->UmtsGprsRelease())
   510 			{
   710 			{
   511 	    	case TPacketDataConfigBase::KConfigGPRS:
   711 	    	case TPacketDataConfigBase::KConfigGPRS:
   512 				{
   712 				{
   513 				SetImsSignallingFlagL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigGPRS>().iProtocolConfigOption, imsprov->iImsSignalIndicator);
   713 				SetImsSignallingFlagL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigGPRS>().iProtocolConfigOption, imsprov->iImsSignalIndicator);
       
   714 
       
   715 				// Only request SIP server address retrieval when network not in GSM/GPRS mode
       
   716 			    // e.g. UMTS/WCDMA
       
   717 				if (!iContext.Node().iIsModeGsm)
       
   718 				    {
       
   719 				    SetupSipServerAddrRetrievalL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigGPRS>().iProtocolConfigOption);
       
   720 				    }
       
   721 				
       
   722 				SetChapInformationL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigGPRS>().iProtocolConfigOption);
       
   723 
   514 				}
   724 				}
   515 				break;
   725 				break;
       
   726 
   516 	    	case TPacketDataConfigBase::KConfigRel5:
   727 	    	case TPacketDataConfigBase::KConfigRel5:
   517 		    case TPacketDataConfigBase::KConfigRel99Rel4:
   728 		    case TPacketDataConfigBase::KConfigRel99Rel4:
   518 				{
   729 				{
   519 				SetImsSignallingFlagL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigR99_R4>().iProtocolConfigOption, imsprov->iImsSignalIndicator);
   730 				SetImsSignallingFlagL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigR99_R4>().iProtocolConfigOption, imsprov->iImsSignalIndicator);
       
   731 
       
   732 			    // Only request SIP server address retrieval when network not in GSM/GPRS mode
       
   733 			    // e.g. UMTS/WCDMA
       
   734 				if (!iContext.Node().iIsModeGsm)
       
   735                     {
       
   736                     SetupSipServerAddrRetrievalL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigR99_R4>().iProtocolConfigOption);
       
   737                     }
       
   738 				
       
   739 				SetChapInformationL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigR99_R4>().iProtocolConfigOption);
       
   740 				
   520 				}
   741 				}
   521 				break;
   742 				break;				
   522 			}
   743 			}
   523 
       
   524 	TRAP_IGNORE(iContext.Node().iIsModeGsm = IsModeGsmL());
       
   525 
       
   526 	// Only request SIP server address retrieval when network not in GSM/GPRS mode
       
   527 	// e.g. UMTS/WCDMA
       
   528 	if (!iContext.Node().iIsModeGsm)
       
   529 		{
       
   530 		switch (gprsProvision->UmtsGprsRelease())
       
   531 			{
       
   532 	    	case TPacketDataConfigBase::KConfigGPRS:
       
   533 				{
       
   534 				SetupSipServerAddrRetrievalL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigGPRS>().iProtocolConfigOption);
       
   535 				}
       
   536 				break;
       
   537 	    	case TPacketDataConfigBase::KConfigRel5:
       
   538 		    case TPacketDataConfigBase::KConfigRel99Rel4:
       
   539 				{
       
   540 				SetupSipServerAddrRetrievalL(gprsProvision->GetScratchContextAs<RPacketContext::TContextConfigR99_R4>().iProtocolConfigOption);
       
   541 				}
       
   542 				break;
       
   543 			}
       
   544 		}
       
   545 	
   744 	
   546 	iContext.Node().iPDPFsmContextId = iContext.Node().iPdpFsmInterface->NewFsmContextL(iContext.Node(),SpudMan::EPrimary);
   745 	iContext.Node().iPDPFsmContextId = iContext.Node().iPdpFsmInterface->NewFsmContextL(iContext.Node(),SpudMan::EPrimary);
   547 
   746 
   548     iContext.Node().PostToClients<TDefaultClientMatchPolicy>(
   747     iContext.Node().PostToClients<TDefaultClientMatchPolicy>(
   549             iContext.NodeId(),
   748             iContext.NodeId(),
   616     }
   815     }
   617 
   816 
   618 DEFINE_SMELEMENT(TSendErrorRecoveryRequest, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
   817 DEFINE_SMELEMENT(TSendErrorRecoveryRequest, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
   619 void TSendErrorRecoveryRequest::DoL()
   818 void TSendErrorRecoveryRequest::DoL()
   620 	{
   819 	{
   621 	TPDPFSMMessages::TPDPFSMMessage* msg = message_cast<TPDPFSMMessages::TPDPFSMMessage>(&iContext.iMessage);
   820 	TPDPMessages::TPDPFSMMessage* msg = message_cast<TPDPMessages::TPDPFSMMessage>(&iContext.iMessage);
   622 
   821 
   623 	__ASSERT_DEBUG(msg, User::Panic(KPdpSCprPanic,  CorePanics::KPanicIncorrectMessage));
   822 	__ASSERT_DEBUG(msg, User::Panic(KPdpSCprPanic,  CorePanics::KPanicIncorrectMessage));
   624 	__ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KPdpSCprPanic, CorePanics::KPanicNoActivity));
   823 	__ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KPdpSCprPanic, CorePanics::KPanicNoActivity));
   625 
   824 
   626 	const RNodeInterface* controlProvider = iContext.Node().ControlProvider();
   825 	const RNodeInterface* controlProvider = iContext.Node().ControlProvider();
   683         User::LeaveIfError(iContext.Node().iPdpFsmInterface->Input(iContext.Node().iPDPFsmContextId, SpudMan::EContextModifyActive));
   882         User::LeaveIfError(iContext.Node().iPdpFsmInterface->Input(iContext.Node().iPDPFsmContextId, SpudMan::EContextModifyActive));
   684    	    }
   883    	    }
   685    	else
   884    	else
   686    	    {
   885    	    {
   687         RClientInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   886         RClientInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   688             TPDPFSMMessages::TPDPFSMMessage(KContextModifyActiveEvent, KErrNone).CRef());
   887                 TPDPMessages::TPDPFSMMessage(KContextModifyActiveEvent, KErrNone).CRef());
   689    	    }
   888    	    }
   690 
   889 
   691     //Expect Response
   890     //Expect Response
   692     iContext.iNodeActivity->ClearPostedTo();
   891     iContext.iNodeActivity->ClearPostedTo();
   693     iContext.Node().iActivityAwaitingResponse = iContext.iNodeActivity->ActivityId();
   892     iContext.Node().iActivityAwaitingResponse = iContext.iNodeActivity->ActivityId();
   713     	{
   912     	{
   714     	//just move to next step
   913     	//just move to next step
   715     	RClientInterface::OpenPostMessageClose(
   914     	RClientInterface::OpenPostMessageClose(
   716     			TNodeCtxId(iContext.ActivityId(), iContext.NodeId()),
   915     			TNodeCtxId(iContext.ActivityId(), iContext.NodeId()),
   717     			iContext.NodeId(),
   916     			iContext.NodeId(),
   718     			TPDPFSMMessages::TPDPFSMMessage(KGetNegQoSEvent, KErrNone).CRef()
   917     			TPDPMessages::TPDPFSMMessage(KGetNegQoSEvent, KErrNone).CRef()
   719     			);
   918     			);
   720     	}
   919     	}
   721     else
   920     else
   722     	{
   921     	{
   723     	ASSERT(iContext.Node().iPdpFsmInterface);
   922     	ASSERT(iContext.Node().iPdpFsmInterface);
   765         }
   964         }
   766     else
   965     else
   767         {
   966         {
   768         //No QoS Requested. Complete this message locally to push yourself forward
   967         //No QoS Requested. Complete this message locally to push yourself forward
   769         RClientInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   968         RClientInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   770         	TPDPFSMMessages::TPDPFSMMessage(KContextQoSSetEvent, KErrNone).CRef());
   969                 TPDPMessages::TPDPFSMMessage(KContextQoSSetEvent, KErrNone).CRef());
   771         }
   970         }
   772 
   971 
   773     //Expect Response
   972     //Expect Response
   774     iContext.iNodeActivity->ClearPostedTo();
   973     iContext.iNodeActivity->ClearPostedTo();
   775     iContext.Node().iActivityAwaitingResponse = iContext.iNodeActivity->ActivityId();
   974     iContext.Node().iActivityAwaitingResponse = iContext.iNodeActivity->ActivityId();
   806         }
  1005         }
   807     else
  1006     else
   808         {
  1007         {
   809         //No QoS Requested. Complete this message locally to push yourself forward
  1008         //No QoS Requested. Complete this message locally to push yourself forward
   810         RClientInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
  1009         RClientInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   811         	TPDPFSMMessages::TPDPFSMMessage(KContextTFTModifiedEvent, KErrNone).CRef());
  1010                 TPDPMessages::TPDPFSMMessage(KContextTFTModifiedEvent, KErrNone).CRef());
   812         }
  1011         }
   813 
  1012 
   814     //Expect Response
  1013     //Expect Response
   815     iContext.iNodeActivity->ClearPostedTo();
  1014     iContext.iNodeActivity->ClearPostedTo();
   816     iContext.Node().iActivityAwaitingResponse = iContext.iNodeActivity->ActivityId();
  1015     iContext.Node().iActivityAwaitingResponse = iContext.iNodeActivity->ActivityId();
   858 //Events
  1057 //Events
   859 //-=========================================================
  1058 //-=========================================================
   860 DEFINE_SMELEMENT(TBlockedOrUnblocked, NetStateMachine::MStateFork, PDPSCprStates::TContext)
  1059 DEFINE_SMELEMENT(TBlockedOrUnblocked, NetStateMachine::MStateFork, PDPSCprStates::TContext)
   861 TInt TBlockedOrUnblocked::TransitionTag()
  1060 TInt TBlockedOrUnblocked::TransitionTag()
   862 	{
  1061 	{
   863 	TPDPFSMMessages::TPDPFSMMessage& pdpmsg = message_cast<TPDPFSMMessages::TPDPFSMMessage>(iContext.iMessage);
  1062 	TPDPMessages::TPDPFSMMessage& pdpmsg = message_cast<TPDPMessages::TPDPFSMMessage>(iContext.iMessage);
   864 	if (pdpmsg.iValue1 == KContextBlockedEvent)
  1063 	if (pdpmsg.iValue1 == KContextBlockedEvent)
   865 		return KBlocked;
  1064 		return KBlocked;
   866 	else
  1065 	else
   867 		return KUnblocked;
  1066 		return KUnblocked;
   868 	}
  1067 	}
   882     }
  1081     }
   883 
  1082 
   884 DEFINE_SMELEMENT(TForwardContextBlockedOrUnblockedToDC, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
  1083 DEFINE_SMELEMENT(TForwardContextBlockedOrUnblockedToDC, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
   885 void TForwardContextBlockedOrUnblockedToDC::DoL()
  1084 void TForwardContextBlockedOrUnblockedToDC::DoL()
   886     {
  1085     {
   887     TPDPFSMMessages::TPDPFSMMessage& pdpmsg = message_cast<TPDPFSMMessages::TPDPFSMMessage>(iContext.iMessage);
  1086     TPDPMessages::TPDPFSMMessage& pdpmsg = message_cast<TPDPMessages::TPDPFSMMessage>(iContext.iMessage);
   888 
  1087 
   889 	RNodeInterface* theOnlyDataClient = iContext.iNode.GetFirstClient<TDefaultClientMatchPolicy>(TCFClientType::EData);
  1088 	RNodeInterface* theOnlyDataClient = iContext.iNode.GetFirstClient<TDefaultClientMatchPolicy>(TCFClientType::EData);
   890 	ASSERT(iContext.iNode.GetClientIter<TDefaultClientMatchPolicy>(TCFClientType::EData)[1] == NULL);
  1089 	ASSERT(iContext.iNode.GetClientIter<TDefaultClientMatchPolicy>(TCFClientType::EData)[1] == NULL);
   891     ASSERT(theOnlyDataClient);
  1090     ASSERT(theOnlyDataClient);
   892 
  1091 
  1127     CSubConGenEventParamsRejected* event= CSubConGenEventParamsRejected::NewL();
  1326     CSubConGenEventParamsRejected* event= CSubConGenEventParamsRejected::NewL();
  1128     CleanupStack::PushL(event);
  1327     CleanupStack::PushL(event);
  1129 
  1328 
  1130 	if (iContext.Node().iContextType == SpudMan::EMbms)
  1329 	if (iContext.Node().iContextType == SpudMan::EMbms)
  1131 		{
  1330 		{
  1132 		TPDPFSMMessages::TPDPFSMMessage& message = message_cast<TPDPFSMMessages::TPDPFSMMessage>(iContext.iMessage);
  1331 		TPDPMessages::TPDPFSMMessage& message = message_cast<TPDPMessages::TPDPFSMMessage>(iContext.iMessage);
  1133 		TInt prevOperationValue = message.iValue2;
  1332 		TInt prevOperationValue = message.iValue2;
  1134 		if ((prevOperationValue == KErrNotFound) || (prevOperationValue == KErrNotSupported ) ||
  1333 		if ((prevOperationValue == KErrNotFound) || (prevOperationValue == KErrNotSupported ) ||
  1135 			 (prevOperationValue == KErrMbmsImpreciseServiceEntries ) ||(prevOperationValue == KErrMbmsServicePreempted) )
  1334 			 (prevOperationValue == KErrMbmsImpreciseServiceEntries ) ||(prevOperationValue == KErrMbmsServicePreempted) )
  1136 			{
  1335 			{
  1137     		event->SetFamilyId (KSubConChannelParamsType);
  1336     		event->SetFamilyId (KSubConChannelParamsType);
  1151 	}
  1350 	}
  1152 
  1351 
  1153 DEFINE_SMELEMENT(TRaiseParamsChanged, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
  1352 DEFINE_SMELEMENT(TRaiseParamsChanged, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
  1154 void TRaiseParamsChanged::DoL()
  1353 void TRaiseParamsChanged::DoL()
  1155     {
  1354     {
  1156     TPDPFSMMessages::TPDPFSMMessage& message = message_cast<TPDPFSMMessages::TPDPFSMMessage>(iContext.iMessage);
  1355     TPDPMessages::TPDPFSMMessage& message = message_cast<TPDPMessages::TPDPFSMMessage>(iContext.iMessage);
  1157 	TInt err=KErrNone;
  1356 	TInt err=KErrNone;
  1158     ASSERT(message.iValue2 == KErrNone);
  1357     ASSERT(message.iValue2 == KErrNone);
  1159     CSubConGenEventParamsChanged* event = NULL;
  1358     CSubConGenEventParamsChanged* event = NULL;
  1160     TRAP_IGNORE(event = CSubConGenEventParamsChanged::NewL());
  1359     TRAP_IGNORE(event = CSubConGenEventParamsChanged::NewL());
  1161     if (event)
  1360     if (event)
  1619         {
  1818         {
  1620         RClientInterface::OpenPostMessageClose(TNodeCtxId(ECFActivityStart, iContext.NodeId()), iContext.NodeId(), TEBase::TCancel().CRef());
  1819         RClientInterface::OpenPostMessageClose(TNodeCtxId(ECFActivityStart, iContext.NodeId()), iContext.NodeId(), TEBase::TCancel().CRef());
  1621         }
  1820         }
  1622     }
  1821     }
  1623 
  1822 
       
  1823 //===========================================================
       
  1824 //   User Authentication
       
  1825 //===========================================================
       
  1826 
       
  1827 DEFINE_SMELEMENT(TSendAuthenticate, NetStateMachine::MStateTransition, PDPSCprStates::TDefContext)
       
  1828 void TSendAuthenticate::DoL()
       
  1829     {
       
  1830     iContext.Node().AuthenticateL();
       
  1831     }
       
  1832 
       
  1833 DEFINE_SMELEMENT(TAwaitingAuthenticateComplete, NetStateMachine::MState, PDPSCprStates::TDefContext)
       
  1834 TBool TAwaitingAuthenticateComplete::Accept()
       
  1835     {
       
  1836     if (iContext.iMessage.IsMessage<TPDPMessages::TAuthenticateComplete>())
       
  1837         {
       
  1838         TPDPMessages::TAuthenticateComplete& msg = message_cast<TPDPMessages::TAuthenticateComplete>(iContext.iMessage);
       
  1839         if (msg.iValue != KErrNone)
       
  1840             {
       
  1841             iContext.iNodeActivity->SetError(msg.iValue);
       
  1842             }
       
  1843         return ETrue;
       
  1844         }
       
  1845     return EFalse;
       
  1846     }
       
  1847 
  1624 } //namespace end
  1848 } //namespace end