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