telephonyprotocols/pdplayer/src/PDPConfig.cpp
changeset 0 3553901f7fa8
child 3 962e6306d9d2
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // PDP Config structures for TProvision message.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <hash.h>
       
    24 #include <e32math.h>
       
    25 #include <comms-infras/ss_log.h>
       
    26 #include <in_sock.h>
       
    27 #include <comms-infras/metadata.h>
       
    28 #include <comms-infras/agentmcpr.h>
       
    29 #include <comms-infras/ss_log.h>
       
    30 #include <comms-infras/ss_tiermanagerutils.h>
       
    31 
       
    32 #include "PDPProvision.h"
       
    33 
       
    34 using namespace ESock;
       
    35 
       
    36 #if defined(__CFLOG_ACTIVE)
       
    37 #define KPDPMCprTag KESockMetaConnectionTag
       
    38 _LIT8(KPDPMCprSubTag, "pdpmcpr");
       
    39 #endif
       
    40 
       
    41 const TUint8 KGenericNifChallengeSize = 8;
       
    42 const TUint KGenericNifIdLength = 1;
       
    43 
       
    44 //
       
    45 // Attribute table for provisioning structure passed to CFProtocol
       
    46 //
       
    47 START_ATTRIBUTE_TABLE(CGPRSProvision, CGPRSProvision::EUid, CGPRSProvision::ETypeId)
       
    48 // No attributes defined, as no serialisation takes place.
       
    49 END_ATTRIBUTE_TABLE()
       
    50 
       
    51 START_ATTRIBUTE_TABLE(CTSYProvision, CGPRSProvision::EUid, CTSYProvision::ETypeId)
       
    52 // No attributes defined, as no serialisation takes place.
       
    53 END_ATTRIBUTE_TABLE()
       
    54 
       
    55 START_ATTRIBUTE_TABLE(CDefaultPacketQoSProvision, CDefaultPacketQoSProvision::EUid, CDefaultPacketQoSProvision::ETypeId)
       
    56 // No attributes defined, as no serialisation takes place.
       
    57 END_ATTRIBUTE_TABLE()
       
    58 
       
    59 START_ATTRIBUTE_TABLE(CImsExtProvision, CImsExtProvision::EUid, CImsExtProvision::ETypeId)
       
    60 // No attributes defined, as no serialisation takes place.
       
    61 END_ATTRIBUTE_TABLE()
       
    62 
       
    63 CGPRSProvision* CGPRSProvision::NewLC(ESock::CCommsDatIapView* aIapView)
       
    64 	{
       
    65 	CGPRSProvision* self = new (ELeave) CGPRSProvision;
       
    66 	CleanupStack::PushL(self);
       
    67 	self->InitialiseConfigL(aIapView);
       
    68 	return self;
       
    69 	}
       
    70 TInt CGPRSProvision::UmtsGprsRelease() const
       
    71 	{
       
    72 	return iUmtsGprsRelease;
       
    73 	}
       
    74 
       
    75 void CGPRSProvision::InitialiseConfigL(ESock::CCommsDatIapView* aIapView)
       
    76     {	
       
    77 	TInt getErr = aIapView->GetInt(KCDTIdUmtsGprsRelease | KCDTIdOutgoingGprsRecord, iUmtsGprsRelease);
       
    78 		
       
    79 	if (getErr == KErrNotFound || getErr == KErrUnknown)
       
    80 	    {
       
    81 	    // default to GPRS
       
    82 	    getErr = KErrNone;
       
    83 	    iUmtsGprsRelease = TPacketDataConfigBase::KConfigGPRS;
       
    84 	    }
       
    85 	
       
    86 	getErr = InitialiseScratchContext(iUmtsGprsRelease);
       
    87 	//-====================================================
       
    88 	//LENIENT PROVISION
       
    89 	//-====================================================
       
    90 	//With some provision parameters (e.g.: pdpAddress), CGPRSProvision 
       
    91 	//tries to be lenient as technically they can be supplied by
       
    92 	//someone further in the chain (e.g.: GPRS), if not found in the db.
       
    93 	switch (iUmtsGprsRelease)
       
    94 		{
       
    95     	case TPacketDataConfigBase::KConfigGPRS:
       
    96 			{
       
    97             RPacketContext::TContextConfigGPRS& contextGPRS = GetScratchContextAs<RPacketContext::TContextConfigGPRS>();
       
    98             RetrievePdpTypeL(contextGPRS.iPdpType, aIapView);
       
    99             RetrieveApnNameL(contextGPRS.iAccessPointName, aIapView);
       
   100             RetrieveIPAndDnsSettingsL(contextGPRS.iPdpAddress,
       
   101                 contextGPRS.iProtocolConfigOption.iDnsAddresses.iPrimaryDns,
       
   102                 contextGPRS.iProtocolConfigOption.iDnsAddresses.iSecondaryDns, aIapView);
       
   103             RetrieveAuthenticationInfoL(contextGPRS.iProtocolConfigOption, aIapView);
       
   104             // GPRS specific
       
   105         	RetrieveGprsCompression(contextGPRS.iPdpCompression, aIapView);
       
   106         	RetrieveGprsAnonymousAccess(contextGPRS.iAnonymousAccessReqd, aIapView);
       
   107         	contextGPRS.iUseEdge = EFalse;
       
   108 			}
       
   109 			break;
       
   110 	    case TPacketDataConfigBase::KConfigRel5:
       
   111 			{
       
   112             // Rel 5 specific
       
   113             RPacketContext::TContextConfig_R5& contextR5 = GetScratchContextAs<RPacketContext::TContextConfig_R5>();
       
   114             RetrieveUmtsCompressionL(contextR5.iPdpHeaderCompression, contextR5.iPdpDataCompression, aIapView);
       
   115             
       
   116             RetrievePdpTypeL(contextR5.iPdpType, aIapView);
       
   117             RetrieveApnNameL(contextR5.iAccessPointName, aIapView);
       
   118             RetrieveIPAndDnsSettingsL(contextR5.iPdpAddress,
       
   119             		contextR5.iProtocolConfigOption.iDnsAddresses.iPrimaryDns,
       
   120             		contextR5.iProtocolConfigOption.iDnsAddresses.iSecondaryDns, aIapView);
       
   121             RetrieveAuthenticationInfoL(contextR5.iProtocolConfigOption, aIapView);
       
   122             contextR5.iUseEdge = EFalse;
       
   123 
       
   124     		RetrieveUmtsPacketFlowIdentifierL(contextR5.iPFI, aIapView);
       
   125 			}
       
   126 			break;
       
   127 	    case TPacketDataConfigBase::KConfigRel99Rel4:
       
   128 			{
       
   129             RPacketContext::TContextConfigR99_R4& contextUMTS = GetScratchContextAs<RPacketContext::TContextConfigR99_R4>();
       
   130 
       
   131             RetrievePdpTypeL(contextUMTS.iPdpType, aIapView);
       
   132             RetrieveApnNameL(contextUMTS.iAccessPointName, aIapView);
       
   133             RetrieveIPAndDnsSettingsL(contextUMTS.iPdpAddress,
       
   134                 contextUMTS.iProtocolConfigOption.iDnsAddresses.iPrimaryDns,
       
   135                 contextUMTS.iProtocolConfigOption.iDnsAddresses.iSecondaryDns, aIapView);
       
   136             RetrieveAuthenticationInfoL(contextUMTS.iProtocolConfigOption, aIapView);
       
   137             contextUMTS.iUseEdge = EFalse;
       
   138             RetrieveUmtsPacketFlowIdentifierL(contextUMTS.iPFI, aIapView);
       
   139 			}
       
   140 			break;
       
   141 	    default:
       
   142 	    	User::Leave(KErrNotSupported);
       
   143 		}
       
   144     }
       
   145 
       
   146 void CGPRSProvision::RetrieveGprsCompression(TUint& aCompression, ESock::CCommsDatIapView* aIapView) const
       
   147 	{
       
   148 	aCompression = 0;
       
   149 	TBool isCompression = EFalse;
       
   150 	aIapView->GetBool(KCDTIdWCDMADataCompression | KCDTIdOutgoingGprsRecord, isCompression);
       
   151 	if (isCompression)
       
   152 		{
       
   153 		aCompression |= RPacketContext::KPdpDataCompression;
       
   154 		}
       
   155 
       
   156 	isCompression = EFalse;
       
   157 	aIapView->GetBool(KCDTIdWCDMAHeaderCompression | KCDTIdOutgoingGprsRecord, isCompression);
       
   158 	if (isCompression)
       
   159 		{
       
   160 		aCompression |= RPacketContext::KPdpHeaderCompression;
       
   161 		}
       
   162 	__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::InitialiseConfigL() KCDTIdWCDMADataCompression|KCDTIdWCDMAHeaderCompression [%d]"), this, aCompression));
       
   163 	}
       
   164 
       
   165 void CGPRSProvision::RetrieveGprsAnonymousAccess(RPacketContext::TAnonymousAccess& aAnonymous, ESock::CCommsDatIapView* aIapView) const
       
   166 	{	
       
   167 	TBool isAnonymous = EFalse;
       
   168 	aIapView->GetBool(KCDTIdWCDMAAnonymousAccess | KCDTIdOutgoingGprsRecord,isAnonymous);
       
   169 	if (isAnonymous)
       
   170 		aAnonymous = RPacketContext::ERequired;
       
   171 	else
       
   172 		aAnonymous = RPacketContext::ENotRequired;
       
   173 	
       
   174 	__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::InitialiseConfigL() KCDTIdWCDMAAnonymousAccess [%d]"), this, aAnonymous));
       
   175 	}
       
   176 
       
   177 void CGPRSProvision::RetrieveApnNameL(TDes8& aApnName, ESock::CCommsDatIapView* aIapView) const
       
   178 	{
       
   179 	HBufC* buf = NULL;
       
   180 	TInt getErr;
       
   181 
       
   182 	if ((getErr = aIapView->GetText(KCDTIdAPN | KCDTIdOutgoingGprsRecord, buf)) == KErrNone)
       
   183     		{
       
   184     		aApnName.Copy(*buf);
       
   185     		delete buf;
       
   186     		}
       
   187     	else if (getErr != KErrNotFound )
       
   188     		{
       
   189     		User::Leave(getErr);
       
   190     		}
       
   191 	__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::InitialiseConfigL() KCDTIdAPN [%S]"), this, &aApnName));
       
   192 	}
       
   193 
       
   194 void CGPRSProvision::RetrievePdpTypeL(RPacketContext::TProtocolType& aPdpType, ESock::CCommsDatIapView* aIapView) const	
       
   195 	{
       
   196 	TUint32 pdpType(0);
       
   197 
       
   198 	aIapView->GetIntL(KCDTIdWCDMPDPType | KCDTIdOutgoingGprsRecord, pdpType);
       
   199 	aPdpType = static_cast<RPacketContext::TProtocolType>(pdpType);
       
   200 	__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::InitialiseConfigL() KCDTIdWCDMPDPType=%d"), this, aPdpType)); 	
       
   201 	}
       
   202 
       
   203 void CGPRSProvision::RetrieveAuthenticationInfoL(RPacketContext::TProtocolConfigOptionV2& aProtocolConfigOption, ESock::CCommsDatIapView* aIapView)
       
   204     {
       
   205     HBufC* buf = NULL;
       
   206     TInt getErr;
       
   207 
       
   208     __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL()"), this));
       
   209     
       
   210     getErr = aIapView->GetText(KCDTIdWCDMAIfAuthName | KCDTIdOutgoingGprsRecord, buf);
       
   211     if ( getErr == KErrNone )
       
   212         {
       
   213         ASSERT(buf);
       
   214         aProtocolConfigOption.iAuthInfo.iUsername.Copy(*buf);
       
   215         delete buf;
       
   216         buf = NULL;
       
   217 
       
   218         __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMAIfAuthName [%S] "), this, &aProtocolConfigOption.iAuthInfo.iUsername));
       
   219 
       
   220         aProtocolConfigOption.iId = 1;
       
   221 
       
   222         TBool isDisableAuth = EFalse;
       
   223         getErr = aIapView->GetBool(KCDTIdWCDMADisablePlainTextAuth | KCDTIdOutgoingGprsRecord,isDisableAuth);
       
   224         __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMADisablePlainTextAuth [%d]"), this, isDisableAuth));
       
   225         if (getErr == KErrNone)
       
   226             {
       
   227             getErr = aIapView->GetText(KCDTIdWCDMAIfAuthPass | KCDTIdOutgoingGprsRecord, buf);
       
   228             if ( getErr == KErrNone )
       
   229                 {
       
   230                 ASSERT(buf);
       
   231                 aProtocolConfigOption.iAuthInfo.iPassword.Copy(*buf);
       
   232                 delete buf;
       
   233                 buf = NULL;
       
   234 
       
   235                 __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMAIfAuthPass [%S]"), this, &aProtocolConfigOption.iAuthInfo.iPassword));
       
   236 
       
   237                 if (isDisableAuth)  //If Disable, CHAP will be used.
       
   238                     {
       
   239                     aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolCHAP;
       
   240                     CreateChallengeAndResponseForChapL(aProtocolConfigOption);
       
   241                     }
       
   242                 else
       
   243                     {
       
   244                     aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolPAP;
       
   245                     }
       
   246                 }
       
   247             else if (getErr == KErrNotFound)
       
   248                 {
       
   249                 if (isDisableAuth) //ERROR: CHAP used without password???
       
   250                     {
       
   251                     User::Leave(KErrArgument);
       
   252                     }
       
   253                 else    //PAP used without password.
       
   254                     {
       
   255                     aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolPAP;
       
   256                     }
       
   257                 }
       
   258             else    //getErr != KErrNotFound
       
   259                 {
       
   260                 User::Leave(getErr);
       
   261                 }
       
   262             }
       
   263         else
       
   264             {
       
   265             User::Leave(getErr);
       
   266             }
       
   267         }
       
   268     else if (getErr == KErrNotFound )   //No Authentication Required.
       
   269         {
       
   270         aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolNone;
       
   271         }
       
   272     else    //getErr != KErrNotFound
       
   273         {
       
   274         User::Leave(getErr);
       
   275         }
       
   276     }
       
   277 
       
   278 void CGPRSProvision::CreateChallengeAndResponseForChapL(RPacketContext::TProtocolConfigOptionV2& aProtocolConfigOption)
       
   279     {
       
   280     //Challenge
       
   281     TTime currentTime;
       
   282     currentTime.UniversalTime();
       
   283     
       
   284     TInt64 seedValue = currentTime.Int64();
       
   285 
       
   286     TUint8 challenge[KGenericNifChallengeSize] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
       
   287     
       
   288     TUint8 i=0;
       
   289     while(i < KGenericNifChallengeSize)
       
   290         {
       
   291         challenge[i] = (TUint8)(Math::Rand(seedValue)%256);
       
   292         aProtocolConfigOption.iChallenge.Append(challenge[i++]);
       
   293         }
       
   294 
       
   295     //Response
       
   296     TBuf8<KGenericNifIdLength+KCommsDbSvrMaxColumnNameLength+KGenericNifChallengeSize> message;
       
   297     message.Append(aProtocolConfigOption.iId);
       
   298     message.Append(aProtocolConfigOption.iAuthInfo.iPassword);
       
   299     message.Append(aProtocolConfigOption.iChallenge);
       
   300     
       
   301     TInt length = 1 /*iId length */ + aProtocolConfigOption.iAuthInfo.iPassword.Length() + KGenericNifChallengeSize;
       
   302 
       
   303     HBufC8* buf = HBufC8::NewL(length);
       
   304     
       
   305     CleanupStack::PushL(buf);
       
   306      
       
   307     TPtr8 ptr((TUint8*)buf->Des().Ptr(),length);
       
   308     
       
   309     ptr.Copy(message);
       
   310     
       
   311     CMD5* md5=0;
       
   312     md5 = CMD5::NewL();
       
   313     
       
   314     CleanupStack::PushL(md5);
       
   315     
       
   316     TPtrC8 Response = md5->Hash(ptr);
       
   317     
       
   318     aProtocolConfigOption.iResponse.Copy(Response);
       
   319     
       
   320     CleanupStack::PopAndDestroy(2);
       
   321     }
       
   322 
       
   323 void CGPRSProvision::RetrieveIPAndDnsSettingsL(TDes8& aPdpAddress, TDes8& aDns1, TDes8& aDns2, ESock::CCommsDatIapView* aIapView) const
       
   324 	{
       
   325 	HBufC* buf = NULL;
       
   326 
       
   327 	aPdpAddress.SetLength(0);
       
   328 	aDns1.SetLength(0);
       
   329 	aDns2.SetLength(0);
       
   330 	
       
   331 	TBool fromServer;
       
   332 	aIapView->GetBoolL(KCDTIdWCDMAIPAddrFromServer | KCDTIdOutgoingGprsRecord, fromServer);
       
   333 	if (!fromServer)
       
   334 	    {
       
   335     	aIapView->GetTextL(KCDTIdWCDMAIPAddr | KCDTIdOutgoingGprsRecord, buf);
       
   336     	aPdpAddress.Copy(*buf);
       
   337     	delete buf;
       
   338     	buf = NULL;
       
   339 	    }
       
   340 	
       
   341     // We can only use IPv4 or IPv6 - we use the first one listed in the IfNetworks field
       
   342 	aIapView->GetTextL(KCDTIdWCDMAIfNetworks | KCDTIdOutgoingGprsRecord, buf);
       
   343 
       
   344 	TInt pos = buf->Find(_L(","));
       
   345 	if (pos == KErrNotFound)
       
   346 	    {
       
   347 	    pos = buf->Length();
       
   348 	    }
       
   349 
       
   350 	TBufC<KCommsDbSvrMaxFieldLength> temp(buf->Mid(0, pos));
       
   351 	delete buf;
       
   352 	buf = NULL;
       
   353 	_LIT(KIp4, "ip");
       
   354 	_LIT(KIp6, "ip6");
       
   355 	if (temp.CompareF(KIp4) == 0)
       
   356 	    {
       
   357 	    // IPv4 settings
       
   358     	aIapView->GetBoolL(KCDTIdWCDMAIPDNSAddrFromServer | KCDTIdOutgoingGprsRecord, fromServer);
       
   359     	if (!fromServer)
       
   360     	    {
       
   361     	    aIapView->GetTextL(KCDTIdWCDMAIPNameServer1 | KCDTIdOutgoingGprsRecord, buf);
       
   362     	    aDns1.Copy(*buf);
       
   363         	delete buf;
       
   364         	buf = NULL;
       
   365     	    aIapView->GetTextL(KCDTIdWCDMAIPNameServer2 | KCDTIdOutgoingGprsRecord, buf);
       
   366         	aDns2.Copy(*buf);
       
   367     	    delete buf;
       
   368         	buf = NULL;
       
   369     	    }
       
   370 	    }
       
   371 	else if (temp.CompareF(KIp6) == 0)
       
   372 	    {
       
   373 	    // IPv6 settings
       
   374     	aIapView->GetBoolL(KCDTIdWCDMAIP6DNSAddrFromServer | KCDTIdOutgoingGprsRecord, fromServer);
       
   375     	if (!fromServer)
       
   376     	    {
       
   377     	    aIapView->GetTextL(KCDTIdWCDMAIP6NameServer1 | KCDTIdOutgoingGprsRecord, buf);
       
   378     	    aDns1.Copy(*buf);
       
   379     	    delete buf;
       
   380     		buf = NULL;
       
   381     	    aIapView->GetTextL(KCDTIdWCDMAIP6NameServer2 | KCDTIdOutgoingGprsRecord, buf);
       
   382           	aDns2.Copy(*buf);
       
   383         	delete buf;
       
   384             buf = NULL;
       
   385     	    }
       
   386 	    }
       
   387 	else
       
   388 	    {
       
   389 	    // Anything else is a serious misconfiguration
       
   390 	    User::Leave(KErrArgument);
       
   391 	    }
       
   392 	}
       
   393 void CGPRSProvision::RetrieveUmtsCompressionL(RPacketContext::THeaderCompression& aHeaderCompression, RPacketContext::TDataCompression& aDataCompression, ESock::CCommsDatIapView* aIapView) const
       
   394 	{
       
   395 	TUint32 headerComp;
       
   396 	TUint32 dataComp;
       
   397 	TInt err;
       
   398 	
       
   399 	err = aIapView->GetInt(KCDTIdR5DataCompression | KCDTIdOutgoingGprsRecord, headerComp);
       
   400 	if (err == KErrNotFound || err == KErrUnknown)
       
   401 	    {
       
   402 	    err = KErrNone;
       
   403 	    headerComp = RPacketContext::ENoHeaderCompression;
       
   404 	    }
       
   405 	User::LeaveIfError(err);
       
   406 	
       
   407 	aHeaderCompression = static_cast<RPacketContext::THeaderCompression>(headerComp);
       
   408 	
       
   409 	err = aIapView->GetInt(KCDTIdR5HeaderCompression | KCDTIdOutgoingGprsRecord, dataComp);
       
   410 	if (err == KErrNotFound || err == KErrUnknown)
       
   411 	    {
       
   412 	    err = KErrNone;
       
   413 	    dataComp = RPacketContext::ENoDataCompression;
       
   414 	    }
       
   415 	User::LeaveIfError(err);
       
   416 
       
   417 	aDataCompression = static_cast<RPacketContext::TDataCompression>(dataComp);	
       
   418 	}
       
   419 
       
   420 void CGPRSProvision::RetrieveUmtsPacketFlowIdentifierL(RPacketContext::TPacketFlowIdentifier& aPfi, ESock::CCommsDatIapView* aIapView) const
       
   421 	{
       
   422 	TUint32 pfi;
       
   423 	TInt err = aIapView->GetInt(KCDTIdPacketFlowIdentifier | KCDTIdOutgoingGprsRecord, pfi);
       
   424 	if (err == KErrNotFound || err == KErrUnknown)
       
   425 	    {
       
   426 	    err = KErrNone;
       
   427 	    pfi = RPacketContext::EBestEffort;
       
   428 	    }
       
   429 	User::LeaveIfError(err);
       
   430 	aPfi = static_cast<RPacketContext::TPacketFlowIdentifier>(pfi);
       
   431 	}
       
   432 
       
   433 
       
   434 TInt CGPRSProvision::InitialiseScratchContext(TUint32 aConfigRel) const
       
   435 	{
       
   436     switch(aConfigRel)
       
   437         {
       
   438         case TPacketDataConfigBase::KConfigGPRS:
       
   439             {
       
   440             RPacketContext::TContextConfigGPRS tmp;
       
   441             Mem::Copy(const_cast<TUint8*>(iScratchContext.Ptr()), &tmp, sizeof(tmp));
       
   442             }
       
   443             break;
       
   444             
       
   445         case TPacketDataConfigBase::KConfigRel99Rel4:
       
   446             {
       
   447             RPacketContext::TContextConfigR99_R4 tmp;
       
   448             Mem::Copy(const_cast<TUint8*>(iScratchContext.Ptr()), &tmp, sizeof(tmp));
       
   449             }
       
   450             break;
       
   451             
       
   452         case TPacketDataConfigBase::KConfigRel5:
       
   453             {
       
   454             RPacketContext::TContextConfig_R5 tmp;
       
   455             Mem::Copy(const_cast<TUint8*>(iScratchContext.Ptr()), &tmp, sizeof(tmp));
       
   456             }
       
   457             break;
       
   458         default:
       
   459         	return KErrNotSupported;
       
   460         }
       
   461     return KErrNone;
       
   462     }
       
   463 
       
   464 
       
   465 CTSYProvision* CTSYProvision::NewLC(ESock::CCommsDatIapView* aIapView)
       
   466 	{
       
   467 	CTSYProvision* self = new (ELeave) CTSYProvision;
       
   468 	CleanupStack::PushL(self);
       
   469 	self->InitialiseConfigL(aIapView);
       
   470 	return self;
       
   471 	}
       
   472 
       
   473 void CTSYProvision::InitialiseConfigL(ESock::CCommsDatIapView* aIapView)
       
   474     {
       
   475 	HBufC* buf = NULL;
       
   476 	
       
   477 	aIapView->GetTextL(KCDTIdTsyName, buf);
       
   478 	iTsyName.Copy(*buf);
       
   479 	__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CTSYProvision [this=%08x]::InitialiseConfigL() KCDTIdTsyName=%s"), this, &iTsyName)); 	
       
   480 	delete buf;
       
   481     }
       
   482 
       
   483 CDefaultPacketQoSProvision* CDefaultPacketQoSProvision::NewL(ESock::CCommsDatIapView* aIapView)
       
   484 	{
       
   485 	CDefaultPacketQoSProvision* self = new (ELeave) CDefaultPacketQoSProvision;
       
   486 	CleanupStack::PushL(self);
       
   487 	self->InitialiseConfigL(aIapView);
       
   488 	CleanupStack::Pop(self);
       
   489 	return self;
       
   490 	}
       
   491 	
       
   492  void CDefaultPacketQoSProvision::InitialiseConfigL(ESock::CCommsDatIapView* aIapView)
       
   493     {
       
   494     TUint32 data;
       
   495 	    
       
   496 	aIapView->GetIntL(KCDTIdWCDMAReqTrafficClass,data);
       
   497 	iParams.iReqTrafficClass = (RPacketQoS::TTrafficClass)data;
       
   498 	
       
   499 	aIapView->GetIntL(KCDTIdWCDMAMinTrafficClass,data);
       
   500 	iParams.iMinTrafficClass = (RPacketQoS::TTrafficClass)data;
       
   501 	
       
   502 	aIapView->GetIntL(KCDTIdWCDMAReqDeliveryOrder,data);
       
   503 	iParams.iReqDeliveryOrderReqd = (RPacketQoS::TDeliveryOrder)data;
       
   504 	
       
   505 	aIapView->GetIntL(KCDTIdWCDMAMinDeliveryOrder,data);
       
   506 	iParams.iMinDeliveryOrderReqd = (RPacketQoS::TDeliveryOrder)data;
       
   507 	
       
   508 	aIapView->GetIntL(KCDTIdWCDMAReqDeliverErroneousSDU,data);
       
   509 	iParams.iReqDeliverErroneousSDU = (RPacketQoS::TErroneousSDUDelivery)data;
       
   510 	
       
   511 	aIapView->GetIntL(KCDTIdWCDMAMinDeliverErroneousSDU,data);
       
   512 	iParams.iMinDeliverErroneousSDU = (RPacketQoS::TErroneousSDUDelivery)data;
       
   513 	
       
   514 	aIapView->GetIntL(KCDTIdWCDMAReqMaxSDUSize,data);
       
   515 	iParams.iReqMaxSDUSize = (TInt)data;
       
   516 	
       
   517 	aIapView->GetIntL(KCDTIdWCDMAMinAcceptableMaxSDUSize,data);
       
   518 	iParams.iMinAcceptableMaxSDUSize = (TInt)data;
       
   519 	
       
   520 	aIapView->GetIntL(KCDTIdWCDMAReqMaxUplinkRate,data);
       
   521 	iParams.iReqMaxRate.iUplinkRate = (TInt)data;
       
   522 	
       
   523 	aIapView->GetIntL(KCDTIdWCDMAReqMinUplinkRate,data);
       
   524 	iParams.iMinAcceptableMaxRate.iUplinkRate = (TInt)data;
       
   525 	
       
   526 	aIapView->GetIntL(KCDTIdWCDMAReqMaxDownlinkRate,data);
       
   527 	iParams.iReqMaxRate.iDownlinkRate = (TInt)data;
       
   528 	
       
   529 	aIapView->GetIntL(KCDTIdWCDMAReqMinDownlinkRate,data);
       
   530 	iParams.iMinAcceptableMaxRate.iDownlinkRate = (TInt)data;
       
   531 		
       
   532 	aIapView->GetIntL(KCDTIdWCDMAReqBER,data);
       
   533 	iParams.iReqBER = (RPacketQoS::TBitErrorRatio)data;
       
   534 	
       
   535 	aIapView->GetIntL(KCDTIdWCDMAMaxBER,data);
       
   536 	iParams.iMaxBER = (RPacketQoS::TBitErrorRatio)data;
       
   537 	
       
   538 	aIapView->GetIntL(KCDTIdWCDMAReqSDUErrorRatio,data);
       
   539 	iParams.iReqSDUErrorRatio = (RPacketQoS::TSDUErrorRatio)data;
       
   540 	
       
   541 	aIapView->GetIntL(KCDTIdWCDMAMaxSDUErrorRatio,data);
       
   542 	iParams.iMaxSDUErrorRatio = (RPacketQoS::TSDUErrorRatio)data;
       
   543 	
       
   544 	aIapView->GetIntL(KCDTIdWCDMAReqTrafficHandlingPriority,data);
       
   545 	iParams.iReqTrafficHandlingPriority = (RPacketQoS::TTrafficHandlingPriority)data;
       
   546 	
       
   547 	aIapView->GetIntL(KCDTIdWCDMAMinTrafficHandlingPriority,data);
       
   548 	iParams.iMinTrafficHandlingPriority = (RPacketQoS::TTrafficHandlingPriority)data;
       
   549 	
       
   550 	aIapView->GetIntL(KCDTIdWCDMAReqTransferDelay,data);
       
   551 	iParams.iReqTransferDelay = (TInt)data;
       
   552 	
       
   553 	aIapView->GetIntL(KCDTIdWCDMAMaxTransferDelay,data);
       
   554 	iParams.iMaxTransferDelay = (TInt)data;
       
   555 	
       
   556 	aIapView->GetIntL(KCDTIdWCDMAReqGuaranteedUplinkRate,data);
       
   557 	iParams.iReqGuaranteedRate.iUplinkRate = (TInt)data;
       
   558 	
       
   559 	aIapView->GetIntL(KCDTIdWCDMAMinGuaranteedUplinkRate,data);			
       
   560 	iParams.iMinGuaranteedRate.iUplinkRate = (TInt)data;
       
   561 	
       
   562 	aIapView->GetIntL(KCDTIdWCDMAReqGuaranteedDownlinkRate,data);
       
   563 	iParams.iReqGuaranteedRate.iDownlinkRate = (TInt)data;
       
   564 		
       
   565 	aIapView->GetIntL(KCDTIdWCDMAMinGuaranteedDownlinkRate,data);
       
   566 	iParams.iMinGuaranteedRate.iDownlinkRate = (TInt)data;
       
   567 
       
   568 	TBool bdata = EFalse;
       
   569 #ifdef _DEBUG
       
   570 	TInt debugErr = 
       
   571 #endif
       
   572 	aIapView->GetBool(KCDTIdWCDMASignallingIndication,bdata);
       
   573 	iParams.iSignallingIndication = bdata;
       
   574     }
       
   575     
       
   576 CImsExtProvision* CImsExtProvision::NewLC(ESock::CCommsDatIapView* aIapView)
       
   577 	{
       
   578 	CImsExtProvision* self = new (ELeave) CImsExtProvision;
       
   579 	CleanupStack::PushL(self);
       
   580 	self->InitialiseConfigL(aIapView);
       
   581 	return self;
       
   582 	}
       
   583 
       
   584 void CImsExtProvision::InitialiseConfigL(ESock::CCommsDatIapView* aIapView)
       
   585     {
       
   586 	TBool bdata = EFalse;
       
   587 	aIapView->GetBool(KCDTIdWCDMAImCmSignallingIndication,bdata);
       
   588 	iImsSignalIndicator = bdata;
       
   589     }
       
   590 
       
   591