telephonyprotocols/rawipnif/src/RawIPFlow.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 16 fe8b59ab9fa0
child 66 07a122eea281
child 73 70d75957b98f
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
    18 //
    18 //
    19 
    19 
    20 /**
    20 /**
    21  @file
    21  @file
    22 */
    22 */
       
    23 
       
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "RawIPFlowTraces.h"
       
    28 #endif
    23 
    29 
    24 #include <f32file.h>
    30 #include <f32file.h>
    25 #include <nifman.h>
    31 #include <nifman.h>
    26 #include <nifmbuf.h>
    32 #include <nifmbuf.h>
    27 #include <in_iface.h>
    33 #include <in_iface.h>
    44 //These variables are used only if flog is active.
    50 //These variables are used only if flog is active.
    45 _LIT8(KTcpDumpFirstTag,"TcpDump");
    51 _LIT8(KTcpDumpFirstTag,"TcpDump");
    46 static const TUint16 KTcpDumpLinkType = 12;
    52 static const TUint16 KTcpDumpLinkType = 12;
    47 #endif
    53 #endif
    48 
    54 
    49 CRawIPFlow::CRawIPFlow(CSubConnectionFlowFactoryBase& aFactory, const TNodeId& aSubConnId, CProtocolIntfBase* aProtocolIntf, CBttLogger* aTheLogger)
    55 CRawIPFlow::CRawIPFlow(CSubConnectionFlowFactoryBase& aFactory, const TNodeId& aSubConnId, CProtocolIntfBase* aProtocolIntf)
    50 /**
    56 /**
    51  * Constructor.
    57  * Constructor.
    52  *
    58  *
    53  * @param aFactory Reference to the factory which created this object.
    59  * @param aFactory Reference to the factory which created this object.
    54  * @param aTheLogger The logging object, ownership is passed to this object
       
    55  */
    60  */
    56 	: CSubConnectionFlowBase(aFactory, aSubConnId, aProtocolIntf),
    61 	: CSubConnectionFlowBase(aFactory, aSubConnId, aProtocolIntf),
    57 	  iTheLogger(aTheLogger),
       
    58 	  iInitError(KErrNone),
    62 	  iInitError(KErrNone),
    59 	  iStarted(EFalse),
    63 	  iStarted(EFalse),
    60 	  iStopping(EFalse)
    64 	  iStopping(EFalse)
    61 	{
    65 	{
    62 	LOG_NODE_CREATE(KNifSubDir, CRawIPFlow);
    66 	LOG_NODE_CREATE(KNifSubDir, CRawIPFlow);
    68  * control engine
    72  * control engine
    69  *
    73  *
    70  * @param aName The name of the NIF (unused)
    74  * @param aName The name of the NIF (unused)
    71  */
    75  */
    72 	{
    76 	{
    73 	_LOG_L1C2(_L8("CRawIPFlow %08x:\tConstructL()"), this);
    77 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_CONSTRUCTL_1, "CRawIPFlow %08x:\tConstructL()", this);
    74     iBinderControl = new (ELeave) TBinderControlProxy(*this);
    78     iBinderControl = new (ELeave) TBinderControlProxy(*this);
    75 	iBcaController = CBcaIoController::NewL(*this, iTheLogger);
    79 	iBcaController = CBcaIoController::NewL(*this);
    76 	}
    80 	}
    77 
    81 
    78 CRawIPFlow::~CRawIPFlow()
    82 CRawIPFlow::~CRawIPFlow()
    79 /**
    83 /**
    80  * Destructor. Cancels and deletes all owned active objects.
    84  * Destructor. Cancels and deletes all owned active objects.
    81  */
    85  */
    82 	{
    86 	{
    83 	// Note that we don't delete iBinder because it's not owned by us.
    87 	// Note that we don't delete iBinder because it's not owned by us.
    84 	delete iBcaController;
    88 	delete iBcaController;
    85 	// This class also deletes the logging object
       
    86 	delete iTheLogger;
       
    87 
    89 
    88 	ASSERT(iBinder == NULL);
    90 	ASSERT(iBinder == NULL);
    89 	
    91 	
    90 	delete iBinderControl;	
    92 	delete iBinderControl;	
    91 	LOG_NODE_DESTROY(KNifSubDir, CRawIPFlow);
    93 	LOG_NODE_DESTROY(KNifSubDir, CRawIPFlow);
   103  * @return Allways KErrNone
   105  * @return Allways KErrNone
   104  */
   106  */
   105 	{
   107 	{
   106 	ASSERT(iStarting==EFalse);
   108 	ASSERT(iStarting==EFalse);
   107 	iStarting = ETrue;
   109 	iStarting = ETrue;
   108 	_LOG_L1C2(_L8("CRawIPFlow %08x:\tStartFlowL()"), this);
   110 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_STARTFLOWL_1, "CRawIPFlow %08x:\tStartFlowL()", this);
   109 
   111 
   110 	// If there were any errors during earlier processing of the ProvisionConfig message
   112 	// If there were any errors during earlier processing of the ProvisionConfig message
   111 	// then send an Error message in response to the StartFlow (because ProvisionConfig
   113 	// then send an Error message in response to the StartFlow (because ProvisionConfig
   112 	// does not have a response code).
   114 	// does not have a response code).
   113 	if (iProvisionError != KErrNone)
   115 	if (iProvisionError != KErrNone)
   138 	TBuf8<KTimeStampLen> logFileName;
   140 	TBuf8<KTimeStampLen> logFileName;
   139 
   141 
   140 	_LIT8(KTimeFormat, "%08X");
   142 	_LIT8(KTimeFormat, "%08X");
   141 	TUint32 counter = User::FastCounter();
   143 	TUint32 counter = User::FastCounter();
   142 	logFileName.Format(KTimeFormat, counter);
   144 	logFileName.Format(KTimeFormat, counter);
   143 
   145 	
   144 	TRAPD(err,__PACKETLOG_NEWL(KTcpDumpFirstTag, logFileName, CPacketLogger::ETcpDump, KTcpDumpLinkType));
   146     TRAPD(err,__PACKETLOG_NEWL(KTcpDumpFirstTag, logFileName, CPacketLogger::ETcpDump, KTcpDumpLinkType));
   145 	if (err)
   147         if (err)
   146 		{
   148             {
   147 		_LOG_L1C1(_L8("Trapped leave from __PACKETLOG_NEWL"));
   149             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_STARTFLOWL_2, "Trapped leave from __PACKETLOG_NEWL");
   148 		}
   150             }
   149 
   151 	
   150 	const TUint KLogTextLen = KModemNameLen+KTimeStampLen+30;
   152 	const TUint KLogTextLen = KModemNameLen+KTimeStampLen+30;
   151 	TBuf8<KLogTextLen> logText;
   153 	TBuf8<KLogTextLen> logText;
   152 	_LIT8(KLogTimeText, "TcpDump log file time stamp:");
   154 	_LIT8(KLogTimeText, "TcpDump log file time stamp:");
   153 	_LIT8(KLogModemText, " for modem:");
   155 	_LIT8(KLogModemText, " for modem:");
   154 	logText.Append(KLogTimeText);
   156 	logText.Append(KLogTimeText);
   155 	logText.Append(logFileName);
   157 	logText.Append(logFileName);
   156 	logText.Append(KLogModemText);
   158 	logText.Append(KLogModemText);
   157 	logText.Append(modemName);
   159 	logText.Append(modemName);
   158 	_LOG_L1C1(logText);
   160 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_STARTFLOWL_3, "%s", logText);
   159 #endif
   161 #endif
   160 	}
   162 	}
   161 
   163 
   162 
   164 
   163 void CRawIPFlow::LinkLayerUp()
   165 void CRawIPFlow::LinkLayerUp()
   165  * This function is called when initialisation is complete and the Flow is
   167  * This function is called when initialisation is complete and the Flow is
   166  * ready to send/receive data. It notifies NifMan and the IP interface that it's
   168  * ready to send/receive data. It notifies NifMan and the IP interface that it's
   167  * ready to go.
   169  * ready to go.
   168  */
   170  */
   169 	{
   171 	{
   170 	_LOG_L1C2(_L8("CRawIPFlow %08x:\tLinkLayerUp()"), this);
   172 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_LINKLAYERUP_1, "CRawIPFlow %08x:\tLinkLayerUp()", this);
   171 
   173 
   172 	iLastRequestOriginator.ReplyTo(Id(), TCFDataClient::TStarted().CRef());
   174 	iLastRequestOriginator.ReplyTo(Id(), TCFDataClient::TStarted().CRef());
   173 
   175 
   174 
   176 
   175 	iBinder->StartSending();
   177 	iBinder->StartSending();
   184  * notify NifMan that the link has gone down, so it can delete the NIF.
   186  * notify NifMan that the link has gone down, so it can delete the NIF.
   185  *
   187  *
   186  * @param aError An error code to propagate to NifMan
   188  * @param aError An error code to propagate to NifMan
   187  */
   189  */
   188 	{
   190 	{
   189 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tLinkLayerDown(aError %d)"), this, aError);
   191 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_LINKLAYERDOWN_1, "CRawIPFlow %08x:\tLinkLayerDown(aError %d)", (TUint)this, aError);
       
   192 	
   190 	__PACKETLOG_DELETE;
   193 	__PACKETLOG_DELETE;
   191 
   194 	
   192 	if (iStopping)
   195 	if (iStopping)
   193 		{
   196 		{
   194 		iLastRequestOriginator.ReplyTo(Id(), TCFDataClient::TStopped(aError).CRef());
   197 		iLastRequestOriginator.ReplyTo(Id(), TCFDataClient::TStopped(aError).CRef());
   195 		}
   198 		}
   196     else if (iStarting)
   199     else if (iStarting)
   215  *
   218  *
   216  * @param aError A code specifying why the link is to be brought down
   219  * @param aError A code specifying why the link is to be brought down
   217  * @param aAction The action to take: disconnect or reconnect
   220  * @param aAction The action to take: disconnect or reconnect
   218  */
   221  */
   219 	{
   222 	{
   220 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tStopFlow(aError %d)"), this, aError);
   223 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_STOPFLOW_1, "CRawIPFlow %08x:\tStopFlow(aError %d)", (TUint)this, aError);
   221 	__PACKETLOG_DELETE;
   224 	__PACKETLOG_DELETE;
   222 	iStopping = ETrue;
   225 	iStopping = ETrue;
   223 	ShutDown(MControllerObserver::EInitialised, aError);
   226 	ShutDown(MControllerObserver::EInitialised, aError);
   224 	}
   227 	}
   225 
   228 
   231  *
   234  *
   232  * @param aPdu The packet to send
   235  * @param aPdu The packet to send
   233  * @return MLowerDataSender::TSendResult
   236  * @return MLowerDataSender::TSendResult
   234  */
   237  */
   235 	{
   238 	{
   236 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tSendPacket(): length=%d"),
   239     OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_SENDPACKET_1, "CRawIPFlow %08x:\tSendPacket(): length=%d, blocked=%d", (TUint)this, aPdu.Length() - aPdu.First()->Length(),iBlocked);
   237 		this, aPdu.Length() - aPdu.First()->Length());
       
   238 
       
   239     __PACKETLOG_WRITE_PACKET(aPdu, 0);
   240     __PACKETLOG_WRITE_PACKET(aPdu, 0);
   240     return iBcaController->Send(aPdu);
   241     return iBcaController->Send(aPdu);
   241 	}
   242 	}
   242 
   243 
   243 void CRawIPFlow::Process(RMBufChain& aPdu, TUint16 aProtocolCode)
   244 void CRawIPFlow::Process(RMBufChain& aPdu, TUint16 aProtocolCode)
   247  * the packet is binned.
   248  * the packet is binned.
   248  *
   249  *
   249  * @param aPdu The incoming packet
   250  * @param aPdu The incoming packet
   250  */
   251  */
   251 	{
   252 	{
   252 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tProcess() [aPdu length=%d]"),
   253 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_PROCESS_1, "CRawIPFlow %08x:\tProcess() [aPdu length=%d]",(TUint)this, aPdu.Length() - aPdu.First()->Length());
   253 		this, aPdu.Length() - aPdu.First()->Length());
       
   254 
   254 
   255 	// If the packet has zero or negative length, bin it.
   255 	// If the packet has zero or negative length, bin it.
   256 	if ((aPdu.Length() - aPdu.First()->Length()) <= 0)
   256 	if ((aPdu.Length() - aPdu.First()->Length()) <= 0)
   257 		{
   257 		{
   258 		_LOG_L1C1(_L8("Dumped packet: illegal length"));
   258 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_PROCESS_2, "Dumped packet: illegal length");
   259 		aPdu.Free();
   259 		aPdu.Free();
   260 		return;
   260 		return;
   261 		}
   261 		}
   262 
   262 
   263 	// See if the protocol interface wants the packet.
   263 	// See if the protocol interface wants the packet.
   267 		iBinder->Process(aPdu);
   267 		iBinder->Process(aPdu);
   268 		}
   268 		}
   269 	else
   269 	else
   270 		{
   270 		{
   271 		// The protocol didn't want the packet, so bin it.
   271 		// The protocol didn't want the packet, so bin it.
   272 		_LOG_L1C2(_L8("Packet was not processed: freeing (protocol code: %X)"),
   272 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_PROCESS_3, "Packet was not processed: freeing (protocol code: %X)",aProtocolCode);
   273 			aProtocolCode);
       
   274 		if (iBinder == NULL)
   273 		if (iBinder == NULL)
   275 			{
   274 			{
   276 			_LOG_L1C2(_L8("CRawIPFlow %08x:\tProcess(): NOTE: Binder not present"), this);
   275 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_PROCESS_4, "CRawIPFlow %08x:\tProcess(): NOTE: Binder not present", this);
   277 			}
   276 			}
   278 		aPdu.Free();
   277 		aPdu.Free();
   279 		}
   278 		}
   280 	}
   279 	}
   281 
   280 
   282 void CRawIPFlow::ResumeSending()
   281 void CRawIPFlow::ResumeSending()
   283 /**
   282 /**
   284  * Notifies the protocol interface that it can resume sending packets.
   283  * Notifies the protocol interface that it can resume sending packets.
   285  */
   284  */
   286 	{
   285 	{
   287 	_LOG_L1C2(_L8("CRawIPFlow %08x:\tResumeSending()"), this);
   286 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_RESUMESENDING_1, "CRawIPFlow %08x:\tResumeSending()", this);
   288 
   287 
   289 	if (iBinder)
   288 	if (iBinder)
   290 		{
   289 		{
   291 		iBinder->StartSending();
   290 		iBinder->StartSending();
   292 		}
   291 		}
   293 	else
   292 	else
   294 		{
   293 		{
   295 		_LOG_L1C2(_L8("CRawIPFlow %08x:\tResumeSending(): NOTE: Binder not present"), this);
   294 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_RESUMESENDING_2, "CRawIPFlow %08x:\tResumeSending(): NOTE: Binder not present", this);
   296 		}
   295 		}
   297 	}
   296 	}
   298 
   297 
   299 void CRawIPFlow::InitialiseL(TInitialisationState aState, TInt aError)
   298 void CRawIPFlow::InitialiseL(TInitialisationState aState, TInt aError)
   300 /**
   299 /**
   305  *
   304  *
   306  * @param aState The current initialisation step
   305  * @param aState The current initialisation step
   307  * @param aError A possible error
   306  * @param aError A possible error
   308  */
   307  */
   309 	{
   308 	{
   310 	_LOG_L1C4(_L8("CRawIPFlow %08x:\tInitialiseL(aState %d, aError %d)"),
   309 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_1, "CRawIPFlow %08x:\tInitialiseL(aState %d, aError %d)",(TUint)this, aState, aError);
   311 		this, aState, aError);		
       
   312 
   310 
   313 	if (aError != KErrNone)
   311 	if (aError != KErrNone)
   314 		{
   312 		{
   315 		_LOG_L2C2(_L8("  *** FAILED to initialise NIF *** Error =%d"),aError);
   313 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_2, "  *** FAILED to initialise NIF *** Error =%d",aError);
   316 
   314 
   317 		// Initialise shutdown sequence
   315 		// Initialise shutdown sequence
   318 		switch (aState)
   316 		switch (aState)
   319 		{
   317 		{
   320 		case MControllerObserver::EBcaController:
   318 		case MControllerObserver::EBcaController:
   321 			ShutDown(MControllerObserver::EInitialised, aError);
   319 			ShutDown(MControllerObserver::EInitialised, aError);
   322 			break;
   320 			break;
   323 		default:
   321 		default:
   324 			_LOG_L2C3(_L8("ERROR CRawIPFlow: Unknown state:%d in NIF: %S"), aState, &KNifName);
   322 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_3, "ERROR CRawIPFlow: Unknown state:%d in NIF: %S", aState, KNifName);
   325 			User::Leave(KErrUnknown);
   323 			User::Leave(KErrUnknown);
   326 			break;
   324 			break;
   327 			}
   325 			}
   328 		return;
   326 		return;
   329 		}
   327 		}
   334 		{
   332 		{
   335 		// Update local state from TSY information originally from Agent.
   333 		// Update local state from TSY information originally from Agent.
   336 		GetBinder()->UpdateContextConfigL(*iAgentProvision->iGprsConfig);
   334 		GetBinder()->UpdateContextConfigL(*iAgentProvision->iGprsConfig);
   337 		GetBinder()->UpdateConnectionSpeed(iAgentProvision->iConnectionSpeed);
   335 		GetBinder()->UpdateConnectionSpeed(iAgentProvision->iConnectionSpeed);
   338 
   336 
   339 		_LOG_L1C2(_L8("Port details %S"), &iProvision->GetPortName());
   337 		OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_4, "Port details %S", iProvision->GetPortName());
   340 		iBcaController->SetPort(iProvision->GetPortName());
   338 		iBcaController->SetPort(iProvision->GetPortName());
   341 
   339 
   342 		_LOG_L1C3(_L8("bcaName details %S,%S"),&iProvision->GetBCAStack(), &iProvision->GetBCAName());
   340 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_5, "bcaName details %S,%S",iProvision->GetBCAStack(), iProvision->GetBCAName());
   343 		iBcaController->SetBcaStackAndName(iProvision->GetBCAStack(), iProvision->GetBCAName());
   341 		iBcaController->SetBcaStackAndName(iProvision->GetBCAStack(), iProvision->GetBCAName());
   344 
   342 
   345 		_LOG_L1C2(_L8("IAP ID details %u"), iProvision->GetIAPid());
   343 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_6, "IAP ID details %u", iProvision->GetIAPid());
   346 		iBcaController->SetIapId(iProvision->GetIAPid());
   344 		iBcaController->SetIapId(iProvision->GetIAPid());
   347 
   345 
   348 		UpdateContextState(RPacketContext::EStatusActive, KErrNone);
   346 		UpdateContextState(RPacketContext::EStatusActive, KErrNone);
   349 
   347 
   350 		iBcaController->StartL();
   348 		iBcaController->StartL();
   351 		}
   349 		}
   352 		break;
   350 		break;
   353 	case MControllerObserver::EBcaController:
   351 	case MControllerObserver::EBcaController:
   354 		_LOG_L1C1(_L8("  ***** NIF INITIALISED *****"));
   352 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_7, "  ***** NIF INITIALISED *****");
   355 		LinkLayerUp();
   353 		LinkLayerUp();
   356 		break;
   354 		break;
   357 	default:
   355 	default:
   358 		_LOG_L2C3(_L8("ERROR CRawIPFlow: Unknown state:%d in NIF: %S"), aState, &KNifName);
   356 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_INITIALISEL_8, "ERROR CRawIPFlow: Unknown state:%d in NIF: %S", aState, KNifName);
   359 		User::Leave(KErrUnknown);
   357 		User::Leave(KErrUnknown);
   360 		break;
   358 		break;
   361 		}
   359 		}
   362 	}
   360 	}
   363 
   361 
   369  *
   367  *
   370  * @param aState The current state
   368  * @param aState The current state
   371  * @param aError A possible error (only during initialisation)
   369  * @param aError A possible error (only during initialisation)
   372  */
   370  */
   373 	{
   371 	{
   374 	_LOG_L1C4(_L8("CRawIPFlow %08x:\tShutDown(aState %d, aError %d)"),
   372 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_SHUTDOWN_1, "CRawIPFlow %08x:\tShutDown(aState %d, aError %d)",(TUint)this, aState, aError);
   375 		this, aState, aError);	
       
   376 			
   373 			
   377 	if (aError != KErrNone)
   374 	if (aError != KErrNone)
   378 		{
   375 		{
   379 		// Flow is shutting down due to an error.
   376 		// Flow is shutting down due to an error.
   380 		// The error code must be stored in order to call linklayer down
   377 		// The error code must be stored in order to call linklayer down
   389 		break;
   386 		break;
   390 	case MControllerObserver::EBcaController:
   387 	case MControllerObserver::EBcaController:
   391 		LinkLayerDown(iInitError);
   388 		LinkLayerDown(iInitError);
   392 		break;
   389 		break;
   393 	default:
   390 	default:
   394 		_LOG_L2C1(_L8("ERROR CRawIPFlow: Unknown Shutdown step"));
   391 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_SHUTDOWN_2, "ERROR CRawIPFlow: Unknown Shutdown step");
   395 		_BTT_PANIC(KNifName,KNifUnknownShutDownState);
   392         OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_SHUTDOWN_3, "PANIC: %S %d", KNifName, KNifUnknownShutDownState);
       
   393           User::Panic(KNifName,KNifUnknownShutDownState);
   396 		break;
   394 		break;
   397 		}
   395 		}
   398 	}
   396 	}
   399 
   397 
   400 CBinderBase* CRawIPFlow::GetBinder()
   398 CBinderBase* CRawIPFlow::GetBinder()
   424  *
   422  *
   425  * @param aState The new state
   423  * @param aState The new state
   426  * @param aError A possible error
   424  * @param aError A possible error
   427  */
   425  */
   428 	{
   426 	{
   429 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tUpdateContextState(aState %d)"), this, aState);
   427 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_UPDATECONTEXTSTATE_1, "CRawIPFlow %08x:\tUpdateContextState(aState %d)",(TUint) this, aState);
   430 
   428 
   431 	// Note that we do not need to close the Flow down if there's been an
   429 	// Note that we do not need to close the Flow down if there's been an
   432 	// error, as the context state machine will do this for us.
   430 	// error, as the context state machine will do this for us.
   433 
   431 
   434 	iContextStatus = aState;
   432 	iContextStatus = aState;
   449 // MFlowBinderControl methods
   447 // MFlowBinderControl methods
   450 //
   448 //
   451 
   449 
   452 MLowerControl* CRawIPFlow::GetControlL(const TDesC8& aProtocol)
   450 MLowerControl* CRawIPFlow::GetControlL(const TDesC8& aProtocol)
   453 	{
   451 	{
   454 #ifdef __BTT_LOGGING__
   452 
   455 	//TBuf8<256> debugBuffer;
   453 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_GETCONTROLL_1, "CRawIPFlow %08x:\tGetControlL(aProtocol %s)", (TUint)this, aProtocol);
   456 	//debugBuffer.Copy(aProtocol);
   454 
   457 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tGetControlL(aProtocol %S)"), this, &aProtocol);
       
   458 #endif
       
   459 
   455 
   460 	// IPv4 and ICMP Protocols
   456 	// IPv4 and ICMP Protocols
   461 	if (aProtocol.CompareF(KDescIp()) == 0 || aProtocol.CompareF(KDescIcmp()) == 0)
   457 	if (aProtocol.CompareF(KDescIp()) == 0 || aProtocol.CompareF(KDescIcmp()) == 0)
   462 		{
   458 		{
   463 		if (!iBinder)
   459 		if (!iBinder)
   464 			{
   460 			{
   465 			iBinder = new (ELeave) CIPv4Binder(*this, iTheLogger);
   461 			iBinder = new (ELeave) CIPv4Binder(*this);
   466 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
   462 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
   467  			iBcaController->SetType(KIp4FrameType);
   463  			iBcaController->SetType(KIp4FrameType);
   468 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
   464 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
   469 			}
   465 			}
   470 		else
   466 		else
   471 			{
   467 			{
   472 			_LOG_L1C2(_L8("CRawIPFlow %08x:\tGetControlL(): IPv4 binder already exists"), this);
   468 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_GETCONTROLL_2, "CRawIPFlow %08x:\tGetControlL(): IPv4 binder already exists", this);
   473 			}
   469 			}
   474 		}
   470 		}
   475 	// IPv6 Protocol
   471 	// IPv6 Protocol
   476 	else if (aProtocol.CompareF(KDescIp6()) == 0)
   472 	else if (aProtocol.CompareF(KDescIp6()) == 0)
   477 		{
   473 		{
   478 		if (!iBinder)
   474 		if (!iBinder)
   479 			{
   475 			{
   480 			iBinder = new (ELeave) CIPv6Binder(*this, iTheLogger);
   476 			iBinder = new (ELeave) CIPv6Binder(*this);
   481 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
   477 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
   482  			iBcaController->SetType(KIp6FrameType);
   478  			iBcaController->SetType(KIp6FrameType);
   483 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
   479 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
   484 			}
   480 			}
   485 		else
   481 		else
   486 			{
   482 			{
   487 			_LOG_L1C2(_L8("CRawIPFlow %08x:\tGetControlL(): IPv6 binder already exists"), this);
   483 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_GETCONTROLL_3, "CRawIPFlow %08x:\tGetControlL(): IPv6 binder already exists", this);
   488 			}
   484 			}
   489 		}		
   485 		}		
   490 	else
   486 	else
   491 		{
   487 		{
   492 		User::Leave(KErrNotSupported);
   488 		User::Leave(KErrNotSupported);
   515 	return iBinder->Bind(aReceiver, aControl);
   511 	return iBinder->Bind(aReceiver, aControl);
   516 	}
   512 	}
   517 
   513 
   518 void CRawIPFlow::Unbind(MUpperDataReceiver* aUpperReceiver, MUpperControl* aUpperControl)
   514 void CRawIPFlow::Unbind(MUpperDataReceiver* aUpperReceiver, MUpperControl* aUpperControl)
   519     {
   515     {
   520     _LOG_L1C2(_L8("CRawIPFlow %08x:\tUnbind()"), this);
   516     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_UNBIND_1, "CRawIPFlow %08x:\tUnbind()", this);
   521 
   517 
   522 	if (iBinder)
   518 	if (iBinder)
   523 	    {
   519 	    {
   524         iBinder->Unbind(aUpperReceiver, aUpperControl);
   520         iBinder->Unbind(aUpperReceiver, aUpperControl);
   525 
   521 
   638 			//to the flow representing the default, the datapath needs
   634 			//to the flow representing the default, the datapath needs
   639 			//to perform a transparent swap too, so that the upper layer
   635 			//to perform a transparent swap too, so that the upper layer
   640 			//doesn't notice anything. It does that by swapping the
   636 			//doesn't notice anything. It does that by swapping the
   641 			//flows below the binders.
   637 			//flows below the binders.
   642 			CBinderBase* localBinder = iBinder;
   638 			CBinderBase* localBinder = iBinder;
   643 			CBttLogger* logger = localBinder->iTheLogger;
       
   644 
   639 
   645 			TBinderControlProxy* localBinderControl = iBinderControl;
   640 			TBinderControlProxy* localBinderControl = iBinderControl;
   646 			iBinder = otherFlow->iBinder;
   641 			iBinder = otherFlow->iBinder;
   647 			otherFlow->iBinder->ChangeFlow(*this);
   642 			otherFlow->iBinder->ChangeFlow(*this);
   648 			localBinder->ChangeFlow(*otherFlow);
   643 			localBinder->ChangeFlow(*otherFlow);
   650 			iBinderControl = otherFlow->iBinderControl;
   645 			iBinderControl = otherFlow->iBinderControl;
   651 			otherFlow->iBinderControl = localBinderControl;
   646 			otherFlow->iBinderControl = localBinderControl;
   652 			otherFlow->iBinderControl->iFlow = otherFlow;
   647 			otherFlow->iBinderControl->iFlow = otherFlow;
   653 			iBinderControl->iFlow = this;
   648 			iBinderControl->iFlow = this;
   654 
   649 
   655 			iBinder->iTheLogger = logger;
       
   656 
   650 
   657 			iSubConnectionProvider.Close();
   651 			iSubConnectionProvider.Close();
   658 			iSubConnectionProvider.Open(address_cast<TNodeId>(rejoinMsg.iNodeId));
   652 			iSubConnectionProvider.Open(address_cast<TNodeId>(rejoinMsg.iNodeId));
   659 			}
   653 			}
   660 			break;
   654 			break;
   724 Just save the pointer for now - validate it later on StartFlow.
   718 Just save the pointer for now - validate it later on StartFlow.
   725 
   719 
   726 @param aData provisioning pointer from message
   720 @param aData provisioning pointer from message
   727 */
   721 */
   728 	{
   722 	{
   729 	_LOG_L1C2(_L8("CRawIPFlow %08x:\tProvisionConfig()"), this);
   723 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_PROVISIONCONFIG_1, "CRawIPFlow %08x:\tProvisionConfig()", this);
   730 
   724 
   731 	AccessPointConfig().Close();
   725 	AccessPointConfig().Close();
   732 	AccessPointConfig().Open(aConfigData);
   726 	AccessPointConfig().Open(aConfigData);
   733 
   727 
   734     iProvision = static_cast<const CBCAProvision*>(AccessPointConfig().FindExtension(
   728     iProvision = static_cast<const CBCAProvision*>(AccessPointConfig().FindExtension(
   741 Retrieve provisioning information available only at StartFlow time.
   735 Retrieve provisioning information available only at StartFlow time.
   742 */
   736 */
   743 	{
   737 	{
   744     if (iProvision == NULL)
   738     if (iProvision == NULL)
   745         {
   739         {
   746         _LOG_L1C1(_L8("CRawIPFlow:\tProvisionConfigL() - CBCAProvision config incomplete"));
   740         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_DYNAMICPROVISIONCONFIGL_1, "CRawIPFlow:\tProvisionConfigL() - CBCAProvision config incomplete");
   747 		iProvisionError = KErrCorrupt;
   741 		iProvisionError = KErrCorrupt;
   748 		return;
   742 		return;
   749         }
   743         }
   750 
   744 
   751     ASSERT(iAgentProvision == NULL);
   745     ASSERT(iAgentProvision == NULL);
   759 
   753 
   760     const CIPConfig* wcdmaIpProvision = static_cast<const CIPConfig*>(AccessPointConfig().FindExtension(
   754     const CIPConfig* wcdmaIpProvision = static_cast<const CIPConfig*>(AccessPointConfig().FindExtension(
   761             STypeId::CreateSTypeId(CIPConfig::EUid, CIPConfig::ETypeId)));
   755             STypeId::CreateSTypeId(CIPConfig::EUid, CIPConfig::ETypeId)));
   762     if (wcdmaIpProvision == NULL)
   756     if (wcdmaIpProvision == NULL)
   763         {
   757         {
   764         _LOG_L1C2(_L8("CRawIPFlow %08x:\tDynamicProvisionConfigL() - WCDMA config incomplete"), this);
   758         OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_DYNAMICPROVISIONCONFIGL_2, "CRawIPFlow %08x:\tDynamicProvisionConfigL() - WCDMA config incomplete", this);
   765 		iProvisionError = KErrCorrupt;
   759 		iProvisionError = KErrCorrupt;
   766 		return;
   760 		return;
   767         }
   761         }
   768    	// Pass pointer to binder specific provisioning information to binder
   762    	// Pass pointer to binder specific provisioning information to binder
   769 	if (iBinder)
   763 	if (iBinder)
   787 
   781 
   788 These used to be implemented as Agent <-> NIF Notifications, hence the method name to promote
   782 These used to be implemented as Agent <-> NIF Notifications, hence the method name to promote
   789 some historical understanding.
   783 some historical understanding.
   790 */
   784 */
   791 	{
   785 	{
   792 	_LOG_L1C3(_L8("CRawIPFlow %08x:\tNotification(aEvent %d)"), this, aEvent);
   786 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_NOTIFICATION_1, "CRawIPFlow %08x:\tNotification(aEvent %d)", (TUint)this, aEvent);
   793 
   787 
   794 	switch (aEvent)
   788 	switch (aEvent)
   795 	{
   789 	{
   796     case EAgentToNifEventTypeDisableTimers: //GPRS suspension
   790 	case EAgentToNifEventTypeDisableTimers: //GPRS suspension
   797         {
   791 		{
   798         _LOG_L1C1(_L8("CRawIPFlow::Received Suspend from Agent..."));
   792 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_NOTIFICATION_2, "CRawIPFlow::Received Suspend from Agent...");
   799 
   793 
   800         // Let the BCA controller know that data can no longer be sent over
   794         // Let the BCA controller know that data can no longer be sent over
   801         // the PDP context.
   795         // the PDP context.
   802         iBcaController->BlockSending();
   796         iBcaController->BlockSending();
   803 
   797 
   804         break;
   798         break;
   805         }
   799         }
   806 
   800 
   807     case EAgentToNifEventTypeEnableTimers: //GPRS resumption
   801     case EAgentToNifEventTypeEnableTimers: //GPRS resumption
   808         {
   802         {
   809         _LOG_L1C1(_L8("CRawIPFlow::Received Resume from Agent..."));
   803         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_NOTIFICATION_3, "CRawIPFlow::Received Resume from Agent...");
   810         iBcaController->ResumeSending();
   804         iBcaController->ResumeSending();
   811 
   805 
   812         break;
   806         break;
   813         }
   807         }
   814 	case (EAgentToNifEventTypeDisableConnection) :
   808 	case (EAgentToNifEventTypeDisableConnection) :
   815 		{
   809 		{
   816 		// This is handled by NIFMAN and passed to Flow as a Stop() call
   810 		// This is handled by NIFMAN and passed to Flow as a Stop() call
   817 		_LOG_L1C1(_L8("CRawIPFlow::Received Disable connection from Agent..."));
   811 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_NOTIFICATION_4, "CRawIPFlow::Received Disable connection from Agent...");
   818 		break;
   812 		break;
   819 		}
   813 		}
   820 
   814 
   821 	default :
   815 	default :
   822 		{
   816 		{
   823 		_LOG_L1C2(_L8("CRawIPFlow::Received Notification [%d] from Agent..."), aEvent);
   817 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CRAWIPFLOW_NOTIFICATION_5, "CRawIPFlow::Received Notification [%d] from Agent...", aEvent);
   824 		break;
   818 		break;
   825 		}
   819 		}
   826 	}//endswitch
   820 	}//endswitch
   827 	}
   821 	}
   828 
   822