24
|
1 |
// Copyright (c) 2007-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 |
//
|
|
15 |
|
|
16 |
#include <es_ini.h>
|
|
17 |
#include <timeout.h>
|
|
18 |
#include <es_prot_internal.h>
|
|
19 |
|
|
20 |
#include "guqos.h"
|
|
21 |
#include "iface.h"
|
|
22 |
#include "tc.h"
|
|
23 |
#include "guqos_ini.h"
|
|
24 |
#include "context.h"
|
|
25 |
#include "async_request.h"
|
|
26 |
#include "guqos_log.h"
|
|
27 |
|
|
28 |
CModuleGuqos* CModuleGuqos::NewL()
|
|
29 |
{
|
|
30 |
CModuleGuqos* module = new (ELeave) CModuleGuqos();
|
|
31 |
CleanupStack::PushL(module);
|
|
32 |
module->ConstructL();
|
|
33 |
CleanupStack::Pop();
|
|
34 |
return module;
|
|
35 |
}
|
|
36 |
|
|
37 |
CModuleGuqos::CModuleGuqos()
|
|
38 |
{
|
|
39 |
LOG(Log::Printf(_L("")));
|
|
40 |
LOG(Log::Printf(_L("**** CREATING MODULE GUQOS (size=%u) ****"), sizeof(*this)));
|
|
41 |
iFlowCount = 0;
|
|
42 |
}
|
|
43 |
|
|
44 |
void CModuleGuqos::ConstructL()
|
|
45 |
{
|
|
46 |
iIfManager = CNifManager::NewL();
|
|
47 |
iTimeoutManager = TimeoutFactory::NewL(100); // Time Unit is [1/100 seconds]
|
|
48 |
ReadConfigOptions();
|
|
49 |
}
|
|
50 |
|
|
51 |
void CModuleGuqos::ReadConfigOptions()
|
|
52 |
{
|
|
53 |
CESockIniData* config = NULL;
|
|
54 |
TRAP_IGNORE(config = CESockIniData::NewL(GUQOS_INI_DATA));
|
|
55 |
TInt value;
|
|
56 |
if (config == NULL || !config->FindVar(GUQOS_INI_VARIABLES, GUQOS_INI_TIMEOUT, value))
|
|
57 |
value = KPdpContextDeleteTimeout;
|
|
58 |
delete config;
|
|
59 |
iOptions.iTimeout = (value + 9999) / 10000;
|
|
60 |
LOG(Log::Printf(_L("%S = %d [microseconds] converted to %d [1/100 seconds]"), &GUQOS_INI_TIMEOUT, value, iOptions.iTimeout));
|
|
61 |
}
|
|
62 |
|
|
63 |
CModuleGuqos::~CModuleGuqos()
|
|
64 |
{
|
|
65 |
LOG(Log::Printf(_L("~\tGUGOS DESTRUCTOR")));
|
|
66 |
ASSERT(iFlowCount == 0);
|
|
67 |
delete iIfManager;
|
|
68 |
delete iTimeoutManager;
|
|
69 |
}
|
|
70 |
|
|
71 |
void CModuleGuqos::InterfaceAttached(const TDesC& /*aName*/, CNifIfBase* aIf)
|
|
72 |
{
|
|
73 |
LOG(Log::Printf(_L("")));
|
|
74 |
LOG(Log::Printf(_L("Guqos::InterfaceAttached -- start CNifIfBase[%u]"), (TInt)aIf));
|
|
75 |
if (!aIf)
|
|
76 |
return; // Nothing to attach! (someone is making invalid calls!).
|
|
77 |
|
|
78 |
if (!iIfManager->FindInterface(aIf))
|
|
79 |
{
|
|
80 |
TRAPD(err, iIfManager->CreateNifL(*aIf, *this));
|
|
81 |
if (err != KErrNone)
|
|
82 |
{
|
|
83 |
LOG(Log::Printf(_L("\tError creating Nif [error code = %d]"), err));
|
|
84 |
}
|
|
85 |
}
|
|
86 |
LOG(Log::Printf(_L("Guqos::InterfaceAttached -- end")));
|
|
87 |
}
|
|
88 |
|
|
89 |
void CModuleGuqos::InterfaceDetached(const TDesC& /*aName*/, CNifIfBase* aIf)
|
|
90 |
{
|
|
91 |
LOG(Log::Printf(_L("")));
|
|
92 |
LOG(Log::Printf(_L("Guqos::InterfaceDetached -- start")));
|
|
93 |
iIfManager->DeleteNif(aIf);
|
|
94 |
LOG(Log::Printf(_L("Guqos::InterfaceDetached -- end")));
|
|
95 |
}
|
|
96 |
|
|
97 |
// references to protocol must be removed, i.e. drop all packets because they contain CFlowContext references
|
|
98 |
void CModuleGuqos::Unbind(CProtocolBase* /*aProtocol*/, TUint /*aId = 0*/)
|
|
99 |
{
|
|
100 |
LOG(Log::Printf(_L("")));
|
|
101 |
LOG(Log::Printf(_L("Guqos::Unbind -- Nothing to do")));
|
|
102 |
// NOTHING TO ´DO FOR NOW
|
|
103 |
// CFlowData may include CFlowContext reference, but those
|
|
104 |
// are never dereferenced, unless the context is otherwise
|
|
105 |
// known to be valid (e.g. in OpenL or is referenced from
|
|
106 |
// RMBufSendInfo. Otherwise the reference is used only as
|
|
107 |
// opaque identifier.
|
|
108 |
}
|
|
109 |
|
|
110 |
void CModuleGuqos::InitModuleL(MEventInterface& aEventInterface, CExtension* /*aData*/)
|
|
111 |
{
|
|
112 |
iNotify = &aEventInterface;
|
|
113 |
}
|
|
114 |
|
|
115 |
void CModuleGuqos::OpenL(CFlowContext& aFlow, CNifIfBase* aIf)
|
|
116 |
{
|
|
117 |
LOG(Log::Printf(_L("")));
|
|
118 |
LOG(Log::Printf(_L("Guqos::OpenL -- start")));
|
|
119 |
CNif* nif = iIfManager->FindInterface(aIf);
|
|
120 |
if (!nif)
|
|
121 |
{
|
|
122 |
User::Leave(KErrNotFound);
|
|
123 |
}
|
|
124 |
CFlowData *flowdata = FindFlow(&aFlow);
|
|
125 |
if (flowdata)
|
|
126 |
{
|
|
127 |
User::Leave(KErrAlreadyExists);
|
|
128 |
}
|
|
129 |
|
|
130 |
// Add new CFlowData to iList (will be the first element in the list)
|
|
131 |
iList = CFlowData::NewL(aFlow, *nif, iList);
|
|
132 |
iFlowCount++;
|
|
133 |
aFlow.iIgnoreFlowControl = ETrue;
|
|
134 |
iList->SetContext(nif->DefaultPdpContext());
|
|
135 |
//aFlow.SetStatus(EFlow_READY);
|
|
136 |
LOG(Log::Printf(_L("Guqos::OpenL -- end")));
|
|
137 |
}
|
|
138 |
|
|
139 |
void CModuleGuqos::Close(CFlowContext& aFlow)
|
|
140 |
{
|
|
141 |
LOG(Log::Printf(_L("")));
|
|
142 |
LOG(Log::Printf(_L("Guqos::Close -- start")));
|
|
143 |
CFlowData* flowdata = CFlowData::Remove(&aFlow, &iList);
|
|
144 |
if (flowdata)
|
|
145 |
{
|
|
146 |
CPdpContext* context = flowdata->PdpContext();
|
|
147 |
if (context && !context->IsPrimary())
|
|
148 |
{
|
|
149 |
// Schedule a detached CClose request for updating
|
|
150 |
// the TFT filters on secondary context. (Either
|
|
151 |
// the context is flow specific or leave has not
|
|
152 |
// been issued).
|
|
153 |
CClose* request = CClose::New(*context);
|
|
154 |
if (request)
|
|
155 |
{
|
|
156 |
context->Nif().AddRequest(*request);
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
// Note: If the CClose cannot be allocated due to
|
|
161 |
// memory problem, the TFT will remain in effect,
|
|
162 |
// it will automaticly correct itself when there
|
|
163 |
// is another Leave or Close, that can be executed.
|
|
164 |
LOG(Log::Printf(_L("\tCannot schedule TFT filter removal due to out of memory")));
|
|
165 |
}
|
|
166 |
}
|
|
167 |
iFlowCount--;
|
|
168 |
iIfManager->CancelPendingRequests(flowdata);
|
|
169 |
delete flowdata;
|
|
170 |
}
|
|
171 |
LOG(Log::Printf(_L("Guqos::Close -- end")));
|
|
172 |
}
|
|
173 |
|
|
174 |
void CModuleGuqos::Release(CFlowContext& aFlow)
|
|
175 |
{
|
|
176 |
LOG(Log::Printf(_L("")));
|
|
177 |
LOG(Log::Printf(_L("Guqos::Release -- start")));
|
|
178 |
CFlowData* flowdata = FindFlow(&aFlow);
|
|
179 |
if (!flowdata)
|
|
180 |
return;
|
|
181 |
// Abort any pending actions on the flow
|
|
182 |
iIfManager->CancelPendingRequests(flowdata);
|
|
183 |
|
|
184 |
CPdpContext* context = flowdata->PdpContext();
|
|
185 |
CPdpContext* default_context = flowdata->Nif().DefaultPdpContext();
|
|
186 |
if (context && context != default_context)
|
|
187 |
{
|
|
188 |
// Flow was attached to some other context, shedule some
|
|
189 |
// cleanup for that context.
|
|
190 |
CClose* request = CClose::New(*context);
|
|
191 |
if (request)
|
|
192 |
{
|
|
193 |
context->Nif().AddRequest(*request);
|
|
194 |
}
|
|
195 |
}
|
|
196 |
// Note: this detaches the flow from the old context,
|
|
197 |
// and may trigger destruction of the "context". Do not
|
|
198 |
// reference "context" after this! (the sheduled
|
|
199 |
// request is also cancelled implicitly in such case).
|
|
200 |
flowdata->SetContext(default_context);
|
|
201 |
// Flow will be in blocked state, if default_context does not exist.
|
|
202 |
}
|
|
203 |
|
|
204 |
void CModuleGuqos::OpenChannel(TInt aChannelId, const TQoSParameters& aParams, CExtensionPolicy& aPolicy, MQoSNegotiateEvent& aNotify, CFlowContext& aFlow)
|
|
205 |
{
|
|
206 |
LOG(Log::Printf(_L("")));
|
|
207 |
LOG(Log::Printf(_L("Guqos::OpenChannel -- start id=%d"), aChannelId));
|
|
208 |
TInt ret = KErrNone;
|
|
209 |
|
|
210 |
for (;;) /* FOR EXISTS ONLY FOR BREAK EXITS */
|
|
211 |
{
|
|
212 |
if (aChannelId <= 0)
|
|
213 |
{
|
|
214 |
// Channel ID must be > 0
|
|
215 |
ret = KErrArgument;
|
|
216 |
break;
|
|
217 |
}
|
|
218 |
CFlowData *flowdata = FindFlow(&aFlow);
|
|
219 |
if (flowdata == NULL)
|
|
220 |
{
|
|
221 |
ret = KErrNotFound;
|
|
222 |
break;
|
|
223 |
}
|
|
224 |
|
|
225 |
if (IfManager()->FindChannel(aChannelId))
|
|
226 |
{
|
|
227 |
// Note: This could be due to FindChannel finding a channel
|
|
228 |
// which has the delayed destruction and QoS framework is
|
|
229 |
// for some reason reusing the channel id for new channel
|
|
230 |
// (not possible currently, because QoS does not reuse
|
|
231 |
// channel ids).
|
|
232 |
ret = KErrAlreadyExists;
|
|
233 |
break;
|
|
234 |
}
|
|
235 |
|
|
236 |
// Instead of creating totally new secondary context, there
|
|
237 |
// could be a check for expiring, but not yet deleted contexts,
|
|
238 |
// and reuse one of them for this channel -- that action
|
|
239 |
// would require a different request class, not COpenChannel,
|
|
240 |
// which would renegotiate the channel and recompute it's
|
|
241 |
// filters.
|
|
242 |
// coverity[alloc_fn] coverity[assign] coverity [memory_leak]
|
|
243 |
COpenChannel* open_request = COpenChannel::New(aChannelId, *flowdata, &aNotify);
|
|
244 |
if (open_request == NULL)
|
|
245 |
{
|
|
246 |
ret = KErrNoMemory;
|
|
247 |
break;
|
|
248 |
}
|
|
249 |
open_request->SetParameters(aParams, aPolicy);
|
|
250 |
open_request->SetParametersFlowExtn(aPolicy);
|
|
251 |
flowdata->Nif().AddRequest(*open_request);
|
|
252 |
/* TERMINATE FOR LOOP -- OpenChannel success -- request completes asyncronously */
|
|
253 |
LOG(Log::Printf(_L("Guqos::OpenChannel -- end")));
|
|
254 |
return;
|
|
255 |
}
|
|
256 |
|
|
257 |
aNotify.RequestComplete(ret, &aParams);
|
|
258 |
LOG(Log::Printf(_L("Guqos::OpenChannel -- end err=%d"), ret));
|
|
259 |
}
|
|
260 |
|
|
261 |
void CModuleGuqos::CloseChannel(TInt aChannelId)
|
|
262 |
{
|
|
263 |
LOG(Log::Printf(_L("")));
|
|
264 |
LOG(Log::Printf(_L("Guqos::CloseChannel -- start id=%d"), aChannelId));
|
|
265 |
if (aChannelId <= 0)
|
|
266 |
return;
|
|
267 |
CPdpContext* context = IfManager()->FindChannel(aChannelId);
|
|
268 |
if (!context)
|
|
269 |
return;
|
|
270 |
if (context->IsPrimary())
|
|
271 |
{
|
|
272 |
// This is a secondary context turned into a default context. The use
|
|
273 |
// context as a channel is terminated, but it must continue to live as
|
|
274 |
// a default context. Thus, only remove the channel association from
|
|
275 |
// the context.
|
|
276 |
LOG(Log::Printf(_L("\tTurning secondary context into default only")));
|
|
277 |
context->SetChannelId(0);
|
|
278 |
}
|
|
279 |
else
|
|
280 |
{
|
|
281 |
//?? Need to use CDeleteRequest request to serialize NIF control!!!
|
|
282 |
//?? What happens if this is called in the middle of some request processing?
|
|
283 |
context->Delete(); // Notify NIF, destroy context on NIF.
|
|
284 |
context->Nif().DeletePdpContext(context);
|
|
285 |
}
|
|
286 |
LOG(Log::Printf(_L("Guqos::CloseChannel -- end")));
|
|
287 |
}
|
|
288 |
|
|
289 |
void CModuleGuqos::NegotiateChannel(TInt aChannelId, const TQoSParameters& aParams, CExtensionPolicy& aPolicy, MQoSNegotiateEvent& aNotify)
|
|
290 |
{
|
|
291 |
LOG(Log::Printf(_L("")));
|
|
292 |
LOG(Log::Printf(_L("Guqos::NegotiateChannel -- start id=%d"), aChannelId));
|
|
293 |
TInt ret = KErrNone;
|
|
294 |
|
|
295 |
if (aChannelId <= 0)
|
|
296 |
{
|
|
297 |
ret = KErrArgument;
|
|
298 |
}
|
|
299 |
else
|
|
300 |
{
|
|
301 |
CPdpContext* context = IfManager()->FindChannel(aChannelId);
|
|
302 |
if (context == NULL)
|
|
303 |
{
|
|
304 |
ret = KErrNotFound;
|
|
305 |
}
|
|
306 |
else
|
|
307 |
{
|
|
308 |
CNegotiateChannel* request = CNegotiateChannel::New(context, &aNotify);
|
|
309 |
if (request)
|
|
310 |
{
|
|
311 |
//coverity[leave_without_push]
|
|
312 |
request->SetParameters(aParams, aPolicy);
|
|
313 |
//coverity[leave_without_push]
|
|
314 |
request->SetParametersFlowExtn(aPolicy);
|
|
315 |
context->Nif().AddRequest(*request);
|
|
316 |
}
|
|
317 |
else
|
|
318 |
ret = KErrNoMemory;
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
if (ret != KErrNone)
|
|
323 |
aNotify.RequestComplete(ret, &aParams);
|
|
324 |
LOG(Log::Printf(_L("Guqos::NegotiateChannel -- end res=%d"), ret));
|
|
325 |
}
|
|
326 |
|
|
327 |
void CModuleGuqos::Join(TInt aChannelId, CFlowContext& aFlow, MQoSNegotiateEvent& aNotify)
|
|
328 |
{
|
|
329 |
LOG(Log::Printf(_L("")));
|
|
330 |
LOG(Log::Printf(_L("Guqos::JoinChannel -- start id=%d"), aChannelId));
|
|
331 |
TInt ret = KErrNone;
|
|
332 |
CPdpContext* channel = IfManager()->FindChannel(aChannelId);
|
|
333 |
CFlowData *flowdata = FindFlow(&aFlow);
|
|
334 |
if (!channel || !flowdata)
|
|
335 |
ret = KErrNotFound;
|
|
336 |
else
|
|
337 |
{
|
|
338 |
CJoinRequest* join_request = CJoinRequest::New(channel, flowdata, &aNotify);
|
|
339 |
if (join_request)
|
|
340 |
channel->Nif().AddRequest(*join_request);
|
|
341 |
else
|
|
342 |
ret = KErrNoMemory;
|
|
343 |
}
|
|
344 |
|
|
345 |
if (ret != KErrNone)
|
|
346 |
aNotify.RequestComplete(ret, NULL);
|
|
347 |
LOG(Log::Printf(_L("Guqos::JoinChannel -- end err=%d"), ret));
|
|
348 |
}
|
|
349 |
|
|
350 |
void CModuleGuqos::Leave(TInt aChannelId, CFlowContext& aFlow, MQoSNegotiateEvent& aNotify)
|
|
351 |
{
|
|
352 |
LOG(Log::Printf(_L("")));
|
|
353 |
LOG(Log::Printf(_L("Guqos::LeaveChannel -- start id=%d"), aChannelId));
|
|
354 |
TInt ret = KErrNone;
|
|
355 |
CPdpContext* channel = IfManager()->FindChannel(aChannelId);
|
|
356 |
CFlowData *flowdata = FindFlow(&aFlow);
|
|
357 |
if (!channel || !flowdata)
|
|
358 |
ret = KErrNotFound;
|
|
359 |
|
|
360 |
if (ret == KErrNone)
|
|
361 |
{
|
|
362 |
CLeaveRequest* leave_request = CLeaveRequest::New(channel, flowdata, &aNotify);
|
|
363 |
if (leave_request)
|
|
364 |
channel->Nif().AddRequest(*leave_request);
|
|
365 |
else
|
|
366 |
ret = KErrNoMemory;
|
|
367 |
}
|
|
368 |
|
|
369 |
if (ret != KErrNone)
|
|
370 |
aNotify.RequestComplete(ret, NULL);
|
|
371 |
LOG(Log::Printf(_L("Guqos::LeaveChannel -- end ret=%d"), ret));
|
|
372 |
}
|
|
373 |
|
|
374 |
void CModuleGuqos::Negotiate(CFlowContext &aFlow, const TQoSParameters& aParams, MQoSNegotiateEvent& aNotify)
|
|
375 |
{
|
|
376 |
LOG(Log::Printf(_L("")));
|
|
377 |
LOG(Log::Printf(_L("Guqos::Negotiate -- start")));
|
|
378 |
TInt ret = KErrNone;
|
|
379 |
|
|
380 |
for (;;) /* FOR EXISTS ONLY FOR BREAK EXITS */
|
|
381 |
{
|
|
382 |
CFlowData* flowdata = FindFlow(&aFlow);
|
|
383 |
if (!flowdata)
|
|
384 |
{
|
|
385 |
ret = KErrNotFound;
|
|
386 |
break;
|
|
387 |
}
|
|
388 |
//?? This needs rework and specification of how things should work!
|
|
389 |
//?? But, for now the assumption is that the Negotiate() is not used in the
|
|
390 |
//?? current framework.
|
|
391 |
|
|
392 |
// The Negotiate operation does not have the extension policies as parameter,
|
|
393 |
// like OpenChannel or NegotiateChannel has. The code below attempts to fix
|
|
394 |
// this by searching the matching policy. However, only first found is used
|
|
395 |
// (in order Override, Application, Default). This gets murky, if more than
|
|
396 |
// one match would exist -- should extensions be merged in such case?
|
|
397 |
CExtensionPolicy *policy = NULL;
|
|
398 |
if ((policy = (CExtensionPolicy*)iNotify->Lookup(aFlow, EPfqosExtensionPolicy, EPfqosOverridePriority)) == NULL &&
|
|
399 |
(policy = (CExtensionPolicy*)iNotify->Lookup(aFlow, EPfqosExtensionPolicy, EPfqosApplicationPriority)) == NULL &&
|
|
400 |
(policy = (CExtensionPolicy*)iNotify->Lookup(aFlow, EPfqosExtensionPolicy, EPfqosDefaultPriority)) == NULL)
|
|
401 |
{
|
|
402 |
ret = KErrNotFound;
|
|
403 |
break;
|
|
404 |
}
|
|
405 |
|
|
406 |
// Instead of creating totally new context, one could search for
|
|
407 |
// expiring contexts, and reuse one of them for this flow. Could
|
|
408 |
// also prefer a context that has been used for this same flow
|
|
409 |
// previously -- less negotiating, as the filter might already be
|
|
410 |
// correct.
|
|
411 |
COpenChannel* negotiate_request = COpenChannel::New(0, *flowdata, &aNotify);
|
|
412 |
if (negotiate_request == NULL)
|
|
413 |
{
|
|
414 |
ret = KErrNoMemory;
|
|
415 |
break;
|
|
416 |
}
|
|
417 |
//coverity[leave_without_push]
|
|
418 |
negotiate_request->SetParameters(aParams, *policy);
|
|
419 |
//coverity[leave_without_push]
|
|
420 |
negotiate_request->SetParametersFlowExtn(*policy);
|
|
421 |
flowdata->Nif().AddRequest(*negotiate_request);
|
|
422 |
LOG(Log::Printf(_L("Guqos::Negotiate -- end OK")));
|
|
423 |
return;
|
|
424 |
}
|
|
425 |
|
|
426 |
aNotify.RequestComplete(ret, &aParams);
|
|
427 |
LOG(Log::Printf(_L("Guqos::Negotiate -- end ret=%d"), ret));
|
|
428 |
}
|
|
429 |
|
|
430 |
TInt CModuleGuqos::Configure(TUint aLevel,TUint aName, TDes8& aOption, TAny* /*aSource*/)
|
|
431 |
{
|
|
432 |
LOG(Log::Printf(_L("guqos::Configure")));
|
|
433 |
if (aLevel == KSOLQoSModule)
|
|
434 |
{
|
|
435 |
switch (aName)
|
|
436 |
{
|
|
437 |
case KSoCapabilities:
|
|
438 |
if (aOption.Length() >= (TInt)sizeof(TInt))
|
|
439 |
{
|
|
440 |
//lint -e{826} complains, pointer conversion is ok
|
|
441 |
TInt& opt = *(TInt*)aOption.Ptr();
|
|
442 |
opt = KModuleCapabilites;
|
|
443 |
return KErrNone;
|
|
444 |
}
|
|
445 |
return KErrArgument;
|
|
446 |
default:
|
|
447 |
break;
|
|
448 |
}
|
|
449 |
}
|
|
450 |
return KErrNotSupported;
|
|
451 |
}
|
|
452 |
|
|
453 |
|
|
454 |
TInt CModuleGuqos::Send(RMBufChain& aPacket, CProtocolBase* /*aSourceProtocol*/)
|
|
455 |
{
|
|
456 |
for (;;) /* FOREVER, ONLY FOR BREAK EXITS */
|
|
457 |
{
|
|
458 |
RMBufSendInfo* const info = RMBufSendPacket::PeekInfoInChain(aPacket);
|
|
459 |
if (!info)
|
|
460 |
{
|
|
461 |
// Malformed packet, cannot do anything with it
|
|
462 |
LOG(Log::Printf(_L("Guqos::Send -- packet has no info block!")));
|
|
463 |
break;
|
|
464 |
}
|
|
465 |
CFlowContext* const context = info->iFlow.FlowContext();
|
|
466 |
if (!context)
|
|
467 |
{
|
|
468 |
// Malformed packet, cannot do anything with it
|
|
469 |
LOG(Log::Printf(_L("Guqos::Send -- packet has no flow context!")));
|
|
470 |
break;
|
|
471 |
}
|
|
472 |
|
|
473 |
CFlowData* flowdata = FindFlow(context);
|
|
474 |
if (!flowdata)
|
|
475 |
{
|
|
476 |
// Flow is not registered with GUQOS and this Send should
|
|
477 |
// not have happened.
|
|
478 |
info->iFlow.Close();
|
|
479 |
LOG(Log::Printf(_L("Guqos::Send -- flow is not open in GUQOS!")));
|
|
480 |
break;
|
|
481 |
}
|
|
482 |
return flowdata->Send(aPacket, *info);
|
|
483 |
}
|
|
484 |
aPacket.Free();
|
|
485 |
return 1;
|
|
486 |
}
|
|
487 |
|
|
488 |
void CModuleGuqos::Identify(TServerProtocolDesc* aProtocolDesc) const
|
|
489 |
{
|
|
490 |
Identify(*aProtocolDesc);
|
|
491 |
}
|
|
492 |
|
|
493 |
void CModuleGuqos::Identify(TServerProtocolDesc& aDesc)
|
|
494 |
{
|
|
495 |
_LIT(Kguqos, "quqos");
|
|
496 |
|
|
497 |
aDesc.iName=Kguqos;
|
|
498 |
aDesc.iAddrFamily=KAfInet;
|
|
499 |
aDesc.iSockType=KSockDatagram;
|
|
500 |
aDesc.iProtocol=KModuleGUQoS;
|
|
501 |
aDesc.iVersion=TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
|
|
502 |
aDesc.iByteOrder=EBigEndian;
|
|
503 |
aDesc.iServiceInfo=0;
|
|
504 |
aDesc.iNamingServices=0;
|
|
505 |
aDesc.iSecurity=KSocketNoSecurity;
|
|
506 |
aDesc.iMessageSize=0xffff;
|
|
507 |
aDesc.iServiceTypeInfo=EPreferMBufChains | ENeedMBufs;
|
|
508 |
aDesc.iNumSockets=KUnlimitedSockets;
|
|
509 |
}
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
CFlowData* CModuleGuqos::FindFlow(const CFlowContext* aFlow)
|
|
514 |
{
|
|
515 |
return CFlowData::Find(aFlow, iList);
|
|
516 |
}
|
|
517 |
|
|
518 |
// Default parameters are fetched from the QoS policy db.
|
|
519 |
TInt CModuleGuqos::GetDefaultParameters(TQoSRequested& aParameters, TUint32 aIapId)
|
|
520 |
{
|
|
521 |
TInetAddr addr;
|
|
522 |
addr.SetAddress(KInet6AddrNone);
|
|
523 |
TUidType uid(TUid::Uid(0), TUid::Uid(0), TUid::Uid(0));
|
|
524 |
CExtensionPolicy* sel = (CExtensionPolicy*)iNotify->Lookup(addr, addr, 0, 0, 0, EPfqosExtensionPolicy, uid, aIapId, 0);
|
|
525 |
if (!sel)
|
|
526 |
return KErrNotFound;
|
|
527 |
aParameters.ParsePolicyData(sel);
|
|
528 |
return KErrNone;
|
|
529 |
}
|