24
|
1 |
// Copyright (c) 2006-2010 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 |
// Implements the CRawIPFlow class, which provides a central point for the NIF
|
|
15 |
// to communicate with NifMan and the BCA controllers. This class creates an interface
|
|
16 |
// to the IPv4 protocol when it is required.
|
|
17 |
//
|
|
18 |
//
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <f32file.h>
|
|
25 |
#include <nifman.h>
|
|
26 |
#include <nifmbuf.h>
|
|
27 |
#include <in_iface.h>
|
|
28 |
#include <nifvar.h>
|
|
29 |
#include "IPv4Binder.h"
|
|
30 |
#include "IPv6Binder.h"
|
|
31 |
#include "RawIPFlow.h"
|
|
32 |
#include <comms-infras/linkprovision.h>
|
|
33 |
#include <comms-infras/linkmessages.h>
|
|
34 |
#include <comms-infras/ss_metaconnprov.h> // for SAccessPointConfig
|
|
35 |
#include <elements/nm_messages_base.h>
|
|
36 |
#include <elements/nm_messages_child.h>
|
|
37 |
#include <comms-infras/ss_nodemessages_flow.h>
|
|
38 |
|
|
39 |
using namespace Messages;
|
|
40 |
using namespace MeshMachine;
|
|
41 |
using namespace ESock;
|
|
42 |
|
|
43 |
#ifdef __FLOG_ACTIVE
|
|
44 |
//These variables are used only if flog is active.
|
|
45 |
_LIT8(KTcpDumpFirstTag,"TcpDump");
|
|
46 |
static const TUint16 KTcpDumpLinkType = 12;
|
|
47 |
#endif
|
|
48 |
|
|
49 |
CRawIPFlow::CRawIPFlow(CSubConnectionFlowFactoryBase& aFactory, const TNodeId& aSubConnId, CProtocolIntfBase* aProtocolIntf, CBttLogger* aTheLogger)
|
|
50 |
/**
|
|
51 |
* Constructor.
|
|
52 |
*
|
|
53 |
* @param aFactory Reference to the factory which created this object.
|
|
54 |
* @param aTheLogger The logging object, ownership is passed to this object
|
|
55 |
*/
|
|
56 |
: CSubConnectionFlowBase(aFactory, aSubConnId, aProtocolIntf),
|
|
57 |
iTheLogger(aTheLogger),
|
|
58 |
iInitError(KErrNone),
|
|
59 |
iStarted(EFalse),
|
|
60 |
iStopping(EFalse)
|
|
61 |
{
|
|
62 |
LOG_NODE_CREATE(KNifSubDir, CRawIPFlow);
|
|
63 |
}
|
|
64 |
|
|
65 |
void CRawIPFlow::ConstructL()
|
|
66 |
/**
|
|
67 |
* Second-phase constructor. Creates the Etel
|
|
68 |
* control engine
|
|
69 |
*
|
|
70 |
* @param aName The name of the NIF (unused)
|
|
71 |
*/
|
|
72 |
{
|
|
73 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tConstructL()"), this);
|
|
74 |
iBinderControl = new (ELeave) TBinderControlProxy(*this);
|
|
75 |
iBcaController = CBcaIoController::NewL(*this, iTheLogger);
|
|
76 |
}
|
|
77 |
|
|
78 |
CRawIPFlow::~CRawIPFlow()
|
|
79 |
/**
|
|
80 |
* Destructor. Cancels and deletes all owned active objects.
|
|
81 |
*/
|
|
82 |
{
|
|
83 |
// Note that we don't delete iBinder because it's not owned by us.
|
|
84 |
delete iBcaController;
|
|
85 |
// This class also deletes the logging object
|
|
86 |
delete iTheLogger;
|
|
87 |
|
|
88 |
ASSERT(iBinder == NULL);
|
|
89 |
|
|
90 |
delete iBinderControl;
|
|
91 |
LOG_NODE_DESTROY(KNifSubDir, CRawIPFlow);
|
|
92 |
// Cleanup when stop was not called - harmless as it null's the pointer
|
|
93 |
__PACKETLOG_DELETE;
|
|
94 |
}
|
|
95 |
|
|
96 |
void CRawIPFlow::StartFlowL()
|
|
97 |
/**
|
|
98 |
* Starts the Flow up. This process involves connecting to the BCA. When startup is
|
|
99 |
* complete, LinkLayerUp() will be called.
|
|
100 |
*
|
|
101 |
* Called in response to corresponding SCPR message.
|
|
102 |
*
|
|
103 |
* @return Allways KErrNone
|
|
104 |
*/
|
|
105 |
{
|
|
106 |
ASSERT(iStarting==EFalse);
|
|
107 |
iStarting = ETrue;
|
|
108 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tStartFlowL()"), this);
|
|
109 |
|
|
110 |
// If there were any errors during earlier processing of the ProvisionConfig message
|
|
111 |
// then send an Error message in response to the StartFlow (because ProvisionConfig
|
|
112 |
// does not have a response code).
|
|
113 |
if (iProvisionError != KErrNone)
|
|
114 |
{
|
|
115 |
User::Leave(iProvisionError);
|
|
116 |
}
|
|
117 |
|
|
118 |
// Retrieve Agent provisioned information only available at StartFlow time
|
|
119 |
DynamicProvisionConfigL();
|
|
120 |
InitialiseL(MControllerObserver::EStart, KErrNone);
|
|
121 |
|
|
122 |
//the name calculation should be done only if logging is enabled
|
|
123 |
#ifdef __FLOG_ACTIVE
|
|
124 |
const TUint KModemNameLen = KCommsDbSvrMaxColumnNameLength + 10; // need enough for ppp-XXX.txt - e.g. ppp-comm-1.txt, ppp-btcomm-10.txt etc
|
|
125 |
TBuf8<KModemNameLen> modemName;
|
|
126 |
|
|
127 |
_LIT8(KDoubleColon, "::");
|
|
128 |
|
|
129 |
modemName.Copy(iProvision->GetPortName());
|
|
130 |
const TInt pos = modemName.FindC((const TDesC8&)KDoubleColon);
|
|
131 |
if(pos != KErrNotFound)
|
|
132 |
{
|
|
133 |
modemName.Delete(pos, 2);
|
|
134 |
}
|
|
135 |
|
|
136 |
//append time stamp
|
|
137 |
const TUint KTimeStampLen = 8;
|
|
138 |
TBuf8<KTimeStampLen> logFileName;
|
|
139 |
|
|
140 |
_LIT8(KTimeFormat, "%08X");
|
|
141 |
TUint32 counter = User::FastCounter();
|
|
142 |
logFileName.Format(KTimeFormat, counter);
|
|
143 |
|
|
144 |
TRAPD(err,__PACKETLOG_NEWL(KTcpDumpFirstTag, logFileName, CPacketLogger::ETcpDump, KTcpDumpLinkType));
|
|
145 |
if (err)
|
|
146 |
{
|
|
147 |
_LOG_L1C1(_L8("Trapped leave from __PACKETLOG_NEWL"));
|
|
148 |
}
|
|
149 |
|
|
150 |
const TUint KLogTextLen = KModemNameLen+KTimeStampLen+30;
|
|
151 |
TBuf8<KLogTextLen> logText;
|
|
152 |
_LIT8(KLogTimeText, "TcpDump log file time stamp:");
|
|
153 |
_LIT8(KLogModemText, " for modem:");
|
|
154 |
logText.Append(KLogTimeText);
|
|
155 |
logText.Append(logFileName);
|
|
156 |
logText.Append(KLogModemText);
|
|
157 |
logText.Append(modemName);
|
|
158 |
_LOG_L1C1(logText);
|
|
159 |
#endif
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
void CRawIPFlow::LinkLayerUp()
|
|
164 |
/**
|
|
165 |
* This function is called when initialisation is complete and the Flow is
|
|
166 |
* ready to send/receive data. It notifies NifMan and the IP interface that it's
|
|
167 |
* ready to go.
|
|
168 |
*/
|
|
169 |
{
|
|
170 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tLinkLayerUp()"), this);
|
|
171 |
|
|
172 |
iLastRequestOriginator.ReplyTo(Id(), TCFDataClient::TStarted().CRef());
|
|
173 |
|
|
174 |
|
|
175 |
iBinder->StartSending();
|
|
176 |
iStarted = ETrue;
|
|
177 |
iStarting = EFalse;
|
|
178 |
}
|
|
179 |
|
|
180 |
void CRawIPFlow::LinkLayerDown(TInt aError)
|
|
181 |
/**
|
|
182 |
* This function is called when the context has been deactivated and the NIF
|
|
183 |
* is ready to be deleted, or if there is an error on startup. Its job is to
|
|
184 |
* notify NifMan that the link has gone down, so it can delete the NIF.
|
|
185 |
*
|
|
186 |
* @param aError An error code to propagate to NifMan
|
|
187 |
*/
|
|
188 |
{
|
|
189 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tLinkLayerDown(aError %d)"), this, aError);
|
|
190 |
__PACKETLOG_DELETE;
|
|
191 |
|
|
192 |
if (iStopping)
|
|
193 |
{
|
|
194 |
iLastRequestOriginator.ReplyTo(Id(), TCFDataClient::TStopped(aError).CRef());
|
|
195 |
}
|
|
196 |
else if (iStarting)
|
|
197 |
{
|
|
198 |
iSubConnectionProvider.PostMessage(Id(), TEBase::TError(TCFServiceProvider::TStart::Id(), aError).CRef());
|
|
199 |
}
|
|
200 |
else
|
|
201 |
{
|
|
202 |
iSubConnectionProvider.PostMessage(Id(), TCFControlProvider::TDataClientGoneDown(aError, MNifIfNotify::EDisconnect).CRef());
|
|
203 |
}
|
|
204 |
|
|
205 |
iStarted = EFalse;
|
|
206 |
iStarting = EFalse;
|
|
207 |
iStopping = EFalse;
|
|
208 |
}
|
|
209 |
|
|
210 |
void CRawIPFlow::StopFlow(TInt aError)
|
|
211 |
/**
|
|
212 |
* This function is called by NifMan to bring down the link. It starts
|
|
213 |
* the asynchronous context deactivation process; LinkLayerDown() will be
|
|
214 |
* called when the context has been deactivated.
|
|
215 |
*
|
|
216 |
* @param aError A code specifying why the link is to be brought down
|
|
217 |
* @param aAction The action to take: disconnect or reconnect
|
|
218 |
*/
|
|
219 |
{
|
|
220 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tStopFlow(aError %d)"), this, aError);
|
|
221 |
__PACKETLOG_DELETE;
|
|
222 |
iStopping = ETrue;
|
|
223 |
ShutDown(MControllerObserver::EInitialised, aError);
|
|
224 |
}
|
|
225 |
|
|
226 |
MLowerDataSender::TSendResult CRawIPFlow::SendPacket(RMBufChain& aPdu, TAny* /*aProtocol*/,
|
|
227 |
TUint16 /*aType*/)
|
|
228 |
/**
|
|
229 |
* Sends a packet, via the BCA controller. This method is protocol-agnostic,
|
|
230 |
* and is called by the IPv4 and IPv6 binder to actually send packets.
|
|
231 |
*
|
|
232 |
* @param aPdu The packet to send
|
|
233 |
* @return MLowerDataSender::TSendResult
|
|
234 |
*/
|
|
235 |
{
|
|
236 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tSendPacket(): length=%d"),
|
|
237 |
this, aPdu.Length() - aPdu.First()->Length());
|
|
238 |
|
|
239 |
__PACKETLOG_WRITE_PACKET(aPdu, 0);
|
|
240 |
return iBcaController->Send(aPdu);
|
|
241 |
}
|
|
242 |
|
|
243 |
void CRawIPFlow::Process(RMBufChain& aPdu, TUint16 aProtocolCode)
|
|
244 |
/**
|
|
245 |
* Handles incoming packets which have been passed up from the BCA controller.
|
|
246 |
* If the IPv4 binder wants to process the packet, it hands it on; otherwise,
|
|
247 |
* the packet is binned.
|
|
248 |
*
|
|
249 |
* @param aPdu The incoming packet
|
|
250 |
*/
|
|
251 |
{
|
|
252 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tProcess() [aPdu length=%d]"),
|
|
253 |
this, aPdu.Length() - aPdu.First()->Length());
|
|
254 |
|
|
255 |
// If the packet has zero or negative length, bin it.
|
|
256 |
if ((aPdu.Length() - aPdu.First()->Length()) <= 0)
|
|
257 |
{
|
|
258 |
_LOG_L1C1(_L8("Dumped packet: illegal length"));
|
|
259 |
aPdu.Free();
|
|
260 |
return;
|
|
261 |
}
|
|
262 |
|
|
263 |
// See if the protocol interface wants the packet.
|
|
264 |
if (iBinder && iBinder->WantsProtocol(aProtocolCode))
|
|
265 |
{
|
|
266 |
__PACKETLOG_WRITE_PACKET(aPdu, 0);
|
|
267 |
iBinder->Process(aPdu);
|
|
268 |
}
|
|
269 |
else
|
|
270 |
{
|
|
271 |
// The protocol didn't want the packet, so bin it.
|
|
272 |
_LOG_L1C2(_L8("Packet was not processed: freeing (protocol code: %X)"),
|
|
273 |
aProtocolCode);
|
|
274 |
if (iBinder == NULL)
|
|
275 |
{
|
|
276 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tProcess(): NOTE: Binder not present"), this);
|
|
277 |
}
|
|
278 |
aPdu.Free();
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
void CRawIPFlow::ResumeSending()
|
|
283 |
/**
|
|
284 |
* Notifies the protocol interface that it can resume sending packets.
|
|
285 |
*/
|
|
286 |
{
|
|
287 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tResumeSending()"), this);
|
|
288 |
|
|
289 |
if (iBinder)
|
|
290 |
{
|
|
291 |
iBinder->StartSending();
|
|
292 |
}
|
|
293 |
else
|
|
294 |
{
|
|
295 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tResumeSending(): NOTE: Binder not present"), this);
|
|
296 |
}
|
|
297 |
}
|
|
298 |
|
|
299 |
void CRawIPFlow::InitialiseL(TInitialisationState aState, TInt aError)
|
|
300 |
/**
|
|
301 |
* This method controls the initialisation sequence of the different modules
|
|
302 |
* in the Flow. When a module completes all the initialisation tasks it will
|
|
303 |
* call again this method with the new state. If an error occurs then the
|
|
304 |
* ShutDown() method will be called.
|
|
305 |
*
|
|
306 |
* @param aState The current initialisation step
|
|
307 |
* @param aError A possible error
|
|
308 |
*/
|
|
309 |
{
|
|
310 |
_LOG_L1C4(_L8("CRawIPFlow %08x:\tInitialiseL(aState %d, aError %d)"),
|
|
311 |
this, aState, aError);
|
|
312 |
|
|
313 |
if (aError != KErrNone)
|
|
314 |
{
|
|
315 |
_LOG_L2C2(_L8(" *** FAILED to initialise NIF *** Error =%d"),aError);
|
|
316 |
|
|
317 |
// Initialise shutdown sequence
|
|
318 |
switch (aState)
|
|
319 |
{
|
|
320 |
case MControllerObserver::EBcaController:
|
|
321 |
ShutDown(MControllerObserver::EInitialised, aError);
|
|
322 |
break;
|
|
323 |
default:
|
|
324 |
_LOG_L2C3(_L8("ERROR CRawIPFlow: Unknown state:%d in NIF: %S"), aState, &KNifName);
|
|
325 |
User::Leave(KErrUnknown);
|
|
326 |
break;
|
|
327 |
}
|
|
328 |
return;
|
|
329 |
}
|
|
330 |
|
|
331 |
switch (aState)
|
|
332 |
{
|
|
333 |
case MControllerObserver::EStart:
|
|
334 |
{
|
|
335 |
// Update local state from TSY information originally from Agent.
|
|
336 |
GetBinder()->UpdateContextConfigL(*iAgentProvision->iGprsConfig);
|
|
337 |
GetBinder()->UpdateConnectionSpeed(iAgentProvision->iConnectionSpeed);
|
|
338 |
|
|
339 |
_LOG_L1C2(_L8("Port details %S"), &iProvision->GetPortName());
|
|
340 |
iBcaController->SetPort(iProvision->GetPortName());
|
|
341 |
|
|
342 |
_LOG_L1C3(_L8("bcaName details %S,%S"),&iProvision->GetBCAStack(), &iProvision->GetBCAName());
|
|
343 |
iBcaController->SetBcaStackAndName(iProvision->GetBCAStack(), iProvision->GetBCAName());
|
|
344 |
|
|
345 |
_LOG_L1C2(_L8("IAP ID details %u"), iProvision->GetIAPid());
|
|
346 |
iBcaController->SetIapId(iProvision->GetIAPid());
|
|
347 |
|
|
348 |
UpdateContextState(RPacketContext::EStatusActive, KErrNone);
|
|
349 |
|
|
350 |
iBcaController->StartL();
|
|
351 |
}
|
|
352 |
break;
|
|
353 |
case MControllerObserver::EBcaController:
|
|
354 |
_LOG_L1C1(_L8(" ***** NIF INITIALISED *****"));
|
|
355 |
LinkLayerUp();
|
|
356 |
break;
|
|
357 |
default:
|
|
358 |
_LOG_L2C3(_L8("ERROR CRawIPFlow: Unknown state:%d in NIF: %S"), aState, &KNifName);
|
|
359 |
User::Leave(KErrUnknown);
|
|
360 |
break;
|
|
361 |
}
|
|
362 |
}
|
|
363 |
|
|
364 |
void CRawIPFlow::ShutDown(TInitialisationState aState, TInt aError)
|
|
365 |
/**
|
|
366 |
* This method controls the shutdown sequence of the different modules
|
|
367 |
* in the Flow. When a module completes all the shutdown tasks it will
|
|
368 |
* call again this method with the new state.
|
|
369 |
*
|
|
370 |
* @param aState The current state
|
|
371 |
* @param aError A possible error (only during initialisation)
|
|
372 |
*/
|
|
373 |
{
|
|
374 |
_LOG_L1C4(_L8("CRawIPFlow %08x:\tShutDown(aState %d, aError %d)"),
|
|
375 |
this, aState, aError);
|
|
376 |
|
|
377 |
if (aError != KErrNone)
|
|
378 |
{
|
|
379 |
// Flow is shutting down due to an error.
|
|
380 |
// The error code must be stored in order to call linklayer down
|
|
381 |
// passing that value
|
|
382 |
iInitError = aError;
|
|
383 |
}
|
|
384 |
|
|
385 |
switch (aState)
|
|
386 |
{
|
|
387 |
case MControllerObserver::EInitialised:
|
|
388 |
iBcaController->Stop(aError);
|
|
389 |
break;
|
|
390 |
case MControllerObserver::EBcaController:
|
|
391 |
LinkLayerDown(iInitError);
|
|
392 |
break;
|
|
393 |
default:
|
|
394 |
_LOG_L2C1(_L8("ERROR CRawIPFlow: Unknown Shutdown step"));
|
|
395 |
_BTT_PANIC(KNifName,KNifUnknownShutDownState);
|
|
396 |
break;
|
|
397 |
}
|
|
398 |
}
|
|
399 |
|
|
400 |
CBinderBase* CRawIPFlow::GetBinder()
|
|
401 |
/**
|
|
402 |
* Returns a pointer to the Binder class
|
|
403 |
*
|
|
404 |
* @return a pointer to a CBinderBase derived class
|
|
405 |
*/
|
|
406 |
{
|
|
407 |
return iBinder;
|
|
408 |
}
|
|
409 |
|
|
410 |
CBcaIoController* CRawIPFlow::GetBcaController()
|
|
411 |
/**
|
|
412 |
* Returns a pointer to the CBcaIoController class
|
|
413 |
*
|
|
414 |
* @return a pointer to CBcaIoController
|
|
415 |
*/
|
|
416 |
{
|
|
417 |
return iBcaController;
|
|
418 |
}
|
|
419 |
|
|
420 |
void CRawIPFlow::UpdateContextState(
|
|
421 |
RPacketContext::TContextStatus aState, TInt /*aError*/)
|
|
422 |
/**
|
|
423 |
* Updates the state of the iContextState variable
|
|
424 |
*
|
|
425 |
* @param aState The new state
|
|
426 |
* @param aError A possible error
|
|
427 |
*/
|
|
428 |
{
|
|
429 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tUpdateContextState(aState %d)"), this, aState);
|
|
430 |
|
|
431 |
// Note that we do not need to close the Flow down if there's been an
|
|
432 |
// error, as the context state machine will do this for us.
|
|
433 |
|
|
434 |
iContextStatus = aState;
|
|
435 |
}
|
|
436 |
|
|
437 |
// =====================================================================================
|
|
438 |
//
|
|
439 |
// CSubConnectionFlowBase
|
|
440 |
//
|
|
441 |
|
|
442 |
MFlowBinderControl* CRawIPFlow::DoGetBinderControlL()
|
|
443 |
{
|
|
444 |
return iBinderControl;
|
|
445 |
}
|
|
446 |
|
|
447 |
// =====================================================================================
|
|
448 |
//
|
|
449 |
// MFlowBinderControl methods
|
|
450 |
//
|
|
451 |
|
|
452 |
MLowerControl* CRawIPFlow::GetControlL(const TDesC8& aProtocol)
|
|
453 |
{
|
|
454 |
#ifdef __BTT_LOGGING__
|
|
455 |
//TBuf8<256> debugBuffer;
|
|
456 |
//debugBuffer.Copy(aProtocol);
|
|
457 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tGetControlL(aProtocol %S)"), this, &aProtocol);
|
|
458 |
#endif
|
|
459 |
|
|
460 |
// IPv4 and ICMP Protocols
|
|
461 |
if (aProtocol.CompareF(KDescIp()) == 0 || aProtocol.CompareF(KDescIcmp()) == 0)
|
|
462 |
{
|
|
463 |
if (!iBinder)
|
|
464 |
{
|
|
465 |
iBinder = new (ELeave) CIPv4Binder(*this, iTheLogger);
|
|
466 |
#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
467 |
iBcaController->SetType(KIp4FrameType);
|
|
468 |
#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
469 |
}
|
|
470 |
else
|
|
471 |
{
|
|
472 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tGetControlL(): IPv4 binder already exists"), this);
|
|
473 |
}
|
|
474 |
}
|
|
475 |
// IPv6 Protocol
|
|
476 |
else if (aProtocol.CompareF(KDescIp6()) == 0)
|
|
477 |
{
|
|
478 |
if (!iBinder)
|
|
479 |
{
|
|
480 |
iBinder = new (ELeave) CIPv6Binder(*this, iTheLogger);
|
|
481 |
#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
482 |
iBcaController->SetType(KIp6FrameType);
|
|
483 |
#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
484 |
}
|
|
485 |
else
|
|
486 |
{
|
|
487 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tGetControlL(): IPv6 binder already exists"), this);
|
|
488 |
}
|
|
489 |
}
|
|
490 |
else
|
|
491 |
{
|
|
492 |
User::Leave(KErrNotSupported);
|
|
493 |
}
|
|
494 |
|
|
495 |
return iBinder;
|
|
496 |
}
|
|
497 |
|
|
498 |
MLowerDataSender* CRawIPFlow::BindL(const TDesC8& aProtocol, MUpperDataReceiver* aReceiver, MUpperControl* aControl)
|
|
499 |
/**
|
|
500 |
* Binds upper CFProtocol to this CFProtocol
|
|
501 |
*
|
|
502 |
* @param aUpperReceiver A pointer to Upper layer Receive class
|
|
503 |
* @param aUpperControl A pointer to Upper layer control class
|
|
504 |
*/
|
|
505 |
{
|
|
506 |
#ifndef _DEBUG
|
|
507 |
(void) aProtocol;
|
|
508 |
#endif
|
|
509 |
|
|
510 |
ASSERT (aProtocol.CompareF(KDescIp()) == 0 || aProtocol.CompareF(KDescIcmp()) == 0
|
|
511 |
|| aProtocol.CompareF(KDescIp6()) == 0);
|
|
512 |
ASSERT(iBinder);
|
|
513 |
|
|
514 |
iSubConnectionProvider.PostMessage(Id(), TCFControlProvider::TActive().CRef());
|
|
515 |
return iBinder->Bind(aReceiver, aControl);
|
|
516 |
}
|
|
517 |
|
|
518 |
void CRawIPFlow::Unbind(MUpperDataReceiver* aUpperReceiver, MUpperControl* aUpperControl)
|
|
519 |
{
|
|
520 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tUnbind()"), this);
|
|
521 |
|
|
522 |
if (iBinder)
|
|
523 |
{
|
|
524 |
iBinder->Unbind(aUpperReceiver, aUpperControl);
|
|
525 |
|
|
526 |
delete iBinder;
|
|
527 |
iBinder = NULL;
|
|
528 |
}
|
|
529 |
|
|
530 |
SendDataClientIdleIfNoClients();
|
|
531 |
}
|
|
532 |
|
|
533 |
|
|
534 |
void CRawIPFlow::SendDataClientIdleIfNoClients()
|
|
535 |
{
|
|
536 |
if (iBinder == NULL)
|
|
537 |
{
|
|
538 |
iSubConnectionProvider.PostMessage(Id(), TCFControlProvider::TIdle().CRef());
|
|
539 |
}
|
|
540 |
}
|
|
541 |
|
|
542 |
CSubConnectionFlowBase* CRawIPFlow::Flow()
|
|
543 |
/**
|
|
544 |
Return the Flow corresponding to the MFlowBinderControl
|
|
545 |
*/
|
|
546 |
{
|
|
547 |
return this;
|
|
548 |
}
|
|
549 |
|
|
550 |
// =====================================================================================
|
|
551 |
//
|
|
552 |
// Messages::ANode
|
|
553 |
//
|
|
554 |
|
|
555 |
void CRawIPFlow::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage)
|
|
556 |
{
|
|
557 |
CSubConnectionFlowBase::ReceivedL(aSender, aRecipient, aMessage);
|
|
558 |
|
|
559 |
if (aMessage.IsMessage<TEBase::TError>())
|
|
560 |
{
|
|
561 |
SubConnectionError(static_cast<TEBase::TError&>(aMessage).iValue);
|
|
562 |
}
|
|
563 |
else if (TEChild::ERealmId == aMessage.MessageId().Realm())
|
|
564 |
{
|
|
565 |
switch (aMessage.MessageId().MessageId())
|
|
566 |
{
|
|
567 |
case TEChild::TDestroy::EId :
|
|
568 |
Destroy();
|
|
569 |
break;
|
|
570 |
default:
|
|
571 |
//TODO - logging
|
|
572 |
ASSERT(EFalse);
|
|
573 |
}
|
|
574 |
}
|
|
575 |
else if (TCFDataClient::ERealmId == aMessage.MessageId().Realm())
|
|
576 |
{
|
|
577 |
switch (aMessage.MessageId().MessageId())
|
|
578 |
{
|
|
579 |
case TCFDataClient::TStart::EId :
|
|
580 |
StartFlowL();
|
|
581 |
break;
|
|
582 |
case TCFDataClient::TStop::EId :
|
|
583 |
StopFlow(static_cast<TCFDataClient::TStop&>(aMessage).iValue);
|
|
584 |
break;
|
|
585 |
case TCFDataClient::TProvisionConfig::EId:
|
|
586 |
ProvisionConfig(static_cast<TCFDataClient::TProvisionConfig&>(aMessage).iConfig);
|
|
587 |
break;
|
|
588 |
case TCFDataClient::TBindTo::EId:
|
|
589 |
{
|
|
590 |
TCFDataClient::TBindTo& bindToReq = message_cast<TCFDataClient::TBindTo>(aMessage);
|
|
591 |
if (!bindToReq.iNodeId.IsNull())
|
|
592 |
{
|
|
593 |
User::Leave(KErrNotSupported);
|
|
594 |
}
|
|
595 |
RClientInterface::OpenPostMessageClose(Id(), aSender, TCFDataClient::TBindToComplete().CRef());
|
|
596 |
}
|
|
597 |
break;
|
|
598 |
default:
|
|
599 |
//TODO - logging
|
|
600 |
ASSERT(EFalse);
|
|
601 |
}
|
|
602 |
}
|
|
603 |
else if (TCFFlow::ERealmId == aMessage.MessageId().Realm())
|
|
604 |
{
|
|
605 |
switch (aMessage.MessageId().MessageId())
|
|
606 |
{
|
|
607 |
case TCFFlow::TBlock::EId :
|
|
608 |
{
|
|
609 |
// if there is a packet being sent and it completes
|
|
610 |
// flow control will stop sending any further packets
|
|
611 |
// while the flow is blocked.
|
|
612 |
|
|
613 |
iBcaController->BlockSending();
|
|
614 |
}
|
|
615 |
break;
|
|
616 |
case TCFFlow::TUnBlock::EId :
|
|
617 |
{
|
|
618 |
// ResumeSending is specific for the unblocking the flow - it
|
|
619 |
// cancels the flow control and restarts the flow appropriately
|
|
620 |
// (i.e. if there is a packet outstanding, messages in the queue
|
|
621 |
// or idle and no queue).
|
|
622 |
iBcaController->ResumeSending();
|
|
623 |
}
|
|
624 |
break;
|
|
625 |
case TCFFlow::TRejoin::EId:
|
|
626 |
{
|
|
627 |
TCFFlow::TRejoin& rejoinMsg = message_cast<TCFFlow::TRejoin>(aMessage);
|
|
628 |
TDefaultFlowFactoryQuery query(rejoinMsg.iNodeId);
|
|
629 |
CRawIPFlow* otherFlow = static_cast<CRawIPFlow*>(Factory().Find(query));
|
|
630 |
ASSERT(otherFlow);
|
|
631 |
|
|
632 |
//This rather ugly looking snipped of code implements
|
|
633 |
//the scenario whereat the network tears down the default
|
|
634 |
//scpr and the default scpr selects a new default amongst
|
|
635 |
//the non-default and subsequently performs a transparant
|
|
636 |
//swap - i.e.: the upper layer perceives this as a
|
|
637 |
//non-default going down. Since the datapath is pre-bound
|
|
638 |
//to the flow representing the default, the datapath needs
|
|
639 |
//to perform a transparent swap too, so that the upper layer
|
|
640 |
//doesn't notice anything. It does that by swapping the
|
|
641 |
//flows below the binders.
|
|
642 |
CBinderBase* localBinder = iBinder;
|
|
643 |
CBttLogger* logger = localBinder->iTheLogger;
|
|
644 |
|
|
645 |
TBinderControlProxy* localBinderControl = iBinderControl;
|
|
646 |
iBinder = otherFlow->iBinder;
|
|
647 |
otherFlow->iBinder->ChangeFlow(*this);
|
|
648 |
localBinder->ChangeFlow(*otherFlow);
|
|
649 |
otherFlow->iBinder = localBinder;
|
|
650 |
iBinderControl = otherFlow->iBinderControl;
|
|
651 |
otherFlow->iBinderControl = localBinderControl;
|
|
652 |
otherFlow->iBinderControl->iFlow = otherFlow;
|
|
653 |
iBinderControl->iFlow = this;
|
|
654 |
|
|
655 |
iBinder->iTheLogger = logger;
|
|
656 |
|
|
657 |
iSubConnectionProvider.Close();
|
|
658 |
iSubConnectionProvider.Open(address_cast<TNodeId>(rejoinMsg.iNodeId));
|
|
659 |
}
|
|
660 |
break;
|
|
661 |
default:
|
|
662 |
//TODO - logging
|
|
663 |
ASSERT(EFalse);
|
|
664 |
}
|
|
665 |
}
|
|
666 |
else if (TLinkMessage::ERealmId == aMessage.MessageId().Realm())
|
|
667 |
{
|
|
668 |
switch (aMessage.MessageId().MessageId())
|
|
669 |
{
|
|
670 |
case TLinkMessage::TAgentToFlowNotification::EId:
|
|
671 |
{
|
|
672 |
TLinkMessage::TAgentToFlowNotification& msg = static_cast<TLinkMessage::TAgentToFlowNotification&>(aMessage);
|
|
673 |
Notification(msg.iValue);
|
|
674 |
break;
|
|
675 |
}
|
|
676 |
default:
|
|
677 |
ASSERT(EFalse);
|
|
678 |
}
|
|
679 |
}
|
|
680 |
else // not a recognised realm or message
|
|
681 |
{
|
|
682 |
ASSERT(EFalse);
|
|
683 |
}
|
|
684 |
}
|
|
685 |
|
|
686 |
|
|
687 |
// =====================================================================================
|
|
688 |
//
|
|
689 |
// Methods for handling incoming SCPR messages
|
|
690 |
//
|
|
691 |
|
|
692 |
void CRawIPFlow::SubConnectionGoingDown()
|
|
693 |
{
|
|
694 |
}
|
|
695 |
|
|
696 |
void CRawIPFlow::SubConnectionError(TInt /*aError*/)
|
|
697 |
{
|
|
698 |
}
|
|
699 |
|
|
700 |
/*
|
|
701 |
Provisioning description for RawIp CFProtocol Flow:
|
|
702 |
|
|
703 |
- on receipt of the ProvisionConfig message, the pointer contained within is stored
|
|
704 |
in iAccessPointConfig and the provisioning information contained within it is validated:
|
|
705 |
- CBCAProvision must be present. It is added by the RawIpMCPr and populated from CommsDat. A pointer to it
|
|
706 |
is stored in iProvision.
|
|
707 |
if any are missing, an error is stored in iProvisionError and sent in response to the StartFlow
|
|
708 |
message later on (ProvisionConfig has no response).
|
|
709 |
|
|
710 |
- on receipt of the StartFlow message, further provisioning information is retrieved:
|
|
711 |
- CIPConfig must be present. It is added by the RawIpMCPr and populated from CommsDat. The binder retrieves
|
|
712 |
individual fields from it.
|
|
713 |
- CRawIpAgentConfig must be present. It is added by the RawIpAgentHandler and populated via calls
|
|
714 |
to the Agent. A pointer to it is stored in iAgentProvision. Note that the iGprsConfig field
|
|
715 |
is a pointer to a (large) structure in the Agent (see CRawIpAgentHandler).
|
|
716 |
if any of the above are missing, an Error message is signalled back to the SCPr in response
|
|
717 |
to the StartFlow.
|
|
718 |
*/
|
|
719 |
|
|
720 |
void CRawIPFlow::ProvisionConfig(const ESock::RMetaExtensionContainerC& aConfigData)
|
|
721 |
/**
|
|
722 |
Handle ProvisionConfig message from SCPR.
|
|
723 |
|
|
724 |
Just save the pointer for now - validate it later on StartFlow.
|
|
725 |
|
|
726 |
@param aData provisioning pointer from message
|
|
727 |
*/
|
|
728 |
{
|
|
729 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tProvisionConfig()"), this);
|
|
730 |
|
|
731 |
AccessPointConfig().Close();
|
|
732 |
AccessPointConfig().Open(aConfigData);
|
|
733 |
|
|
734 |
iProvision = static_cast<const CBCAProvision*>(AccessPointConfig().FindExtension(
|
|
735 |
STypeId::CreateSTypeId(CBCAProvision::EUid, CBCAProvision::ETypeId)));
|
|
736 |
|
|
737 |
}
|
|
738 |
|
|
739 |
void CRawIPFlow::DynamicProvisionConfigL()
|
|
740 |
/**
|
|
741 |
Retrieve provisioning information available only at StartFlow time.
|
|
742 |
*/
|
|
743 |
{
|
|
744 |
if (iProvision == NULL)
|
|
745 |
{
|
|
746 |
_LOG_L1C1(_L8("CRawIPFlow:\tProvisionConfigL() - CBCAProvision config incomplete"));
|
|
747 |
iProvisionError = KErrCorrupt;
|
|
748 |
return;
|
|
749 |
}
|
|
750 |
|
|
751 |
ASSERT(iAgentProvision == NULL);
|
|
752 |
iAgentProvision = static_cast<const CRawIpAgentConfig*>(AccessPointConfig().FindExtension(
|
|
753 |
STypeId::CreateSTypeId(CRawIpAgentConfig::EUid, CRawIpAgentConfig::ETypeId)));
|
|
754 |
|
|
755 |
if (iAgentProvision == NULL)
|
|
756 |
{
|
|
757 |
User::Leave(KErrCorrupt);
|
|
758 |
}
|
|
759 |
|
|
760 |
const CIPConfig* wcdmaIpProvision = static_cast<const CIPConfig*>(AccessPointConfig().FindExtension(
|
|
761 |
STypeId::CreateSTypeId(CIPConfig::EUid, CIPConfig::ETypeId)));
|
|
762 |
if (wcdmaIpProvision == NULL)
|
|
763 |
{
|
|
764 |
_LOG_L1C2(_L8("CRawIPFlow %08x:\tDynamicProvisionConfigL() - WCDMA config incomplete"), this);
|
|
765 |
iProvisionError = KErrCorrupt;
|
|
766 |
return;
|
|
767 |
}
|
|
768 |
// Pass pointer to binder specific provisioning information to binder
|
|
769 |
if (iBinder)
|
|
770 |
{
|
|
771 |
iBinder->SetProvision(*wcdmaIpProvision);
|
|
772 |
}
|
|
773 |
}
|
|
774 |
|
|
775 |
|
|
776 |
void CRawIPFlow::Destroy()
|
|
777 |
/**
|
|
778 |
Handle Destroy message from SCPR.
|
|
779 |
*/
|
|
780 |
{
|
|
781 |
DeleteThisFlow();
|
|
782 |
}
|
|
783 |
|
|
784 |
void CRawIPFlow::Notification(TInt aEvent)
|
|
785 |
/**
|
|
786 |
Handle Generic Link Tier messages from SCPR.
|
|
787 |
|
|
788 |
These used to be implemented as Agent <-> NIF Notifications, hence the method name to promote
|
|
789 |
some historical understanding.
|
|
790 |
*/
|
|
791 |
{
|
|
792 |
_LOG_L1C3(_L8("CRawIPFlow %08x:\tNotification(aEvent %d)"), this, aEvent);
|
|
793 |
|
|
794 |
switch (aEvent)
|
|
795 |
{
|
|
796 |
case EAgentToNifEventTypeDisableTimers: //GPRS suspension
|
|
797 |
{
|
|
798 |
_LOG_L1C1(_L8("CRawIPFlow::Received Suspend from Agent..."));
|
|
799 |
|
|
800 |
// Let the BCA controller know that data can no longer be sent over
|
|
801 |
// the PDP context.
|
|
802 |
iBcaController->BlockSending();
|
|
803 |
|
|
804 |
break;
|
|
805 |
}
|
|
806 |
|
|
807 |
case EAgentToNifEventTypeEnableTimers: //GPRS resumption
|
|
808 |
{
|
|
809 |
_LOG_L1C1(_L8("CRawIPFlow::Received Resume from Agent..."));
|
|
810 |
iBcaController->ResumeSending();
|
|
811 |
|
|
812 |
break;
|
|
813 |
}
|
|
814 |
case (EAgentToNifEventTypeDisableConnection) :
|
|
815 |
{
|
|
816 |
// This is handled by NIFMAN and passed to Flow as a Stop() call
|
|
817 |
_LOG_L1C1(_L8("CRawIPFlow::Received Disable connection from Agent..."));
|
|
818 |
break;
|
|
819 |
}
|
|
820 |
|
|
821 |
default :
|
|
822 |
{
|
|
823 |
_LOG_L1C2(_L8("CRawIPFlow::Received Notification [%d] from Agent..."), aEvent);
|
|
824 |
break;
|
|
825 |
}
|
|
826 |
}//endswitch
|
|
827 |
}
|
|
828 |
|
|
829 |
|
|
830 |
ESock::MLowerControl* CRawIPFlow::TBinderControlProxy::GetControlL(const TDesC8& aProtocol)
|
|
831 |
{
|
|
832 |
return RawIPFlow().GetControlL(aProtocol);
|
|
833 |
}
|
|
834 |
|
|
835 |
ESock::MLowerDataSender* CRawIPFlow::TBinderControlProxy::BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl)
|
|
836 |
{
|
|
837 |
return RawIPFlow().BindL(aProtocol, aReceiver, aControl);
|
|
838 |
}
|
|
839 |
|
|
840 |
void CRawIPFlow::TBinderControlProxy::Unbind(ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl)
|
|
841 |
{
|
|
842 |
return RawIPFlow().Unbind(aReceiver, aControl);
|
|
843 |
}
|
|
844 |
|
|
845 |
CSubConnectionFlowBase* CRawIPFlow::TBinderControlProxy::Flow()
|
|
846 |
{
|
|
847 |
return iFlow;
|
|
848 |
}
|
|
849 |
|
|
850 |
// =====================================================================================
|
|
851 |
//
|
|
852 |
// Utility functions
|
|
853 |
//
|
|
854 |
|
|
855 |
void CRawIPFlow::PostProgressMessage(TInt aStage, TInt aError)
|
|
856 |
{
|
|
857 |
iSubConnectionProvider.PostMessage(Id(), TCFMessage::TStateChange(Elements::TStateChange( aStage, aError)).CRef());
|
|
858 |
}
|
|
859 |
|
|
860 |
//
|
|
861 |
// NOTE:
|
|
862 |
// Attribute table should be in the control side module that instantiates CRawIpProvision.
|
|
863 |
// RawIP CFProtocol does not instantiate the CRawIpProvision object, so does not need to
|
|
864 |
// define the attribute tables. The attribute table can therefore be placed directly into
|
|
865 |
// the control side module.
|
|
866 |
//
|
|
867 |
// The reason for this is to save splitting RawIP CFProtocol into two DLL's - ECOM and Main -
|
|
868 |
// just for control side module to link against Main DLL to retrieve the attribute table.
|
|
869 |
// In fact, it can be placed into control side module as "START_ATTRIBUTE_TABLE" rather
|
|
870 |
// than "EXPORT_START_ATTRIBUTE_TABLE". In fact, do we just need "TYPEID_TABLE" ?
|
|
871 |
//
|
|
872 |
// EXPORT_START_ATTRIBUTE_TABLE(CRawIpProvision, KRawIpConfigUid, KRawIpConfigType)
|
|
873 |
// END_ATTRIBUTE_TABLE()
|