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 |
#ifndef __ASYNC_REQUEST_H__
|
|
17 |
#define __ASYNC_REQUEST_H__
|
|
18 |
|
|
19 |
#include <networking/umtsnifcontrolif.h>
|
|
20 |
#include "extension.h"
|
|
21 |
#include "guqos_log.h"
|
|
22 |
|
|
23 |
enum TRequest
|
|
24 |
{
|
|
25 |
EPendingAny = 0,
|
|
26 |
EPendingCreate,
|
|
27 |
EPendingDelete,
|
|
28 |
EPendingConfig,
|
|
29 |
EPendingSetQoS,
|
|
30 |
EPendingModifyActive,
|
|
31 |
EPendingActivate,
|
|
32 |
EPendingPacketFilterAdd,
|
|
33 |
EPendingPacketFilterRemove,
|
|
34 |
EPendingSblpParameterAdd, // Request for adding sblp parameter
|
|
35 |
EPendingSblpParameterRemove, // Request for removing sblp parameter
|
|
36 |
EPendingTFTRemove,
|
|
37 |
EPendingCancel,
|
|
38 |
EPendingNone
|
|
39 |
};
|
|
40 |
|
|
41 |
class CFlowData;
|
|
42 |
class CPdpContext;
|
|
43 |
class CNif;
|
|
44 |
|
|
45 |
template <class T>
|
|
46 |
struct SActionStep
|
|
47 |
{
|
|
48 |
/**
|
|
49 |
* An action of the state machine.
|
|
50 |
*
|
|
51 |
* Its it up to the action whether parameters are used or not. When the
|
|
52 |
* state machine is started, the parameters are both NULL, as there is
|
|
53 |
* no preceding event from NIF. Thus, the first action(s) usually ignore
|
|
54 |
* the parameters.
|
|
55 |
*
|
|
56 |
* The aContext parameter is initially NULL and upon each event reply
|
|
57 |
* from the NIF, it is filled with the related context. Action can
|
|
58 |
* change the current context for the subsequent actions using
|
|
59 |
* CRequestBase::SetContext . This change persists for the duration
|
|
60 |
* of the current CRequestBase::Run or CRequestBase::Start .
|
|
61 |
*
|
|
62 |
* @param aContext The context
|
|
63 |
* @param aParams NULL or the parameters of the event from NIF
|
|
64 |
*
|
|
65 |
* @return
|
|
66 |
* @li EFalse - No action activated, proceed to the next state
|
|
67 |
* @li ETrue - Action activated. Action can be completion and
|
|
68 |
* destruction of the request object. Thus, when action
|
|
69 |
* returns ETrue, the member variables of the current
|
|
70 |
* request MUST NOT BE REFERENCED.
|
|
71 |
*/
|
|
72 |
TBool (T::*iAction)(CPdpContext* aContext, const TContextParameters* aParams);
|
|
73 |
/**
|
|
74 |
* Expected result, if action activated.
|
|
75 |
* When action activates some NIF Control request, this code specifies the
|
|
76 |
* type of the expected result. When the event arrives, this code can be
|
|
77 |
* checked in the Run() function.
|
|
78 |
*/
|
|
79 |
//TRequest iRequest;
|
|
80 |
};
|
|
81 |
|
|
82 |
// Base class for async requests: separate flow-specific and channel-specific requests?
|
|
83 |
class CRequestBase : public CBase
|
|
84 |
{
|
|
85 |
protected:
|
|
86 |
virtual ~CRequestBase();
|
|
87 |
public:
|
|
88 |
CRequestBase(CNif& aNif);
|
|
89 |
|
|
90 |
virtual void Start();
|
|
91 |
void Run(const TRequest aRequest, CPdpContext* aPdpContext, const TContextParameters& aParams);
|
|
92 |
virtual TBool Action(CPdpContext* aPdpContext, const TContextParameters* aParams) = 0;
|
|
93 |
|
|
94 |
virtual void Cancel(CFlowData* aFlowData);
|
|
95 |
virtual void Cancel(CPdpContext* aContext) = 0;
|
|
96 |
|
|
97 |
TBool IsOk(TInt aResult, CPdpContext *aContext);
|
|
98 |
|
|
99 |
void CompleteAndDestruct(TInt aErrorCode, const TQoSParameters* aParams, const TExtensionData& aExtension=TExtensionData());
|
|
100 |
|
|
101 |
|
|
102 |
TSglQueLink iLink;
|
|
103 |
protected:
|
|
104 |
virtual void Failure(CPdpContext* aPdpContext, TInt aErrorCode);
|
|
105 |
|
|
106 |
void SetContext(CPdpContext *aContext);
|
|
107 |
void SetExpected(const TRequest aRequest);
|
|
108 |
|
|
109 |
TBool ActionRemovePacketFilter(CPdpContext*, const TContextParameters*);
|
|
110 |
|
|
111 |
TBool ActionAddPacketFilter(CPdpContext*, const TContextParameters*);
|
|
112 |
TBool DoAddFlowToContext(CPdpContext*, const TContextParameters*);
|
|
113 |
TBool ActionCommit(CPdpContext*, const TContextParameters*);
|
|
114 |
TBool ActionRequestComplete(CPdpContext*, const TContextParameters*);
|
|
115 |
|
|
116 |
RExtensionData iExtension; // Extension Data for the completion message
|
|
117 |
MQoSNegotiateEvent* iNotify;
|
|
118 |
CNif& iNif;
|
|
119 |
|
|
120 |
//
|
|
121 |
// The state machine information
|
|
122 |
//
|
|
123 |
TInt iState; // Current State number [0...]
|
|
124 |
/**
|
|
125 |
* Associated flow, or NULL, if none.
|
|
126 |
*
|
|
127 |
* Some actions may use a flow as an additional input. The validity
|
|
128 |
* of this is at responsibility of the request implementation.
|
|
129 |
*/
|
|
130 |
CFlowData* iFlow;
|
|
131 |
/**
|
|
132 |
* The context has been modified.
|
|
133 |
*
|
|
134 |
* iContextModified is TRUE, when the iContext has queued modifications in NIF.
|
|
135 |
* This only controls whether ModifyActive can be skipped in ActionCommit.
|
|
136 |
*
|
|
137 |
* This is currently automaticly set whenever SetExpected is called,
|
|
138 |
* and cleared when iContext is changed.
|
|
139 |
*/
|
|
140 |
TBool iContextModified;
|
|
141 |
private:
|
|
142 |
/**
|
|
143 |
* The expected event completion.
|
|
144 |
*
|
|
145 |
* This value is defined only when some request has been passed to
|
|
146 |
* NIF Control() and then the value is the expected reply event
|
|
147 |
* from the NIF.
|
|
148 |
*/
|
|
149 |
TRequest iExpected;
|
|
150 |
/**
|
|
151 |
* The current context being acted on (or NULL).
|
|
152 |
*
|
|
153 |
* This value is defined only when executing the actions (e.g. while
|
|
154 |
* executing Run or Start. In other times, it is just left over
|
|
155 |
* value that might point to already destroyed context and must
|
|
156 |
* never be used.
|
|
157 |
*/
|
|
158 |
CPdpContext* iContext;
|
|
159 |
/**
|
|
160 |
* The current context parameters from NIF (or NULL)
|
|
161 |
*
|
|
162 |
* This value is defined only when executin Run().
|
|
163 |
*/
|
|
164 |
const TContextParameters* iParams;
|
|
165 |
#ifdef _LOG
|
|
166 |
//
|
|
167 |
// For DEBUG / LOGGING purposes only
|
|
168 |
public:
|
|
169 |
const TDesC* iName; // Name must be set by the constructor of each derived class.
|
|
170 |
#endif
|
|
171 |
};
|
|
172 |
|
|
173 |
|
|
174 |
// Remove unneeded TFT's from the context
|
|
175 |
class CClose : public CRequestBase
|
|
176 |
{
|
|
177 |
~CClose();
|
|
178 |
public:
|
|
179 |
static CClose* New(CPdpContext& aContext);
|
|
180 |
|
|
181 |
virtual void Start();
|
|
182 |
virtual TBool Action(CPdpContext* aContext, const TContextParameters* aParams)
|
|
183 |
{return (this->*iActionList[iState].iAction)(aContext, aParams); }
|
|
184 |
|
|
185 |
virtual void Cancel(CPdpContext* aContext);
|
|
186 |
|
|
187 |
protected:
|
|
188 |
CClose(CPdpContext& aContext);
|
|
189 |
|
|
190 |
private:
|
|
191 |
static const SActionStep<CClose> iActionList[];
|
|
192 |
CPdpContext& iClosing;
|
|
193 |
};
|
|
194 |
|
|
195 |
// Context deletion requst
|
|
196 |
class CDeleteRequest : public CRequestBase
|
|
197 |
{
|
|
198 |
public:
|
|
199 |
static CDeleteRequest* NewL(CPdpContext* aContext);
|
|
200 |
|
|
201 |
virtual void Start();
|
|
202 |
// This request has no "action list", it's all done in Start()
|
|
203 |
virtual TBool Action(CPdpContext*, const TContextParameters*) {return ETrue; }
|
|
204 |
virtual void Cancel(CPdpContext* aContext);
|
|
205 |
protected:
|
|
206 |
CDeleteRequest(CPdpContext* aContext);
|
|
207 |
private:
|
|
208 |
CPdpContext *iDelete;
|
|
209 |
};
|
|
210 |
|
|
211 |
// Intermediate shared class for requests that negotiate QoS
|
|
212 |
class CNegotiationBase : public CRequestBase
|
|
213 |
{
|
|
214 |
protected:
|
|
215 |
~CNegotiationBase() {}
|
|
216 |
public:
|
|
217 |
void SetParameters(const TQoSParameters& aParams, CExtensionPolicy& aPolicy);
|
|
218 |
void SetParametersFlowExtn(CExtensionPolicy &aPolicy);
|
|
219 |
protected:
|
|
220 |
CNegotiationBase(CNif& aNif);
|
|
221 |
void Failure(CPdpContext* aPdpContext, TInt aErrorCode);
|
|
222 |
|
|
223 |
|
|
224 |
TBool ActionAddSblpParameter(CPdpContext*, const TContextParameters*);
|
|
225 |
TBool ActionSetQoS(CPdpContext*, const TContextParameters*);
|
|
226 |
TBool ActionNegotiationComplete(CPdpContext *, const TContextParameters*);
|
|
227 |
|
|
228 |
TBool iSblp;
|
|
229 |
RFlowExtensionParams iFlowExtnParams;
|
|
230 |
TQoSParameters iGeneric;
|
|
231 |
TQoSRequested iUmts;
|
|
232 |
};
|
|
233 |
|
|
234 |
|
|
235 |
class COpenChannel : public CNegotiationBase
|
|
236 |
{
|
|
237 |
~COpenChannel();
|
|
238 |
public:
|
|
239 |
static COpenChannel* New(TUint aChannelId, CFlowData &aFlow, MQoSNegotiateEvent* aNotify);
|
|
240 |
|
|
241 |
|
|
242 |
virtual void Start();
|
|
243 |
virtual TBool Action(CPdpContext* aContext, const TContextParameters* aParams)
|
|
244 |
{return (this->*iActionList[iState].iAction)(aContext, aParams); }
|
|
245 |
|
|
246 |
virtual void Failure(CPdpContext* aPdpContext, TInt aErrorCode);
|
|
247 |
virtual void Cancel(CPdpContext* aContext);
|
|
248 |
|
|
249 |
protected:
|
|
250 |
COpenChannel(TInt aChannelId, CFlowData& aFlow, MQoSNegotiateEvent* aNotify);
|
|
251 |
|
|
252 |
TBool ActionNewContext(CPdpContext*, const TContextParameters*);
|
|
253 |
TBool DoRememberCreatedContext(CPdpContext*, const TContextParameters*);
|
|
254 |
|
|
255 |
private:
|
|
256 |
|
|
257 |
static const SActionStep<COpenChannel> iActionList[];
|
|
258 |
|
|
259 |
const TInt iChannelId;
|
|
260 |
CPdpContext* iNewContext;
|
|
261 |
};
|
|
262 |
|
|
263 |
|
|
264 |
class CNegotiateChannel : public CNegotiationBase
|
|
265 |
{
|
|
266 |
~CNegotiateChannel();
|
|
267 |
public:
|
|
268 |
static CNegotiateChannel* New(CPdpContext* aContext, MQoSNegotiateEvent* aNotify);
|
|
269 |
|
|
270 |
virtual void Start();
|
|
271 |
virtual TBool Action(CPdpContext* aContext, const TContextParameters* aParams)
|
|
272 |
{return (this->*iActionList[iState].iAction)(aContext, aParams); }
|
|
273 |
virtual void Cancel(CPdpContext* aContext);
|
|
274 |
|
|
275 |
protected:
|
|
276 |
CNegotiateChannel(CPdpContext* aContext, MQoSNegotiateEvent* aNotify);
|
|
277 |
void ConstructL();
|
|
278 |
|
|
279 |
private:
|
|
280 |
static const SActionStep<CNegotiateChannel> iActionList[];
|
|
281 |
CPdpContext* iChannel;
|
|
282 |
};
|
|
283 |
|
|
284 |
class CJoinRequest : public CRequestBase
|
|
285 |
{
|
|
286 |
~CJoinRequest();
|
|
287 |
public:
|
|
288 |
static CJoinRequest* New(CPdpContext* aContext, CFlowData* aFlowData, MQoSNegotiateEvent* aNotify);
|
|
289 |
|
|
290 |
virtual void Start();
|
|
291 |
virtual TBool Action(CPdpContext* aContext, const TContextParameters* aParams)
|
|
292 |
{return (this->*iActionList[iState].iAction)(aContext, aParams); }
|
|
293 |
|
|
294 |
virtual void Failure(CPdpContext* aPdpContext, TInt aErrorCode);
|
|
295 |
virtual void Cancel(CPdpContext* aContext);
|
|
296 |
|
|
297 |
protected:
|
|
298 |
CJoinRequest(CPdpContext* aContext, CFlowData* aFlowData, MQoSNegotiateEvent* aNotify);
|
|
299 |
|
|
300 |
TBool DoStartWithTargetContext(CPdpContext *, const TContextParameters*);
|
|
301 |
|
|
302 |
|
|
303 |
private:
|
|
304 |
static const SActionStep<CJoinRequest> iActionList[];
|
|
305 |
CPdpContext* iChannel;
|
|
306 |
};
|
|
307 |
|
|
308 |
class CLeaveRequest : public CRequestBase
|
|
309 |
{
|
|
310 |
~CLeaveRequest();
|
|
311 |
public:
|
|
312 |
static CLeaveRequest* New(CPdpContext* aContext, CFlowData* aFlowData, MQoSNegotiateEvent* aNotify);
|
|
313 |
|
|
314 |
virtual void Start();
|
|
315 |
virtual TBool Action(CPdpContext* aContext, const TContextParameters* aParams)
|
|
316 |
{return (this->*iActionList[iState].iAction)(aContext, aParams); }
|
|
317 |
|
|
318 |
virtual void Failure(CPdpContext* aPdpContext, TInt aErrorCode);
|
|
319 |
virtual void Cancel(CPdpContext* aContext);
|
|
320 |
|
|
321 |
protected:
|
|
322 |
CLeaveRequest(CPdpContext* aContext, CFlowData* aFlowData, MQoSNegotiateEvent* aNotify);
|
|
323 |
void ConstructL();
|
|
324 |
|
|
325 |
private:
|
|
326 |
static const SActionStep<CLeaveRequest> iActionList[];
|
|
327 |
CPdpContext* iChannel;
|
|
328 |
};
|
|
329 |
|
|
330 |
#endif
|