networkcontrol/ipscpr/src/ipscpr.cpp
branchRCL_3
changeset 22 8d540f55e491
parent 21 abbed5a4b42a
child 23 425d8f4f7fa5
equal deleted inserted replaced
21:abbed5a4b42a 22:8d540f55e491
     1 // Copyright (c) 2005-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 // Implementation file for the IP SubConnection Provider and its basic version.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file ipscpr.cpp
       
    20 */
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32test.h>
       
    24 #include <ecom/ecom.h>
       
    25 #include <implementationproxy.h>
       
    26 #include <es_prot.h>
       
    27 #include <cs_subconevents.h>
       
    28 #include <cs_subconparams.h>
       
    29 #include "ipscpr.h"
       
    30 #include "ipscprlog.h"
       
    31 #include "sblpextn.h"
       
    32 #include <ip_subconparams.h>
       
    33 
       
    34 #ifndef BASIC_IPSCPR
       
    35 #include "pfqos_stream.h"
       
    36 #include "ipscprlog.h"
       
    37 #include <ip_subconparams.h>
       
    38 #include "qos_msg.h"
       
    39 #include "pfqoslib.h"
       
    40 #include <networking/qoserr.h>
       
    41 
       
    42 #ifdef SYMBIAN_NETWORKING_UMTSR5  
       
    43 #include <networking/imsextn.h>
       
    44 #include <networking/sblpextn.h>
       
    45 #include <networking/umtsextn.h>
       
    46 #else
       
    47 #include <networking/umtsapi.h>
       
    48 #include <networking/sblpapi.h>
       
    49 #endif 
       
    50 // SYMBIAN_NETWORKING_UMTSR5 
       
    51 
       
    52 #endif
       
    53 
       
    54 #ifndef SYMBIAN_NETWORKING_3GPPDEFAULTQOS
       
    55 // need to ensure the original TUid of the factory class is used for implementions in this component
       
    56 #undef KSubConIPParamsUid
       
    57 #endif
       
    58 
       
    59 
       
    60 /**
       
    61 Data required for instantiating ECOM Plugin
       
    62 */
       
    63 const TImplementationProxy ImplementationTable[] =
       
    64 	{
       
    65 	IMPLEMENTATION_PROXY_ENTRY(KSubConnectionProviderImplementationUid, CIpSubConnectionProviderFactory::NewL),
       
    66 	IMPLEMENTATION_PROXY_ENTRY(KSubConIPParamsUid, CSubConIPExtensionParamsFactory::NewL)
       
    67 	};
       
    68 
       
    69 
       
    70 /**
       
    71 ECOM Implementation Factory
       
    72 */
       
    73 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
    74     {
       
    75     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    76 
       
    77     return ImplementationTable;
       
    78     }
       
    79 
       
    80 
       
    81 /**
       
    82 Plugin Implementation
       
    83 */
       
    84 
       
    85 
       
    86 CIpSubConnectionProviderFactory* CIpSubConnectionProviderFactory::NewL(TAny* aConstructionParameters)
       
    87 /**
       
    88 Constructs a IP Connection Provider Factory
       
    89 
       
    90 @param aConstructionParameters construction data passed by ECOM
       
    91 
       
    92 @return pointer to a constructed factory
       
    93 */
       
    94 	{
       
    95 	CIpSubConnectionProviderFactory* ptr = new (ELeave) CIpSubConnectionProviderFactory(KIPConnectionProviderFactoryId, *(reinterpret_cast<CSubConnectionFactoryContainer*>(aConstructionParameters)));
       
    96 	return ptr;
       
    97 	}
       
    98 
       
    99 
       
   100 CIpSubConnectionProviderFactory::CIpSubConnectionProviderFactory(TUint aFactoryId, CSubConnectionFactoryContainer& aParentContainer)
       
   101 	: CSubConnectionProviderFactoryBase(aFactoryId, aParentContainer)
       
   102 /**
       
   103 IP SubConnection Provider Factory Constructor
       
   104 
       
   105 @param aFactoryId ECOM Implementation Id
       
   106 @param aParentContainer Object Owner
       
   107 */
       
   108 	{
       
   109 	}
       
   110 
       
   111 
       
   112 CIpSubConnectionProviderFactory::~CIpSubConnectionProviderFactory()
       
   113 /**
       
   114 IP SubConnection Provider Factory Destructor
       
   115 */
       
   116 	{
       
   117 	}
       
   118 
       
   119 
       
   120 CSubConnectionProviderBase* CIpSubConnectionProviderFactory::DoCreateProviderL(CConnectionProviderBase& aConnProvider, RSubConnection::TSubConnType aType)
       
   121 /**
       
   122 Factory Function that either creates a new SubConnection Provider or attaches
       
   123 to the default Provider.  The type of creation can be either RSubConnection::ECreateNew
       
   124 or RSubConnection::EAttachToDefault.
       
   125 
       
   126 Use of other types will cause the factory to leave with KErrNotSupported.
       
   127 
       
   128 @param aConnProvider Associated Connection Provider
       
   129 @param aType Type of SubConnection Provider Creation.
       
   130 */
       
   131 	{
       
   132 	CSubConnectionProviderBase* p = NULL;
       
   133 	switch (aType)
       
   134 		{
       
   135 #ifdef SYMBIAN_NETWORKING_3GPPDEFAULTQOS
       
   136 		case RSubConnection::EAttachToDefault:
       
   137 			p = new(ELeave)CDefaultSubConnectionProvider(*this, aConnProvider, aType);
       
   138 			break;
       
   139 #ifdef BASIC_IPSCPR
       
   140 		case RSubConnection::ECreateNew:
       
   141             // The Basic IPSCPR, itself, by definition, doesn't support secondary contexts.
       
   142             // Ideally it should defer to the transport layer provider as for primary contexts...
       
   143             //        
       
   144 			User::Leave(KErrNotSupported);
       
   145 			break;
       
   146 #else
       
   147 		case RSubConnection::ECreateNew:
       
   148 			p = CIpSubConnectionProvider::NewL(*this, aConnProvider);
       
   149 			break;
       
   150 #endif // BASIC_IPSCPR
       
   151 #else
       
   152 		case RSubConnection::ECreateNew:
       
   153 			p = CIpSubConnectionProvider::NewL(*this, aConnProvider);
       
   154 			break;
       
   155 		case RSubConnection::EAttachToDefault:
       
   156 			p = new(ELeave)CDefaultSubConnectionProvider(*this, aConnProvider);
       
   157 			break;
       
   158 #endif // SYMBIAN_NETWORKING_3GPPDEFAULTQOS
       
   159 		default:
       
   160 			{
       
   161 			User::Leave(KErrNotSupported);
       
   162 			}
       
   163 		};
       
   164 	return p;
       
   165 	}
       
   166 
       
   167 
       
   168 #ifndef BASIC_IPSCPR
       
   169 
       
   170 /**
       
   171 Provider Implementation
       
   172 */
       
   173 
       
   174 
       
   175 CIpSubConnectionProvider* CIpSubConnectionProvider::NewL(CIpSubConnectionProviderFactory& aFactory, CConnectionProviderBase& aConnProvider)
       
   176 /**
       
   177 Construct a new IP SubConnection Provider Object
       
   178 
       
   179 @param aFactory factory that create this object
       
   180 @param aConnProvider Connection Provider associated with this object
       
   181 */
       
   182 	{
       
   183 	CIpSubConnectionProvider* ptr = new (ELeave) CIpSubConnectionProvider(aFactory, aConnProvider);
       
   184 
       
   185     CleanupStack::PushL(ptr);
       
   186     ptr->ConstructL();
       
   187     CleanupStack::Pop();
       
   188 
       
   189 	return ptr;
       
   190 	}
       
   191 
       
   192 
       
   193 CIpSubConnectionProvider::CIpSubConnectionProvider(CIpSubConnectionProviderFactory& aFactory, CConnectionProviderBase& aConnProvider)
       
   194 	: CEmptySubConnectionProvider(aFactory, aConnProvider)
       
   195 	, iChannelId(-1)
       
   196 	, iPrtExtensions(_FOFF(CExtensionBase,iLink))
       
   197 	, iParametersSet(EFalse)
       
   198 /**
       
   199 IP SubConnection Provider Constructor
       
   200 
       
   201 @param aFactory factory that create this object
       
   202 @param aConnProvider Connection Provider associated with this object
       
   203 */
       
   204 	{
       
   205 		__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider [this=%08x]:\tCIpSubConnectionProvider() [MConnectionDataClient=%08x]"),
       
   206 		   this, (MConnectionDataClient*)this));
       
   207 	}
       
   208 
       
   209 
       
   210 CIpSubConnectionProvider::~CIpSubConnectionProvider()
       
   211 /**
       
   212 IP SubConnection Provider Destructor
       
   213 */
       
   214 	{
       
   215 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::Destruct [%08x]"), this));
       
   216 
       
   217 	if( iChannelId >= 0 ) // Only send a Close if have opened a channel
       
   218 		{
       
   219 		TRAPD(ret,SendCloseL());
       
   220 		if( ret != KErrNone )
       
   221 			{
       
   222 			__IPCPRLOG(IpCprLog::Printf(_L("SendCloseL left with error: %d"), ret));
       
   223 			}
       
   224 		}
       
   225 
       
   226 	if( iWriter )
       
   227 		{
       
   228 		iWriter->Cancel();
       
   229 		delete iWriter;
       
   230 		iWriter = NULL;
       
   231 		}
       
   232 
       
   233 	if( iReader )
       
   234 		{
       
   235 		iReader->Cancel();
       
   236 		delete iReader;
       
   237 		iReader = NULL;
       
   238 		}
       
   239 
       
   240 	delete iPrtParameters;
       
   241 	delete iAsyncWriter;
       
   242 	ResetPrtExtensions();
       
   243 
       
   244 	iSocket.Close();
       
   245 	}
       
   246 
       
   247 
       
   248 void CIpSubConnectionProvider::ConstructL()
       
   249 /**
       
   250 IP SubConnection Provider Second Phase Constructor
       
   251 */
       
   252 	{
       
   253 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::Construct [%08x]"), this));
       
   254 
       
   255 	// Open a connection to the QoS PRT
       
   256     _LIT(KDescPfqos, "pfqos");
       
   257 
       
   258 #ifdef SYMBIAN_NETWORKING_3GPPDEFAULTQOS
       
   259     // If we couldn't open pipe to QoS framework then it is not supported
       
   260     TInt ret = iSocket.Open(KDescPfqos);
       
   261     if(ret == KErrNotFound)
       
   262     {
       
   263     	User::Leave(KErrNotSupported);
       
   264     }
       
   265     else if (ret != KErrNone)
       
   266     {
       
   267     	User::Leave(ret);
       
   268     }
       
   269 #else
       
   270     User::LeaveIfError(iSocket.Open(KDescPfqos));
       
   271 #endif
       
   272     iUid = RProcess().Type();
       
   273 
       
   274 	iReader = CQoSMsgReader::NewL(this,	 iSocket);
       
   275 	iWriter = CQoSMsgWriter::NewL(this, iSocket);
       
   276 	iAsyncWriter = CAsyncWriter::NewL(iWriter);
       
   277 
       
   278 	/** Create the CQoSParameters to hold the Qos
       
   279 	* and Extension Parameters. The values will initially
       
   280 	be set to default
       
   281 	*/
       
   282 	iPrtParameters = new (ELeave) CQoSParameters;
       
   283 	// Set Default Uplink Parameters
       
   284 	iPrtParameters->SetUpLinkMaximumBurstSize(3000);  // for TokenBucketSizeUplink
       
   285 	iPrtParameters->SetUpLinkMaximumPacketSize(1500);	// for MaxPacketSizeUplink
       
   286 	iPrtParameters->SetUplinkBandwidth(1500);	// for TokenRateUplink
       
   287 	iPrtParameters->SetUpLinkAveragePacketSize(1500); // for MinimumPolicedUnitUplink
       
   288 	iPrtParameters->SetUpLinkPriority(KQoSLowestPriority); // for PriorityUplink
       
   289 	iPrtParameters->SetUpLinkDelay(0); // for DelayUplink
       
   290 	// Set Default Downlink parameters
       
   291 	iPrtParameters->SetDownLinkMaximumBurstSize(3000); // for TokenBucketSizeDownlink
       
   292 	iPrtParameters->SetDownLinkMaximumPacketSize(1500); // for MaxPacketSizeDownlink
       
   293 	iPrtParameters->SetDownlinkBandwidth(1500); // for TokenRateDownlink
       
   294 	iPrtParameters->SetDownLinkAveragePacketSize(1500); // for MinimumPolicedUnitDownlink
       
   295 	iPrtParameters->SetDownLinkPriority(KQoSLowestPriority); // for PriorityDownlonk
       
   296 	iPrtParameters->SetDownLinkDelay(0); // for DelayDownlink
       
   297 
       
   298 	iPrtParameters->SetAdaptMode(EFalse);
       
   299 //	iPrtParameters->SetHeaderMode(???);
       
   300 //	User::LeaveIfError(iPrtParameters->SetName(name));
       
   301 	}
       
   302 
       
   303 
       
   304 TAny* CIpSubConnectionProvider::FetchInterfaceInstanceL(CSubConnectionProviderBase& /*aProvider*/, const STypeId& aTid)
       
   305 	{
       
   306 	return (aTid == STypeId::CreateSTypeId(KConnectionClientExtUid,EConnectionEnumerateClients)) ? static_cast<MConnectionEnumerateClients*>(this) : NULL;
       
   307 	}
       
   308 
       
   309 void CIpSubConnectionProvider::DoDataClientJoiningL(MSubConnectionDataClient& aDataClient)
       
   310 /**
       
   311 Function called by Connection Provider when a socket is to be added to a QoS Flow
       
   312 
       
   313 @param aDataClient Data Client to add to the QoS Channel
       
   314 */
       
   315 	{
       
   316 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider [this=%08x]:\tDoDataClientJoiningL() [iDataClients.Count=%d] [aDataClient=%08x]"), this, iDataClients.Count(), &aDataClient));
       
   317 
       
   318 	// Can only join to a channel once it has been successfully routed
       
   319 	// Can only open/create/join the channel once the connection has been established
       
   320 	const TSockAddr* srcAddr = NULL;
       
   321 	const TSockAddr* dstAddr = NULL;
       
   322 	const TDesC8* connInfo;
       
   323 	if(aDataClient.ReadAddressInformation(srcAddr, dstAddr, connInfo) == KErrNone)
       
   324 		{
       
   325 		if( srcAddr == NULL || srcAddr->Family() == KAFUnspec )
       
   326 			{
       
   327 			__IPCPRLOG(IpCprLog::Printf(_L("Source Address not defined")));
       
   328 			User::Leave( KErrNotReady );
       
   329 			}
       
   330 
       
   331 		if( dstAddr == NULL || dstAddr->Family() == KAFUnspec )
       
   332 			{
       
   333 			__IPCPRLOG(IpCprLog::Printf(_L("Destination Address not defined")));
       
   334 			User::Leave( KErrNotReady );
       
   335 			}
       
   336 
       
   337 		if( connInfo == NULL )
       
   338 			{
       
   339 			__IPCPRLOG(IpCprLog::Printf(_L("Connection Information not defined")));
       
   340 			User::Leave( KErrNotReady );
       
   341 			}
       
   342 
       
   343 		TConnectionInfoBuf* connInfoBuf = (TConnectionInfoBuf*)connInfo->Ptr();
       
   344 		TUint32 iapId = (*connInfoBuf)().iIapId;
       
   345 
       
   346 		if( iChannelId >= 0 )
       
   347 			{
       
   348 			SendJoinL((TInetAddr)*srcAddr, (TInetAddr)*dstAddr, iapId, aDataClient.ProtocolId());
       
   349 			}
       
   350 		else
       
   351 			{
       
   352 			SendCreateL((TInetAddr)*srcAddr, (TInetAddr)*dstAddr, iapId, aDataClient.ProtocolId());
       
   353 			}
       
   354 		}
       
   355 	}
       
   356 
       
   357 
       
   358 void CIpSubConnectionProvider::DoDataClientLeaving(MSubConnectionDataClient& aDataClient)
       
   359 /**
       
   360 Function called by Connection Provider when a socket is to be removed from a QoS Flow
       
   361 
       
   362 @param aDataClient Data Client to remove from the QoS Channel
       
   363 */
       
   364 	{
       
   365 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider [this=%08x]:\tDoDataClientLeaving() [iDataClients.Count=%d] [aDataClient=%08x]"), this, iDataClients.Count(), &aDataClient));
       
   366 
       
   367 	// Can only leave on a routed conection that has been successfully
       
   368 	// attached to a QoS Channel.  Otherwise we cannot leave
       
   369 	const TSockAddr* srcAddr = NULL;
       
   370 	const TSockAddr* dstAddr = NULL;
       
   371 	const TDesC8* connInfo;
       
   372 	TInt err = aDataClient.ReadAddressInformation(srcAddr, dstAddr, connInfo);
       
   373 	if( err != KErrNone )
       
   374 		{
       
   375 		__IPCPRLOG(IpCprLog::Printf(_L("Unable to read Address Information")));
       
   376 		return;
       
   377 		}
       
   378 
       
   379 	if( srcAddr == NULL || srcAddr->Family() == KAFUnspec )
       
   380 		{
       
   381 		__IPCPRLOG(IpCprLog::Printf(_L("Source Address not defined")));
       
   382 		return;
       
   383 		}
       
   384 
       
   385 	if( dstAddr == NULL || dstAddr->Family() == KAFUnspec )
       
   386 		{
       
   387 		__IPCPRLOG(IpCprLog::Printf(_L("Destination Address not defined")));
       
   388 		return;
       
   389 		}
       
   390 
       
   391 	if( connInfo == NULL )
       
   392 		{
       
   393 		__IPCPRLOG(IpCprLog::Printf(_L("Connection Information not defined")));
       
   394 		return;
       
   395 		}
       
   396 
       
   397 	TConnectionInfoBuf* connInfoBuf = (TConnectionInfoBuf*)connInfo->Ptr();
       
   398 	TUint32 iapId = (*connInfoBuf)().iIapId;
       
   399 
       
   400 	if( iChannelId >= 0 )
       
   401 		{
       
   402 		TRAPD(ret, SendLeaveL((TInetAddr)*srcAddr, (TInetAddr)*dstAddr, iapId, aDataClient.ProtocolId()));
       
   403 		if (ret != KErrNone)
       
   404 			{
       
   405 			__IPCPRLOG(IpCprLog::Printf(_L("SendLeaveL left with err=%d"), ret));
       
   406 			}
       
   407 		}
       
   408 	else
       
   409 		{
       
   410 		__IPCPRLOG(IpCprLog::Printf(_L("Attempted to leave on an unconnected channel")));
       
   411 		}
       
   412 	}
       
   413 
       
   414 
       
   415 void CIpSubConnectionProvider::DoSourceAddressUpdate(MSubConnectionDataClient& /*aDataClient*/, const TSockAddr& /*aSource*/)
       
   416 /**
       
   417 Function called by Connection Provider when the source address on a data client is set
       
   418 
       
   419 @param aDataClient Data Client affected
       
   420 @param aSource Source Address
       
   421 */
       
   422 	{
       
   423 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::DoSourceAddressUpdate [%08x]"), this));
       
   424 	// Not Interested in either souce or destination updates; wait until connected
       
   425 	}
       
   426 
       
   427 
       
   428 void CIpSubConnectionProvider::DoDestinationAddressUpdate(MSubConnectionDataClient& /*aDataClient*/, const TSockAddr& /*aDestination*/)
       
   429 /**
       
   430 Function called by Connection Provider when the destination address on a data client is set
       
   431 
       
   432 @param aDataClient Data Client affected
       
   433 @param aDestination Destination Address
       
   434 */
       
   435 	{
       
   436 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::DoDestinationAddressUpdate [%08x]"), this));
       
   437 	// Not Interested in either souce or destination updates; wait until connected
       
   438 	}
       
   439 
       
   440 
       
   441 void CIpSubConnectionProvider::DoDataClientRouted(MSubConnectionDataClient& aDataClient, const TSockAddr& aSource, const TSockAddr& aDestination, const TDesC8& aConnectionInfo)
       
   442 /**
       
   443 Function called by Connection Provider when the connection has been established
       
   444 
       
   445 @param aDataClient Data Client affected
       
   446 @param aSource Source Address
       
   447 @param aDestination Destination Address
       
   448 @param aConnectionInfo Connection Data
       
   449 */
       
   450 	{
       
   451 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::DoDestinationAddressUpdate [%08x]"), this));
       
   452 
       
   453 	TConnectionInfoBuf* connInfo = (TConnectionInfoBuf*)aConnectionInfo.Ptr();
       
   454 	TUint32 iapId = (*connInfo)().iIapId;
       
   455 
       
   456   	if( aSource.Family() != KAFUnspec && aDestination.Family() != KAFUnspec)
       
   457 		{
       
   458 		// If already have a open channel add this socket.  o/w create a new channel
       
   459 		if( iChannelId >= 0 )
       
   460 			{
       
   461 			TRAPD(ret,SendJoinL((TInetAddr)aSource, (TInetAddr)aDestination, iapId, aDataClient.ProtocolId()));
       
   462 			if( ret != KErrNone )
       
   463 				{
       
   464 				__IPCPRLOG(IpCprLog::Printf(_L("SendJoinL left with error: %d"), ret));
       
   465 				}
       
   466 			}
       
   467 		else
       
   468 			{
       
   469 			TRAPD(ret,SendCreateL((TInetAddr)aSource, (TInetAddr)aDestination, iapId, aDataClient.ProtocolId()));
       
   470 			if( ret != KErrNone )
       
   471 				{
       
   472 				__IPCPRLOG(IpCprLog::Printf(_L("SendCreateL left with error: %d"), ret));
       
   473 				}
       
   474 			}
       
   475 		}
       
   476 	else
       
   477 		{
       
   478 		__IPCPRLOG(IpCprLog::Printf(_L("Data Client Routed contains invalid source or dest address")));
       
   479 		}
       
   480 	}
       
   481 
       
   482 
       
   483 void CIpSubConnectionProvider::DoParametersAboutToBeSetL(CSubConParameterBundle& aParameterBundle)
       
   484 /**
       
   485 Function called by the Connection Provider before the QoS Parameters are set by the client
       
   486 
       
   487 @param aParameterBundle Container holding pending QoS Parameters
       
   488 */
       
   489 	{
       
   490 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::DoParametersAboutToBeSetL [%08x]"), this));
       
   491 
       
   492 	iParameterRelease = KParameterRelInvalid;
       
   493 	ConvertParametersFromESockL( aParameterBundle );
       
   494 	iParametersSet = ETrue;
       
   495 
       
   496   	if(iChannelId >= 0)
       
   497 		{
       
   498 		SendSetQoSL();
       
   499 		}
       
   500 	}
       
   501 
       
   502 
       
   503 TInt CIpSubConnectionProvider::DoControl(TUint /*aOptionLevel*/, TUint /*aOptionName*/, TDes8& /*aOption*/)
       
   504 /**
       
   505 @param aOptionLevel
       
   506 @param aOptionName
       
   507 @param aOption
       
   508 */
       
   509 	{
       
   510 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::DoControl [%08x]"), this));
       
   511 
       
   512 	return KErrNotSupported;
       
   513 	}
       
   514 
       
   515 
       
   516 void CIpSubConnectionProvider::DoStartL()
       
   517 	{
       
   518 	}
       
   519 
       
   520 void CIpSubConnectionProvider::DoStop()
       
   521 	{
       
   522 	}
       
   523 
       
   524 CSubConnectionProviderBase* CIpSubConnectionProvider::DoNextLayer()
       
   525 	{
       
   526 	return NULL;
       
   527 	}
       
   528 
       
   529 CConnDataTransfer& CIpSubConnectionProvider::DoDataTransferL()
       
   530 	{
       
   531 	User::Leave(KErrNotSupported);
       
   532 	//unreachable code
       
   533 	return iNextLayer->DataTransferL();
       
   534 //	return *((CConnDataTransfer*)this);
       
   535 	}
       
   536 
       
   537 //MConnectionDataClient
       
   538 void CIpSubConnectionProvider::ConnectionGoingDown(CConnectionProviderBase& /*aConnProvider*/)
       
   539 	{
       
   540 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ConnectionGoingDown [%08x]"), this));
       
   541 	iConnectionProvider = NULL;
       
   542 	DeleteMeNow();
       
   543 	}
       
   544 
       
   545 void CIpSubConnectionProvider::Notify(TNotify /*aNotifyType*/,  CConnectionProviderBase* /*aConnProvider*/, TInt /*aError*/, const CConNotificationEvent* /*aConNotificationEvent*/)
       
   546 	{
       
   547 	}
       
   548 
       
   549 void CIpSubConnectionProvider::AttachToNext(CSubConnectionProviderBase* /*aSubConnProvider*/)
       
   550 	{
       
   551 	}
       
   552 
       
   553 
       
   554 
       
   555 void CIpSubConnectionProvider::SendOpenExistingL(const TInetAddr &aSrcAddr, const TInetAddr &aDstAddr, TUint32 aIapId, TUint32 aProtocolId)
       
   556 /**
       
   557 Sends a Message to QoS PRT to open a QoS Channel
       
   558 
       
   559 @param aSrcAddr Source Address
       
   560 @param aDstAddr Destination Address
       
   561 @param aIapId IAP Id
       
   562 @param aProtocolId Protocol Id
       
   563 */
       
   564     {
       
   565 	__IPCPRLOG(IpCprLog::Printf(_L("Sending PRT Msg: EPfqosOpenExistingChannel")));
       
   566 
       
   567     CQoSMsg* msg = CQoSMsg::NewL(EPfqosOpenExistingChannel);
       
   568     msg->AddConnInfo(aProtocolId, iUid, aIapId);
       
   569     msg->AddSrcAddr(aSrcAddr);
       
   570     msg->AddDstAddr(aDstAddr);
       
   571     msg->AddChannel(0);
       
   572 
       
   573     iWriter->Send(msg);
       
   574     }
       
   575 
       
   576 
       
   577 void CIpSubConnectionProvider::SendCreateL(const TInetAddr &aSrcAddr, const TInetAddr &aDstAddr, TUint32 aIapId, TUint32 aProtocolId)
       
   578 /**
       
   579 Sends a Message to QoS PRT to create a QoS Channel
       
   580 
       
   581 @param aSrcAddr Source Address
       
   582 @param aDstAddr Destination Address
       
   583 @param aIapId IAP Id
       
   584 @param aProtocolId Protocol Id
       
   585 */
       
   586     {
       
   587 	__IPCPRLOG(IpCprLog::Printf(_L("Sending PRT Msg: EPfqosCreateChannel")));
       
   588 
       
   589     CQoSMsg* msg = CQoSMsg::NewL(EPfqosCreateChannel);
       
   590     msg->AddConnInfo(aProtocolId, iUid, aIapId);
       
   591     msg->AddSrcAddr(aSrcAddr);
       
   592     msg->AddDstAddr(aDstAddr);
       
   593     msg->AddChannel(0);
       
   594 
       
   595     TQoSParameters qosParams;
       
   596     ConvertCQoSIntoTQoSParamsL(qosParams);
       
   597 	msg->AddQoSParameters(qosParams);
       
   598     msg->AddExtensionPolicy(iPrtExtensions);
       
   599 	//Now we need to write to the qos.prt asynchronously. This becuase the TCP/IP stack in CIp6Flow::Connect() calls Bearer() before RefreshFlow()
       
   600     iAsyncWriter->Send(msg);
       
   601     }
       
   602 
       
   603 
       
   604 void CIpSubConnectionProvider::SendCloseL()
       
   605 /**
       
   606 Sends a Message to QoS PRT to close a QoS Channel
       
   607 */
       
   608 	{
       
   609 	__IPCPRLOG(IpCprLog::Printf(_L("Sending PRT Msg: EPfqosDeleteChannel")));
       
   610 
       
   611     CQoSMsg* msg = CQoSMsg::NewL(EPfqosDeleteChannel);
       
   612     msg->AddChannel(iChannelId);
       
   613 
       
   614     iWriter->Send(msg);
       
   615 	}
       
   616 
       
   617 
       
   618 void CIpSubConnectionProvider::SendJoinL(const TInetAddr &aSrcAddr, const TInetAddr &aDstAddr, TUint32 aIapId, TUint32 aProtocolId)
       
   619 /**
       
   620 Sends a Message to QoS PRT to add a socket to a QoS Channel
       
   621 
       
   622 @param aSrcAddr Source Address
       
   623 @param aDstAddr Destination Address
       
   624 @param aIapId IAP Id
       
   625 @param aProtocolId Protocol Id
       
   626 */
       
   627     {
       
   628 	__IPCPRLOG(IpCprLog::Printf(_L("Sending PRT Msg: EPfqosJoin")));
       
   629 
       
   630     CQoSMsg* msg = CQoSMsg::NewL(EPfqosJoin);
       
   631     msg->AddConnInfo(aProtocolId, iUid, aIapId);
       
   632     msg->AddSrcAddr(aSrcAddr);
       
   633     msg->AddDstAddr(aDstAddr);
       
   634     msg->AddChannel(iChannelId);
       
   635 
       
   636     iWriter->Send(msg);
       
   637     }
       
   638 
       
   639 
       
   640 void CIpSubConnectionProvider::SendLeaveL(const TInetAddr &aSrcAddr, const TInetAddr &aDstAddr, TUint32 aIapId, TUint32 aProtocolId)
       
   641 /**
       
   642 Sends a Message to QoS PRT to remove a socket from a QoS Channel
       
   643 
       
   644 @param aSrcAddr Source Address
       
   645 @param aDstAddr Destination Address
       
   646 @param aIapId IAP Id
       
   647 @param aProtocolId Protocol Id
       
   648 */
       
   649     {
       
   650 	__IPCPRLOG(IpCprLog::Printf(_L("Sending PRT Msg: EPfqosLeave")));
       
   651 
       
   652     CQoSMsg* msg = CQoSMsg::NewL(EPfqosLeave);
       
   653     msg->AddConnInfo(aProtocolId, iUid, aIapId);
       
   654     msg->AddSrcAddr(aSrcAddr);
       
   655     msg->AddDstAddr(aDstAddr);
       
   656     msg->AddChannel(iChannelId);
       
   657 
       
   658     iWriter->Send(msg);
       
   659     }
       
   660 
       
   661 
       
   662 
       
   663 void CIpSubConnectionProvider::SendSetQoSL()
       
   664 /**
       
   665 Sends Message to QoS PRT to update the parameters for a QoS Channel
       
   666 */
       
   667     {
       
   668 	__IPCPRLOG(IpCprLog::Printf(_L("Sending PRT Msg: EPfqosConfigChannel")));
       
   669 
       
   670     CQoSMsg* msg = CQoSMsg::NewL(EPfqosConfigChannel);
       
   671     msg->AddChannel(iChannelId);
       
   672 
       
   673     TQoSParameters qosParams;
       
   674     ConvertCQoSIntoTQoSParamsL(qosParams);
       
   675     msg->AddQoSParameters(qosParams);
       
   676     msg->AddExtensionPolicy(iPrtExtensions);
       
   677 
       
   678     iWriter->Send(msg);
       
   679     }
       
   680 
       
   681 
       
   682 void CIpSubConnectionProvider::ProcessPRTMsg(TPfqosMessage& aMsg)
       
   683 /**
       
   684 Process Messages sent from the PRT to the SubConnection Provider
       
   685 Messages are either replies or events
       
   686 
       
   687 @param aMsg the message from the PRT
       
   688 */
       
   689 	{
       
   690 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ProcessPRTMsg [%08x]"), this));
       
   691 
       
   692     if( aMsg.iBase.iMsg == NULL )
       
   693     	{
       
   694 		__IPCPRLOG(IpCprLog::Printf(_L("Received malformed message from PRT")));
       
   695     	}
       
   696     else
       
   697     	{
       
   698 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Msg: %d"), aMsg.iBase.iMsg->pfqos_msg_type));
       
   699 	    switch(aMsg.iBase.iMsg->pfqos_msg_type)
       
   700 			{
       
   701 		case EPfqosEvent:
       
   702 			{
       
   703 			TRAPD(ret, ProcessPRTEventL(aMsg) );
       
   704 			if( ret != KErrNone )
       
   705 				{
       
   706 				__IPCPRLOG(IpCprLog::Printf(_L("ProcessPRTEventL left with error: %d"), ret));
       
   707 				}
       
   708 			}
       
   709 			break;
       
   710 
       
   711 		case EPfqosUpdate:
       
   712 		case EPfqosDelete:
       
   713 		case EPfqosAdd:
       
   714 		case EPfqosGet:
       
   715 		case EPfqosReject:
       
   716 		case EPfqosDump:
       
   717 		case EPfqosConfigure:
       
   718 		case EPfqosJoin:
       
   719 		case EPfqosLeave:
       
   720 		case EPfqosCreateChannel:
       
   721 		case EPfqosOpenExistingChannel:
       
   722 		case EPfqosDeleteChannel:
       
   723 		case EPfqosConfigChannel:
       
   724 		case EPfqosLoadFile:
       
   725 		case EPfqosUnloadFile:
       
   726 			{
       
   727 			TRAPD(ret, ProcessPRTReplyL(aMsg) );
       
   728 			if( ret != KErrNone )
       
   729 				{
       
   730 				__IPCPRLOG(IpCprLog::Printf(_L("ProcessPRTReplyL left with error: %d"), ret));
       
   731 				}
       
   732 			}
       
   733 		    break;
       
   734 
       
   735 		default:
       
   736 			__IPCPRLOG(IpCprLog::Printf(_L("Received Unknown PRT Msg: %d"), aMsg.iBase.iMsg->pfqos_msg_type));
       
   737 		    break;
       
   738 			}
       
   739     	}
       
   740 	}
       
   741 
       
   742 
       
   743 void CIpSubConnectionProvider::ProcessPRTEventL(TPfqosMessage& aMsg)
       
   744 /**
       
   745 Process Events sent from the PRT to the SubConnection Provider
       
   746 
       
   747 @param aMsg the message from the PRT
       
   748 */
       
   749 	{
       
   750 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ProcessPRTEventL [%08x]"), this));
       
   751 
       
   752 	// Only interested in Channel Events
       
   753     if (aMsg.iEvent.iExt == NULL || aMsg.iFlowSpec.iExt == NULL || aMsg.iChannel.iExt == NULL)
       
   754     	{
       
   755 		__IPCPRLOG(IpCprLog::Printf(_L("Received malformed event message from PRT")));
       
   756     	return;
       
   757     	}
       
   758 
       
   759 	MSubConnectionDataClient* client = NULL;
       
   760 	TInt ret = DetermineClient(aMsg, client);
       
   761 	if( ret != KErrNone || client == NULL )
       
   762 		{
       
   763 		__IPCPRLOG(IpCprLog::Printf(_L("Could not determine DataClient from message.  Error=%d"), ret));
       
   764 		}
       
   765 
       
   766 	switch (aMsg.iEvent.iExt->event_type)
       
   767 		{
       
   768 	case KPfqosEventFailure:
       
   769 		{
       
   770 /*		
       
   771 		EQoSOk,
       
   772     EQoSPolicyExists = -5119,       //< -5119 Policy exists in database
       
   773     EQoSNoModules,					//< -5118 No QoS modules available
       
   774     EQoSInterface,			        //< -5117 Flows are using different interfaces
       
   775 	EQoSModules,					//< -5116 Flows use different QoS modules
       
   776 	EQoSModuleLoadFailed,			//< -5115 Loading of QoS module failed
       
   777 	EQoSMessageCorrupt,				//< -5114 Pfqos message corrupted
       
   778 	EQoSJoinFailure,				//< -5113 Join to QoS channel failed
       
   779 	EQoSLeaveFailure,				//< -5112 Leave from QoS channel failed
       
   780 	EQoSNoInterface,				//< -5111 Network interface deleted
       
   781 	EQoSChannelDeleted,				//< -5110 QoS channel deleted
       
   782 	EQoSDowngradeForced				//< -5109 QoS parameters downgraded by administrative policy
       
   783 */
       
   784 		CSubConNotificationEvent* event = NULL;
       
   785 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Event: KPfqosEventFailure.  Error=%d"),aMsg.iBase.iMsg->pfqos_msg_errno));
       
   786 
       
   787 #if defined(QOS_ERROR_REPORTING) //Awaiting code delivery for qos and guqos to support this functionality 		
       
   788 		switch(aMsg.iBase.iMsg->pfqos_msg_errno)
       
   789 			{
       
   790 				case EQoSJoinFailure:
       
   791 				
       
   792 					if( client )
       
   793 						{
       
   794 						__IPCPRLOG(IpCprLog::Printf(_L("Join failed Event")));
       
   795 						client->JoinFailed(*this,aMsg.iBase.iMsg->pfqos_msg_errno);
       
   796 						}
       
   797 					break;
       
   798 				
       
   799 				case EQoSLeaveFailure:
       
   800 					if( client )
       
   801 						{
       
   802 						__IPCPRLOG(IpCprLog::Printf(_L("Leave failed Event")));
       
   803 						//We don't particularly care that it failed - just pretend that it was successful
       
   804 						client->LeaveComplete(*this);
       
   805 						}
       
   806 					break;
       
   807 				case EQoSNoInterface:
       
   808 				case EQoSChannelDeleted:
       
   809 					{
       
   810 					CSubConGenEventSubConDown* scde = CSubConGenEventSubConDown::NewL();
       
   811 					scde->SetError(aMsg.iBase.iMsg->pfqos_msg_errno);
       
   812 					event = scde;
       
   813 					iChannelId = -1;	
       
   814 					break;
       
   815 					}
       
   816 				case EQoSDowngradeForced:
       
   817 					{
       
   818 					event = CSubConGenEventParamsChanged::NewL();
       
   819 					break;
       
   820 					}
       
   821 					
       
   822 				case EQoSChannelFailed:
       
   823 					if( client )
       
   824 						{
       
   825 						__IPCPRLOG(IpCprLog::Printf(_L("Join failed Event")));
       
   826 						client->JoinFailed(*this,aMsg.iBase.iMsg->pfqos_msg_errno);
       
   827 						}
       
   828 					// no break here we want to continue into the next case statement;
       
   829 				case EQoSParamsRejected:
       
   830 					{
       
   831 					CSubConGenEventParamsRejected* scde = CSubConGenEventParamsRejected::NewL();
       
   832 					scde->SetError(aMsg.iBase.iMsg->pfqos_msg_errno);
       
   833 					scde->SetFamilyId(KSubConQoSFamily);
       
   834 					event = scde;
       
   835 					break;	
       
   836 					}
       
   837 
       
   838 				default:
       
   839 					__IPCPRLOG(IpCprLog::Printf(_L("Unknown event sent ")));			
       
   840 			};
       
   841 #else
       
   842 			if( client )
       
   843 				{
       
   844 				__IPCPRLOG(IpCprLog::Printf(_L("Join failed Event")));
       
   845 				client->JoinFailed(*this,aMsg.iBase.iMsg->pfqos_msg_errno);
       
   846 				CSubConGenEventParamsRejected* scde = CSubConGenEventParamsRejected::NewL();
       
   847 				/**
       
   848 				There can be two set of parameters that are sent to QOS either as KSubConQoSFamily
       
   849 				or as KSubConAuthorisationFamily. Here we should differentiate, the QOS is rejected 
       
   850 				because of which parameter family. 
       
   851 				At present there is no indication comes from the lower layer why the QOS has failed, and in 
       
   852 				all the case the member *aMsg.iBase.iMsg->pfqos_msg_type* will return *EPfQoSReject*.
       
   853 				
       
   854 				At the time of writing this code any differentiation method was not available to differentiate
       
   855 				between events. i.e whether the event is SBLP or UMTS events. So this has not been done.
       
   856 				This needs to be done when the TPfqosMessage will have the differentiation
       
   857 				*/
       
   858 				scde->SetError(aMsg.iBase.iMsg->pfqos_msg_errno);
       
   859 				scde->SetFamilyId(KSubConQoSFamily);
       
   860 				event = scde;
       
   861 				}			
       
   862 #endif
       
   863 		
       
   864 		// Setting QoS Parameters Failed
       
   865 		/**
       
   866 		There can be two set of parameters that are sent to QOS either as KSubConQoSFamily
       
   867 		or as KSubConAuthorisationFamily. Here we should differentiate, the QOS is rejected
       
   868 		because of which parameter family.
       
   869 		At present there is no indication comes from the lower layer why the QOS has failed, and in
       
   870 		all the case the member *aMsg.iBase.iMsg->pfqos_msg_type* will return *EPfQoSReject*.
       
   871 
       
   872 		At the time of writing this code any differentiation method was not available to differentiate
       
   873 		between events. i.e whether the event is SBLP or UMTS events. So this has not been done.
       
   874 		This needs to be done when the TPfqosMessage will have the differentiation
       
   875 		*/
       
   876 		if (event)
       
   877 			{
       
   878 				
       
   879 			NotifyClientEvent(*event);
       
   880 			delete event;
       
   881 			}
       
   882 		}
       
   883 	    break;
       
   884 
       
   885 	case KPfqosEventConfirm:
       
   886 		{
       
   887 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Event: KPfqosEventConfirm")));
       
   888 
       
   889 		// Setting QoS Parameters OK
       
   890 		CSubConGenEventParamsGranted* event = CSubConGenEventParamsGranted::NewL();
       
   891 		ConvertParametersFromQOSL(aMsg, event);
       
   892 
       
   893 		NotifyClientEvent(*event);
       
   894 		delete event;
       
   895 
       
   896 		if( client != NULL )
       
   897 			{
       
   898 			client->JoinComplete(*this);
       
   899 			}
       
   900 		}
       
   901 	    break;
       
   902 
       
   903 	case KPfqosEventAdapt:
       
   904 		{
       
   905 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Event: KPfqosEventAdapt")));
       
   906 
       
   907 		// Available QoS Changed
       
   908 		CSubConGenEventParamsChanged* event = CSubConGenEventParamsChanged::NewL();
       
   909 		event->SetError(aMsg.iBase.iMsg->pfqos_msg_errno);
       
   910 		ConvertParametersFromQOSL(aMsg, event);
       
   911 
       
   912 		NotifyClientEvent(*event);
       
   913 		delete event;
       
   914 		}
       
   915 	    break;
       
   916 
       
   917 	case KPfqosEventJoin:
       
   918 		{
       
   919 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Event: KPfqosEventJoin")));
       
   920 		if (aMsg.iBase.iMsg->pfqos_msg_errno)
       
   921 		   {
       
   922 		   ProcessPRTError( aMsg, aMsg.iBase.iMsg->pfqos_msg_errno );
       
   923 		   return;
       
   924 		   }
       
   925 
       
   926 
       
   927 		CSubConGenEventDataClientJoined* event = CSubConGenEventDataClientJoined::NewL();
       
   928 
       
   929 		if( client )
       
   930 			{
       
   931 			const TSockAddr* SrcAddr = NULL;
       
   932 			const TSockAddr* DstAddr = NULL;
       
   933 			const TDesC8* connInfo;
       
   934 			client->ReadAddressInformation(SrcAddr, DstAddr, connInfo);  // return can be would have errored above
       
   935 
       
   936 			TConnectionInfoBuf* connInfoBuf = (TConnectionInfoBuf*)connInfo->Ptr();
       
   937 			TUint32 iapId = (*connInfoBuf)().iIapId;
       
   938 
       
   939 			event->SetSourceAddress( *SrcAddr );
       
   940 			event->SetDestAddress( *DstAddr );
       
   941 			event->SetIap( iapId );
       
   942 
       
   943 			client->JoinComplete(*this);
       
   944 			}
       
   945 
       
   946 		NotifyClientEvent(*event);
       
   947 		delete event;
       
   948 		}
       
   949 	    break;
       
   950 
       
   951 	case KPfqosEventLeave:
       
   952 		{
       
   953 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Event: KPfqosEventLeave")));
       
   954 	
       
   955 		CSubConGenEventDataClientLeft* event = CSubConGenEventDataClientLeft::NewL();
       
   956 
       
   957 		if( client )
       
   958 			{
       
   959 			const TSockAddr* SrcAddr = NULL;
       
   960 			const TSockAddr* DstAddr = NULL;
       
   961 			const TDesC8* connInfo;
       
   962 			client->ReadAddressInformation(SrcAddr, DstAddr, connInfo);  // return can be would have errored above
       
   963 
       
   964 			TConnectionInfoBuf* connInfoBuf = (TConnectionInfoBuf*)connInfo->Ptr();
       
   965 			TUint32 iapId = (*connInfoBuf)().iIapId;
       
   966 
       
   967 			event->SetSourceAddress( *SrcAddr );
       
   968 			event->SetDestAddress( *DstAddr );
       
   969 			event->SetIap( iapId );
       
   970 			}
       
   971 
       
   972 		NotifyClientEvent(*event);
       
   973 		delete event;
       
   974 		
       
   975 		if( client != NULL )
       
   976 			{
       
   977 			client->LeaveComplete(*this);
       
   978 			}
       
   979 		}
       
   980 	    break;
       
   981 
       
   982 	default:
       
   983 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Event: Unknown - %d"), aMsg.iEvent.iExt->event_type));
       
   984 	    break;
       
   985 		}
       
   986 	}
       
   987 
       
   988 void CIpSubConnectionProvider::ProcessPRTReplyL(TPfqosMessage& aMsg)
       
   989 /**
       
   990 Process Replies sent from the PRT to the SubConnection Provider
       
   991 
       
   992 @param aMsg the message from the PRT
       
   993 */
       
   994 	{
       
   995 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ProcessPRTReplyL [%08x]"), this));
       
   996 
       
   997 	if( aMsg.iChannel.iExt == NULL )
       
   998 		{
       
   999 		__IPCPRLOG(IpCprLog::Printf(_L("Received malformed reply message from PRT")));
       
  1000 		}
       
  1001 	else if( aMsg.iBase.iMsg->pfqos_msg_errno != KErrNone )
       
  1002     	{
       
  1003     	ProcessPRTError( aMsg, aMsg.iBase.iMsg->pfqos_msg_errno );
       
  1004     	}
       
  1005 	else
       
  1006     	{
       
  1007 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Reply: %d"), aMsg.iBase.iMsg->pfqos_msg_type));
       
  1008 
       
  1009 		MSubConnectionDataClient* client = NULL;
       
  1010 		TInt ret = DetermineClient(aMsg, client);
       
  1011 		if( ret != KErrNone || client == NULL )
       
  1012 			{
       
  1013 			__IPCPRLOG(IpCprLog::Printf(_L("Could not determine DataClient from message.  Error=%d"),ret));
       
  1014 			}
       
  1015 
       
  1016 		switch (aMsg.iBase.iMsg->pfqos_msg_type)
       
  1017 			{
       
  1018 		case EPfqosOpenExistingChannel:
       
  1019 			iChannelId = aMsg.iChannel.iExt->channel_id;
       
  1020 			__IPCPRLOG(IpCprLog::Printf(_L("Processing Reply for message: EPfqosOpenExistingChannel")));
       
  1021 			break;
       
  1022 
       
  1023 		case EPfqosCreateChannel:
       
  1024 			iChannelId = aMsg.iChannel.iExt->channel_id;
       
  1025 			__IPCPRLOG(IpCprLog::Printf(_L("Processing Reply for message: EPfqosCreateChannel")));
       
  1026 			//Now you will expect to complete the join here. This will not work becuase
       
  1027 			//qos.prt send a reply before finishing the join down to the nif level
       
  1028 			//we will have to delay the response until the event is received
       
  1029 			break;
       
  1030 
       
  1031 		case EPfqosJoin:
       
  1032 			__IPCPRLOG(IpCprLog::Printf(_L("Processing Reply for message: EPfqosJoin")));
       
  1033 			//Now you will expect to complete the join here. This will not work becuase
       
  1034 			//qos.prt send a reply before finishing the join down to the nif level
       
  1035 			//we will have to delay the response until the event is received
       
  1036 			break;
       
  1037 
       
  1038 		case EPfqosLeave:
       
  1039 			__IPCPRLOG(IpCprLog::Printf(_L("Processing Reply for message: EPfqosLeave")));
       
  1040 			break;
       
  1041 
       
  1042 		case EPfqosConfigChannel:
       
  1043 			{
       
  1044 			__IPCPRLOG(IpCprLog::Printf(_L("Processing Reply for message: EPfqosConfigChannel")));
       
  1045 			}
       
  1046 			break;
       
  1047 
       
  1048 		case EPfqosDeleteChannel:
       
  1049 			iChannelId = -1;
       
  1050 			__IPCPRLOG(IpCprLog::Printf(_L("Processing Reply for message: EPfqosDeleteChannel")));
       
  1051 			break;
       
  1052 
       
  1053 		default:
       
  1054 			__IPCPRLOG(IpCprLog::Printf(_L("Ignoring Reply for unknown message: %d"), aMsg.iBase.iMsg->pfqos_msg_type));
       
  1055 			break;
       
  1056 			}
       
  1057     	}
       
  1058 
       
  1059 	__IPCPRLOG(IpCprLog::Printf(_L("Provider=0x%x Channel=%d"), this, iChannelId));
       
  1060 	}
       
  1061 
       
  1062 
       
  1063 #ifdef _DEBUG
       
  1064 void CIpSubConnectionProvider::ProcessPRTError(TInt aMsgType, TInt __IPCPRLOG(aError))
       
  1065 /**
       
  1066 Process Errors that occur in communicating between the PRT and the
       
  1067 SubConnection Provider
       
  1068 
       
  1069 @param aMsgType the type of message that encountered the error
       
  1070 @param aError the error ththas occurred
       
  1071 */
       
  1072 	{
       
  1073 	switch (aMsgType)
       
  1074 		{
       
  1075 	case EPfqosOpenExistingChannel:
       
  1076 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosOpenExistingChannel"), aError));
       
  1077 		break;
       
  1078 
       
  1079 	case EPfqosCreateChannel:
       
  1080 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosCreateChannel"), aError));
       
  1081 		break;
       
  1082 
       
  1083 	case EPfqosDeleteChannel:
       
  1084 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosDeleteChannel"), aError));
       
  1085 		break;
       
  1086 
       
  1087 	case EPfqosJoin:
       
  1088 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosJoin"), aError));
       
  1089 		break;
       
  1090 
       
  1091 	case EPfqosLeave:
       
  1092 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosLeave"), aError));
       
  1093 		break;
       
  1094 
       
  1095 	case EPfqosConfigChannel:
       
  1096 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosConfigChannel"), aError));
       
  1097 		break;
       
  1098 
       
  1099    case  EPfqosEvent:
       
  1100 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on EPfqosEvent"), aError));
       
  1101 		break;
       
  1102 
       
  1103 	default:
       
  1104 		__IPCPRLOG(IpCprLog::Printf(_L("Received PRT Error %d on Unknown Message"), aError));
       
  1105 		break;
       
  1106 		}
       
  1107 	}
       
  1108 #endif
       
  1109 
       
  1110 
       
  1111 void CIpSubConnectionProvider::ProcessPRTError(TPfqosMessage& aMsg, TInt aError)
       
  1112 /**
       
  1113 Process Errors that occur in communicating between the PRT and the
       
  1114 SubConnection Provider
       
  1115 
       
  1116 @param aMsg the message from the PRT
       
  1117 @param aError the error ththas occurred
       
  1118 */
       
  1119 	{
       
  1120 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ProcessPRTError [%08x]"), this));
       
  1121 
       
  1122 	if( aError != KErrNone)
       
  1123 		{
       
  1124 		TInt msgType = aMsg.iBase.iMsg->pfqos_msg_type;
       
  1125 
       
  1126 #ifdef _DEBUG
       
  1127 		ProcessPRTError(msgType, aError);
       
  1128 #endif
       
  1129 
       
  1130 		MSubConnectionDataClient* client = NULL;
       
  1131 		TInt ret = DetermineClient(aMsg, client);
       
  1132 		if( ret != KErrNone || client == NULL )
       
  1133 			{
       
  1134 			__IPCPRLOG(IpCprLog::Printf(_L("Could not determine DataClient from message.  Error=%d"),ret));
       
  1135 			}
       
  1136 
       
  1137 		if( msgType == EPfqosJoin ||
       
  1138 		    msgType == EPfqosOpenExistingChannel ||
       
  1139 		    msgType == EPfqosCreateChannel ||
       
  1140 		    (msgType == EPfqosEvent && aMsg.iBase.iMsg->pfqos_msg_errno == EQoSJoinFailure))
       
  1141 			{
       
  1142 			if( client )
       
  1143 				{
       
  1144 				client->JoinFailed(*this,aError);
       
  1145 				}
       
  1146 			}
       
  1147 		else if( msgType == EPfqosConfigChannel )
       
  1148 			{
       
  1149 			//This will send an error only if ECom successfuly constructs the event object
       
  1150 			CSubConGenEventParamsRejected* event = NULL;
       
  1151 			TRAP_IGNORE(event = CSubConGenEventParamsRejected::NewL());
       
  1152 			if (event)
       
  1153 				{
       
  1154 				/**
       
  1155 				comments give in case of *KPfqosEventFailure* in function *ProcessPRTEventL*
       
  1156 				will also applicable here
       
  1157 				*/
       
  1158 				if (aMsg.iBase.iMsg->pfqos_msg_errno == RPacketContext::EEtelPcktPolicyControlRejectionCode)
       
  1159 					{
       
  1160 					event->SetFamilyId(KSubConAuthorisationFamily);
       
  1161 					}
       
  1162 				else
       
  1163 					{
       
  1164 					event->SetFamilyId(KSubConQoSFamily);
       
  1165 					}
       
  1166 
       
  1167 				event->SetError(aError);
       
  1168 
       
  1169 				NotifyClientEvent(*event);
       
  1170 				delete event;
       
  1171 				}
       
  1172 			}
       
  1173 		else if( msgType == EPfqosLeave ||
       
  1174 		   (msgType == EPfqosEvent && aMsg.iBase.iMsg->pfqos_msg_errno == EQoSLeaveFailure))
       
  1175 			{
       
  1176 			// Not Interested in whether the leave was successful.  Inform client regardless
       
  1177 			if( client != NULL )
       
  1178 				{
       
  1179 				client->LeaveComplete(*this);
       
  1180 				}
       
  1181 			}
       
  1182 		else
       
  1183 			{
       
  1184 			if( client )
       
  1185 				{
       
  1186 				client->SubConnectionError(*this, MSubConnectionDataClient::ESubConnection, aError);
       
  1187 				}
       
  1188 			}
       
  1189 		}
       
  1190 	}
       
  1191 
       
  1192 
       
  1193 TInt CIpSubConnectionProvider::DetermineClient(const TPfqosMessage& aMsg, MSubConnectionDataClient*& aDataClient)
       
  1194 /**
       
  1195 Determines which Data Client a message from the QoS PRT is for based upon source and destination
       
  1196 address; and Protocol Id.
       
  1197 
       
  1198 @param aMsg QoS PRT Response Message
       
  1199 @param aDataClient Output Variable as Data Client that matches reponse.
       
  1200 
       
  1201 @return KErrNone on finding the required client.  Client passed back as argument.
       
  1202 */
       
  1203 	{
       
  1204 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::DetermineClient [%08x]"), this));
       
  1205 
       
  1206 	aDataClient = NULL;
       
  1207 
       
  1208 	const TInetAddr* msgSrcAddr = aMsg.iSrcAddr.iAddr;
       
  1209 	const TInetAddr* msgDstAddr = aMsg.iDstAddr.iAddr;
       
  1210 
       
  1211 	if( msgSrcAddr == NULL || msgDstAddr == NULL || aMsg.iSelector.iExt == NULL )
       
  1212 		{
       
  1213 		__IPCPRLOG(IpCprLog::Printf(_L("Received malformed message from PRT")););
       
  1214     	}
       
  1215     else
       
  1216 		{
       
  1217 		TUint32 msgProtocol = aMsg.iSelector.iExt->protocol;
       
  1218 
       
  1219 		__IPCPRLOG(
       
  1220 			THostName srcName;
       
  1221 			msgSrcAddr->OutputWithScope(srcName);
       
  1222 			THostName dstName;
       
  1223 			msgDstAddr->OutputWithScope(dstName);
       
  1224 		    IpCprLog::Printf(_L("Msg SAddr[%S][%d] DAddr[%S][%d] Prot[%d]"), &srcName, msgSrcAddr->Port(), &dstName, msgDstAddr->Port(), msgProtocol);
       
  1225 	    );
       
  1226 
       
  1227 		// Compare message parameters with those from each client finding the one required
       
  1228 		TInt numClients = iDataClients.Count();
       
  1229 		for( TInt index=0; index<numClients; index++ )
       
  1230 			{
       
  1231 			MSubConnectionDataClient* client = iDataClients[index];
       
  1232 			if( client != NULL )
       
  1233 				{
       
  1234 				const TSockAddr* cliSrcAddr = NULL;
       
  1235 				const TSockAddr* cliDstAddr = NULL;
       
  1236 				const TDesC8* connInfo;
       
  1237 				TInt err = client->ReadAddressInformation(cliSrcAddr, cliDstAddr, connInfo);
       
  1238 				if( err != KErrNone )
       
  1239 					{
       
  1240 					__IPCPRLOG(IpCprLog::Printf(_L("Unable to read Address Information")));
       
  1241 					continue;
       
  1242 					}
       
  1243 
       
  1244 				if( cliSrcAddr != NULL && cliDstAddr != NULL && connInfo != NULL )
       
  1245 					{
       
  1246 					TUint32 cliProtocol = client->ProtocolId();
       
  1247 
       
  1248 					TInetAddr srcInetAddr(*cliSrcAddr);
       
  1249 					TInetAddr dstInetAddr(*cliDstAddr);
       
  1250 
       
  1251 					if (dstInetAddr.Family() == KAfInet)
       
  1252 						{
       
  1253 						dstInetAddr.ConvertToV4Mapped();
       
  1254 						}
       
  1255 
       
  1256 					__IPCPRLOG(
       
  1257 						srcInetAddr.OutputWithScope(srcName);
       
  1258 						dstInetAddr.OutputWithScope(dstName);
       
  1259 			    		IpCprLog::Printf(_L("Cli SAddr[%S][%d] DAddr[%S][%d] Prot[%d]"), &srcName, srcInetAddr.Port(), &dstName, dstInetAddr.Port(), cliProtocol);
       
  1260 			    	);
       
  1261 
       
  1262 					if( (msgSrcAddr->Port() == srcInetAddr.Port() &&
       
  1263 					    (msgDstAddr->CmpAddr(dstInetAddr) && msgDstAddr->Port() == dstInetAddr.Port())) &&
       
  1264 						msgProtocol == cliProtocol )
       
  1265 						{
       
  1266 						// Have our required client
       
  1267 						__IPCPRLOG(IpCprLog::Printf(_L("Client Matched [%08x]"), client));
       
  1268 						aDataClient = client;
       
  1269 						break;
       
  1270 						}
       
  1271 					}
       
  1272 				}
       
  1273 			}
       
  1274     	}
       
  1275 
       
  1276 	if( aDataClient != NULL )
       
  1277 		{
       
  1278 		__IPCPRLOG(IpCprLog::Printf(_L("Client Found")));
       
  1279 		}
       
  1280 	else
       
  1281 		{
       
  1282 		__IPCPRLOG(IpCprLog::Printf(_L("Client Not Found!")));
       
  1283 		}
       
  1284 
       
  1285 	return aDataClient != NULL ? KErrNone : KErrNotFound;
       
  1286 	}
       
  1287 
       
  1288 
       
  1289 void CIpSubConnectionProvider::MapGenericParamsFromESockToPRTL(const CSubConQosGenericParamSet& generic) const
       
  1290 /**
       
  1291 Mapping function to map the generic parameters from the ESock to QoS PRT equivalent
       
  1292 @param Generic Input structure contains the generic parameters
       
  1293 */
       
  1294 	{
       
  1295 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::MapGenericParamsFromESockToPRTL")));
       
  1296 	/**
       
  1297 	Get and Set Uplink Parameters
       
  1298 	*/
       
  1299 	iPrtParameters->SetUpLinkMaximumBurstSize(generic.GetUpLinkMaximumBurstSize());
       
  1300 	iPrtParameters->SetUpLinkMaximumPacketSize(generic.GetUpLinkMaximumPacketSize());
       
  1301 	iPrtParameters->SetUplinkBandwidth(generic.GetUplinkBandwidth());
       
  1302 	iPrtParameters->SetUpLinkAveragePacketSize(generic.GetUpLinkAveragePacketSize());
       
  1303 	iPrtParameters->SetUpLinkPriority(generic.GetUpLinkPriority());
       
  1304 	iPrtParameters->SetUpLinkDelay(generic.GetUpLinkDelay());
       
  1305 	/**
       
  1306 	Get and Set Downlink Parameters
       
  1307 	*/
       
  1308 	iPrtParameters->SetDownLinkMaximumBurstSize(generic.GetDownLinkMaximumBurstSize());
       
  1309 	iPrtParameters->SetDownLinkMaximumPacketSize(generic.GetDownLinkMaximumPacketSize());
       
  1310 	iPrtParameters->SetDownlinkBandwidth(generic.GetDownlinkBandwidth());
       
  1311 	iPrtParameters->SetDownLinkAveragePacketSize(generic.GetDownLinkAveragePacketSize());
       
  1312 	iPrtParameters->SetDownLinkPriority(generic.GetDownLinkPriority());
       
  1313 	iPrtParameters->SetDownLinkDelay(generic.GetDownLinkDelay());
       
  1314 	/**
       
  1315 	Get and Set rest of the Parameters
       
  1316 	*/
       
  1317 	iPrtParameters->SetHeaderMode(generic.GetHeaderMode());
       
  1318 	TName name = generic.GetName();
       
  1319 	iPrtParameters->SetName(name);
       
  1320 	}
       
  1321 
       
  1322 void CIpSubConnectionProvider::MapGenericParamsFromPRTToESockL(CSubConQosGenericParamSet& generic) const
       
  1323 /**
       
  1324 Map generic parameters from QoS PRT to the ESock Equivalents
       
  1325 
       
  1326 @param params input structure that contains the QoS PRT generic parameters
       
  1327 */
       
  1328 	{
       
  1329 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::MapGenericParamsFromPRTToESockL")));
       
  1330 	/**
       
  1331 	Get and Set Uplink Parameters
       
  1332 	*/
       
  1333 	generic.SetUpLinkMaximumBurstSize(iPrtParameters->GetUpLinkMaximumBurstSize());
       
  1334 	generic.SetUpLinkMaximumPacketSize(iPrtParameters->GetUpLinkMaximumPacketSize());
       
  1335 	generic.SetUplinkBandwidth(iPrtParameters->GetUplinkBandwidth());
       
  1336 	generic.SetUpLinkAveragePacketSize(iPrtParameters->GetUpLinkAveragePacketSize());
       
  1337 	generic.SetUpLinkPriority(iPrtParameters->GetUpLinkPriority());
       
  1338 	generic.SetUpLinkDelay(iPrtParameters->GetUpLinkDelay());
       
  1339 	/**
       
  1340 	Get and Set Downlink Parameters
       
  1341 	*/
       
  1342 	generic.SetDownLinkMaximumBurstSize(iPrtParameters->GetDownLinkMaximumBurstSize());
       
  1343 	generic.SetDownLinkMaximumPacketSize(iPrtParameters->GetDownLinkMaximumPacketSize());
       
  1344 	generic.SetDownlinkBandwidth(iPrtParameters->GetDownlinkBandwidth());
       
  1345 	generic.SetDownLinkAveragePacketSize(iPrtParameters->GetDownLinkAveragePacketSize());
       
  1346 	generic.SetDownLinkPriority(iPrtParameters->GetDownLinkPriority());
       
  1347 	generic.SetDownLinkDelay(iPrtParameters->GetDownLinkDelay());
       
  1348 	/**
       
  1349 	Get and Set rest of the Parameters
       
  1350 	*/
       
  1351 	generic.SetHeaderMode(iPrtParameters->GetHeaderMode());
       
  1352 	TName name = iPrtParameters->GetName();
       
  1353 	generic.SetName(name);
       
  1354 	}
       
  1355 
       
  1356 void CIpSubConnectionProvider::ConvertTQoSIntoCQoSParamsL(const TQoSParameters& aParameters)
       
  1357 /**
       
  1358 This function will copy the aParameters into the class CQoSParameters
       
  1359 using member access functions
       
  1360 @param aParameters input parameters that needs to be copied
       
  1361 */
       
  1362 	{
       
  1363 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ConvertTQoSIntoCQoSParamsL")));
       
  1364 	/**
       
  1365 	Get and Set Uplink Parameters
       
  1366 	*/
       
  1367 	iPrtParameters->SetUplinkBandwidth(aParameters.GetUplinkBandwidth());
       
  1368 	iPrtParameters->SetUpLinkMaximumBurstSize(aParameters.GetUpLinkMaximumBurstSize());
       
  1369 	iPrtParameters->SetUpLinkMaximumPacketSize(aParameters.GetUpLinkMaximumPacketSize());
       
  1370 	iPrtParameters->SetUpLinkAveragePacketSize(aParameters.GetUpLinkAveragePacketSize());
       
  1371 	iPrtParameters->SetUpLinkDelay(aParameters.GetUpLinkDelay());
       
  1372 	iPrtParameters->SetUpLinkPriority(aParameters.GetUpLinkPriority());
       
  1373 	/**
       
  1374 	Get and Set Downlink Parameters
       
  1375 	*/
       
  1376 	iPrtParameters->SetDownlinkBandwidth(aParameters.GetDownlinkBandwidth());
       
  1377 	iPrtParameters->SetDownLinkMaximumBurstSize(aParameters.GetDownLinkMaximumBurstSize());
       
  1378 	iPrtParameters->SetDownLinkMaximumPacketSize(aParameters.GetDownLinkMaximumPacketSize());
       
  1379 	iPrtParameters->SetDownLinkAveragePacketSize(aParameters.GetDownLinkAveragePacketSize());
       
  1380 	iPrtParameters->SetDownLinkDelay(aParameters.GetDownLinkDelay());
       
  1381 	iPrtParameters->SetDownLinkPriority(aParameters.GetDownLinkPriority());
       
  1382 
       
  1383 	iPrtParameters->SetAdaptMode(aParameters.AdaptMode());
       
  1384 	iPrtParameters->SetHeaderMode(aParameters.GetHeaderMode());
       
  1385 	const TName name = aParameters.GetName();
       
  1386 	iPrtParameters->SetName(name);
       
  1387 	}
       
  1388 
       
  1389 void CIpSubConnectionProvider::ConvertCQoSIntoTQoSParamsL(TQoSParameters& aParameters) const
       
  1390 /**
       
  1391 This function will copy the iParameters (CQoSParameters) into aParameters
       
  1392 using member access functions
       
  1393 @param aParameters output parameters that iParameters will be copied into
       
  1394 */
       
  1395 	{
       
  1396 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ConvertCQoSIntoTQoSParamsL")));
       
  1397 	/**
       
  1398 	Get and Set Uplink Parameters
       
  1399 	*/
       
  1400 	aParameters.SetUplinkBandwidth(iPrtParameters->GetUplinkBandwidth());
       
  1401 	aParameters.SetUpLinkMaximumBurstSize(iPrtParameters->GetUpLinkMaximumBurstSize());
       
  1402 	aParameters.SetUpLinkMaximumPacketSize(iPrtParameters->GetUpLinkMaximumPacketSize());
       
  1403 	aParameters.SetUpLinkAveragePacketSize(iPrtParameters->GetUpLinkAveragePacketSize());
       
  1404 	aParameters.SetUpLinkDelay(iPrtParameters->GetUpLinkDelay());
       
  1405 	aParameters.SetUpLinkPriority(iPrtParameters->GetUpLinkPriority());
       
  1406 
       
  1407 	/**
       
  1408 	Get and Set Downlink Parameters
       
  1409 	*/
       
  1410 	aParameters.SetDownlinkBandwidth(iPrtParameters->GetDownlinkBandwidth());
       
  1411 	aParameters.SetDownLinkMaximumBurstSize(iPrtParameters->GetDownLinkMaximumBurstSize());
       
  1412 	aParameters.SetDownLinkMaximumPacketSize(iPrtParameters->GetDownLinkMaximumPacketSize());
       
  1413 	aParameters.SetDownLinkAveragePacketSize(iPrtParameters->GetDownLinkAveragePacketSize());
       
  1414 	aParameters.SetDownLinkDelay(iPrtParameters->GetDownLinkDelay());
       
  1415 	aParameters.SetDownLinkPriority(iPrtParameters->GetDownLinkPriority());
       
  1416 
       
  1417 	aParameters.SetAdaptMode(iPrtParameters->AdaptMode());
       
  1418 	aParameters.SetHeaderMode(iPrtParameters->GetHeaderMode());
       
  1419 	const TName name = iPrtParameters->GetName();
       
  1420 	aParameters.SetName(name);
       
  1421 	}
       
  1422 
       
  1423 
       
  1424 void CIpSubConnectionProvider::MapExtensionParamsFromESockToPRTL(const CSubConQosIPLinkR99ParamSet& extension, TUmtsQoSParameters& params)
       
  1425 /**
       
  1426 Map extension parameters from QoS PRT to the ESock Equivalents
       
  1427 
       
  1428 @param extension input structure that contains the ESock extension parameters
       
  1429 @param params structure updated to contains the equivalent QoS PRT extension parameters
       
  1430 */
       
  1431 	{
       
  1432 	__IPCPRLOG(IpCprLog::Printf(_L("MapExtensionParamsFromESockToPRTL")));
       
  1433 
       
  1434 	RPacketQoS::TTrafficClass trafficClass = extension.GetTrafficClass();
       
  1435 	User::LeaveIfError(params.SetTrafficClass((TUmtsTrafficClass)trafficClass));
       
  1436 
       
  1437 	RPacketQoS::TDeliveryOrder deliveryOrder = extension.GetDeliveryOrder();
       
  1438 	User::LeaveIfError(params.SetDeliveryOrder((TUmtsDeliveryOrder)deliveryOrder));
       
  1439 
       
  1440 	RPacketQoS::TErroneousSDUDelivery sduDelivery = extension.GetErroneousSDUDelivery();
       
  1441 	User::LeaveIfError(params.SetDeliveryOfErroneusSdu((TUmtsErroneousSDUDelivery)sduDelivery));
       
  1442 
       
  1443 	RPacketQoS::TBitErrorRatio bitErrorRate = extension.GetResidualBitErrorRatio();
       
  1444 	User::LeaveIfError(params.SetResidualBer((TUmtsBitErrorRatio)bitErrorRate));
       
  1445 
       
  1446 	RPacketQoS::TSDUErrorRatio sduErrorRatio = extension.GetSDUErrorRatio();
       
  1447 	User::LeaveIfError(params.SetErrorRatio((TUmtsSDUErrorRatio)sduErrorRatio));
       
  1448 
       
  1449 	RPacketQoS::TTrafficHandlingPriority trafficHandlingPriority = extension.GetTrafficHandlingPriority();
       
  1450 	User::LeaveIfError(params.SetPriority((TUmtsTrafficHandlingPriority)trafficHandlingPriority));
       
  1451 
       
  1452 	TInt transferDelay = extension.GetTransferDelay();
       
  1453 	User::LeaveIfError(params.SetTransferDelay(transferDelay));
       
  1454 
       
  1455 	TInt maxSduSize = extension.GetMaxSduSize();
       
  1456 	User::LeaveIfError(params.SetMaxSduSize(maxSduSize));
       
  1457 
       
  1458 	TInt maxBitRateUp = extension.GetMaxBitrateUplink();
       
  1459 	User::LeaveIfError(params.SetMaxBitrateUplink(maxBitRateUp));
       
  1460 
       
  1461 	TInt maxBitRateDown = extension.GetMaxBitrateDownlink();
       
  1462 	User::LeaveIfError(params.SetMaxBitrateDownlink(maxBitRateDown));
       
  1463 
       
  1464 	TInt guaBitRateUp = extension.GetGuaBitrateUplink();
       
  1465 	User::LeaveIfError(params.SetGuaranteedBitrateUplink(guaBitRateUp));
       
  1466 
       
  1467 	TInt guaBitRateDown = extension.GetGuaBitrateDownlink();
       
  1468 	User::LeaveIfError(params.SetGuaranteedBitrateDownlink(guaBitRateDown));
       
  1469 
       
  1470     iParameterRelease = KParameterRel4Rel99;
       
  1471 	}
       
  1472 
       
  1473 void CIpSubConnectionProvider::MapExtensionParamsFromESockToPRTL(const CSubConSBLPR5ExtensionParamSet& extension, CSblpParameters& params) const
       
  1474 	{
       
  1475 	TAuthToken authToken = extension.GetMAT();
       
  1476 	params.SetMAT(authToken);
       
  1477 
       
  1478 	/**
       
  1479 	Get Flow Identifires And store that into the RArray of Flow Ids
       
  1480 	of SBLP Paramters
       
  1481 	*/
       
  1482 	RArray<CSblpParameters::TFlowIdentifier> arrFlowIds;
       
  1483 	CleanupClosePushL(arrFlowIds);
       
  1484 
       
  1485 	TInt nrOfFlows = extension.GetNumberOfFlowIds();
       
  1486 	for ( TInt i = 0; i < nrOfFlows; i ++ )
       
  1487 	{
       
  1488 	    const TFlowId & Fid = extension.GetFlowIdAt(i);
       
  1489 		CSblpParameters::TFlowIdentifier FlowId;
       
  1490 		FlowId.iMediaComponentNumber = Fid.GetMediaComponentNumber();
       
  1491 		FlowId.iIPFlowNumber = Fid.GetIPFlowNumber();
       
  1492 		arrFlowIds.AppendL(FlowId);
       
  1493 	}
       
  1494 	params.SetFlowIds(arrFlowIds);
       
  1495 	CleanupStack::Pop(&arrFlowIds);
       
  1496 	arrFlowIds.Close();
       
  1497 	}
       
  1498 
       
  1499 void MapExtensionParamsFromPRTToESockL(TUmtsQoSParameters& params, CSubConQosIPLinkR99ParamSet& extension)
       
  1500 /**
       
  1501 Map extension parameters from ESock to the QoS PRT Equivalents
       
  1502 
       
  1503 @param params input structure that contains the QoS PRT extension parameters
       
  1504 @param extension structure updated to contain the ESock equivalent extension parameters
       
  1505 */
       
  1506 	{
       
  1507 	__IPCPRLOG(IpCprLog::Printf(_L("MapExtensionParamsFromPRTToESockL")));
       
  1508 
       
  1509 	TUmtsTrafficClass trafficClass = params.TrafficClass();
       
  1510 	extension.SetTrafficClass((RPacketQoS::TTrafficClass) trafficClass);
       
  1511 
       
  1512 	TUmtsDeliveryOrder deliveryOrder = params.DeliveryOrder();
       
  1513 	extension.SetDeliveryOrder((RPacketQoS::TDeliveryOrder) deliveryOrder);
       
  1514 
       
  1515 	TUmtsErroneousSDUDelivery deliveryOfErroneusSdu = params.DeliveryOfErroneusSdu();
       
  1516 	extension.SetErroneousSDUDelivery((RPacketQoS::TErroneousSDUDelivery) deliveryOfErroneusSdu);
       
  1517 
       
  1518 	TUmtsBitErrorRatio residualBer = params.ResidualBer();
       
  1519 	extension.SetResidualBitErrorRatio((RPacketQoS::TBitErrorRatio) residualBer);
       
  1520 
       
  1521 	TUmtsSDUErrorRatio errorRatio = params.ErrorRatio();
       
  1522 	extension.SetSDUErrorRatio((RPacketQoS::TSDUErrorRatio) errorRatio);
       
  1523 
       
  1524 	TUmtsTrafficHandlingPriority priority = params.Priority();
       
  1525 	extension.SetTrafficHandlingPriority((RPacketQoS::TTrafficHandlingPriority) priority);
       
  1526 
       
  1527 	TInt transferDelay = params.TransferDelay();
       
  1528 	extension.SetTransferDelay(transferDelay);
       
  1529 
       
  1530 	TInt maxSduSize = params.MaxSduSize();
       
  1531 	extension.SetMaxSduSize(maxSduSize);
       
  1532 
       
  1533 	TInt maxBitrateUplink = params.MaxBitrateUplink();
       
  1534 	extension.SetMaxBitrateUplink(maxBitrateUplink);
       
  1535 
       
  1536 	TInt maxBitrateDownlink = params.MaxBitrateDownlink();
       
  1537 	extension.SetMaxBitrateDownlink(maxBitrateDownlink);
       
  1538 
       
  1539 	TInt guaBitrateUplink = params.GuaranteedBitrateUplink();
       
  1540 	extension.SetGuaBitrateUplink(guaBitrateUplink);
       
  1541 
       
  1542 	TInt guaBitrateDownlink = params.GuaranteedBitrateDownlink();
       
  1543 	extension.SetGuaBitrateDownlink(guaBitrateDownlink);
       
  1544 	}
       
  1545 
       
  1546 
       
  1547 #ifdef SYMBIAN_NETWORKING_UMTSR5  	
       
  1548 void CIpSubConnectionProvider::MapExtensionParamsFromESockToPRTL(const CSubConQosR5ParamSet& aExtension, TUmtsR5QoSParameters& aParams)
       
  1549 /**
       
  1550 Map extension parameters from QoS PRT to the ESock Equivalents
       
  1551 
       
  1552 @param extension input structure that contains the ESock extension parameters
       
  1553 @param params structure updated to contains the equivalent QoS PRT extension parameters
       
  1554 */
       
  1555 	{
       
  1556 		
       
  1557 	__IPCPRLOG(IpCprLog::Printf(_L("MapExtensionParamsFromESockToPRTL")));				
       
  1558 	
       
  1559 	MapExtensionParamsFromESockToPRTL(static_cast<const CSubConQosIPLinkR99ParamSet&>(aExtension), static_cast<TUmtsQoSParameters&>(aParams));
       
  1560 		
       
  1561 	TBool signallingIndicator = aExtension.GetSignallingIndicator();
       
  1562 	User::LeaveIfError(aParams.SetSignallingIndicator(signallingIndicator));
       
  1563 	
       
  1564 	RPacketQoS::TSourceStatisticsDescriptor sourceStatisticsDescriptor = aExtension.GetSourceStatisticsDescriptor();
       
  1565 	User::LeaveIfError(aParams.SetSourceStatisticsDescriptor(reinterpret_cast<TUmtsSourceStatisticsDescriptor&>(sourceStatisticsDescriptor)));
       
  1566 
       
  1567     iParameterRelease = KParameterRel5;
       
  1568 	}
       
  1569 	
       
  1570 void MapExtensionParamsFromPRTToESockL(TUmtsR5QoSParameters& aParams, CSubConQosR5ParamSet& aExtension)
       
  1571 /**
       
  1572 Map extension parameters from ESock to the QoS PRT Equivalents
       
  1573 
       
  1574 @param params input structure that contains the QoS PRT extension parameters
       
  1575 @param extension structure updated to contain the ESock equivalent extension parameters
       
  1576 */
       
  1577 	{
       
  1578 	
       
  1579 	__IPCPRLOG(IpCprLog::Printf(_L("MapExtensionParamsFromPRTToESockL")));
       
  1580 		
       
  1581 	MapExtensionParamsFromPRTToESockL(static_cast<TUmtsQoSParameters&>(aParams),static_cast<CSubConQosIPLinkR99ParamSet&>(aExtension));
       
  1582 	
       
  1583 	TBool signallingprtIndicator = aParams.SignallingIndicator();
       
  1584 	aExtension.SetSignallingIndicator(signallingprtIndicator);
       
  1585 	
       
  1586 	TUmtsSourceStatisticsDescriptor sourceStatisticsprtDescriptor = aParams.SourceStatisticsDescriptor();
       
  1587 	aExtension.SetSourceStatisticsDescriptor(reinterpret_cast<RPacketQoS::TSourceStatisticsDescriptor&>(sourceStatisticsprtDescriptor));
       
  1588 	
       
  1589 	}
       
  1590 
       
  1591 void CIpSubConnectionProvider::MapExtensionParamsFromESockToPRTL(const CSubConImsExtParamSet& aExtension, TImsParameter& aParams)
       
  1592 /**
       
  1593 Map extension parameters from QoS PRT to the ESock Equivalents
       
  1594 
       
  1595 @param extension input structure that contains the ESock extension parameters
       
  1596 @param params structure updated to contains the equivalent QoS PRT extension parameters
       
  1597 */
       
  1598 	{
       
  1599 
       
  1600 		
       
  1601 	__IPCPRLOG(IpCprLog::Printf(_L("MapExtensionParamsFromESockToPRTL")));
       
  1602 	
       
  1603 	TBool IMSSignallingIndicator = aExtension.GetImsSignallingIndicator();
       
  1604 	aParams.SetIMSSigallingIndicator(IMSSignallingIndicator);
       
  1605 		
       
  1606 	}
       
  1607 	
       
  1608 void MapExtensionParamsFromPRTToESockL(TImsParameter& aParams, CSubConImsExtParamSet& aExtension)
       
  1609 /**
       
  1610 Map extension parameters from ESock to the QoS PRT Equivalents
       
  1611 
       
  1612 @param params input structure that contains the QoS PRT extension parameters
       
  1613 @param extension structure updated to contain the ESock equivalent extension parameters
       
  1614 */
       
  1615 	{
       
  1616 	
       
  1617 	__IPCPRLOG(IpCprLog::Printf(_L("MapExtensionParamsFromPRTToESockL")));
       
  1618 		
       
  1619 	TBool IMSSignallingIndicator = aParams.GetIMSSigallingIndicator();
       
  1620 	aExtension.SetImsSignallingIndicator(IMSSignallingIndicator);
       
  1621 	
       
  1622 	}
       
  1623 
       
  1624 #endif 
       
  1625 // SYMBIAN_NETWORKING_UMTSR5 
       
  1626 
       
  1627 void CIpSubConnectionProvider::ResetPrtExtensions()
       
  1628 	{
       
  1629 	TQoSExtensionQueueIter iter(iPrtExtensions);
       
  1630 	CExtensionBase *ext;
       
  1631 	ext = iter++;
       
  1632 	while (ext)
       
  1633 		{
       
  1634 		delete ext;
       
  1635 		ext = iter++;
       
  1636 		}
       
  1637 	iPrtExtensions.Reset();
       
  1638 	}
       
  1639 
       
  1640 void CIpSubConnectionProvider::ConvertParametersFromESockL(CSubConParameterBundle& aParameterBundle)
       
  1641 /**
       
  1642 Covert QoS Parameters sent from ESock to QoS PRT values and cache the values
       
  1643 
       
  1644 @param aParameterBundle the bundle that contains all of ESock's QoS Variables
       
  1645 */
       
  1646 	{
       
  1647 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ConvertParametersFromESockL [%08x]"), this));
       
  1648 
       
  1649     ResetPrtExtensions();
       
  1650 
       
  1651 	CSubConParameterFamily* family = aParameterBundle.FindFamily(KSubConQoSFamily);
       
  1652 	if(family)
       
  1653 		{
       
  1654 		CUmtsQoSPolicy* policy = CUmtsQoSPolicy::NewL();
       
  1655 		CleanupStack::PushL(policy);
       
  1656 		TBool policySet = EFalse;
       
  1657 
       
  1658 		// Map Requested Generic Parameters from ESock to PRT Values
       
  1659 		CSubConQosGenericParamSet* generic = (CSubConQosGenericParamSet*)family->GetGenericSet(CSubConParameterFamily::ERequested);
       
  1660 		if(generic)
       
  1661 			{
       
  1662 			TRAPD(err, MapGenericParamsFromESockToPRTL(*generic));
       
  1663 			if( err != KErrNone )
       
  1664 				{
       
  1665 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Generic Parameters (Requested) with Error: %d"),err));
       
  1666 				}
       
  1667 			}
       
  1668 
       
  1669 		// Map Requested UMTS Parameters from ESock to PRT values
       
  1670 		CSubConQosIPLinkR99ParamSet* extension = (CSubConQosIPLinkR99ParamSet*)family->FindExtensionSet(
       
  1671 				STypeId::CreateSTypeId(KSubConIPParamsUid,KSubConQosIPLinkR99ParamsType), CSubConParameterFamily::ERequested);
       
  1672 		if(extension)
       
  1673 			{
       
  1674 			TUmtsQoSParameters params;
       
  1675 
       
  1676 			TRAPD(err, MapExtensionParamsFromESockToPRTL(*extension, params));
       
  1677 			if( err != KErrNone )
       
  1678 				{
       
  1679 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Extension Parameters (Requested) with Error: %d"),err));
       
  1680 				}
       
  1681 
       
  1682 			policy->SetQoSRequested(params);
       
  1683 			policySet = ETrue;
       
  1684 			}
       
  1685 
       
  1686 		// Map Minimum UMTS Parameters from ESock to PRT values
       
  1687 		extension = (CSubConQosIPLinkR99ParamSet*)family->FindExtensionSet(
       
  1688 				STypeId::CreateSTypeId(KSubConIPParamsUid,KSubConQosIPLinkR99ParamsType), CSubConParameterFamily::EAcceptable);
       
  1689 		if(extension)
       
  1690 			{
       
  1691 			TUmtsQoSParameters params;
       
  1692 			TRAPD(err, MapExtensionParamsFromESockToPRTL(*extension,params));
       
  1693 			if( err != KErrNone )
       
  1694 				{
       
  1695 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Extension Parameters (Minimum) with Error: %d"),err));
       
  1696 				}
       
  1697 
       
  1698 			policy->SetQoSMinimum(params);
       
  1699 			policySet = ETrue;
       
  1700 			}
       
  1701 
       
  1702 		if(policySet)
       
  1703 			{
       
  1704 			iPrtExtensions.AddFirst(*policy);
       
  1705 			CleanupStack::Pop();
       
  1706 			}
       
  1707 		else
       
  1708 			{
       
  1709 		    CleanupStack::PopAndDestroy(policy);
       
  1710 			}
       
  1711 		
       
  1712 #ifdef SYMBIAN_NETWORKING_UMTSR5  
       
  1713 
       
  1714 		CUmtsR5QoSPolicy* policyR5 = CUmtsR5QoSPolicy::NewL();
       
  1715 		CleanupStack::PushL(policyR5);
       
  1716 		TBool policySetR5 = EFalse;
       
  1717 		// Map Requested UMTS Parameters from ESock to PRT values
       
  1718 		CSubConQosR5ParamSet* extensionR5 = static_cast<CSubConQosR5ParamSet*>(family->FindExtensionSet(STypeId::CreateSTypeId(KSubConIPParamsUid,KSubConQosR5ParamsType), CSubConParameterFamily::ERequested));
       
  1719 		if(extensionR5)
       
  1720 			{
       
  1721 			 TUmtsR5QoSParameters paramsR5;
       
  1722 	         TRAPD(err, MapExtensionParamsFromESockToPRTL(*extensionR5, paramsR5));
       
  1723 			 if( err != KErrNone )
       
  1724 				{
       
  1725 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Extension Parameters (Requested) with Error: %d"),err));
       
  1726 				}
       
  1727 
       
  1728 			policyR5->SetQoSRequested(paramsR5);
       
  1729 			policySetR5 = ETrue;
       
  1730 			}
       
  1731 		// Map Minimum UMTS Parameters from ESock to PRT values
       
  1732 		extensionR5 = static_cast<CSubConQosR5ParamSet*>(family->FindExtensionSet(STypeId::CreateSTypeId(KSubConIPParamsUid,KSubConQosR5ParamsType), CSubConParameterFamily::EAcceptable));
       
  1733 		if(extensionR5)
       
  1734 			{
       
  1735 			TUmtsR5QoSParameters paramsR5;
       
  1736 			TRAPD(err, MapExtensionParamsFromESockToPRTL(*extensionR5,paramsR5));
       
  1737 			if( err != KErrNone )
       
  1738 				{
       
  1739 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Extension Parameters (Minimum) with Error: %d"),err));
       
  1740 				}
       
  1741 
       
  1742 			policyR5->SetQoSMinimum(paramsR5);
       
  1743 			policySetR5 = ETrue;
       
  1744 			}
       
  1745 
       
  1746 		if(policySetR5)
       
  1747 			{
       
  1748 			iPrtExtensions.AddFirst(*policyR5);
       
  1749 			CleanupStack::Pop();
       
  1750 			}
       
  1751 		else
       
  1752 			{
       
  1753 		    CleanupStack::PopAndDestroy(policyR5);
       
  1754 			}
       
  1755 		
       
  1756 			
       
  1757 			CImsPolicy* policyIms = CImsPolicy ::NewL();
       
  1758 			CleanupStack::PushL(policyIms);
       
  1759 			TBool policySetIms = EFalse;
       
  1760 			// Map Requested UMTS IMS Parameters from ESock to PRT values
       
  1761 			CSubConImsExtParamSet* extensionIms = static_cast<CSubConImsExtParamSet*>(family->FindExtensionSet(STypeId::CreateSTypeId(KSubConIPParamsUid,KSubConImsExtParamsType), CSubConParameterFamily::ERequested));
       
  1762 		if(extensionIms)
       
  1763 			{
       
  1764 			TImsParameter paramsIms;
       
  1765 
       
  1766 			TRAPD(err, MapExtensionParamsFromESockToPRTL(*extensionIms, paramsIms));
       
  1767 			if( err != KErrNone )
       
  1768 				{
       
  1769 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Extension Parameters (Requested) with Error: %d"),err));
       
  1770 				}
       
  1771 			
       
  1772 			policyIms->SetImsParameter(paramsIms); 
       
  1773 			policySetIms = ETrue;
       
  1774 			}
       
  1775 	
       
  1776 		if(policySetIms)
       
  1777 			{
       
  1778 			iPrtExtensions.AddFirst(*policyIms);
       
  1779 			CleanupStack::Pop();
       
  1780 			}
       
  1781 		else
       
  1782 			{
       
  1783 		    CleanupStack::PopAndDestroy(policyIms);
       
  1784 			}
       
  1785 		
       
  1786 #endif 
       
  1787 // SYMBIAN_NETWORKING_UMTSR5 
       
  1788 	
       
  1789 	}
       
  1790 
       
  1791 	// Convert SBLP set if present
       
  1792 	// Check for the presence of the family in the bundle
       
  1793 	CSubConParameterFamily* sblpFamily = aParameterBundle.FindFamily(KSubConAuthorisationFamily);
       
  1794 	if (sblpFamily)
       
  1795 		{
       
  1796 		CSblpPolicy* policy = CSblpPolicy::NewL();
       
  1797 		CleanupStack::PushL(policy);
       
  1798 		TBool policySet = EFalse;
       
  1799 
       
  1800 		/**
       
  1801 		Extract the generic and extension Parmaters of the Family. At present the generic
       
  1802 		parameters will just contains a dummy , and will not be used. The code is commented
       
  1803 		and can be enabled sometimes when any parameter varification at the code is required
       
  1804 		*/
       
  1805 		// CSubConAuthorisationGenericParamSet* generic = (CSubConAuthorisationGenericParamSet*)SblpFamily->GetGenericSet(CSubConParameterFamily::ERequested);
       
  1806 		/**
       
  1807 		There can be more than one extension set containing multiple MATs, as a requirement for the R6.
       
  1808 		currently the APIs in CSubConParameterFamily is not able to extract multiple parameters. once this
       
  1809 		is done, the code below must be changed to run on a loop on number of extensions
       
  1810 		*/
       
  1811 
       
  1812 		// Map Requested UMTS Parameters from ESock to PRT values
       
  1813 		CSubConSBLPR5ExtensionParamSet* extension = (CSubConSBLPR5ExtensionParamSet*)sblpFamily->FindExtensionSet(
       
  1814 				STypeId::CreateSTypeId(KSubConIPParamsUid,KSubConnSBLPR5ExtensionParamsType), CSubConParameterFamily::ERequested);
       
  1815 		if(extension)
       
  1816 			{
       
  1817 			CSblpParameters* params = new (ELeave)CSblpParameters;
       
  1818 			CleanupStack::PushL(params);
       
  1819 			TRAPD(err, MapExtensionParamsFromESockToPRTL(*extension,*params));
       
  1820 			if( err != KErrNone )
       
  1821 				{
       
  1822 				__IPCPRLOG(IpCprLog::Printf(_L("Failed to convert from ESock to PRT Extension Parameters (Requested) with Error: %d"),err));
       
  1823 				}
       
  1824 
       
  1825 			policy->SetSblpParameters(*params); //does a bitwise copy therefore we must still delete params afterwards
       
  1826 			policySet = ETrue;
       
  1827 			CleanupStack::Pop(params);
       
  1828 			delete params;
       
  1829 			}
       
  1830 
       
  1831 		if( policySet )
       
  1832 			{
       
  1833 			iPrtExtensions.AddFirst(*policy);
       
  1834 			CleanupStack::Pop();
       
  1835 			}
       
  1836 		else
       
  1837     		{
       
  1838 		    CleanupStack::PopAndDestroy(policy);
       
  1839 	    	}
       
  1840 		}
       
  1841 	}
       
  1842 
       
  1843 
       
  1844 void CIpSubConnectionProvider::ConvertParametersFromQOSL(TPfqosMessage& aMsg, CSubConGenEventParamsGranted* aEvent)
       
  1845 /**
       
  1846 Convert parameters from a PRT response to ESock equivalents.  PRT parameters are cached
       
  1847 
       
  1848 @param aMsg QoS PRT Response Message
       
  1849 @param aEvent ESock event to contain changed QoS Parameters
       
  1850 */
       
  1851 	{
       
  1852 	__IPCPRLOG(IpCprLog::Printf(_L("CIpSubConnectionProvider::ConvertParametersFromQOSL [%08x]"), this));
       
  1853 
       
  1854 	/** Changed as per usase of CQosParamaters instead of
       
  1855 	TQoSParameter
       
  1856 	*/
       
  1857 
       
  1858     TQoSParameters qosParams;
       
  1859 	aMsg.SetQoSParameters(qosParams);
       
  1860 
       
  1861     // Copy qosParams into the iPrtParameters
       
  1862 	ConvertTQoSIntoCQoSParamsL(qosParams);
       
  1863 	aEvent->SetFamily(KSubConQoSFamily);
       
  1864 
       
  1865 	CSubConQosGenericParamSet* generic = CSubConQosGenericParamSet::NewL();
       
  1866 	MapGenericParamsFromPRTToESockL(*generic);
       
  1867 	aEvent->SetGenericSet(generic);
       
  1868 
       
  1869 
       
  1870 
       
  1871     TSglQueIter<CPfqosPolicyData> iter(aMsg.iExtensions);
       
  1872 	CPfqosPolicyData* data = NULL;
       
  1873 	
       
  1874 	// for each pfqos extension that exists in aMsg
       
  1875 	while ((data = iter++) != NULL)
       
  1876 		{
       
  1877 	    const TUint8 *p = data->Data().Ptr();
       
  1878 	    TInt length = data->Data().Length();
       
  1879 	    const struct pfqos_configure* pfqosExtConfig = reinterpret_cast<const struct pfqos_configure*>(p);
       
  1880 
       
  1881 	    if (length > (TInt)sizeof(pfqos_configure) &&
       
  1882 		    pfqosExtConfig->pfqos_configure_len * 8 == length &&
       
  1883 		    pfqosExtConfig->pfqos_ext_type == EPfqosExtExtension)
       
  1884 	    	{
       
  1885 	    	
       
  1886 	    	// pfqos_extension struct is located straight after pfqos_configure struct
       
  1887 		    p += sizeof(struct pfqos_configure);
       
  1888 		    const struct pfqos_extension* pfqosExtension = reinterpret_cast<const struct pfqos_extension*>(p);
       
  1889 			TInt extType = pfqosExtension->pfqos_extension_type;
       
  1890 
       
  1891 			CExtensionBase* scPfqosExtension = NULL;
       
  1892 			TQoSExtensionQueueIter iter2(iPrtExtensions);
       
  1893 			
       
  1894 			// for each pfqos extension that has been configured in this subconnection
       
  1895 			while ((scPfqosExtension = iter2++) != NULL)
       
  1896 				{
       
  1897 				if (scPfqosExtension->Type() == extType)
       
  1898 					{
       
  1899 					// the extension in the message matches an extension that is configured on the
       
  1900 					// subconnection, now we can parse it
       
  1901 					scPfqosExtension->ParseMessage(data->Data());
       
  1902 
       
  1903                     CSubConExtensionParameterSet* extension = NULL;
       
  1904 #ifdef SYMBIAN_NETWORKING_UMTSR5
       
  1905                     switch (extType)
       
  1906                         {
       
  1907 						case KPfqosExtensionUmts:                   
       
  1908 #endif
       
  1909 						    {
       
  1910 							CUmtsQoSPolicy *policy = static_cast<CUmtsQoSPolicy*>(scPfqosExtension);
       
  1911 							TNegotiatedUmtsQoSParameters grantedQoS;
       
  1912 							policy->GetQoSNegotiated(grantedQoS);
       
  1913 							extension = CSubConQosIPLinkR99ParamSet::NewL();
       
  1914                             CleanupStack::PushL(extension);
       
  1915 							MapExtensionParamsFromPRTToESockL(grantedQoS,*static_cast<CSubConQosIPLinkR99ParamSet*>(extension));
       
  1916 #ifdef SYMBIAN_NETWORKING_UMTSR5
       
  1917                             break;
       
  1918 						    }
       
  1919                         case KPfqosR5ExtensionUmts:
       
  1920                             extension = MapFromUmtsR5ExtensionL(static_cast<CUmtsR5QoSPolicy*>(scPfqosExtension));
       
  1921                             CleanupStack::PushL(extension);
       
  1922                             break;
       
  1923 
       
  1924                         case KPfqosExtensionIMS:
       
  1925                             extension = MapFromImsExtensionL(static_cast<CImsPolicy*>(scPfqosExtension));
       
  1926                             CleanupStack::PushL(extension);
       
  1927                             break;
       
  1928 #endif
       
  1929                         }
       
  1930 
       
  1931                     if (extension)
       
  1932                         {
       
  1933                         // Need to add it to the cleanup stack so we don't lose the ptr
       
  1934                         // in the event that AddExtensionSetL leaves
       
  1935 	                    aEvent->AddExtensionSetL(extension);
       
  1936 	                    CleanupStack::Pop(extension);
       
  1937                         }
       
  1938 
       
  1939 					// Next extension from aMsg
       
  1940 					break;
       
  1941 					}
       
  1942 				}
       
  1943 			}
       
  1944 		}
       
  1945 	}
       
  1946 	
       
  1947 
       
  1948 
       
  1949 #ifdef SYMBIAN_NETWORKING_UMTSR5
       
  1950 CSubConExtensionParameterSet* CIpSubConnectionProvider::MapFromUmtsR5ExtensionL (const CUmtsR5QoSPolicy* aPolicy)
       
  1951     {
       
  1952     ASSERT(aPolicy);
       
  1953     
       
  1954 	TNegotiatedUmtsR5QoSParameters grantedR5QoS;
       
  1955 	aPolicy->GetQoSNegotiated(grantedR5QoS);
       
  1956 	
       
  1957 	CSubConExtensionParameterSet* paramSet;
       
  1958 
       
  1959     switch (iParameterRelease)
       
  1960         {
       
  1961         case KParameterRel5:
       
  1962     		paramSet = CSubConQosR5ParamSet::NewL();
       
  1963     		CleanupStack::PushL(paramSet);
       
  1964     		MapExtensionParamsFromPRTToESockL(static_cast<TUmtsR5QoSParameters&>(grantedR5QoS),
       
  1965     		    *static_cast<CSubConQosR5ParamSet*>(paramSet));
       
  1966     		CleanupStack::Pop(paramSet);
       
  1967             break;
       
  1968 
       
  1969         case KParameterRel4Rel99:
       
  1970     		paramSet = CSubConQosR99ParamSet::NewL();
       
  1971     		CleanupStack::PushL(paramSet);
       
  1972     		MapExtensionParamsFromPRTToESockL(static_cast<TUmtsQoSParameters&>(grantedR5QoS),
       
  1973     		    *static_cast<CSubConQosR99ParamSet*>(paramSet));
       
  1974             CleanupStack::Pop(paramSet);
       
  1975             break;
       
  1976     
       
  1977         default:
       
  1978             // Break in debug builds
       
  1979             ASSERT(EFalse);
       
  1980             return NULL;
       
  1981         }
       
  1982     
       
  1983     return paramSet;
       
  1984     }
       
  1985 
       
  1986 
       
  1987 CSubConExtensionParameterSet* CIpSubConnectionProvider::MapFromImsExtensionL (const CImsPolicy* aPolicy)
       
  1988     {
       
  1989     ASSERT(aPolicy);
       
  1990     
       
  1991 	TImsParameter grantedImsQoS; 
       
  1992 	aPolicy->GetImsParameter(grantedImsQoS); 
       
  1993 
       
  1994 	CSubConImsExtParamSet* extensionIms = CSubConImsExtParamSet::NewL();
       
  1995 	CleanupStack::PushL(extensionIms);
       
  1996 	MapExtensionParamsFromPRTToESockL(grantedImsQoS, *extensionIms);
       
  1997 	CleanupStack::Pop(extensionIms);
       
  1998 	
       
  1999 	return extensionIms;
       
  2000     }
       
  2001 #endif
       
  2002 // SYMBIAN_NETWORKING_UMTSR5
       
  2003 
       
  2004 #endif
       
  2005 // BASIC_IPSCPR
       
  2006