24
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// This file implements the CIPv6Binder class, which handles the transmission
|
|
15 |
// of IPv6 data to and from the TCP/IP stack.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <etelpckt.h>
|
|
24 |
#include <in_iface.h>
|
|
25 |
#include "RawIP2Flow.h"
|
|
26 |
#include "IPv6Binder.h"
|
|
27 |
#include <comms-infras/linkprovision.h>
|
|
28 |
#include <e32hal.h>
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
#ifdef WCDMA_STUB
|
|
33 |
#include <networking/umtsnifcontrolif.h>
|
|
34 |
#endif
|
|
35 |
|
|
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 |
|
|
39 |
CIPv6Binder::CIPv6Binder(CRawIP2Flow& aFlow, CBttLogger* aTheLogger)
|
|
40 |
/**
|
|
41 |
* Constructor
|
|
42 |
*/
|
|
43 |
: CBinderBase(aFlow,aTheLogger),
|
|
44 |
iTheLogger(aTheLogger),
|
|
45 |
iSpeedMetric(KDefaultSpeedMetric)
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
CIPv6Binder::~CIPv6Binder()
|
|
50 |
/**
|
|
51 |
* Destructor
|
|
52 |
*/
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
ESock::MLowerDataSender* CIPv6Binder::Bind(ESock::MUpperDataReceiver* aUpperReceiver, ESock::MUpperControl* aUpperControl)
|
|
57 |
/**
|
|
58 |
* Binds TCP/IP protocol to Flow
|
|
59 |
*
|
|
60 |
* @param aUpperReceiver A pointer to Upper layer Receive class
|
|
61 |
* @param aUpperControl A pointer to Upper layer control class
|
|
62 |
*/
|
|
63 |
{
|
|
64 |
CBinderBase::Bind(aUpperReceiver, aUpperControl); // Call the superclass's method.
|
|
65 |
return this;
|
|
66 |
}
|
|
67 |
|
|
68 |
TInt CIPv6Binder::Control(TUint aLevel, TUint aName, TDes8& /*aOption*/)
|
|
69 |
/**
|
|
70 |
* The main function called by the TCP/IP protocol to control the interface.
|
|
71 |
* Can perform a variety of general IP tasks (such as getting IP config)
|
|
72 |
* and "3G" specific tasks (such as deleting the context).
|
|
73 |
*
|
|
74 |
* @param aLevel The level of the interface to control - always KSOLInterface
|
|
75 |
* @param aName The command to perform
|
|
76 |
* @param aOption Data to be input/output as a result of the command
|
|
77 |
* @return Standard error codes
|
|
78 |
*/
|
|
79 |
{
|
|
80 |
_LOG_L1C3(_L8("CIPv6Binder::Control [aLevel=%d, aName=%d]"),
|
|
81 |
aLevel, aName);
|
|
82 |
|
|
83 |
if (aLevel == KSOLInterface)
|
|
84 |
{
|
|
85 |
switch (aName)
|
|
86 |
{
|
|
87 |
case KSoIfHardwareAddr:
|
|
88 |
// unsupported because we don't have a h/w address
|
|
89 |
break;
|
|
90 |
|
|
91 |
// 3G-specific configuration commands are below this point.
|
|
92 |
|
|
93 |
#ifdef WCDMA_STUB
|
|
94 |
case KRegisterEventHandler:
|
|
95 |
// Raw IP NIF Events are not supported
|
|
96 |
case KContextSetEvents:
|
|
97 |
// Raw IP NIF Events are not supported
|
|
98 |
break;
|
|
99 |
|
|
100 |
case KContextCreate:
|
|
101 |
// We don't support creating new secondary contexts.
|
|
102 |
break;
|
|
103 |
|
|
104 |
case KContextDelete:
|
|
105 |
// Deletes the primary PDP context. This will shut down the Nif.
|
|
106 |
return DeleteContext(aOption);
|
|
107 |
|
|
108 |
case KContextActivate:
|
|
109 |
// If the IPv6 interface is up, then the context will already have
|
|
110 |
// been activated. So this command should fail with
|
|
111 |
// KErrAlreadyExists
|
|
112 |
{
|
|
113 |
TUint8* ptr = CONST_CAST(TUint8*, aOption.Ptr());
|
|
114 |
TContextParameters* contextParams =
|
|
115 |
REINTERPRET_CAST(TContextParameters*, ptr);
|
|
116 |
|
|
117 |
if (contextParams->iContextInfo.iContextId !=
|
|
118 |
STATIC_CAST(TInt8, GetFlow().GetBcaController()->Nsapi()))
|
|
119 |
{
|
|
120 |
contextParams->iReasonCode = KErrNotFound;
|
|
121 |
}
|
|
122 |
else
|
|
123 |
{
|
|
124 |
contextParams->iContextInfo.iStatus =
|
|
125 |
GetFlow().GetContextStatus();
|
|
126 |
contextParams->iReasonCode = KErrAlreadyExists;
|
|
127 |
}
|
|
128 |
return KErrNone;
|
|
129 |
}
|
|
130 |
|
|
131 |
case KNifSetDefaultQoS:
|
|
132 |
case KContextQoSSet:
|
|
133 |
// Setting the QoS is meaningless over GPRS, so we just return that
|
|
134 |
// we don't support these operations.
|
|
135 |
break;
|
|
136 |
|
|
137 |
case KContextTFTModify:
|
|
138 |
// As we only have one primary context, we don't support anything
|
|
139 |
// to do with traffic flow templates, which are used by secondary
|
|
140 |
// contexts.
|
|
141 |
break;
|
|
142 |
|
|
143 |
case KContextModifyActive:
|
|
144 |
// This command is only valid aftermodifying TFT/QoS parameters.
|
|
145 |
// As we don't support any of these operations,
|
|
146 |
// this command is never valid.
|
|
147 |
break;
|
|
148 |
#endif
|
|
149 |
|
|
150 |
default:
|
|
151 |
break;
|
|
152 |
}
|
|
153 |
}
|
|
154 |
return KErrNotSupported;
|
|
155 |
}
|
|
156 |
|
|
157 |
TInt CIPv6Binder::GetConfig(TBinderConfig& aConfig)
|
|
158 |
{
|
|
159 |
TBinderConfig6* config = TBinderConfig::Cast<TBinderConfig6>(aConfig);
|
|
160 |
|
|
161 |
if(config == NULL)
|
|
162 |
{
|
|
163 |
return KErrNotSupported;
|
|
164 |
}
|
|
165 |
|
|
166 |
config->iFamily = KAfInet6; /* KAfInet6 - selects TBinderConfig6 */
|
|
167 |
|
|
168 |
config->iInfo.iFeatures = KIfCanBroadcast | KIfCanMulticast; /* Feature flags */
|
|
169 |
config->iInfo.iMtu = KDefaultMtu; /* Maximum transmission unit. */
|
|
170 |
config->iInfo.iRMtu = KDefaultMtu; /* Maximum transmission unit for receiving. */
|
|
171 |
config->iInfo.iSpeedMetric = iSpeedMetric; /* approximation of the interface speed in Kbps. */
|
|
172 |
|
|
173 |
TEui64Addr& localId = TEui64Addr::Cast(config->iLocalId);
|
|
174 |
localId = iSettings.iLocalIfId;
|
|
175 |
config->iNameSer1.SetAddress(iSettings.iPrimaryDns); /* IP primary name server (if any). */
|
|
176 |
config->iNameSer2.SetAddress(iSettings.iSecondaryDns); /* IP secondary name server (if any). */
|
|
177 |
|
|
178 |
return KErrNone;
|
|
179 |
}
|
|
180 |
|
|
181 |
#ifdef WCDMA_STUB
|
|
182 |
|
|
183 |
TInt CIPv6Binder::DeleteContext(TDes8& aContextParameters)
|
|
184 |
/**
|
|
185 |
* Deletes a context. As the NIF is responsible for one primary context,
|
|
186 |
* this is equivalent to closing down the NIF.
|
|
187 |
*
|
|
188 |
* @param aContextParameters Parameters of the context to delete
|
|
189 |
* @return KErrArgument if an incorrect structure is passed, otherwise KErrNone
|
|
190 |
*/
|
|
191 |
{
|
|
192 |
_LOG_L1C1(_L8("CIPv6Binder::DeleteContext"));
|
|
193 |
|
|
194 |
if (aContextParameters.Length() != sizeof(TContextParameters))
|
|
195 |
{
|
|
196 |
return KErrArgument;
|
|
197 |
}
|
|
198 |
|
|
199 |
TUint8* ptr = CONST_CAST(TUint8*, aContextParameters.Ptr());
|
|
200 |
TContextParameters* params = REINTERPRET_CAST(TContextParameters*, ptr);
|
|
201 |
|
|
202 |
if (params->iContextInfo.iContextId !=
|
|
203 |
STATIC_CAST(TInt8, GetFlow().GetBcaController()->Nsapi()))
|
|
204 |
{
|
|
205 |
params->iReasonCode = KErrBadName;
|
|
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
params->iReasonCode = KErrNone;
|
|
210 |
GetFlow().Stop(KErrNone, MNifIfNotify::EDisconnect);
|
|
211 |
}
|
|
212 |
|
|
213 |
return KErrNone;
|
|
214 |
}
|
|
215 |
|
|
216 |
#endif
|
|
217 |
|
|
218 |
/**
|
|
219 |
* Called when the context has been activated to set our IP address and get
|
|
220 |
* any other required settings from CommDB.
|
|
221 |
*
|
|
222 |
* @param aConfig The new context config
|
|
223 |
*/
|
|
224 |
void CIPv6Binder::UpdateContextConfigL(const TPacketDataConfigBase& aConfig)
|
|
225 |
{
|
|
226 |
_LOG_L1C1(_L8("CIPv6Binder::UpdateContextConfig"));
|
|
227 |
|
|
228 |
// Get our IP address from the GPRS context config.
|
|
229 |
TInetAddr address;
|
|
230 |
|
|
231 |
TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
|
|
232 |
|
|
233 |
const RPacketContext::TProtocolConfigOptionV2* pco;
|
|
234 |
TInt rel = const_cast<TPacketDataConfigBase&>(aConfig).ExtensionId();
|
|
235 |
if (rel == TPacketDataConfigBase::KConfigGPRS)
|
|
236 |
{
|
|
237 |
tempAddr.Copy(static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iPdpAddress);
|
|
238 |
pco = &static_cast<const RPacketContext::TContextConfigGPRS&>(aConfig).iProtocolConfigOption;
|
|
239 |
}
|
|
240 |
else
|
|
241 |
{
|
|
242 |
ASSERT(rel == TPacketDataConfigBase::KConfigRel99Rel4 || rel == TPacketDataConfigBase::KConfigRel5);
|
|
243 |
tempAddr.Copy(static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iPdpAddress);
|
|
244 |
pco = &static_cast<const RPacketContext::TContextConfigR99_R4&>(aConfig).iProtocolConfigOption;
|
|
245 |
}
|
|
246 |
TInt ret = address.Input(tempAddr);
|
|
247 |
|
|
248 |
// We've got our IP address! Let's save it.
|
|
249 |
if (ret == KErrNone)
|
|
250 |
{
|
|
251 |
iSettings.iLocalAddr = address.Ip6Address();
|
|
252 |
LOG_IP_ADDRESS("Got local IP address", iSettings.iLocalAddr);
|
|
253 |
}
|
|
254 |
else
|
|
255 |
{
|
|
256 |
_LOG_L2C2(_L8("Couldn't get IP address from GPRS config (err: %d)"),
|
|
257 |
ret);
|
|
258 |
|
|
259 |
// Don't leave on this error: we may still be OK if we read some
|
|
260 |
// settings from CommDB.
|
|
261 |
}
|
|
262 |
|
|
263 |
// @todo - is this correct. We can only get the DNS addresses
|
|
264 |
// from the TSY using the iProtocolConfigOption data. Yet a client could
|
|
265 |
// access those DNS config details without knowing about the state of the
|
|
266 |
// iSettings.iGetDnsFromServer flag.
|
|
267 |
|
|
268 |
if ((iSettings.iGetDnsFromServer) ||
|
|
269 |
((iSettings.iPrimaryDns.IsUnspecified()) &&
|
|
270 |
(iSettings.iSecondaryDns.IsUnspecified())) )
|
|
271 |
{
|
|
272 |
TBuf<RPacketContext::KMaxPDPAddressLength> tempAddr;
|
|
273 |
tempAddr.Copy(pco->iDnsAddresses.iPrimaryDns);
|
|
274 |
ret = address.Input(tempAddr);
|
|
275 |
|
|
276 |
if (ret == KErrNone)
|
|
277 |
{
|
|
278 |
iSettings.iPrimaryDns = address.Ip6Address();
|
|
279 |
LOG_IP_ADDRESS("Got primary DNS", iSettings.iPrimaryDns);
|
|
280 |
}
|
|
281 |
else
|
|
282 |
{
|
|
283 |
_LOG_L2C2(_L8("Couldn't get primary DNS address from GPRS config (err: %d)"),
|
|
284 |
ret);
|
|
285 |
|
|
286 |
// Don't leave on this error: we may still be OK if we read some
|
|
287 |
// settings from CommDB.
|
|
288 |
}
|
|
289 |
|
|
290 |
tempAddr.Copy(pco->iDnsAddresses.iSecondaryDns);
|
|
291 |
ret = address.Input(tempAddr);
|
|
292 |
|
|
293 |
if (ret == KErrNone)
|
|
294 |
{
|
|
295 |
iSettings.iSecondaryDns = address.Ip6Address();
|
|
296 |
LOG_IP_ADDRESS("Got secondary DNS", iSettings.iPrimaryDns);
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
_LOG_L2C2(_L8("Couldn't get secondary DNS address from GPRS config (err: %d)"),
|
|
301 |
ret);
|
|
302 |
|
|
303 |
// Don't leave on this error: we may still be OK if we read some
|
|
304 |
// settings from CommDB.
|
|
305 |
}
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
LOG_IP_ADDRESS("Using CommDB DNS address - Primary ", iSettings.iPrimaryDns);
|
|
310 |
LOG_IP_ADDRESS(" - Secondary ", iSettings.iSecondaryDns);
|
|
311 |
}
|
|
312 |
}
|
|
313 |
|
|
314 |
void CIPv6Binder::UpdateConnectionSpeed(TUint aConnectionSpeed)
|
|
315 |
/**
|
|
316 |
* Sets the speed metric to return to TCP/IP, based on what the TSY tells us.
|
|
317 |
*
|
|
318 |
* @param aConnectionSpeed Our connection speed
|
|
319 |
*/
|
|
320 |
{
|
|
321 |
_LOG_L1C1(_L8("CIPv6Binder::UpdateConnectionSpeed"));
|
|
322 |
|
|
323 |
iSpeedMetric = aConnectionSpeed;
|
|
324 |
}
|
|
325 |
|
|
326 |
ESock::MLowerDataSender::TSendResult CIPv6Binder::Send(RMBufChain& aPdu)
|
|
327 |
{
|
|
328 |
return Send(static_cast<RCommsBufChain&>(aPdu));
|
|
329 |
}
|
|
330 |
|
|
331 |
ESock::MLowerDataSender::TSendResult CIPv6Binder::Send(RCommsBufChain& aPdu)
|
|
332 |
/**
|
|
333 |
* Called by the protocol to send an outgoing IP packet to the network.
|
|
334 |
*
|
|
335 |
* @param aPdu The outgoing packet
|
|
336 |
* @return Standard error codes
|
|
337 |
*/
|
|
338 |
{
|
|
339 |
_LOG_L1C1(_L8("CIPv6Binder::Send"));
|
|
340 |
|
|
341 |
#ifdef __BTT_LOGGING__
|
|
342 |
LogPacket(static_cast<RMBufChain&>(aPdu));
|
|
343 |
#endif
|
|
344 |
|
|
345 |
// Return <0: an error occurred
|
|
346 |
// Return 0: no error, but don't send any more packets
|
|
347 |
|
|
348 |
#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
349 |
iIPTagHeader->AddHeader(aPdu);
|
|
350 |
#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
351 |
|
|
352 |
return ESock::MLowerDataSender::TSendResult(iLowerDataSender->Send(aPdu));
|
|
353 |
|
|
354 |
}
|
|
355 |
|
|
356 |
TInt CIPv6Binder::Notification(TAgentToNifEventType /*aEvent*/,
|
|
357 |
void* /*aInfo*/)
|
|
358 |
/**
|
|
359 |
* The Nif will ignore any notification sent
|
|
360 |
*
|
|
361 |
* @param aEvent Not used
|
|
362 |
* @param aInfo Not used
|
|
363 |
*/
|
|
364 |
{
|
|
365 |
_LOG_L1C1(_L8("CIPv6Binder::Notification"));
|
|
366 |
|
|
367 |
return KErrNone;
|
|
368 |
}
|
|
369 |
|
|
370 |
void CIPv6Binder::StartSending()
|
|
371 |
/**
|
|
372 |
* Indicates to the protocol layer that the NIF is ready to send packets.
|
|
373 |
*
|
|
374 |
* @param aProtocol A pointer to a protocol
|
|
375 |
*/
|
|
376 |
{
|
|
377 |
_LOG_L1C1(_L8("CIPv6Binder::StartSending()"));
|
|
378 |
CBinderBase::StartSending();
|
|
379 |
}
|
|
380 |
|
|
381 |
TBool CIPv6Binder::WantsProtocol(TUint16 aProtocolCode)
|
|
382 |
/**
|
|
383 |
* Indicates the type of protocol implemented by this class.
|
|
384 |
*
|
|
385 |
* @param aProtocolCode The protocol type
|
|
386 |
*/
|
|
387 |
{
|
|
388 |
_LOG_L1C2(_L8("CIPv6Binder::WantsProtocol [aProtocolCode=%X]"),
|
|
389 |
aProtocolCode);
|
|
390 |
|
|
391 |
#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
392 |
return ((aProtocolCode & 0x00FF) == KIp6FrameType);
|
|
393 |
#else
|
|
394 |
(void) aProtocolCode;
|
|
395 |
return ETrue;
|
|
396 |
#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
397 |
}
|
|
398 |
|
|
399 |
void CIPv6Binder::Process(RMBufChain& aPdu)
|
|
400 |
{
|
|
401 |
Process(static_cast<RCommsBufChain&>(aPdu));
|
|
402 |
}
|
|
403 |
|
|
404 |
void CIPv6Binder::Process(RCommsBufChain& aPdu)
|
|
405 |
/**
|
|
406 |
* Called when an incoming IP packet has arrived. Send packets up to the
|
|
407 |
* TCP/IP stack.
|
|
408 |
*
|
|
409 |
* @param aPdu The incoming packet
|
|
410 |
*/
|
|
411 |
{
|
|
412 |
_LOG_L1C1(_L8("CIPv6Binder::Process"));
|
|
413 |
|
|
414 |
#ifdef __BTT_LOGGING__
|
|
415 |
LogPacket(static_cast<RMBufChain&>(aPdu));
|
|
416 |
#endif
|
|
417 |
|
|
418 |
#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
419 |
TUint16 protocolCode = iIPTagHeader->RemoveHeader(aPdu);
|
|
420 |
#else
|
|
421 |
TUint16 protocolCode = 0;
|
|
422 |
#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
// Pass incoming packets up to the protocol, unless it hasn't
|
|
427 |
// been bound yet.
|
|
428 |
if (iUpperReceiver && WantsProtocol(protocolCode))
|
|
429 |
{
|
|
430 |
_LOG_L1C1(_L8("CIPv6Binder: Packet Sent to TCP/IP Protocol!!!"));
|
|
431 |
iUpperReceiver->Process(static_cast<RMBufChain&>(aPdu));
|
|
432 |
}
|
|
433 |
else
|
|
434 |
{
|
|
435 |
_LOG_L2C1(_L8("WARNING: dumping incoming packet, no protocol bound"));
|
|
436 |
aPdu.Free();
|
|
437 |
}
|
|
438 |
|
|
439 |
}
|
|
440 |
|
|
441 |
//
|
|
442 |
// MLowerControl methods
|
|
443 |
//
|
|
444 |
|
|
445 |
TInt CIPv6Binder::GetName(TDes& aName)
|
|
446 |
/**
|
|
447 |
*/
|
|
448 |
{
|
|
449 |
WriteIfName(aName);
|
|
450 |
return KErrNone;
|
|
451 |
}
|
|
452 |
|
|
453 |
//
|
|
454 |
// CBinderBase methods
|
|
455 |
//
|
|
456 |
|
|
457 |
void CIPv6Binder::SetProvision(const CIPConfig& aProvision)
|
|
458 |
/**
|
|
459 |
Set provisioning information for IPv6 binder.
|
|
460 |
|
|
461 |
Called from RawIP Flow.
|
|
462 |
|
|
463 |
@param aProvision Provisioning structure from Control side.
|
|
464 |
*/
|
|
465 |
{
|
|
466 |
iSettings.iPrimaryDns = aProvision.GetIp6NameServer1();
|
|
467 |
iSettings.iSecondaryDns = aProvision.GetIp6NameServer2();
|
|
468 |
iSettings.iGetDnsFromServer = aProvision.GetIp6DNSAddrFromServer();
|
|
469 |
|
|
470 |
// Read whether to get IPv4 address from the server
|
|
471 |
// This is only needed for the integration tests. If it's true then
|
|
472 |
// the IPv4 address will be used to build up the IPv6 address.
|
|
473 |
iSettings.iGetIpFromServer = aProvision.GetIpAddrFromServer();
|
|
474 |
|
|
475 |
if (iSettings.iGetIpFromServer == EFalse)
|
|
476 |
{
|
|
477 |
// Sets the IPv6 Link-local address from IpAddr.
|
|
478 |
// LocalId is derived from IpAddr and it's further used to set the Link-local
|
|
479 |
// address elsewhere by adding a prefix (FE80::) in front.
|
|
480 |
// For IpAddr: 192.168.1.1, link-local address will be FE80::C0A8:101.
|
|
481 |
TUint32 ipAddr = aProvision.GetIpAddress();
|
|
482 |
const TUint8 constantId[8] = { 0, 0, 0, 0,
|
|
483 |
ipAddr >> 24, (ipAddr >> 16) & 0xFF,
|
|
484 |
(ipAddr >> 8) & 0xFF, ipAddr & 0xFF };
|
|
485 |
iSettings.iLocalIfId.SetAddr(constantId, sizeof (constantId));
|
|
486 |
}
|
|
487 |
else
|
|
488 |
{
|
|
489 |
//
|
|
490 |
// Use the 64 bit id of MARM machines as our interface id
|
|
491 |
//
|
|
492 |
TMachineInfoV1Buf machineInfo;
|
|
493 |
UserHal::MachineInfo(machineInfo);
|
|
494 |
iSettings.iLocalIfId.SetAddr(machineInfo().iMachineUniqueId);
|
|
495 |
iSettings.iLocalIfId.SetUniversalBit(0);
|
|
496 |
//
|
|
497 |
// In WINS environment the id is zero which is no-no
|
|
498 |
//
|
|
499 |
if (iSettings.iLocalIfId.IsZero())
|
|
500 |
{
|
|
501 |
iSettings.iLocalIfId.SetAddrRandomNZ();
|
|
502 |
}
|
|
503 |
}
|
|
504 |
}
|
|
505 |
|
|
506 |
#ifdef __BTT_LOGGING__
|
|
507 |
void CIPv6Binder::LogPacket(const RMBufChain& aPacket)
|
|
508 |
/**
|
|
509 |
* Logs packet information into log file.
|
|
510 |
*
|
|
511 |
* @param aPacket The packet
|
|
512 |
*/
|
|
513 |
{
|
|
514 |
_LOG_L1C1(_L8("CIPv6Binder::LogPacket"));
|
|
515 |
|
|
516 |
TInt mBufLength = aPacket.Length() - aPacket.First()->Length();
|
|
517 |
|
|
518 |
_LOG_L3C2(_L8("Analysis of %d byte packet:"), mBufLength);
|
|
519 |
|
|
520 |
//Note: All the constants used on this method are a pragmatic guess of the
|
|
521 |
//IP header fields. The only porpose of this method is logging.
|
|
522 |
|
|
523 |
if (mBufLength < 40)
|
|
524 |
{
|
|
525 |
_LOG_L3C2(_L8(" -doesn't appear to be a valid IPv6 packet (length=%d)")
|
|
526 |
, mBufLength);
|
|
527 |
return;
|
|
528 |
}
|
|
529 |
|
|
530 |
// Get a pointer to the packet's payload.
|
|
531 |
const TUint8* payloadPtr = aPacket.First()->Next()->Ptr();
|
|
532 |
|
|
533 |
if ((payloadPtr[0] & 0xF0) != 0x60)
|
|
534 |
{
|
|
535 |
_LOG_L3C2(_L8(" - doesn't appear to be an IPv6 packet (version=0x%X)"),
|
|
536 |
(payloadPtr[0] & 0xF0) >> 4);
|
|
537 |
return;
|
|
538 |
}
|
|
539 |
|
|
540 |
_LOG_L3C2(_L8(" - traffic class: 0x%X"),
|
|
541 |
((payloadPtr[0] & 0xF) << 4) | ((payloadPtr[1] & 0xF0) >> 4));
|
|
542 |
_LOG_L3C2(_L8(" - flow label: 0x%X"),
|
|
543 |
((payloadPtr[1] & 0x0F) << 16) | (payloadPtr[2] << 8) | payloadPtr[3]);
|
|
544 |
_LOG_L3C2(_L8(" - payload length: 0x%X"),
|
|
545 |
(payloadPtr[4] << 16) | payloadPtr[5]);
|
|
546 |
_LOG_L3C2(_L8(" - next header: 0x%08X"), payloadPtr[6]);
|
|
547 |
_LOG_L3C2(_L8(" - hop limit: 0x%08X"), payloadPtr[7]);
|
|
548 |
}
|
|
549 |
#endif // __BTT_LOGGING__
|