|
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 // |
|
15 |
|
16 #include "qosparameters.h" |
|
17 #include "pfqosparser.h" |
|
18 #include "qosvariables.h" |
|
19 |
|
20 //lint -e{1927} |
|
21 EXPORT_C TQoSParameters::TQoSParameters() |
|
22 /** Default constructor. |
|
23 * |
|
24 * Sets all internal members to zero, priorities are |
|
25 * set to the lowest priority and the adapt flag is cleared. */ |
|
26 { |
|
27 // Uplink |
|
28 iUplinkBandwidth = 0; |
|
29 iUpLinkMaximumBurstSize = 0; |
|
30 iUpLinkMaximumPacketSize = 0; |
|
31 iUpLinkAveragePacketSize = 0; |
|
32 iUpLinkDelay = 0; |
|
33 iUpLinkPriority = KQoSLowestPriority; |
|
34 |
|
35 // Downlink |
|
36 iDownlinkBandwidth = 0; |
|
37 iDownLinkMaximumBurstSize = 0; |
|
38 iDownLinkMaximumPacketSize = 0; |
|
39 iDownLinkAveragePacketSize = 0; |
|
40 iDownLinkDelay = 0; |
|
41 iDownLinkPriority = KQoSLowestPriority; |
|
42 |
|
43 // Others |
|
44 iName.FillZ(); |
|
45 iFlags = 2; // Headers included in bitrate calcs |
|
46 } |
|
47 |
|
48 EXPORT_C TInt TQoSParameters::operator==(const TQoSParameters& aParameters) |
|
49 const |
|
50 /** Equality operator. |
|
51 * |
|
52 * @param aParameters The object to be compared with *this. |
|
53 * @return 1, if the supplied argument is equal to *this; |
|
54 * 0, otherwise.*/ |
|
55 { |
|
56 if (iUplinkBandwidth == aParameters.GetUplinkBandwidth() && |
|
57 iUpLinkMaximumBurstSize == aParameters.GetUpLinkMaximumBurstSize() && |
|
58 iUpLinkMaximumPacketSize == aParameters.GetUpLinkMaximumPacketSize() |
|
59 && |
|
60 iUpLinkAveragePacketSize == aParameters.GetUpLinkAveragePacketSize() |
|
61 && |
|
62 iUpLinkDelay == aParameters.GetUpLinkDelay() && |
|
63 iUpLinkPriority == aParameters.GetUpLinkPriority() && |
|
64 |
|
65 iDownlinkBandwidth == aParameters.GetDownlinkBandwidth() && |
|
66 iDownLinkMaximumBurstSize == aParameters.GetDownLinkMaximumBurstSize() |
|
67 && |
|
68 iDownLinkMaximumPacketSize == |
|
69 aParameters.GetDownLinkMaximumPacketSize() && |
|
70 iDownLinkAveragePacketSize == |
|
71 aParameters.GetDownLinkAveragePacketSize() && |
|
72 iDownLinkDelay == aParameters.GetDownLinkDelay() && |
|
73 iDownLinkPriority == aParameters.GetDownLinkPriority() && |
|
74 |
|
75 iName.Compare(aParameters.GetName()) == 0 && |
|
76 iFlags == aParameters.Flags()) |
|
77 { |
|
78 return 1; |
|
79 } |
|
80 else |
|
81 { |
|
82 return 0; |
|
83 } |
|
84 } |
|
85 |
|
86 |
|
87 EXPORT_C TQoSParameters& TQoSParameters::operator= |
|
88 (const TQoSParameters& aSpec) |
|
89 /** Assignment operator. |
|
90 * |
|
91 * @param aSpec The object to make *this equal to. |
|
92 * @return A reference to *this. */ |
|
93 { |
|
94 if (this != &aSpec) |
|
95 { |
|
96 SetUplinkBandwidth(aSpec.GetUplinkBandwidth()); |
|
97 SetUpLinkMaximumBurstSize(aSpec.GetUpLinkMaximumBurstSize()); |
|
98 SetUpLinkMaximumPacketSize(aSpec.GetUpLinkMaximumPacketSize()); |
|
99 SetUpLinkAveragePacketSize(aSpec.GetUpLinkAveragePacketSize()); |
|
100 SetUpLinkDelay(aSpec.GetUpLinkDelay()); |
|
101 SetUpLinkPriority(aSpec.GetUpLinkPriority()); |
|
102 |
|
103 SetDownlinkBandwidth(aSpec.GetDownlinkBandwidth()); |
|
104 SetDownLinkMaximumBurstSize(aSpec.GetDownLinkMaximumBurstSize()); |
|
105 SetDownLinkMaximumPacketSize(aSpec.GetDownLinkMaximumPacketSize()); |
|
106 SetDownLinkAveragePacketSize(aSpec.GetDownLinkAveragePacketSize()); |
|
107 SetDownLinkDelay(aSpec.GetDownLinkDelay()); |
|
108 SetDownLinkPriority(aSpec.GetDownLinkPriority()); |
|
109 |
|
110 SetFlags(aSpec.Flags()); |
|
111 SetName(aSpec.GetName()); |
|
112 SetAdaptMode(aSpec.AdaptMode()); |
|
113 } |
|
114 return (*this); |
|
115 } |
|
116 |
|
117 EXPORT_C void TQoSParameters::SetUplinkBandwidth(TInt aBandwidth) |
|
118 /** Sets the bandwidth for the uplink. |
|
119 * |
|
120 * @param aBandwidth The bandwidth for the uplink. */ |
|
121 { |
|
122 iUplinkBandwidth = aBandwidth; |
|
123 } |
|
124 |
|
125 EXPORT_C void TQoSParameters::SetUpLinkMaximumBurstSize(TInt aSize) |
|
126 /** Sets the maximum burst size for the uplink. |
|
127 * |
|
128 * @param aSize The maximum burst size for the uplink. */ |
|
129 { |
|
130 iUpLinkMaximumBurstSize = aSize; |
|
131 } |
|
132 |
|
133 EXPORT_C void TQoSParameters::SetUpLinkMaximumPacketSize(TInt aMaxSize) |
|
134 /** Sets the maximum packet size for the uplink. |
|
135 * |
|
136 * @param aMaxSize The maximum packet size for the uplink. */ |
|
137 { |
|
138 iUpLinkMaximumPacketSize = aMaxSize; |
|
139 } |
|
140 |
|
141 EXPORT_C void TQoSParameters::SetUpLinkAveragePacketSize(TInt aSize) |
|
142 /** Sets the average packet size for uplink direction. |
|
143 * |
|
144 * Average packet size is used as the smallest packet size when doing traffic |
|
145 * policing and estimating effect of protocol headers. The average packet size |
|
146 * must be <= maximum packet size. |
|
147 * |
|
148 * @param aSize The average packet size for uplink direction in bytes. */ |
|
149 { |
|
150 iUpLinkAveragePacketSize = aSize; |
|
151 } |
|
152 |
|
153 EXPORT_C void TQoSParameters::SetUpLinkDelay(TInt aDelay) |
|
154 /** Sets the delay for the uplink. |
|
155 * |
|
156 * @param aDelay The uplink delay (in milliseconds). */ |
|
157 { |
|
158 iUpLinkDelay = aDelay; |
|
159 } |
|
160 |
|
161 EXPORT_C void TQoSParameters::SetUpLinkPriority(TInt aPriority) |
|
162 /** Sets the priority for uplink direction. |
|
163 * |
|
164 * Priority can be used to prioritise between traffic flows inside the |
|
165 * terminal. |
|
166 * |
|
167 * @param aPriority The priority for uplink direction, 0 indicates the highest |
|
168 * priority. */ |
|
169 { |
|
170 if (aPriority > KQoSLowestPriority) |
|
171 { |
|
172 iUpLinkPriority = KQoSLowestPriority; |
|
173 } |
|
174 else |
|
175 { |
|
176 iUpLinkPriority = aPriority; |
|
177 } |
|
178 } |
|
179 |
|
180 EXPORT_C void TQoSParameters::SetDownlinkBandwidth(TInt aBandwidth) |
|
181 /** Sets the bandwidth for downlink direction. |
|
182 * |
|
183 * Bandwidth defines the requested transfer rate that the application |
|
184 * requests. bandwidth must be > 0. |
|
185 * |
|
186 * @param aBandwidth The value to which to set the bandwidth for downlink |
|
187 * direction in bytes/second. */ |
|
188 { |
|
189 iDownlinkBandwidth = aBandwidth; |
|
190 } |
|
191 |
|
192 EXPORT_C void TQoSParameters::SetDownLinkMaximumBurstSize(TInt aSize) |
|
193 /** Sets the maximum burst size for downlink direction. |
|
194 * |
|
195 * Maximum burst size defines the burst size that the application might send. |
|
196 * Maximum burst size must be > 0. |
|
197 * |
|
198 * @param aSize The value to which to set the maximum burst size for downlink |
|
199 * direction in bytes. */ |
|
200 { |
|
201 iDownLinkMaximumBurstSize = aSize; |
|
202 } |
|
203 |
|
204 EXPORT_C void TQoSParameters::SetDownLinkMaximumPacketSize(TInt aMaxSize) |
|
205 /** Sets the maximum packet sixe for the downlink. |
|
206 * |
|
207 * @param aMaxSize The maximum packet size for the downlink. */ |
|
208 { |
|
209 iDownLinkMaximumPacketSize = aMaxSize; |
|
210 } |
|
211 |
|
212 EXPORT_C void TQoSParameters::SetDownLinkAveragePacketSize(TInt aSize) |
|
213 /** Sets the average packet size for downlink direction. |
|
214 * |
|
215 * @param aSize The value to which to set the maximum packet size for |
|
216 * downlink direction in bytes. */ |
|
217 { |
|
218 iDownLinkAveragePacketSize = aSize; |
|
219 } |
|
220 |
|
221 EXPORT_C void TQoSParameters::SetDownLinkDelay(TInt aDelay) |
|
222 /** Sets the downlink delay |
|
223 * |
|
224 * @param aDelay The downlink delay (in milliseconds). */ |
|
225 { |
|
226 iDownLinkDelay = aDelay; |
|
227 } |
|
228 |
|
229 EXPORT_C void TQoSParameters::SetDownLinkPriority(TInt aPriority) |
|
230 /** Sets the priority for downlink direction. |
|
231 * |
|
232 * Priority can be used to prioritise between traffic flows inside the |
|
233 * terminal. |
|
234 * |
|
235 * @param aPriority The priority for downlink direction, 0 indicates the |
|
236 * highest priority. */ |
|
237 { |
|
238 if (aPriority > KQoSLowestPriority) |
|
239 { |
|
240 iDownLinkPriority = KQoSLowestPriority; |
|
241 } |
|
242 else |
|
243 { |
|
244 iDownLinkPriority = aPriority; |
|
245 } |
|
246 } |
|
247 |
|
248 EXPORT_C TBool TQoSParameters::AdaptMode() const |
|
249 /** Tests whether the application can adapt. |
|
250 * |
|
251 * @return ETrue, if the application can adapt; otherwise, EFalse. */ |
|
252 // @return The adaption mode. */ |
|
253 { |
|
254 if (iFlags & KPfqosOptionCanAdapt) |
|
255 { |
|
256 return ETrue; |
|
257 } |
|
258 else |
|
259 { |
|
260 return EFalse; |
|
261 } |
|
262 } |
|
263 |
|
264 EXPORT_C TBool TQoSParameters::GetHeaderMode() const |
|
265 { |
|
266 if (iFlags & KPfqosOptionHeadersIncluded) |
|
267 { |
|
268 return ETrue; |
|
269 } |
|
270 else |
|
271 { |
|
272 return EFalse; |
|
273 } |
|
274 } |
|
275 |
|
276 EXPORT_C TInt TQoSParameters::SetName(const TName& aName) |
|
277 /** Sets the name to a copy of the supplied argument. |
|
278 * |
|
279 * @param aName The name. |
|
280 * @return KErrNone, if successful; KErrTooBig, if the supplied argument |
|
281 * is too large (256 characters maximum). */ |
|
282 { |
|
283 if (aName.Length() > iName.MaxLength()) |
|
284 { |
|
285 return KErrTooBig; |
|
286 } |
|
287 iName.Copy(aName); |
|
288 return KErrNone; |
|
289 } |
|
290 |
|
291 EXPORT_C void TQoSParameters::SetAdaptMode(TBool aCanAdapt) |
|
292 /** Sets the adaption mode. |
|
293 * |
|
294 * @param aCanAdapt The adaption mode. */ |
|
295 { |
|
296 if (aCanAdapt) |
|
297 { |
|
298 iFlags |= KPfqosOptionCanAdapt; |
|
299 } |
|
300 else |
|
301 { |
|
302 iFlags &= ~KPfqosOptionCanAdapt; |
|
303 } |
|
304 } |
|
305 |
|
306 EXPORT_C void TQoSParameters::SetHeaderMode(TBool aHeadersIncluded) |
|
307 { |
|
308 if (aHeadersIncluded) |
|
309 { |
|
310 iFlags |= KPfqosOptionHeadersIncluded; |
|
311 } |
|
312 else |
|
313 { |
|
314 iFlags &= ~KPfqosOptionHeadersIncluded; |
|
315 } |
|
316 } |
|
317 |
|
318 EXPORT_C void TQoSParameters::Copy(CExtension& aExtension) |
|
319 /** Makes the members of this object equal to the equivalent settings of the |
|
320 * extension policy (i.e. a module specific policy) of the supplied parameter. |
|
321 * |
|
322 * If any of the extension policy settings do not exist then the appropriate |
|
323 * member of this object is unchanged. |
|
324 * |
|
325 * @param aExtension The extension policy. */ |
|
326 { |
|
327 TVariableBase* var; |
|
328 |
|
329 // bandwidth up |
|
330 var = aExtension.FindVariable(KDescUplinkBandwidth); |
|
331 if (var && var->Type() == KPfqosTypeInteger) |
|
332 { |
|
333 SetUplinkBandwidth(((TIntVariable*)var)->Value()); |
|
334 } |
|
335 |
|
336 // maximum burst size up |
|
337 var = aExtension.FindVariable(KDescUpLinkMaximumBurstSize); |
|
338 if (var && var->Type() == KPfqosTypeInteger) |
|
339 { |
|
340 SetUpLinkMaximumBurstSize(((TIntVariable*)var)->Value()); |
|
341 } |
|
342 |
|
343 // Priority up |
|
344 var = aExtension.FindVariable(KDescUpLinkPriority); |
|
345 if (var && var->Type() == KPfqosTypeInteger) |
|
346 { |
|
347 SetUpLinkPriority((TUint8)((TIntVariable*)var)->Value()); |
|
348 } |
|
349 |
|
350 // Max packet size up |
|
351 var = aExtension.FindVariable(KDescUpLinkMaximumPacketSize); |
|
352 if (var && var->Type() == KPfqosTypeInteger) |
|
353 { |
|
354 SetUpLinkMaximumPacketSize(((TIntVariable*)var)->Value()); |
|
355 } |
|
356 |
|
357 // average packet size up |
|
358 var = aExtension.FindVariable(KDescUpLinkAveragePacketSize); |
|
359 if (var && var->Type() == KPfqosTypeInteger) |
|
360 { |
|
361 SetUpLinkAveragePacketSize(((TIntVariable*)var)->Value()); |
|
362 } |
|
363 |
|
364 // Delay up |
|
365 var = aExtension.FindVariable(KDescUpLinkDelay); |
|
366 if (var && var->Type() == KPfqosTypeInteger) |
|
367 { |
|
368 SetUpLinkDelay(((TIntVariable*)var)->Value()); |
|
369 } |
|
370 |
|
371 // bandwidth down |
|
372 var = aExtension.FindVariable(KDescDownlinkBandwidth); |
|
373 if (var && var->Type() == KPfqosTypeInteger) |
|
374 { |
|
375 SetDownlinkBandwidth(((TIntVariable*)var)->Value()); |
|
376 } |
|
377 |
|
378 // maximum burst size down |
|
379 var = aExtension.FindVariable(KDescDownLinkMaximumBurstSize); |
|
380 if (var && var->Type() == KPfqosTypeInteger) |
|
381 { |
|
382 SetDownLinkMaximumBurstSize(((TIntVariable*)var)->Value()); |
|
383 } |
|
384 |
|
385 // Priority down |
|
386 var = aExtension.FindVariable(KDescDownLinkPriority); |
|
387 if (var && var->Type() == KPfqosTypeInteger) |
|
388 { |
|
389 SetDownLinkPriority((TUint8)((TIntVariable*)var)->Value()); |
|
390 } |
|
391 |
|
392 // Max packet size down |
|
393 var = aExtension.FindVariable(KDescDownLinkMaximumPacketSize); |
|
394 if (var && var->Type() == KPfqosTypeInteger) |
|
395 { |
|
396 SetDownLinkMaximumPacketSize(((TIntVariable*)var)->Value()); |
|
397 } |
|
398 |
|
399 // average packet size down |
|
400 var = aExtension.FindVariable(KDescDownLinkAveragePacketSize); |
|
401 if (var && var->Type() == KPfqosTypeInteger) |
|
402 { |
|
403 SetDownLinkAveragePacketSize(((TIntVariable*)var)->Value()); |
|
404 } |
|
405 |
|
406 // Delay down |
|
407 var = aExtension.FindVariable(KDescDownLinkDelay); |
|
408 if (var && var->Type() == KPfqosTypeInteger) |
|
409 { |
|
410 SetDownLinkDelay(((TIntVariable*)var)->Value()); |
|
411 } |
|
412 |
|
413 // Flags |
|
414 var = aExtension.FindVariable(KDescFlags); |
|
415 if (var && var->Type() == KPfqosTypeInteger) |
|
416 { |
|
417 SetFlags((TUint)((TIntVariable*)var)->Value()); |
|
418 } |
|
419 |
|
420 // Name |
|
421 var = aExtension.FindVariable(KDescName); |
|
422 if (var && var->Type() == KPfqosTypeString) |
|
423 { |
|
424 SetName(((TStringVariable*)var)->Value()); |
|
425 } |
|
426 } |
|
427 |