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