telephonyprotocols/rawipnif/src/RawIPFlow.cpp
branchRCL_3
changeset 7 fe8b59ab9fa0
parent 5 7ef16719d8cb
child 19 630d2f34d719
equal deleted inserted replaced
6:fc69e1e37771 7:fe8b59ab9fa0
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   221 	__PACKETLOG_DELETE;
   221 	__PACKETLOG_DELETE;
   222 	iStopping = ETrue;
   222 	iStopping = ETrue;
   223 	ShutDown(MControllerObserver::EInitialised, aError);
   223 	ShutDown(MControllerObserver::EInitialised, aError);
   224 	}
   224 	}
   225 
   225 
   226 TInt CRawIPFlow::SendPacket(RMBufChain& aPdu, TAny* /*aProtocol*/,
   226 MLowerDataSender::TSendResult CRawIPFlow::SendPacket(RMBufChain& aPdu, TAny* /*aProtocol*/,
   227 							   TUint16 /*aType*/)
   227 							   TUint16 /*aType*/)
   228 /**
   228 /**
   229  * Sends a packet, via the BCA controller. This method is protocol-agnostic,
   229  * Sends a packet, via the BCA controller. This method is protocol-agnostic,
   230  * and is called by the IPv4 and IPv6 binder to actually send packets.
   230  * and is called by the IPv4 and IPv6 binder to actually send packets.
   231  *
   231  *
   232  * @param aPdu The packet to send
   232  * @param aPdu The packet to send
   233  * @return A standard error code
   233  * @return MLowerDataSender::TSendResult
   234  */
   234  */
   235 	{
   235 	{
   236 	_LOG_L1C4(_L8("CRawIPFlow %08x:\tSendPacket(): length=%d, blocked=%d"),
   236 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tSendPacket(): length=%d"),
   237 		this, aPdu.Length() - aPdu.First()->Length(),iBlocked);
   237 		this, aPdu.Length() - aPdu.First()->Length());
   238 
   238 
   239     TInt ret = MLowerDataSender::ESendBlocked;
   239     __PACKETLOG_WRITE_PACKET(aPdu, 0);
   240 	if (!iBlocked)
   240     return iBcaController->Send(aPdu);
   241     	{
       
   242     	__PACKETLOG_WRITE_PACKET(aPdu, 0);
       
   243     	ret = iBcaController->Send(aPdu);
       
   244     	}
       
   245     else
       
   246         {
       
   247         //crude flow cntrl handling: drop..
       
   248         aPdu.Free();
       
   249         }
       
   250 	return ret;
       
   251 	}
   241 	}
   252 
   242 
   253 void CRawIPFlow::Process(RMBufChain& aPdu, TUint16 aProtocolCode)
   243 void CRawIPFlow::Process(RMBufChain& aPdu, TUint16 aProtocolCode)
   254 /**
   244 /**
   255  * Handles incoming packets which have been passed up from the BCA controller.
   245  * Handles incoming packets which have been passed up from the BCA controller.
   613 	else if (TCFFlow::ERealmId == aMessage.MessageId().Realm())
   603 	else if (TCFFlow::ERealmId == aMessage.MessageId().Realm())
   614 		{
   604 		{
   615 		switch (aMessage.MessageId().MessageId())
   605 		switch (aMessage.MessageId().MessageId())
   616 			{
   606 			{
   617 		case TCFFlow::TBlock::EId :
   607 		case TCFFlow::TBlock::EId :
   618 			iBlocked = ETrue;
   608 		    {
   619 			break;
   609 		    // if there is a packet being sent and it completes
   620 		case TCFFlow::TUnBlock::EId :
   610 		    // flow control will stop sending any further packets
   621 			iBlocked = EFalse;
   611 		    // while the flow is blocked.
   622 			if (iBinder)
   612 		    
   623 				{
   613 		    iBcaController->BlockSending();
   624 				iBinder->StartSending();
   614 		    }
   625 				}
   615 			break;
       
   616         case TCFFlow::TUnBlock::EId :
       
   617 		    {          
       
   618             // ResumeSending is specific for the unblocking the flow - it
       
   619             // cancels the flow control and restarts the flow appropriately
       
   620             // (i.e. if there is a packet outstanding, messages in the queue
       
   621             // or idle and no queue).
       
   622             iBcaController->ResumeSending();
       
   623 		    }
   626 			break;
   624 			break;
   627 		case TCFFlow::TRejoin::EId:
   625 		case TCFFlow::TRejoin::EId:
   628 			{
   626 			{
   629 			TCFFlow::TRejoin& rejoinMsg = message_cast<TCFFlow::TRejoin>(aMessage);
   627 			TCFFlow::TRejoin& rejoinMsg = message_cast<TCFFlow::TRejoin>(aMessage);
   630 			TDefaultFlowFactoryQuery query(rejoinMsg.iNodeId);
   628 			TDefaultFlowFactoryQuery query(rejoinMsg.iNodeId);
   793 	{
   791 	{
   794 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tNotification(aEvent %d)"), this, aEvent);
   792 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tNotification(aEvent %d)"), this, aEvent);
   795 
   793 
   796 	switch (aEvent)
   794 	switch (aEvent)
   797 	{
   795 	{
   798 	case EAgentToNifEventTypeDisableTimers: //GPRS suspension
   796     case EAgentToNifEventTypeDisableTimers: //GPRS suspension
   799 		{
   797         {
   800 		_LOG_L1C1(_L8("CRawIPFlow::Received Suspend from Agent..."));
   798         _LOG_L1C1(_L8("CRawIPFlow::Received Suspend from Agent..."));
   801 
   799 
   802 		// Let the BCA controller know that data can no longer be sent over
   800         // Let the BCA controller know that data can no longer be sent over
   803 		// the PDP context.
   801         // the PDP context.
   804 		iBcaController->UpdateContextStateFlag(EFalse);
   802         iBcaController->BlockSending();
   805 
   803 
   806 		break;
   804         break;
   807 		}
   805         }
   808 
   806 
   809 	case EAgentToNifEventTypeEnableTimers: //GPRS resumption
   807     case EAgentToNifEventTypeEnableTimers: //GPRS resumption
   810 		{
   808         {
   811 		_LOG_L1C1(_L8("CRawIPFlow::Received Resume from Agent..."));
   809         _LOG_L1C1(_L8("CRawIPFlow::Received Resume from Agent..."));
   812 		iBcaController->UpdateContextStateFlag(ETrue);
   810         iBcaController->ResumeSending();
   813 
   811 
   814 		break;
   812         break;
   815 		}
   813         }
   816 
       
   817 	case (EAgentToNifEventTypeDisableConnection) :
   814 	case (EAgentToNifEventTypeDisableConnection) :
   818 		{
   815 		{
   819 		// This is handled by NIFMAN and passed to Flow as a Stop() call
   816 		// This is handled by NIFMAN and passed to Flow as a Stop() call
   820 		_LOG_L1C1(_L8("CRawIPFlow::Received Disable connection from Agent..."));
   817 		_LOG_L1C1(_L8("CRawIPFlow::Received Disable connection from Agent..."));
   821 		break;
   818 		break;