31 using namespace ESock; |
37 using namespace ESock; |
32 #ifdef WCDMA_STUB |
38 #ifdef WCDMA_STUB |
33 #include <networking/umtsnifcontrolif.h> |
39 #include <networking/umtsnifcontrolif.h> |
34 #endif |
40 #endif |
35 |
41 |
36 #define LOG_IP_ADDRESS(desc,addr) _LOG_L2C5(_L8(" " desc " = %d:%d:%d:%d from context"), \ |
|
37 addr.u.iAddr32[3], addr.u.iAddr32[2], addr.u.iAddr32[1], addr.u.iAddr32[0]); |
|
38 |
42 |
39 #ifdef __EABI__ |
43 #ifdef __EABI__ |
40 // Patch data is used and KMtuIPv6 and KRMtuIPv6 can be modified to a different value in RawIpNif.iby file |
44 // Patch data is used and KMtuIPv6 and KRMtuIPv6 can be modified to a different value in RawIpNif.iby file |
41 extern const TInt KMtuIPv6 = KDefaultMtu; |
45 extern const TInt KMtuIPv6 = KDefaultMtu; |
42 extern const TInt KRMtuIPv6 = KDefaultMtu; |
46 extern const TInt KRMtuIPv6 = KDefaultMtu; |
43 #endif |
47 #endif |
44 |
48 |
45 CIPv6Binder::CIPv6Binder(CRawIPFlow& aFlow, CBttLogger* aTheLogger) |
49 CIPv6Binder::CIPv6Binder(CRawIPFlow& aFlow) |
46 /** |
50 /** |
47 * Constructor |
51 * Constructor |
48 */ |
52 */ |
49 : CBinderBase(aFlow,aTheLogger), |
53 : CBinderBase(aFlow), |
50 iTheLogger(aTheLogger), |
|
51 iSpeedMetric(KDefaultSpeedMetric) |
54 iSpeedMetric(KDefaultSpeedMetric) |
52 { |
55 { |
53 } |
56 } |
54 |
57 |
55 CIPv6Binder::~CIPv6Binder() |
58 CIPv6Binder::~CIPv6Binder() |
81 * @param aName The command to perform |
84 * @param aName The command to perform |
82 * @param aOption Data to be input/output as a result of the command |
85 * @param aOption Data to be input/output as a result of the command |
83 * @return Standard error codes |
86 * @return Standard error codes |
84 */ |
87 */ |
85 { |
88 { |
86 _LOG_L1C3(_L8("CIPv6Binder::Control [aLevel=%d, aName=%d]"), |
89 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_CONTROL_1, "CIPv6Binder::Control [aLevel=%u, aName=%u]",aLevel, aName); |
87 aLevel, aName); |
|
88 |
90 |
89 if (aLevel == KSOLInterface) |
91 if (aLevel == KSOLInterface) |
90 { |
92 { |
91 switch (aName) |
93 switch (aName) |
92 { |
94 { |
266 { |
268 { |
267 const TUint8* addrTable = &address.Ip6Address().u.iAddr8[8]; |
269 const TUint8* addrTable = &address.Ip6Address().u.iAddr8[8]; |
268 |
270 |
269 iSettings.iLocalIfId.SetAddr(addrTable, 8); |
271 iSettings.iLocalIfId.SetAddr(addrTable, 8); |
270 |
272 |
271 LOG_IP_ADDRESS("Got local IP address", address.Ip6Address()); |
273 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_2, "Got local IP address = %u:%u:%u:%u from context", address.Ip6Address().u.iAddr32[3], address.Ip6Address().u.iAddr32[2], address.Ip6Address().u.iAddr32[1], address.Ip6Address().u.iAddr32[0]); |
272 } |
274 } |
273 else |
275 else |
274 { |
276 { |
275 _LOG_L2C2(_L8("Couldn't get IP address from GPRS config (err: %d)"), |
277 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_3, "Couldn't get IP address from GPRS config (err: %d)",ret); |
276 ret); |
|
277 |
278 |
278 // Don't leave on this error: we may still be OK if we read some |
279 // Don't leave on this error: we may still be OK if we read some |
279 // settings from CommDB. |
280 // settings from CommDB. |
280 } |
281 } |
281 |
282 |
293 ret = address.Input(tempAddr); |
294 ret = address.Input(tempAddr); |
294 |
295 |
295 if (ret == KErrNone) |
296 if (ret == KErrNone) |
296 { |
297 { |
297 iSettings.iPrimaryDns = address.Ip6Address(); |
298 iSettings.iPrimaryDns = address.Ip6Address(); |
298 LOG_IP_ADDRESS("Got primary DNS", iSettings.iPrimaryDns); |
299 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_4, "Got primary DNS = %u:%u:%u:%u from context", iSettings.iPrimaryDns.u.iAddr32[3], iSettings.iPrimaryDns.u.iAddr32[2], iSettings.iPrimaryDns.u.iAddr32[1], iSettings.iPrimaryDns.u.iAddr32[0]); |
299 } |
300 } |
300 else |
301 else |
301 { |
302 { |
302 _LOG_L2C2(_L8("Couldn't get primary DNS address from GPRS config (err: %d)"), |
303 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_5, "Couldn't get primary DNS address from GPRS config (err: %d)",ret); |
303 ret); |
|
304 |
304 |
305 // Don't leave on this error: we may still be OK if we read some |
305 // Don't leave on this error: we may still be OK if we read some |
306 // settings from CommDB. |
306 // settings from CommDB. |
307 } |
307 } |
308 |
308 |
310 ret = address.Input(tempAddr); |
310 ret = address.Input(tempAddr); |
311 |
311 |
312 if (ret == KErrNone) |
312 if (ret == KErrNone) |
313 { |
313 { |
314 iSettings.iSecondaryDns = address.Ip6Address(); |
314 iSettings.iSecondaryDns = address.Ip6Address(); |
315 LOG_IP_ADDRESS("Got secondary DNS", iSettings.iPrimaryDns); |
315 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_6, "Got secondary DNS = %u:%u:%u:%u from context", iSettings.iSecondaryDns.u.iAddr32[3], iSettings.iSecondaryDns.u.iAddr32[2], iSettings.iSecondaryDns.u.iAddr32[1], iSettings.iSecondaryDns.u.iAddr32[0]); |
316 } |
316 } |
317 else |
317 else |
318 { |
318 { |
319 _LOG_L2C2(_L8("Couldn't get secondary DNS address from GPRS config (err: %d)"), |
319 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_7, "Couldn't get secondary DNS address from GPRS config (err: %d)",ret); |
320 ret); |
|
321 |
320 |
322 // Don't leave on this error: we may still be OK if we read some |
321 // Don't leave on this error: we may still be OK if we read some |
323 // settings from CommDB. |
322 // settings from CommDB. |
324 } |
323 } |
325 } |
324 } |
326 else |
325 else |
327 { |
326 { |
328 LOG_IP_ADDRESS("Using CommDB DNS address - Primary ", iSettings.iPrimaryDns); |
327 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_8, "Using CommDB DNS address - Primary = %u:%u:%u:%u", iSettings.iPrimaryDns.u.iAddr32[3], iSettings.iPrimaryDns.u.iAddr32[2], iSettings.iPrimaryDns.u.iAddr32[1], iSettings.iPrimaryDns.u.iAddr32[0]); |
329 LOG_IP_ADDRESS(" - Secondary ", iSettings.iSecondaryDns); |
328 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONTEXTCONFIGL_9, " - Secondary = %u:%u:%u:%u", iSettings.iSecondaryDns.u.iAddr32[3], iSettings.iSecondaryDns.u.iAddr32[2], iSettings.iSecondaryDns.u.iAddr32[1], iSettings.iSecondaryDns.u.iAddr32[0]); |
330 } |
329 } |
331 } |
330 } |
332 |
331 |
333 void CIPv6Binder::UpdateConnectionSpeed(TUint aConnectionSpeed) |
332 void CIPv6Binder::UpdateConnectionSpeed(TUint aConnectionSpeed) |
334 /** |
333 /** |
335 * Sets the speed metric to return to TCP/IP, based on what the TSY tells us. |
334 * Sets the speed metric to return to TCP/IP, based on what the TSY tells us. |
336 * |
335 * |
337 * @param aConnectionSpeed Our connection speed |
336 * @param aConnectionSpeed Our connection speed |
338 */ |
337 */ |
339 { |
338 { |
340 _LOG_L1C1(_L8("CIPv6Binder::UpdateConnectionSpeed")); |
339 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_UPDATECONNECTIONSPEED_1, "CIPv6Binder::UpdateConnectionSpeed"); |
341 |
340 |
342 iSpeedMetric = aConnectionSpeed; |
341 iSpeedMetric = aConnectionSpeed; |
343 } |
342 } |
344 |
343 |
345 |
344 |
394 * Indicates the type of protocol implemented by this class. |
393 * Indicates the type of protocol implemented by this class. |
395 * |
394 * |
396 * @param aProtocolCode The protocol type |
395 * @param aProtocolCode The protocol type |
397 */ |
396 */ |
398 { |
397 { |
399 _LOG_L1C2(_L8("CIPv6Binder::WantsProtocol [aProtocolCode=%X]"), |
398 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_WANTSPROTOCOL_1, "CIPv6Binder::WantsProtocol [aProtocolCode=%X]",aProtocolCode); |
400 aProtocolCode); |
|
401 |
399 |
402 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
400 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
403 return ((aProtocolCode & 0x00FF) == KIp6FrameType); |
401 return ((aProtocolCode & 0x00FF) == KIp6FrameType); |
404 #else |
402 #else |
405 (void) aProtocolCode; |
403 (void) aProtocolCode; |
413 * TCP/IP stack. |
411 * TCP/IP stack. |
414 * |
412 * |
415 * @param aPdu The incoming packet |
413 * @param aPdu The incoming packet |
416 */ |
414 */ |
417 { |
415 { |
418 _LOG_L1C1(_L8("CIPv6Binder::Process")); |
416 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_PROCESS_1, "CIPv6Binder::Process"); |
419 |
417 |
420 #ifdef __BTT_LOGGING__ |
418 #ifdef __BTT_LOGGING__ |
421 LogPacket(aPdu); |
419 LogPacket(aPdu); |
422 #endif |
420 #endif |
423 |
421 |
424 // Pass incoming packets up to the protocol, unless it hasn't |
422 // Pass incoming packets up to the protocol, unless it hasn't |
425 // been bound yet. |
423 // been bound yet. |
426 if (iUpperReceiver) // ASSERT(iUpperReceiver) ? |
424 if (iUpperReceiver) // ASSERT(iUpperReceiver) ? |
427 { |
425 { |
428 _LOG_L1C1(_L8("CIPv6Binder: Packet Sent to TCP/IP Protocol!!!")); |
426 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_PROCESS_2, "CIPv6Binder: Packet Sent to TCP/IP Protocol!!!"); |
429 iUpperReceiver->Process(aPdu); |
427 iUpperReceiver->Process(aPdu); |
430 } |
428 } |
431 else |
429 else |
432 { |
430 { |
433 _LOG_L2C1(_L8("WARNING: dumping incoming packet, no protocol bound")); |
431 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_PROCESS_3, "WARNING: dumping incoming packet, no protocol bound"); |
434 aPdu.Free(); |
432 aPdu.Free(); |
435 } |
433 } |
436 } |
434 } |
437 |
435 |
438 // |
436 // |
506 * Logs packet information into log file. |
504 * Logs packet information into log file. |
507 * |
505 * |
508 * @param aPacket The packet |
506 * @param aPacket The packet |
509 */ |
507 */ |
510 { |
508 { |
511 _LOG_L1C1(_L8("CIPv6Binder::LogPacket")); |
509 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_1, "CIPv6Binder::LogPacket"); |
512 |
510 |
513 TInt mBufLength = aPacket.Length() - aPacket.First()->Length(); |
511 TInt mBufLength = aPacket.Length() - aPacket.First()->Length(); |
514 |
512 |
515 _LOG_L3C2(_L8("Analysis of %d byte packet:"), mBufLength); |
513 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_2, "Analysis of %d byte packet:", mBufLength); |
516 |
514 |
517 //Note: All the constants used on this method are a pragmatic guess of the |
515 //Note: All the constants used on this method are a pragmatic guess of the |
518 //IP header fields. The only porpose of this method is logging. |
516 //IP header fields. The only porpose of this method is logging. |
519 |
517 |
520 if (mBufLength < 40) |
518 if (mBufLength < 40) |
521 { |
519 { |
522 _LOG_L3C2(_L8(" -doesn't appear to be a valid IPv6 packet (length=%d)") |
520 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_3, " -doesn't appear to be a valid IPv6 packet (length=%d)", mBufLength); |
523 , mBufLength); |
|
524 return; |
521 return; |
525 } |
522 } |
526 |
523 |
527 // Get a pointer to the packet's payload. |
524 // Get a pointer to the packet's payload. |
528 const TUint8* payloadPtr = aPacket.First()->Next()->Ptr(); |
525 const TUint8* payloadPtr = aPacket.First()->Next()->Ptr(); |
529 |
526 |
530 if ((payloadPtr[0] & 0xF0) != 0x60) |
527 if ((payloadPtr[0] & 0xF0) != 0x60) |
531 { |
528 { |
532 _LOG_L3C2(_L8(" - doesn't appear to be an IPv6 packet (version=0x%X)"), |
529 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_4, " - doesn't appear to be an IPv6 packet (version=0x%X)",(payloadPtr[0] & 0xF0) >> 4); |
533 (payloadPtr[0] & 0xF0) >> 4); |
|
534 return; |
530 return; |
535 } |
531 } |
536 |
532 |
537 _LOG_L3C2(_L8(" - traffic class: 0x%X"), |
533 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_5, " - traffic class: 0x%X", ((payloadPtr[0] & 0xF) << 4) | ((payloadPtr[1] & 0xF0) >> 4)); |
538 ((payloadPtr[0] & 0xF) << 4) | ((payloadPtr[1] & 0xF0) >> 4)); |
534 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_6, " - flow label: 0x%X", ((payloadPtr[1] & 0x0F) << 16) | (payloadPtr[2] << 8) | payloadPtr[3]); |
539 _LOG_L3C2(_L8(" - flow label: 0x%X"), |
535 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_7, " - payload length: 0x%X", (payloadPtr[4] << 16) | payloadPtr[5]); |
540 ((payloadPtr[1] & 0x0F) << 16) | (payloadPtr[2] << 8) | payloadPtr[3]); |
536 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_8, " - next header: 0x%08X", payloadPtr[6]); |
541 _LOG_L3C2(_L8(" - payload length: 0x%X"), |
537 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_LOGPACKET_9, " - hop limit: 0x%08X", payloadPtr[7]); |
542 (payloadPtr[4] << 16) | payloadPtr[5]); |
|
543 _LOG_L3C2(_L8(" - next header: 0x%08X"), payloadPtr[6]); |
|
544 _LOG_L3C2(_L8(" - hop limit: 0x%08X"), payloadPtr[7]); |
|
545 } |
538 } |
546 #endif // __BTT_LOGGING__ |
539 #endif // __BTT_LOGGING__ |