telephonyprotocols/rawipnif/rawipnif2/src/IPv4Binder.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     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".
    18 
    18 
    19 /**
    19 /**
    20  @file
    20  @file
    21 */
    21 */
    22 
    22 
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "IPv4BinderTraces.h"
       
    27 #endif
       
    28 
    23 #include <etelpckt.h>
    29 #include <etelpckt.h>
    24 #include <in_iface.h>
    30 #include <in_iface.h>
    25 #include "RawIP2Flow.h"
    31 #include "RawIP2Flow.h"
    26 #include "IPv4Binder.h"
    32 #include "IPv4Binder.h"
    27 #include <comms-infras/linkprovision.h>
    33 #include <comms-infras/linkprovision.h>
    28 
    34 
    29 #ifdef WCDMA_STUB
    35 #ifdef WCDMA_STUB
    30 #include <networking/umtsnifcontrolif.h>
    36 #include <networking/umtsnifcontrolif.h>
    31 #endif
    37 #endif
    32 
    38 
    33 #define LOG_IP_ADDRESS(desc,addr) _LOG_L1C5(_L8("    " desc " = %d.%d.%d.%d"), \
    39 
    34 			addr >> 24, (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF);
    40 CIPv4Binder::CIPv4Binder(CRawIP2Flow& aFlow)
    35 
       
    36 CIPv4Binder::CIPv4Binder(CRawIP2Flow& aFlow, CBttLogger* aTheLogger)
       
    37 /**
    41 /**
    38  * Constructor
    42  * Constructor
    39  */ 
    43  */ 
    40 	: CBinderBase(aFlow,aTheLogger),
    44 	: CBinderBase(aFlow),
    41 	  iSpeedMetric(KDefaultSpeedMetric)
    45 	  iSpeedMetric(KDefaultSpeedMetric)
    42 	{	
    46 	{	
    43 	}
    47 	}
    44 
    48 
    45 CIPv4Binder::~CIPv4Binder()
    49 CIPv4Binder::~CIPv4Binder()
    71  * @param aName The command to perform
    75  * @param aName The command to perform
    72  * @param aOption Data to be input/output as a result of the command
    76  * @param aOption Data to be input/output as a result of the command
    73  * @return Standard error codes
    77  * @return Standard error codes
    74  */
    78  */
    75 	{
    79 	{
    76 	_LOG_L1C3(_L8("CIPv4Binder::Control [aLevel=%d, aName=%d]"),
    80 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_CONTROL_1, "CIPv4Binder::Control [aLevel=%d, aName=%d]",aLevel, aName);
    77 		aLevel, aName);
       
    78 
    81 
    79 	if (aLevel == KSOLInterface)
    82 	if (aLevel == KSOLInterface)
    80 		{
    83 		{
    81 		switch (aName)
    84 		switch (aName)
    82 			{
    85 			{
   151 	return KErrNotSupported;
   154 	return KErrNotSupported;
   152 	}
   155 	}
   153 
   156 
   154 TInt CIPv4Binder::GetConfig(TBinderConfig& aConfig)
   157 TInt CIPv4Binder::GetConfig(TBinderConfig& aConfig)
   155 	{
   158 	{
   156 	_LOG_L1C1(_L8("CIPv4Binder::GetConfig"));
   159 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_GETCONFIG_1, "CIPv4Binder::GetConfig");
   157     TBinderConfig4* config = TBinderConfig::Cast<TBinderConfig4>(aConfig);
   160     TBinderConfig4* config = TBinderConfig::Cast<TBinderConfig4>(aConfig);
   158     
   161     
   159    	if(config == NULL)
   162    	if(config == NULL)
   160    		{
   163    		{
   161    		return KErrNotSupported;
   164    		return KErrNotSupported;
   165 	
   168 	
   166 	config->iInfo.iFeatures = KIfCanBroadcast | KIfCanMulticast;		/* Feature flags */
   169 	config->iInfo.iFeatures = KIfCanBroadcast | KIfCanMulticast;		/* Feature flags */
   167 	config->iInfo.iMtu = KDefaultMtu;				/* Maximum transmission unit. */
   170 	config->iInfo.iMtu = KDefaultMtu;				/* Maximum transmission unit. */
   168 	config->iInfo.iRMtu = KDefaultMtu;				/* Maximum transmission unit for receiving. */
   171 	config->iInfo.iRMtu = KDefaultMtu;				/* Maximum transmission unit for receiving. */
   169 	config->iInfo.iSpeedMetric = iSpeedMetric;		/* approximation of the interface speed in Kbps. */
   172 	config->iInfo.iSpeedMetric = iSpeedMetric;		/* approximation of the interface speed in Kbps. */
   170     LOG_IP_ADDRESS("Local IP address from TBinderConfig", iSettings.iLocalAddr);
   173 
   171 	
   174 	OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_GETCONFIG_2, "Local IP address from TBinderConfig = %u.%u.%u.%u",iSettings.iLocalAddr >> 24, (iSettings.iLocalAddr >> 16) & 0xFF, (iSettings.iLocalAddr >> 8) & 0xFF, iSettings.iLocalAddr & 0xFF);   
       
   175     
   172 	config->iAddress.SetAddress(iSettings.iLocalAddr);		/* Interface IP address. */
   176 	config->iAddress.SetAddress(iSettings.iLocalAddr);		/* Interface IP address. */
   173 	config->iNetMask.SetAddress(iSettings.iNetMask);			/* IP netmask. */
   177 	config->iNetMask.SetAddress(iSettings.iNetMask);			/* IP netmask. */
   174 	config->iBrdAddr.SetAddress(iSettings.iBroadcastAddr);	/* IP broadcast address. */
   178 	config->iBrdAddr.SetAddress(iSettings.iBroadcastAddr);	/* IP broadcast address. */
   175 	config->iDefGate.SetAddress(iSettings.iDefGateway);		/* IP default gateway or peer address (if known). */
   179 	config->iDefGate.SetAddress(iSettings.iDefGateway);		/* IP default gateway or peer address (if known). */
   176 	config->iNameSer1.SetAddress(iSettings.iPrimaryDns);		/* IP primary name server (if any). */
   180 	config->iNameSer1.SetAddress(iSettings.iPrimaryDns);		/* IP primary name server (if any). */
   187  *
   191  *
   188  * @param aContextParameters Parameters of the context to delete
   192  * @param aContextParameters Parameters of the context to delete
   189  * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone
   193  * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone
   190  */
   194  */
   191 	{
   195 	{
   192 	_LOG_L1C1(_L8("CIPv4Binder::DeleteContext"));
   196 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_DELETECONTEXT_1, "CIPv4Binder::DeleteContext");
   193 
   197 
   194 	if (aContextParameters.Length() != sizeof(TContextParameters))
   198 	if (aContextParameters.Length() != sizeof(TContextParameters))
   195 		{
   199 		{
   196 		return KErrArgument;
   200 		return KErrArgument;
   197 		}
   201 		}
   221  *
   225  *
   222  * @param aConfig The new context config
   226  * @param aConfig The new context config
   223  */
   227  */
   224 void CIPv4Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig)
   228 void CIPv4Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig)
   225 	{
   229 	{
   226 	_LOG_L1C1(_L8("CIPv4Binder::UpdateContextConfig"));
   230 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_1, "CIPv4Binder::UpdateContextConfig");
   227 
   231 
   228 	// Get our IP address from the GPRS context config.
   232 	// Get our IP address from the GPRS context config.
   229 	TInetAddr address;
   233 	TInetAddr address;
   230 	
   234 	
   231 	TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
   235 	TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
   247 
   251 
   248 	// We've got our IP address! Let's save it.
   252 	// We've got our IP address! Let's save it.
   249 	if (ret == KErrNone)
   253 	if (ret == KErrNone)
   250 		{
   254 		{
   251 		iSettings.iLocalAddr = address.Address();
   255 		iSettings.iLocalAddr = address.Address();
   252 		LOG_IP_ADDRESS("Got local IP address from context", iSettings.iLocalAddr);
   256 		OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_2, "Got local IP address from context = %u.%u.%u.%u",iSettings.iLocalAddr >> 24, (iSettings.iLocalAddr >> 16) & 0xFF, (iSettings.iLocalAddr >> 8) & 0xFF, iSettings.iLocalAddr & 0xFF);
   253 		iSettings.iDefGateway = address.Address();
   257 		iSettings.iDefGateway = address.Address();
   254 		_LOG_L1C1(_L8("Set Default Gateway to local IP address"));
   258 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_3, "Set Default Gateway to local IP address");
   255 		}
   259 		}
   256 	else
   260 	else
   257 		{
   261 		{
   258 		_LOG_L2C2(_L8("Couldn't get IP address from GPRS config (err: %d)"),
   262 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_4, "Couldn't get IP address from GPRS config (err: %d)",ret);
   259 			ret);
       
   260 
   263 
   261 		// Don't leave on this error: we may still be OK if we read some
   264 		// Don't leave on this error: we may still be OK if we read some
   262 		// settings from CommDB.
   265 		// settings from CommDB.
   263 		}
   266 		}
   264 
   267 
   276 		ret = address.Input(tempAddr);
   279 		ret = address.Input(tempAddr);
   277 
   280 
   278 		if (ret == KErrNone)
   281 		if (ret == KErrNone)
   279 			{
   282 			{
   280 			iSettings.iPrimaryDns = address.Address();
   283 			iSettings.iPrimaryDns = address.Address();
   281 			LOG_IP_ADDRESS("Got primary DNS from context PCO", iSettings.iPrimaryDns);
   284 			OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_5, "Got primary DNS from context PCO = %u.%u.%u.%u",iSettings.iPrimaryDns >> 24, (iSettings.iPrimaryDns >> 16) & 0xFF, (iSettings.iPrimaryDns >> 8) & 0xFF, iSettings.iPrimaryDns & 0xFF);
   282 			}
   285 			}
   283 		else
   286 		else
   284 			{
   287 			{
   285 			_LOG_L2C2(_L8("Couldn't get primary DNS address from GPRS config (err: %d)"),
   288 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_6, "Couldn't get primary DNS address from GPRS config (err: %d)",ret);
   286 				ret);
       
   287 
   289 
   288 			// Don't leave on this error: we may still be OK if we read some
   290 			// Don't leave on this error: we may still be OK if we read some
   289 			// settings from CommDB.
   291 			// settings from CommDB.
   290 			}
   292 			}
   291 
   293 
   293 		ret = address.Input(tempAddr);
   295 		ret = address.Input(tempAddr);
   294 
   296 
   295 		if (ret == KErrNone)
   297 		if (ret == KErrNone)
   296 			{
   298 			{
   297 			iSettings.iSecondaryDns = address.Address();
   299 			iSettings.iSecondaryDns = address.Address();
   298 			LOG_IP_ADDRESS("Got secondary DNS from context PCO", iSettings.iPrimaryDns);
   300 	        OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_7, "Got secondary DNS from context PCO = %u.%u.%u.%u",iSettings.iSecondaryDns >> 24, (iSettings.iSecondaryDns >> 16) & 0xFF, (iSettings.iSecondaryDns >> 8) & 0xFF, iSettings.iSecondaryDns);
   299 			}
   301 			}
   300 		else
   302 		else
   301 			{
   303 			{
   302 			_LOG_L2C2(_L8("Couldn't get secondary DNS address from GPRS config (err: %d)"),
   304 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_8, "Couldn't get secondary DNS address from GPRS config (err: %d)",ret);
   303 				ret);
       
   304 
   305 
   305 			// Don't leave on this error: we may still be OK if we read some
   306 			// Don't leave on this error: we may still be OK if we read some
   306 			// settings from CommDB.
   307 			// settings from CommDB.
   307 			}
   308 			}
   308 		}
   309 		}
   309 	else
   310 	else
   310 		{
   311 		{
   311 		LOG_IP_ADDRESS("Using CommDB DNS address - Primary ", iSettings.iPrimaryDns);
   312         OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_9, "Using CommDB DNS address - Primary = %u.%u.%u.%u",iSettings.iPrimaryDns >> 24, (iSettings.iPrimaryDns >> 16) & 0xFF, (iSettings.iPrimaryDns >> 8) & 0xFF, iSettings.iPrimaryDns & 0xFF);
   312 		LOG_IP_ADDRESS("                         - Secondary ", iSettings.iSecondaryDns);
   313 		OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_10, "                         - Secondary = %u.%u.%u.%u",iSettings.iSecondaryDns >> 24, (iSettings.iSecondaryDns >> 16) & 0xFF, (iSettings.iSecondaryDns >> 8) & 0xFF, iSettings.iSecondaryDns);
   313 		}
   314 		}
   314 
   315 
   315 
   316 
   316 	// TProtocolConfigOptionV2::iMiscBuffer is not the correct way to pass a gateway
   317 	// TProtocolConfigOptionV2::iMiscBuffer is not the correct way to pass a gateway
   317 	// address - data needs to be passed in TLV format but there are no TLV content tags
   318 	// address - data needs to be passed in TLV format but there are no TLV content tags
   325 		ret = address.Input(tempAddr);
   326 		ret = address.Input(tempAddr);
   326 
   327 
   327 		if (ret == KErrNone)
   328 		if (ret == KErrNone)
   328 			{
   329 			{
   329 			iSettings.iDefGateway = address.Address();
   330 			iSettings.iDefGateway = address.Address();
   330 			LOG_IP_ADDRESS("Got default gateway", iSettings.iDefGateway);
   331 			OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_10, "Got default gateway = %u.%u.%u.%u",iSettings.iDefGateway >> 24, (iSettings.iDefGateway >> 16) & 0xFF, (iSettings.iDefGateway >> 8) & 0xFF, iSettings.iDefGateway);
   331 			}
   332 			}
   332 		else
   333 		else
   333 			{
   334 			{
   334 			_LOG_L2C2(_L8("Couldn't get default gateway from GPRS config (err: %d)"),
   335 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_6, "Couldn't get default gateway from GPRS config (err: %d)",ret);
   335 				ret);
       
   336 			}
   336 			}
   337 		}*/
   337 		}*/
   338 	}
   338 	}
   339 
   339 
   340 void CIPv4Binder::UpdateConnectionSpeed(TUint aConnectionSpeed)
   340 void CIPv4Binder::UpdateConnectionSpeed(TUint aConnectionSpeed)
   342  * Sets the speed metric to return to TCP/IP, based on what the TSY tells us.
   342  * Sets the speed metric to return to TCP/IP, based on what the TSY tells us.
   343  *
   343  *
   344  * @param aConnectionSpeed Our connection speed
   344  * @param aConnectionSpeed Our connection speed
   345  */
   345  */
   346 	{
   346 	{
   347 	_LOG_L1C1(_L8("CIPv4Binder::UpdateConnectionSpeed"));
   347 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONNECTIONSPEED_1, "CIPv4Binder::UpdateConnectionSpeed");
   348 
   348 
   349 	iSpeedMetric = aConnectionSpeed;
   349 	iSpeedMetric = aConnectionSpeed;
   350 	}
   350 	}
   351 
   351 
   352 ESock::MLowerDataSender::TSendResult CIPv4Binder::Send(RMBufChain& aPdu)
   352 ESock::MLowerDataSender::TSendResult CIPv4Binder::Send(RMBufChain& aPdu)
   360  *
   360  *
   361  * @param aPdu The outgoing packet
   361  * @param aPdu The outgoing packet
   362  * @return Standard error codes
   362  * @return Standard error codes
   363  */
   363  */
   364 	{
   364 	{
   365 	_LOG_L1C1(_L8("CIPv4Binder::Send"));
   365 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_SEND1_1, "CIPv4Binder::Send");
   366 
   366 
   367 #ifdef __BTT_LOGGING__
   367 #ifdef __BTT_LOGGING__
   368 	LogPacket(static_cast<RMBufChain&>(aPdu));
   368 	LogPacket(static_cast<RMBufChain&>(aPdu));
   369 #endif
   369 #endif
   370 
   370 
   385  *
   385  *
   386  * @param aEvent Not used
   386  * @param aEvent Not used
   387  * @param aInfo Not used 
   387  * @param aInfo Not used 
   388  */
   388  */
   389 	{
   389 	{
   390 	_LOG_L1C1(_L8("CIPv4Binder::Notification"));
   390 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_NOTIFICATION_1, "CIPv4Binder::Notification");
   391 
   391 
   392 	return KErrNone;
   392 	return KErrNone;
   393 	}
   393 	}
   394 
   394 
   395 void CIPv4Binder::StartSending()
   395 void CIPv4Binder::StartSending()
   397  * Indicates to the protocol layer that the NIF is ready to send packets.
   397  * Indicates to the protocol layer that the NIF is ready to send packets.
   398  *
   398  *
   399  * @param aProtocol A pointer to a protocol
   399  * @param aProtocol A pointer to a protocol
   400  */
   400  */
   401 	{
   401 	{
   402 	_LOG_L1C1(_L8("CIPv4Binder::StartSending()"));
   402 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_STARTSENDING_1, "CIPv4Binder::StartSending()");
   403 
   403 
   404 	CBinderBase::StartSending();
   404 	CBinderBase::StartSending();
   405 	}
   405 	}
   406 
   406 
   407 TBool CIPv4Binder::WantsProtocol(TUint16 aProtocolCode)
   407 TBool CIPv4Binder::WantsProtocol(TUint16 aProtocolCode)
   409  * Indicates the type of protocol implemented by this class.
   409  * Indicates the type of protocol implemented by this class.
   410  *
   410  *
   411  * @param aProtocolCode The protocol type
   411  * @param aProtocolCode The protocol type
   412  */
   412  */
   413 	{
   413 	{
   414 	_LOG_L1C2(_L8("CIPv4Binder::WantsProtocol [aProtocolCode=%X]"),
   414 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_WANTSPROTOCOL_1, "CIPv4Binder::WantsProtocol [aProtocolCode=%X]",aProtocolCode);
   415 		aProtocolCode);
       
   416 
   415 
   417 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
   416 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
   418 	return ((aProtocolCode & 0x00FF) == KIp4FrameType);
   417 	return ((aProtocolCode & 0x00FF) == KIp4FrameType);
   419 #else
   418 #else
   420 	(void) aProtocolCode;
   419 	(void) aProtocolCode;
   433  * TCP/IP stack.
   432  * TCP/IP stack.
   434  *
   433  *
   435  * @param aPdu The incoming packet
   434  * @param aPdu The incoming packet
   436  */
   435  */
   437 	{
   436 	{
   438 	_LOG_L1C1(_L8("CIPv4Binder::Process"));
   437 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_PROCESS1_1, "CIPv4Binder::Process");
   439 
   438 
   440 #ifdef __BTT_LOGGING__
   439 #ifdef __BTT_LOGGING__
   441 	LogPacket(static_cast<RMBufChain&>(aPdu));
   440 	LogPacket(static_cast<RMBufChain&>(aPdu));
   442 #endif
   441 #endif
   443 
   442 
   450 
   449 
   451 	// Pass incoming packets up to the protocol, unless it hasn't
   450 	// Pass incoming packets up to the protocol, unless it hasn't
   452 	// been bound yet.
   451 	// been bound yet.
   453 	if (iUpperReceiver && WantsProtocol(protocolCode))
   452 	if (iUpperReceiver && WantsProtocol(protocolCode))
   454 		{		
   453 		{		
   455 		_LOG_L1C1(_L8("CIPv4Binder: Packet Sent to TCP/IP Protocol!!!"));
   454 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_PROCESS1_2, "CIPv4Binder: Packet Sent to TCP/IP Protocol!!!");
   456 		iUpperReceiver->Process(static_cast<RMBufChain&>(aPdu));
   455 		iUpperReceiver->Process(static_cast<RMBufChain&>(aPdu));
   457 		}
   456 		}
   458 	else 
   457 	else 
   459 		{
   458 		{
   460 		_LOG_L2C1(_L8("WARNING: dumping incoming packet, no protocol bound"));
   459 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_PROCESS1_3, "WARNING: dumping incoming packet, no protocol bound");
   461 		aPdu.Free();
   460 		aPdu.Free();
   462 		}
   461 		}
   463 	}
   462 	}
   464 
   463 
   465 //
   464 //
   485 Called from RawIP Flow.
   484 Called from RawIP Flow.
   486 
   485 
   487 @param aProvision Provisioning structure from Control side.
   486 @param aProvision Provisioning structure from Control side.
   488 */
   487 */
   489 	{
   488 	{
   490 	_LOG_L1C1(_L8("CIPv4Binder::SetProvision"));
   489 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_SETPROVISION_1, "CIPv4Binder::SetProvision");
   491 	iSettings.iLocalAddr	 = aProvision.GetIpAddress();
   490 	iSettings.iLocalAddr	 = aProvision.GetIpAddress();
   492 	iSettings.iNetMask		 = aProvision.GetIpNetMask();
   491 	iSettings.iNetMask		 = aProvision.GetIpNetMask();
   493 	iSettings.iBroadcastAddr = aProvision.GetBroadCastAddr();
   492 	iSettings.iBroadcastAddr = aProvision.GetBroadCastAddr();
   494 	iSettings.iDefGateway	 = aProvision.GetIpGateway();
   493 	iSettings.iDefGateway	 = aProvision.GetIpGateway();
   495 	iSettings.iPrimaryDns	 = aProvision.GetIp4NameServer1();
   494 	iSettings.iPrimaryDns	 = aProvision.GetIp4NameServer1();
   496 	iSettings.iSecondaryDns	 = aProvision.GetIp4NameServer2();
   495 	iSettings.iSecondaryDns	 = aProvision.GetIp4NameServer2();
   497 	iSettings.iGetGatewayFromServer = aProvision.GetIpAddrFromServer();
   496 	iSettings.iGetGatewayFromServer = aProvision.GetIpAddrFromServer();
   498 	iSettings.iGetDnsFromServer		= aProvision.GetIp4DNSAddrFromServer();
   497 	iSettings.iGetDnsFromServer		= aProvision.GetIp4DNSAddrFromServer();
   499     LOG_IP_ADDRESS("Local IP address from Provisioning", iSettings.iLocalAddr);	
   498 	
       
   499     OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_SETPROVISION_2, "Local IP address from Provisioning = %u.%u.%u.%u",iSettings.iLocalAddr >> 24, (iSettings.iLocalAddr >> 16) & 0xFF, (iSettings.iLocalAddr >> 8) & 0xFF, iSettings.iLocalAddr & 0xFF);
   500 	}
   500 	}
   501 
   501 
   502 #ifdef __BTT_LOGGING__
   502 #ifdef __BTT_LOGGING__
   503 void CIPv4Binder::LogPacket(const RMBufChain& aPacket)
   503 void CIPv4Binder::LogPacket(const RMBufChain& aPacket)
   504 /**
   504 /**
   505 * Logs packet information into log file.
   505 * Logs packet information into log file.
   506 *
   506 *
   507 * @param aPacket The packet 
   507 * @param aPacket The packet 
   508 */
   508 */
   509 	{
   509 	{
   510 	_LOG_L1C1(_L8("CIPv4Binder::LogPacket"));
   510 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_1, "CIPv4Binder::LogPacket");
   511 
   511 
   512 	TInt mBufLength = aPacket.Length() - aPacket.First()->Length();
   512 	TInt mBufLength = aPacket.Length() - aPacket.First()->Length();
   513 
   513 
   514 	_LOG_L3C2(_L8("Analysis of %d byte packet:"), mBufLength);
   514 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_2, "Analysis of %d byte packet:", mBufLength);
   515 
   515 
   516 	//Note: All the constants used on this method are a pragmatic guess of the
   516 	//Note: All the constants used on this method are a pragmatic guess of the
   517 	//IP header fields. The only porpose of this method is logging.
   517 	//IP header fields. The only porpose of this method is logging.
   518 
   518 
   519 	if (mBufLength < 20)
   519 	if (mBufLength < 20)
   520 		{
   520 		{
   521 		_LOG_L3C2(_L8(" -doesn't appear to be a valid IPv4 packet (length=%d)")
   521 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_3, " -doesn't appear to be a valid IPv4 packet (length=%d)", mBufLength);
   522 			, mBufLength);
       
   523 		return;
   522 		return;
   524 		}
   523 		}
   525 
   524 
   526 	// Get a pointer to the packet's payload.
   525 	// Get a pointer to the packet's payload.
   527 	const TUint8* payloadPtr = aPacket.First()->Next()->Ptr();
   526 	const TUint8* payloadPtr = aPacket.First()->Next()->Ptr();
   528 
   527 
   529 	if ((payloadPtr[0] & 0xF0) != 0x40)
   528 	if ((payloadPtr[0] & 0xF0) != 0x40)
   530 		{
   529 		{
   531 		_LOG_L3C2(_L8(" - doesn't appear to be an IPv4 packet (version=0x%X)"),
   530 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_4, " - doesn't appear to be an IPv4 packet (version=0x%X)",(payloadPtr[0] & 0xF0) >> 4);
   532 			(payloadPtr[0] & 0xF0) >> 4);
       
   533 		return;
   531 		return;
   534 		}
   532 		}
   535 
   533 
   536 	if ((payloadPtr[0] & 0xF) != 0x5)
   534 	if ((payloadPtr[0] & 0xF) != 0x5)
   537 		{
   535 		{
   538 		_LOG_L3C2(_L8(" - doesn't have a standard IP header (length=0x%X)"),
   536 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_5, " - doesn't have a standard IP header (length=0x%X)",payloadPtr[0] & 0xF);
   539 			payloadPtr[0] & 0xF);
       
   540 		return;
   537 		return;
   541 		}
   538 		}
   542 
   539 
   543 	_LOG_L3C5(_L8(" - src addr: %d.%d.%d.%d"), payloadPtr[12], payloadPtr[13],
   540 	OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_6, " - src addr: %u.%u.%u.%u", payloadPtr[12], payloadPtr[13],payloadPtr[14], payloadPtr[15]);
   544 		payloadPtr[14], payloadPtr[15]);
   541 	OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_7, " - dst addr: %u.%u.%u.%u", payloadPtr[16], payloadPtr[17],payloadPtr[18], payloadPtr[19]);
   545 	_LOG_L3C5(_L8(" - dst addr: %d.%d.%d.%d"), payloadPtr[16], payloadPtr[17],
       
   546 		payloadPtr[18], payloadPtr[19]);
       
   547 
   542 
   548 	if (payloadPtr[9] == 0x06)
   543 	if (payloadPtr[9] == 0x06)
   549 		{
   544 		{
   550 		_LOG_L3C1(_L8(" - appears to be a TCP packet"));
   545 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_8, " - appears to be a TCP packet");
   551 		if (mBufLength < 40)
   546 		if (mBufLength < 40)
   552 			{
   547 			{
   553 			_LOG_L3C2(_L8(" - but is too short (length=0x%X)"), mBufLength);
   548 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_9, " - but is too short (length=0x%X)", mBufLength);
   554 			return;
   549 			return;
   555 			}
   550 			}
   556 		_LOG_L3C3(_L8(" - src port: %d, dst port: %d"),
   551 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_10, " - src port: %d, dst port: %d",(payloadPtr[20] << 8) + payloadPtr[21],(payloadPtr[22] << 8) + payloadPtr[23]);
   557 			(payloadPtr[20] << 8) + payloadPtr[21],
       
   558 			(payloadPtr[22] << 8) + payloadPtr[23]);
       
   559 		_LOG_L3C3(_L8(" - seq #: 0x%08X, ack #: 0x%08X"),
   552 		_LOG_L3C3(_L8(" - seq #: 0x%08X, ack #: 0x%08X"),
   560 			(payloadPtr[24] << 24) + (payloadPtr[25] << 16) +
   553 			(payloadPtr[24] << 24) + (payloadPtr[25] << 16) +
   561 			(payloadPtr[26] << 8) + payloadPtr[27],
   554 			(payloadPtr[26] << 8) + payloadPtr[27],
   562 			(payloadPtr[28] << 24) + (payloadPtr[29] << 16) +
   555 			(payloadPtr[28] << 24) + (payloadPtr[29] << 16) +
   563 			(payloadPtr[30] << 8) + payloadPtr[31]);
   556 			(payloadPtr[30] << 8) + payloadPtr[31]);
   588 			}
   581 			}
   589 		if (payloadPtr[33] & 0x20)
   582 		if (payloadPtr[33] & 0x20)
   590 			{
   583 			{
   591 			flagsSet.Append(_L8("URG "));
   584 			flagsSet.Append(_L8("URG "));
   592 			}
   585 			}
   593 		_LOG_L3C1(flagsSet);
   586 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_11, flagsSet);
   594 
   587 
   595 		TInt dataOffset = payloadPtr[32] >> 2; // in bytes
   588 		TInt dataOffset = payloadPtr[32] >> 2; // in bytes
   596 		if ((dataOffset > 0) && (mBufLength > dataOffset + 30))
   589 		if ((dataOffset > 0) && (mBufLength > dataOffset + 30))
   597 			{
   590 			{
   598 			TBuf8<100> data;
   591 			TBuf8<100> data;
   611 				else
   604 				else
   612 					{
   605 					{
   613 					data.Append(TChar('?'));
   606 					data.Append(TChar('?'));
   614 					}
   607 					}
   615 				}
   608 				}
   616 			_LOG_L3C1(data);
   609 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_12, data);
   617 			}
   610 			}
   618 		}
   611 		}
   619 	else if (payloadPtr[9] == 0x01)
   612 	else if (payloadPtr[9] == 0x01)
   620 		{
   613 		{
   621 		_LOG_L3C1(_L8(" - appears to be an ICMP packet"));
   614 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_13, " - appears to be an ICMP packet");
   622 		if (mBufLength < 24)
   615 		if (mBufLength < 24)
   623 			{
   616 			{
   624 			_LOG_L3C2(_L8(" - but is too short (length=0x%X)"), mBufLength);
   617 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_14, " - but is too short (length=0x%X)", mBufLength);
   625 			return;
   618 			return;
   626 			}
   619 			}
   627 
   620 
   628 		if (payloadPtr[20] == 0x8)
   621 		if (payloadPtr[20] == 0x8)
   629 			{
   622 			{
   630 			_LOG_L3C1(_L8(" - is an echo request"));
   623 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_15, " - is an echo request");
   631 			}
   624 			}
   632 		else if (payloadPtr[20] == 0x0)
   625 		else if (payloadPtr[20] == 0x0)
   633 			{
   626 			{
   634 			_LOG_L3C1(_L8(" - is an echo reply"));
   627 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_16, " - is an echo reply");
   635 			}
   628 			}
   636 		else
   629 		else
   637 			{
   630 			{
   638 			_LOG_L3C2(_L8(" - unknown type (0x%02X)"), payloadPtr[20]);
   631 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_17, " - unknown type (0x%02X)", payloadPtr[20]);
   639 			return;
   632 			return;
   640 			}
   633 			}
   641 
   634 
   642 		if (mBufLength >= 28)
   635 		if (mBufLength >= 28)
   643 			{
   636 			{
   644 			_LOG_L3C3(_L8(" - ID: 0x%04X, seq #: 0x%04X"),
   637 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_18, " - ID: 0x%04X, seq #: 0x%04X",(payloadPtr[24] << 8) + payloadPtr[25],(payloadPtr[26] << 8) + payloadPtr[27]);
   645 				(payloadPtr[24] << 8) + payloadPtr[25],
       
   646 				(payloadPtr[26] << 8) + payloadPtr[27]);
       
   647 			}
   638 			}
   648 		}
   639 		}
   649 	else if (payloadPtr[9] == 0x11)
   640 	else if (payloadPtr[9] == 0x11)
   650 		{
   641 		{
   651 		_LOG_L3C1(_L8(" - appears to be a UDP packet"));
   642 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_19, " - appears to be a UDP packet");
   652 		if (mBufLength < 28)
   643 		if (mBufLength < 28)
   653 			{
   644 			{
   654 			_LOG_L3C2(_L8(" - but is too short (length=0x%X)"), mBufLength);
   645 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_20, " - but is too short (length=0x%X)", mBufLength);
   655 			return;
   646 			return;
   656 			}
   647 			}
   657 		_LOG_L3C3(_L8(" - src port: %d, dst port: %d"),
   648 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_21, " - src port: %d, dst port: %d",(payloadPtr[20] << 8) + payloadPtr[21],(payloadPtr[22] << 8) + payloadPtr[23]);
   658 			(payloadPtr[20] << 8) + payloadPtr[21],
       
   659 			(payloadPtr[22] << 8) + payloadPtr[23]);
       
   660 		}
   649 		}
   661 	else
   650 	else
   662 		{
   651 		{
   663 		_LOG_L3C2(_L8(" - appears to be for an unknown protocol (0x%X)"),
   652 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_22, " - appears to be for an unknown protocol (0x%X)",payloadPtr[9]);
   664 			payloadPtr[9]);
       
   665 		}
   653 		}
   666 	}
   654 	}
   667 #endif // __BTT_LOGGING__
   655 #endif // __BTT_LOGGING__