37
|
1 |
// Copyright (c) 2004-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 |
// Implementation file for the QoS Mapping Messages
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file qos_msg.cpp
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include "pfqos_stream.h"
|
|
23 |
#include "pfqoslib.h"
|
|
24 |
#include "ipscpr.h"
|
|
25 |
#include "qos_msg.h"
|
|
26 |
#include "ipscprlog.h"
|
|
27 |
|
|
28 |
|
|
29 |
const TIp6Addr KInet6AddrMask = {{{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
30 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}}};
|
|
31 |
|
|
32 |
const TInt KQoSDefaultBufSize = 8000;
|
|
33 |
|
|
34 |
|
|
35 |
CQoSMsg* CQoSMsg::NewL( TPfqosMessages aMsgType )
|
|
36 |
/**
|
|
37 |
Create a new QoS PRT Message
|
|
38 |
|
|
39 |
@param aMsgType Message Type
|
|
40 |
*/
|
|
41 |
{
|
|
42 |
CQoSMsg* msg = new (ELeave) CQoSMsg();
|
|
43 |
|
|
44 |
CleanupStack::PushL( msg );
|
|
45 |
msg->ConstructL( aMsgType );
|
|
46 |
CleanupStack::Pop();
|
|
47 |
|
|
48 |
return msg;
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
CQoSMsg::~CQoSMsg()
|
|
53 |
/**
|
|
54 |
Destructor
|
|
55 |
*/
|
|
56 |
{
|
|
57 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsg::Destroy [%08x] Type=%d"), this, iType));
|
|
58 |
|
|
59 |
delete iMsg;
|
|
60 |
iMsg = NULL;
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
CQoSMsg::CQoSMsg()
|
|
65 |
/**
|
|
66 |
Constructor
|
|
67 |
*/
|
|
68 |
{
|
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
void CQoSMsg::ConstructL( TPfqosMessages aMsgType )
|
|
73 |
/**
|
|
74 |
QoS PRT Message second phase construction
|
|
75 |
|
|
76 |
@param aMsgType Message Type
|
|
77 |
*/
|
|
78 |
{
|
|
79 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsg::Construct [%08x] Type=%d"), this, aMsgType));
|
|
80 |
|
|
81 |
iMsg = CPfqosStream::NewL(KQoSDefaultBufSize);
|
|
82 |
iMsg->Init((TUint8)aMsgType);
|
|
83 |
iType = aMsgType;
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
void CQoSMsg::AddSrcAddr(const TInetAddr &aAddr)
|
|
88 |
/**
|
|
89 |
Adds Source Address Information to the QoS PRT Message
|
|
90 |
|
|
91 |
@param aAddr Source Address
|
|
92 |
*/
|
|
93 |
{
|
|
94 |
TInetAddr srcInetAddr(aAddr);
|
|
95 |
srcInetAddr.SetFamily(KAFUnspec);
|
|
96 |
srcInetAddr.SetAddress(KInet6AddrNone);
|
|
97 |
|
|
98 |
TInetAddr mask;
|
|
99 |
mask.SetAddress(KInet6AddrMask);
|
|
100 |
iMsg->AddSrcAddress(srcInetAddr, mask, (TUint16)srcInetAddr.Port());
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
void CQoSMsg::AddDstAddr(const TInetAddr &aAddr)
|
|
105 |
/**
|
|
106 |
Adds Destination Address Information to the QoS PRT Message
|
|
107 |
|
|
108 |
@param aAddr Destination Address
|
|
109 |
*/
|
|
110 |
{
|
|
111 |
TInetAddr dstInetAddr(aAddr);
|
|
112 |
if (dstInetAddr.Family() == KAfInet)
|
|
113 |
{
|
|
114 |
dstInetAddr.ConvertToV4Mapped();
|
|
115 |
}
|
|
116 |
|
|
117 |
TInetAddr mask;
|
|
118 |
mask.SetAddress(KInet6AddrMask);
|
|
119 |
iMsg->AddDstAddress(dstInetAddr, mask, (TUint16)dstInetAddr.Port());
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
void CQoSMsg::AddExtensionPolicy(TQoSExtensionQueue& aExtensions)
|
|
124 |
/**
|
|
125 |
Add QoS Extension Parameters to the QoS Message
|
|
126 |
|
|
127 |
@param aExtensions Collection of Extensions Parameters
|
|
128 |
*/
|
|
129 |
{
|
|
130 |
TQoSExtensionQueueIter iter(aExtensions);
|
|
131 |
CExtensionBase* extension;
|
|
132 |
while ((extension=iter++) != NULL)
|
|
133 |
{
|
|
134 |
TDesC8& extData = extension->Data();
|
|
135 |
iMsg->AddExtensionPolicy(extData);
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
void CQoSMsg::Send(RInternalSocket &aSocket, TRequestStatus& aStatus)
|
|
141 |
/**
|
|
142 |
Sends the current message to the QoS PRT
|
|
143 |
|
|
144 |
@param aSocket Internal Socket over which to send a message
|
|
145 |
@param aStatus Request Status
|
|
146 |
*/
|
|
147 |
{
|
|
148 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsg::Send [%08x] Type=%d"), this, iType));
|
|
149 |
|
|
150 |
iMsg->Send(aSocket, aStatus);
|
|
151 |
}
|
|
152 |
|
|
153 |
|
|
154 |
// ###########################################################
|
|
155 |
|
|
156 |
|
|
157 |
CQoSMsgWriter* CQoSMsgWriter::NewL(CIpSubConnectionProvider* aOwner, RInternalSocket& aSocket)
|
|
158 |
/**
|
|
159 |
Create QoS PRT Message Writer
|
|
160 |
|
|
161 |
@param aOwner The IP SubConnection Provider that creates this object
|
|
162 |
@param aSocket reference to an Internal Socket owned by the IP SubConnection Provider
|
|
163 |
*/
|
|
164 |
{
|
|
165 |
return new (ELeave) CQoSMsgWriter(aOwner, aSocket);
|
|
166 |
}
|
|
167 |
|
|
168 |
|
|
169 |
CQoSMsgWriter::CQoSMsgWriter(CIpSubConnectionProvider* aOwner, RInternalSocket& aSocket)
|
|
170 |
/**
|
|
171 |
Constructor
|
|
172 |
|
|
173 |
@param aOwner The IP SubConnection Provider that creates this object
|
|
174 |
@param aSocket reference to an Internal Socket owned by the IP SubConnection Provider
|
|
175 |
*/
|
|
176 |
: CActive(EPriorityStandard)
|
|
177 |
, iOwner(aOwner)
|
|
178 |
, iSocket(aSocket)
|
|
179 |
, iClosing(EFalse)
|
|
180 |
{
|
|
181 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::Construct [%08x]"), this));
|
|
182 |
|
|
183 |
CActiveScheduler::Add(this);
|
|
184 |
iPendingMsg.SetOffset(_FOFF(CQoSMsg, iLink));
|
|
185 |
}
|
|
186 |
|
|
187 |
|
|
188 |
CQoSMsgWriter::~CQoSMsgWriter()
|
|
189 |
/**
|
|
190 |
Destructor
|
|
191 |
*/
|
|
192 |
{
|
|
193 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::Destroy [%08x]"), this));
|
|
194 |
|
|
195 |
if (IsActive())
|
|
196 |
{
|
|
197 |
Cancel();
|
|
198 |
}
|
|
199 |
|
|
200 |
iClosing = ETrue;
|
|
201 |
|
|
202 |
if (iCurrentMsg)
|
|
203 |
{
|
|
204 |
delete iCurrentMsg;
|
|
205 |
iCurrentMsg = NULL;
|
|
206 |
}
|
|
207 |
|
|
208 |
while (!iPendingMsg.IsEmpty())
|
|
209 |
{
|
|
210 |
CQoSMsg* msg = iPendingMsg.First();
|
|
211 |
iPendingMsg.Remove(*msg);
|
|
212 |
delete msg;
|
|
213 |
}
|
|
214 |
|
|
215 |
iPendingMsg.Reset();
|
|
216 |
}
|
|
217 |
|
|
218 |
|
|
219 |
void CQoSMsgWriter::Send(CQoSMsg* aMsg)
|
|
220 |
/**
|
|
221 |
Sends a Message to the QoS PRT
|
|
222 |
|
|
223 |
@param aMsg The message to send
|
|
224 |
*/
|
|
225 |
{
|
|
226 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::Send [%08x]"), this));
|
|
227 |
|
|
228 |
// Can only process one message at a time.
|
|
229 |
if (IsActive())
|
|
230 |
{
|
|
231 |
iPendingMsg.AddLast(*aMsg);
|
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
235 |
iCurrentMsg = aMsg;
|
|
236 |
iCurrentMsg->Send(iSocket, iStatus);
|
|
237 |
SetActive();
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
void CQoSMsgWriter::RunL()
|
|
243 |
/**
|
|
244 |
Active Object main processing function
|
|
245 |
*/
|
|
246 |
{
|
|
247 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::RunL [%08x] - Enter"), this));
|
|
248 |
|
|
249 |
TInt err = iStatus.Int();
|
|
250 |
if (err != KErrNone && iOwner)
|
|
251 |
{
|
|
252 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::RunL [%08x] - Process Error"), this));
|
|
253 |
#ifdef _DEBUG
|
|
254 |
TInt msgType = EPfqosReserved;
|
|
255 |
if( iCurrentMsg )
|
|
256 |
{
|
|
257 |
msgType = iCurrentMsg->iType;
|
|
258 |
}
|
|
259 |
iOwner->ProcessPRTError(msgType, err);
|
|
260 |
#endif
|
|
261 |
}
|
|
262 |
|
|
263 |
delete iCurrentMsg;
|
|
264 |
iCurrentMsg = NULL;
|
|
265 |
|
|
266 |
if (!iClosing && !iPendingMsg.IsEmpty())
|
|
267 |
{
|
|
268 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::RunL [%08x] - Send next message"), this));
|
|
269 |
CQoSMsg* msg = iPendingMsg.First();
|
|
270 |
iPendingMsg.Remove(*msg);
|
|
271 |
iCurrentMsg = msg;
|
|
272 |
iCurrentMsg->Send(iSocket, iStatus);
|
|
273 |
SetActive();
|
|
274 |
}
|
|
275 |
|
|
276 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgWriter::RunL [%08x] - Exit"), this));
|
|
277 |
}
|
|
278 |
|
|
279 |
|
|
280 |
// ###########################################################
|
|
281 |
|
|
282 |
|
|
283 |
CQoSMsgReader* CQoSMsgReader::NewL( CIpSubConnectionProvider *aOwner, RInternalSocket& aSocket)
|
|
284 |
/**
|
|
285 |
Create QoS PRT Message Reader
|
|
286 |
|
|
287 |
@param aOwner The IP SubConnection Provider that creates this object
|
|
288 |
@param aSocket reference to an Internal Socket owned by the IP SubConnection Provider
|
|
289 |
*/
|
|
290 |
{
|
|
291 |
CQoSMsgReader* reader = new (ELeave) CQoSMsgReader(aOwner, aSocket);
|
|
292 |
|
|
293 |
CleanupStack::PushL( reader );
|
|
294 |
reader->ConstructL();
|
|
295 |
CleanupStack::Pop();
|
|
296 |
|
|
297 |
return reader;
|
|
298 |
}
|
|
299 |
|
|
300 |
|
|
301 |
CQoSMsgReader::CQoSMsgReader(CIpSubConnectionProvider *aOwner, RInternalSocket& aSocket)
|
|
302 |
/**
|
|
303 |
Constructor
|
|
304 |
|
|
305 |
@param aOwner The IP SubConnection Provider that creates this object
|
|
306 |
@param aSocket reference to an Internal Socket owned by the IP SubConnection Provider
|
|
307 |
*/
|
|
308 |
: CActive(EPriorityStandard)
|
|
309 |
, iOwner(aOwner)
|
|
310 |
, iSocket(aSocket)
|
|
311 |
, iRecvPtr(0,0)
|
|
312 |
, iClosing(EFalse)
|
|
313 |
{
|
|
314 |
CActiveScheduler::Add(this);
|
|
315 |
}
|
|
316 |
|
|
317 |
|
|
318 |
CQoSMsgReader::~CQoSMsgReader()
|
|
319 |
/**
|
|
320 |
Destructor
|
|
321 |
*/
|
|
322 |
{
|
|
323 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgReader::Destruct [%08x]"), this));
|
|
324 |
|
|
325 |
if (IsActive())
|
|
326 |
{
|
|
327 |
Cancel();
|
|
328 |
}
|
|
329 |
|
|
330 |
iClosing = ETrue;
|
|
331 |
|
|
332 |
if (iRecvBuf)
|
|
333 |
{
|
|
334 |
delete iRecvBuf;
|
|
335 |
iRecvBuf = NULL;
|
|
336 |
}
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
void CQoSMsgReader::ConstructL()
|
|
341 |
/**
|
|
342 |
QoS PRT Message Reader second phase construction
|
|
343 |
*/
|
|
344 |
{
|
|
345 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgReader::Construct [%08x]"), this));
|
|
346 |
|
|
347 |
iRecvBuf = HBufC8::NewL(KQoSDefaultBufSize);
|
|
348 |
TPtr8 tmp(iRecvBuf->Des());
|
|
349 |
iRecvPtr.Set(tmp);
|
|
350 |
|
|
351 |
iRecvPtr.Zero();
|
|
352 |
iRecvPtr.SetLength(KQoSDefaultBufSize);
|
|
353 |
iSocket.Recv(iRecvPtr, 0, iStatus);
|
|
354 |
SetActive();
|
|
355 |
}
|
|
356 |
|
|
357 |
|
|
358 |
void CQoSMsgReader::RunL()
|
|
359 |
/**
|
|
360 |
Active Object main processing function
|
|
361 |
*/
|
|
362 |
{
|
|
363 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgReader::RunL [%08x] - Enter"), this));
|
|
364 |
|
|
365 |
if (iStatus.Int() == KErrNone && iRecvPtr.Length() > 0 )
|
|
366 |
{
|
|
367 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgReader::RunL [%08x] - Process Response"), this));
|
|
368 |
TPfqosMessage msg(iRecvPtr);
|
|
369 |
if (msg.iError == KErrNone)
|
|
370 |
{
|
|
371 |
iOwner->ProcessPRTMsg(msg);
|
|
372 |
}
|
|
373 |
#ifdef _DEBUG
|
|
374 |
else
|
|
375 |
{
|
|
376 |
TInt msgType = EPfqosReserved;
|
|
377 |
iOwner->ProcessPRTError(msgType, msg.iError);
|
|
378 |
}
|
|
379 |
#endif
|
|
380 |
}
|
|
381 |
|
|
382 |
if (!iClosing)
|
|
383 |
{
|
|
384 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgReader::RunL [%08x] - Wait for next message"), this));
|
|
385 |
iRecvPtr.Zero();
|
|
386 |
iRecvPtr.SetLength(KQoSDefaultBufSize);
|
|
387 |
iSocket.Recv(iRecvPtr, 0, iStatus);
|
|
388 |
SetActive();
|
|
389 |
}
|
|
390 |
|
|
391 |
__IPCPRLOG(IpCprLog::Printf(_L("CQoSMsgReader::RunL [%08x] - Exit"), this));
|
|
392 |
}
|
|
393 |
|