branch | RCL_3 |
changeset 19 | 630d2f34d719 |
parent 9 | 2492a6e4aed7 |
child 20 | 07a122eea281 |
18:17af172ffa5f | 19:630d2f34d719 |
---|---|
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 "RawIPFlow.h" |
31 #include "RawIPFlow.h" |
26 #include "IPv4Binder.h" |
32 #include "IPv4Binder.h" |
27 #include <comms-infras/linkprovision.h> |
33 #include <comms-infras/linkprovision.h> |
30 using namespace ESock; |
36 using namespace ESock; |
31 #ifdef WCDMA_STUB |
37 #ifdef WCDMA_STUB |
32 #include <networking/umtsnifcontrolif.h> |
38 #include <networking/umtsnifcontrolif.h> |
33 #endif |
39 #endif |
34 |
40 |
35 #define LOG_IP_ADDRESS(desc,addr) _LOG_L1C5(_L8(" " desc " = %d.%d.%d.%d"), \ |
|
36 addr >> 24, (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF); |
|
37 |
41 |
38 #ifdef __EABI__ |
42 #ifdef __EABI__ |
39 // Patch data is used and KMtuIPv4 and KRMtuIPv4 can be modified to a different value in RawIpNif.iby file |
43 // Patch data is used and KMtuIPv4 and KRMtuIPv4 can be modified to a different value in RawIpNif.iby file |
40 extern const TInt KMtuIPv4 = KDefaultMtu; |
44 extern const TInt KMtuIPv4 = KDefaultMtu; |
41 extern const TInt KRMtuIPv4 = KDefaultMtu; |
45 extern const TInt KRMtuIPv4 = KDefaultMtu; |
42 #endif |
46 #endif |
43 |
47 |
44 CIPv4Binder::CIPv4Binder(CRawIPFlow& aFlow, CBttLogger* aTheLogger) |
48 CIPv4Binder::CIPv4Binder(CRawIPFlow& aFlow) |
45 /** |
49 /** |
46 * Constructor |
50 * Constructor |
47 */ |
51 */ |
48 : CBinderBase(aFlow,aTheLogger), |
52 : CBinderBase(aFlow), |
49 iSpeedMetric(KDefaultSpeedMetric) |
53 iSpeedMetric(KDefaultSpeedMetric) |
50 { |
54 { |
51 } |
55 } |
52 |
56 |
53 CIPv4Binder::~CIPv4Binder() |
57 CIPv4Binder::~CIPv4Binder() |
79 * @param aName The command to perform |
83 * @param aName The command to perform |
80 * @param aOption Data to be input/output as a result of the command |
84 * @param aOption Data to be input/output as a result of the command |
81 * @return Standard error codes |
85 * @return Standard error codes |
82 */ |
86 */ |
83 { |
87 { |
84 _LOG_L1C3(_L8("CIPv4Binder::Control [aLevel=%d, aName=%d]"), |
88 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_CONTROL_1, "CIPv4Binder::Control [aLevel=%d, aName=%d]",aLevel, aName); |
85 aLevel, aName); |
|
86 |
89 |
87 if (aLevel == KSOLInterface) |
90 if (aLevel == KSOLInterface) |
88 { |
91 { |
89 switch (aName) |
92 switch (aName) |
90 { |
93 { |
157 return KErrNotSupported; |
160 return KErrNotSupported; |
158 } |
161 } |
159 |
162 |
160 TInt CIPv4Binder::GetConfig(TBinderConfig& aConfig) |
163 TInt CIPv4Binder::GetConfig(TBinderConfig& aConfig) |
161 { |
164 { |
162 _LOG_L1C1(_L8("CIPv4Binder::GetConfig")); |
165 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_GETCONFIG_1, "CIPv4Binder::GetConfig"); |
163 |
166 |
164 TBinderConfig4* config = TBinderConfig::Cast<TBinderConfig4>(aConfig); |
167 TBinderConfig4* config = TBinderConfig::Cast<TBinderConfig4>(aConfig); |
165 |
168 |
166 if(config == NULL) |
169 if(config == NULL) |
167 { |
170 { |
187 UserSvr::HalFunction(EHalGroupEmulator,EEmulatorHalIntProperty,(TAny*)"rawip_KRMtuIPv4",&(config->iInfo.iRMtu)); |
190 UserSvr::HalFunction(EHalGroupEmulator,EEmulatorHalIntProperty,(TAny*)"rawip_KRMtuIPv4",&(config->iInfo.iRMtu)); |
188 #endif |
191 #endif |
189 |
192 |
190 config->iInfo.iSpeedMetric = iSpeedMetric; /* approximation of the interface speed in Kbps. */ |
193 config->iInfo.iSpeedMetric = iSpeedMetric; /* approximation of the interface speed in Kbps. */ |
191 |
194 |
192 LOG_IP_ADDRESS("Local IP address from TBinderConfig", iSettings.iLocalAddr); |
195 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); |
193 |
196 |
194 config->iAddress.SetAddress(iSettings.iLocalAddr); /* Interface IP address. */ |
197 config->iAddress.SetAddress(iSettings.iLocalAddr); /* Interface IP address. */ |
195 config->iNetMask.SetAddress(iSettings.iNetMask); /* IP netmask. */ |
198 config->iNetMask.SetAddress(iSettings.iNetMask); /* IP netmask. */ |
196 config->iBrdAddr.SetAddress(iSettings.iBroadcastAddr); /* IP broadcast address. */ |
199 config->iBrdAddr.SetAddress(iSettings.iBroadcastAddr); /* IP broadcast address. */ |
197 config->iDefGate.SetAddress(iSettings.iDefGateway); /* IP default gateway or peer address (if known). */ |
200 config->iDefGate.SetAddress(iSettings.iDefGateway); /* IP default gateway or peer address (if known). */ |
198 config->iNameSer1.SetAddress(iSettings.iPrimaryDns); /* IP primary name server (if any). */ |
201 config->iNameSer1.SetAddress(iSettings.iPrimaryDns); /* IP primary name server (if any). */ |
209 * |
212 * |
210 * @param aContextParameters Parameters of the context to delete |
213 * @param aContextParameters Parameters of the context to delete |
211 * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone |
214 * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone |
212 */ |
215 */ |
213 { |
216 { |
214 _LOG_L1C1(_L8("CIPv4Binder::DeleteContext")); |
217 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_DELETECONTEXT_1, "CIPv4Binder::DeleteContext"); |
215 |
218 |
216 if (aContextParameters.Length() != sizeof(TContextParameters)) |
219 if (aContextParameters.Length() != sizeof(TContextParameters)) |
217 { |
220 { |
218 return KErrArgument; |
221 return KErrArgument; |
219 } |
222 } |
242 * |
245 * |
243 * @param aConfig The new context config |
246 * @param aConfig The new context config |
244 */ |
247 */ |
245 void CIPv4Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig) |
248 void CIPv4Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig) |
246 { |
249 { |
247 _LOG_L1C1(_L8("CIPv4Binder::UpdateContextConfig")); |
250 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_1, "CIPv4Binder::UpdateContextConfig"); |
248 |
251 |
249 // Get our IP address from the GPRS context config. |
252 // Get our IP address from the GPRS context config. |
250 TInetAddr address; |
253 TInetAddr address; |
251 |
254 |
252 TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr; |
255 TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr; |
268 |
271 |
269 // We've got our IP address! Let's save it. |
272 // We've got our IP address! Let's save it. |
270 if (ret == KErrNone) |
273 if (ret == KErrNone) |
271 { |
274 { |
272 iSettings.iLocalAddr = address.Address(); |
275 iSettings.iLocalAddr = address.Address(); |
273 LOG_IP_ADDRESS("Got local IP address from context", iSettings.iLocalAddr); |
276 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); |
274 iSettings.iDefGateway = address.Address(); |
277 iSettings.iDefGateway = address.Address(); |
275 _LOG_L1C1(_L8("Set Default Gateway to local IP address")); |
278 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_3, "Set Default Gateway to local IP address"); |
276 } |
279 } |
277 else |
280 else |
278 { |
281 { |
279 _LOG_L2C2(_L8("Couldn't get IP address from GPRS config (err: %d)"), |
282 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_4, "Couldn't get IP address from GPRS config (err: %d)",ret); |
280 ret); |
|
281 |
283 |
282 // Don't leave on this error: we may still be OK if we read some |
284 // Don't leave on this error: we may still be OK if we read some |
283 // settings from CommDB. |
285 // settings from CommDB. |
284 } |
286 } |
285 |
287 |
297 ret = address.Input(tempAddr); |
299 ret = address.Input(tempAddr); |
298 |
300 |
299 if (ret == KErrNone) |
301 if (ret == KErrNone) |
300 { |
302 { |
301 iSettings.iPrimaryDns = address.Address(); |
303 iSettings.iPrimaryDns = address.Address(); |
302 LOG_IP_ADDRESS("Got primary DNS from context PCO", iSettings.iPrimaryDns); |
304 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); |
303 } |
305 } |
304 else |
306 else |
305 { |
307 { |
306 _LOG_L2C2(_L8("Couldn't get primary DNS address from GPRS config (err: %d)"), |
308 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_6, "Couldn't get primary DNS address from GPRS config (err: %d)",ret); |
307 ret); |
|
308 |
309 |
309 // Don't leave on this error: we may still be OK if we read some |
310 // Don't leave on this error: we may still be OK if we read some |
310 // settings from CommDB. |
311 // settings from CommDB. |
311 } |
312 } |
312 |
313 |
314 ret = address.Input(tempAddr); |
315 ret = address.Input(tempAddr); |
315 |
316 |
316 if (ret == KErrNone) |
317 if (ret == KErrNone) |
317 { |
318 { |
318 iSettings.iSecondaryDns = address.Address(); |
319 iSettings.iSecondaryDns = address.Address(); |
319 LOG_IP_ADDRESS("Got secondary DNS from context PCO", iSettings.iPrimaryDns); |
320 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); |
320 } |
321 } |
321 else |
322 else |
322 { |
323 { |
323 _LOG_L2C2(_L8("Couldn't get secondary DNS address from GPRS config (err: %d)"), |
324 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_8, "Couldn't get secondary DNS address from GPRS config (err: %d)",ret); |
324 ret); |
|
325 |
325 |
326 // Don't leave on this error: we may still be OK if we read some |
326 // Don't leave on this error: we may still be OK if we read some |
327 // settings from CommDB. |
327 // settings from CommDB. |
328 } |
328 } |
329 } |
329 } |
330 else |
330 else |
331 { |
331 { |
332 LOG_IP_ADDRESS("Using CommDB DNS address - Primary ", iSettings.iPrimaryDns); |
332 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); |
333 LOG_IP_ADDRESS(" - Secondary ", iSettings.iSecondaryDns); |
333 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); |
334 } |
334 } |
335 |
335 |
336 |
336 |
337 // TProtocolConfigOptionV2::iMiscBuffer is not the correct way to pass a gateway |
337 // TProtocolConfigOptionV2::iMiscBuffer is not the correct way to pass a gateway |
338 // address - data needs to be passed in TLV format but there are no TLV content tags |
338 // address - data needs to be passed in TLV format but there are no TLV content tags |
350 iSettings.iDefGateway = address.Address(); |
350 iSettings.iDefGateway = address.Address(); |
351 LOG_IP_ADDRESS("Got default gateway", iSettings.iDefGateway); |
351 LOG_IP_ADDRESS("Got default gateway", iSettings.iDefGateway); |
352 } |
352 } |
353 else |
353 else |
354 { |
354 { |
355 _LOG_L2C2(_L8("Couldn't get default gateway from GPRS config (err: %d)"), |
355 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONTEXTCONFIGL_4, "Couldn't get default gateway from GPRS config (err: %d)",ret); |
356 ret); |
|
357 } |
356 } |
358 }*/ |
357 }*/ |
359 } |
358 } |
360 |
359 |
361 void CIPv4Binder::UpdateConnectionSpeed(TUint aConnectionSpeed) |
360 void CIPv4Binder::UpdateConnectionSpeed(TUint aConnectionSpeed) |
363 * Sets the speed metric to return to TCP/IP, based on what the TSY tells us. |
362 * Sets the speed metric to return to TCP/IP, based on what the TSY tells us. |
364 * |
363 * |
365 * @param aConnectionSpeed Our connection speed |
364 * @param aConnectionSpeed Our connection speed |
366 */ |
365 */ |
367 { |
366 { |
368 _LOG_L1C1(_L8("CIPv4Binder::UpdateConnectionSpeed")); |
367 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_UPDATECONNECTIONSPEED_1, "CIPv4Binder::UpdateConnectionSpeed"); |
369 |
368 |
370 iSpeedMetric = aConnectionSpeed; |
369 iSpeedMetric = aConnectionSpeed; |
371 } |
370 } |
372 |
371 |
373 |
372 |
377 * |
376 * |
378 * @param aPdu The outgoing packet |
377 * @param aPdu The outgoing packet |
379 * @return MLowerDataSender::ESendBlocked or ESendAccepted based on state of flow. |
378 * @return MLowerDataSender::ESendBlocked or ESendAccepted based on state of flow. |
380 */ |
379 */ |
381 { |
380 { |
382 _LOG_L1C1(_L8("CIPv4Binder::Send")); |
381 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_SEND_1, "CIPv4Binder::Send"); |
383 |
382 |
384 #ifdef __BTT_LOGGING__ |
383 #ifdef __BTT_LOGGING__ |
385 LogPacket(aPdu); |
384 LogPacket(aPdu); |
386 #endif |
385 #endif |
387 |
386 |
398 * |
397 * |
399 * @param aEvent Not used |
398 * @param aEvent Not used |
400 * @param aInfo Not used |
399 * @param aInfo Not used |
401 */ |
400 */ |
402 { |
401 { |
403 _LOG_L1C1(_L8("CIPv4Binder::Notification")); |
402 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_NOTIFICATION_1, "CIPv4Binder::Notification"); |
404 |
403 |
405 return KErrNone; |
404 return KErrNone; |
406 } |
405 } |
407 |
406 |
408 void CIPv4Binder::StartSending() |
407 void CIPv4Binder::StartSending() |
410 * Indicates to the protocol layer that the NIF is ready to send packets. |
409 * Indicates to the protocol layer that the NIF is ready to send packets. |
411 * |
410 * |
412 * @param aProtocol A pointer to a protocol |
411 * @param aProtocol A pointer to a protocol |
413 */ |
412 */ |
414 { |
413 { |
415 _LOG_L1C1(_L8("CIPv4Binder::StartSending()")); |
414 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_STARTSENDING_1, "CIPv4Binder::StartSending()"); |
416 |
415 |
417 CBinderBase::StartSending(); |
416 CBinderBase::StartSending(); |
418 } |
417 } |
419 |
418 |
420 TBool CIPv4Binder::WantsProtocol(TUint16 aProtocolCode) |
419 TBool CIPv4Binder::WantsProtocol(TUint16 aProtocolCode) |
422 * Indicates the type of protocol implemented by this class. |
421 * Indicates the type of protocol implemented by this class. |
423 * |
422 * |
424 * @param aProtocolCode The protocol type |
423 * @param aProtocolCode The protocol type |
425 */ |
424 */ |
426 { |
425 { |
427 _LOG_L1C2(_L8("CIPv4Binder::WantsProtocol [aProtocolCode=%X]"), |
426 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_WANTSPROTOCOL_1, "CIPv4Binder::WantsProtocol [aProtocolCode=%X]",aProtocolCode); |
428 aProtocolCode); |
|
429 |
427 |
430 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
428 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
431 return ((aProtocolCode & 0x00FF) == KIp4FrameType); |
429 return ((aProtocolCode & 0x00FF) == KIp4FrameType); |
432 #else |
430 #else |
433 (void) aProtocolCode; |
431 (void) aProtocolCode; |
441 * TCP/IP stack. |
439 * TCP/IP stack. |
442 * |
440 * |
443 * @param aPdu The incoming packet |
441 * @param aPdu The incoming packet |
444 */ |
442 */ |
445 { |
443 { |
446 _LOG_L1C1(_L8("CIPv4Binder::Process")); |
444 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_PROCESS_1, "CIPv4Binder::Process"); |
447 |
445 |
448 #ifdef __BTT_LOGGING__ |
446 #ifdef __BTT_LOGGING__ |
449 LogPacket(aPdu); |
447 LogPacket(aPdu); |
450 #endif |
448 #endif |
451 |
449 |
452 // Pass incoming packets up to the protocol, unless it hasn't |
450 // Pass incoming packets up to the protocol, unless it hasn't |
453 // been bound yet. |
451 // been bound yet. |
454 if (iUpperReceiver) // ASSERT(iUpperReceiver) ? |
452 if (iUpperReceiver) // ASSERT(iUpperReceiver) ? |
455 { |
453 { |
456 _LOG_L1C1(_L8("CIPv4Binder: Packet Sent to TCP/IP Protocol!!!")); |
454 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_PROCESS_2, "CIPv4Binder: Packet Sent to TCP/IP Protocol!!!"); |
457 iUpperReceiver->Process(aPdu); |
455 iUpperReceiver->Process(aPdu); |
458 } |
456 } |
459 else |
457 else |
460 { |
458 { |
461 _LOG_L2C1(_L8("WARNING: dumping incoming packet, no protocol bound")); |
459 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_PROCESS_3, "WARNING: dumping incoming packet, no protocol bound"); |
462 aPdu.Free(); |
460 aPdu.Free(); |
463 } |
461 } |
464 } |
462 } |
465 |
463 |
466 // |
464 // |
486 Called from RawIP Flow. |
484 Called from RawIP Flow. |
487 |
485 |
488 @param aProvision Provisioning structure from Control side. |
486 @param aProvision Provisioning structure from Control side. |
489 */ |
487 */ |
490 { |
488 { |
491 _LOG_L1C1(_L8("CIPv4Binder::SetProvision")); |
489 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_SETPROVISION_1, "CIPv4Binder::SetProvision"); |
492 |
490 |
493 iSettings.iLocalAddr = aProvision.GetIpAddress(); |
491 iSettings.iLocalAddr = aProvision.GetIpAddress(); |
494 iSettings.iNetMask = aProvision.GetIpNetMask(); |
492 iSettings.iNetMask = aProvision.GetIpNetMask(); |
495 iSettings.iBroadcastAddr = aProvision.GetBroadCastAddr(); |
493 iSettings.iBroadcastAddr = aProvision.GetBroadCastAddr(); |
496 iSettings.iDefGateway = aProvision.GetIpGateway(); |
494 iSettings.iDefGateway = aProvision.GetIpGateway(); |
497 iSettings.iPrimaryDns = aProvision.GetIp4NameServer1(); |
495 iSettings.iPrimaryDns = aProvision.GetIp4NameServer1(); |
498 iSettings.iSecondaryDns = aProvision.GetIp4NameServer2(); |
496 iSettings.iSecondaryDns = aProvision.GetIp4NameServer2(); |
499 iSettings.iGetGatewayFromServer = aProvision.GetIpAddrFromServer(); |
497 iSettings.iGetGatewayFromServer = aProvision.GetIpAddrFromServer(); |
500 iSettings.iGetDnsFromServer = aProvision.GetIp4DNSAddrFromServer(); |
498 iSettings.iGetDnsFromServer = aProvision.GetIp4DNSAddrFromServer(); |
501 |
499 |
502 LOG_IP_ADDRESS("Local IP address from Provisioning", iSettings.iLocalAddr); |
500 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); |
503 } |
501 } |
504 |
502 |
505 #ifdef __BTT_LOGGING__ |
503 #ifdef __BTT_LOGGING__ |
506 void CIPv4Binder::LogPacket(const RMBufChain& aPacket) |
504 void CIPv4Binder::LogPacket(const RMBufChain& aPacket) |
507 /** |
505 /** |
508 * Logs packet information into log file. |
506 * Logs packet information into log file. |
509 * |
507 * |
510 * @param aPacket The packet |
508 * @param aPacket The packet |
511 */ |
509 */ |
512 { |
510 { |
513 _LOG_L1C1(_L8("CIPv4Binder::LogPacket")); |
511 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_1, "CIPv4Binder::LogPacket"); |
514 |
512 |
515 TInt mBufLength = aPacket.Length() - aPacket.First()->Length(); |
513 TInt mBufLength = aPacket.Length() - aPacket.First()->Length(); |
516 |
514 |
517 _LOG_L3C2(_L8("Analysis of %d byte packet:"), mBufLength); |
515 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_2, "Analysis of %d byte packet:", mBufLength); |
518 |
516 |
519 //Note: All the constants used on this method are a pragmatic guess of the |
517 //Note: All the constants used on this method are a pragmatic guess of the |
520 //IP header fields. The only porpose of this method is logging. |
518 //IP header fields. The only porpose of this method is logging. |
521 |
519 |
522 if (mBufLength < 20) |
520 if (mBufLength < 20) |
523 { |
521 { |
524 _LOG_L3C2(_L8(" -doesn't appear to be a valid IPv4 packet (length=%d)") |
522 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_3, " -doesn't appear to be a valid IPv4 packet (length=%d)", mBufLength); |
525 , mBufLength); |
|
526 return; |
523 return; |
527 } |
524 } |
528 |
525 |
529 // Get a pointer to the packet's payload. |
526 // Get a pointer to the packet's payload. |
530 const TUint8* payloadPtr = aPacket.First()->Next()->Ptr(); |
527 const TUint8* payloadPtr = aPacket.First()->Next()->Ptr(); |
531 |
528 |
532 if ((payloadPtr[0] & 0xF0) != 0x40) |
529 if ((payloadPtr[0] & 0xF0) != 0x40) |
533 { |
530 { |
534 _LOG_L3C2(_L8(" - doesn't appear to be an IPv4 packet (version=0x%X)"), |
531 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); |
535 (payloadPtr[0] & 0xF0) >> 4); |
|
536 return; |
532 return; |
537 } |
533 } |
538 |
534 |
539 if ((payloadPtr[0] & 0xF) != 0x5) |
535 if ((payloadPtr[0] & 0xF) != 0x5) |
540 { |
536 { |
541 _LOG_L3C2(_L8(" - doesn't have a standard IP header (length=0x%X)"), |
537 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_5, " - doesn't have a standard IP header (length=0x%X)",payloadPtr[0] & 0xF); |
542 payloadPtr[0] & 0xF); |
|
543 return; |
538 return; |
544 } |
539 } |
545 |
540 |
546 _LOG_L3C5(_L8(" - src addr: %d.%d.%d.%d"), payloadPtr[12], payloadPtr[13], |
541 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_6, " - src addr: %d.%d.%d.%d", payloadPtr[12], payloadPtr[13],payloadPtr[14], payloadPtr[15]); |
547 payloadPtr[14], payloadPtr[15]); |
542 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_7, " - dst addr: %d.%d.%d.%d", payloadPtr[16], payloadPtr[17],payloadPtr[18], payloadPtr[19]); |
548 _LOG_L3C5(_L8(" - dst addr: %d.%d.%d.%d"), payloadPtr[16], payloadPtr[17], |
|
549 payloadPtr[18], payloadPtr[19]); |
|
550 |
543 |
551 if (payloadPtr[9] == 0x06) |
544 if (payloadPtr[9] == 0x06) |
552 { |
545 { |
553 _LOG_L3C1(_L8(" - appears to be a TCP packet")); |
546 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_8, " - appears to be a TCP packet"); |
554 if (mBufLength < 40) |
547 if (mBufLength < 40) |
555 { |
548 { |
556 _LOG_L3C2(_L8(" - but is too short (length=0x%X)"), mBufLength); |
549 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_9, " - but is too short (length=0x%X)", mBufLength); |
557 return; |
550 return; |
558 } |
551 } |
559 _LOG_L3C3(_L8(" - src port: %d, dst port: %d"), |
552 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]); |
560 (payloadPtr[20] << 8) + payloadPtr[21], |
553 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_11, " - seq #: 0x%08X, ack #: 0x%08X", |
561 (payloadPtr[22] << 8) + payloadPtr[23]); |
554 (payloadPtr[24] << 24) + (payloadPtr[25] << 16) + |
562 _LOG_L3C3(_L8(" - seq #: 0x%08X, ack #: 0x%08X"), |
555 (payloadPtr[26] << 8) + payloadPtr[27], |
563 (payloadPtr[24] << 24) + (payloadPtr[25] << 16) + |
556 (payloadPtr[28] << 24) + (payloadPtr[29] << 16) + |
564 (payloadPtr[26] << 8) + payloadPtr[27], |
557 (payloadPtr[30] << 8) + payloadPtr[31]); |
565 (payloadPtr[28] << 24) + (payloadPtr[29] << 16) + |
558 |
566 (payloadPtr[30] << 8) + payloadPtr[31]); |
|
567 |
559 |
568 TBuf8<100> flagsSet; |
560 TBuf8<100> flagsSet; |
569 flagsSet.Copy(_L8(" - flags set: ")); |
561 flagsSet.Copy(_L8(" - flags set: ")); |
570 |
562 |
571 // Write description of payload's flags to "flagsSet" |
563 // Write description of payload's flags to "flagsSet" |
591 } |
583 } |
592 if (payloadPtr[33] & 0x20) |
584 if (payloadPtr[33] & 0x20) |
593 { |
585 { |
594 flagsSet.Append(_L8("URG ")); |
586 flagsSet.Append(_L8("URG ")); |
595 } |
587 } |
596 _LOG_L3C1(flagsSet); |
588 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_12, "%s", flagsSet); |
597 |
589 |
598 TInt dataOffset = payloadPtr[32] >> 2; // in bytes |
590 TInt dataOffset = payloadPtr[32] >> 2; // in bytes |
599 if ((dataOffset > 0) && (mBufLength > dataOffset + 30)) |
591 if ((dataOffset > 0) && (mBufLength > dataOffset + 30)) |
600 { |
592 { |
601 TBuf8<100> data; |
593 TBuf8<100> data; |
614 else |
606 else |
615 { |
607 { |
616 data.Append(TChar('?')); |
608 data.Append(TChar('?')); |
617 } |
609 } |
618 } |
610 } |
619 _LOG_L3C1(data); |
611 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_13, "%s", data); |
620 } |
612 } |
621 } |
613 } |
622 else if (payloadPtr[9] == 0x01) |
614 else if (payloadPtr[9] == 0x01) |
623 { |
615 { |
624 _LOG_L3C1(_L8(" - appears to be an ICMP packet")); |
616 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_14, " - appears to be an ICMP packet"); |
625 if (mBufLength < 24) |
617 if (mBufLength < 24) |
626 { |
618 { |
627 _LOG_L3C2(_L8(" - but is too short (length=0x%X)"), mBufLength); |
619 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_15, " - but is too short (length=0x%X)", mBufLength); |
628 return; |
620 return; |
629 } |
621 } |
630 |
622 |
631 if (payloadPtr[20] == 0x8) |
623 if (payloadPtr[20] == 0x8) |
632 { |
624 { |
633 _LOG_L3C1(_L8(" - is an echo request")); |
625 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_16, " - is an echo request"); |
634 } |
626 } |
635 else if (payloadPtr[20] == 0x0) |
627 else if (payloadPtr[20] == 0x0) |
636 { |
628 { |
637 _LOG_L3C1(_L8(" - is an echo reply")); |
629 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_17, " - is an echo reply"); |
638 } |
630 } |
639 else |
631 else |
640 { |
632 { |
641 _LOG_L3C2(_L8(" - unknown type (0x%02X)"), payloadPtr[20]); |
633 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_18, " - unknown type (0x%02X)", payloadPtr[20]); |
642 return; |
634 return; |
643 } |
635 } |
644 |
636 |
645 if (mBufLength >= 28) |
637 if (mBufLength >= 28) |
646 { |
638 { |
647 _LOG_L3C3(_L8(" - ID: 0x%04X, seq #: 0x%04X"), |
639 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_19, " - ID: 0x%04X, seq #: 0x%04X",(payloadPtr[24] << 8) + payloadPtr[25],(payloadPtr[26] << 8) + payloadPtr[27]); |
648 (payloadPtr[24] << 8) + payloadPtr[25], |
|
649 (payloadPtr[26] << 8) + payloadPtr[27]); |
|
650 } |
640 } |
651 } |
641 } |
652 else if (payloadPtr[9] == 0x11) |
642 else if (payloadPtr[9] == 0x11) |
653 { |
643 { |
654 _LOG_L3C1(_L8(" - appears to be a UDP packet")); |
644 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_20, " - appears to be a UDP packet"); |
655 if (mBufLength < 28) |
645 if (mBufLength < 28) |
656 { |
646 { |
657 _LOG_L3C2(_L8(" - but is too short (length=0x%X)"), mBufLength); |
647 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_21, " - but is too short (length=0x%X)", mBufLength); |
658 return; |
648 return; |
659 } |
649 } |
660 _LOG_L3C3(_L8(" - src port: %d, dst port: %d"), |
650 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_22, " - src port: %d, dst port: %d",(payloadPtr[20] << 8) + payloadPtr[21],(payloadPtr[22] << 8) + payloadPtr[23]); |
661 (payloadPtr[20] << 8) + payloadPtr[21], |
|
662 (payloadPtr[22] << 8) + payloadPtr[23]); |
|
663 } |
651 } |
664 else |
652 else |
665 { |
653 { |
666 _LOG_L3C2(_L8(" - appears to be for an unknown protocol (0x%X)"), |
654 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV4BINDER_LOGPACKET_23, " - appears to be for an unknown protocol (0x%X)",payloadPtr[9]); |
667 payloadPtr[9]); |
|
668 } |
655 } |
669 } |
656 } |
670 #endif // __BTT_LOGGING__ |
657 #endif // __BTT_LOGGING__ |