|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "cnatsettings.h" |
|
22 //#include <unsafprotocolscrkeys.h> |
|
23 //#include "tnatportpool.h" |
|
24 #include "tnatserversettings.h" |
|
25 |
|
26 // CONSTANTS |
|
27 const TInt KDefaultUDPRefreshInterval = 28; |
|
28 const TInt KDefaultTCPRefreshInterval = 1200; |
|
29 const TInt KDefaultSTUNRetransmitTimer = 250; // milliseconds |
|
30 const TInt KDefaultTURNBandwidth = 0; // KB/s |
|
31 const TInt KDefaultRequestedTransport = 0; //UDP |
|
32 const TInt KDefaultRequestedPortProps = 0; //no specific port alignment and |
|
33 //special behavior requested |
|
34 const TInt KDefaultTURNLifeTime = 0; |
|
35 //const TInt KDefaultTURNRetryTime = 500; //milliseconds |
|
36 const TInt KDefaultTURNServerTimerVal = 0; //milliseconds |
|
37 const TInt KDefaultTransitioningStateTime = 0; //seconds |
|
38 const TInt KDefaultICECanditateTimer = 0; |
|
39 |
|
40 const TInt KDefaultSTUNServerPort = 3478; |
|
41 const TInt KDefaultTURNServerPort = 0; |
|
42 const TInt KDefaultTCPTimeout = 1200; |
|
43 const TInt KDefaultUDPTimeout = 28; |
|
44 const TInt KDefaultConnectivityCheckTimeout = 2; |
|
45 |
|
46 const TInt KDefaultPortFieldLength = 25; |
|
47 const TInt KDefaultPortPoolStarPort = 25000; |
|
48 const TInt KDefaultPortPoolEndPort = 50000; |
|
49 |
|
50 const TInt KLatestConnectedStunServerPort = 10; |
|
51 const TInt KLatestConnectedTurnServerPort = 20; |
|
52 |
|
53 _LIT8( KStunServer, "0.0.0.0"); |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CNATFWNATSettings::NewL |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CNATFWNATSettings* CNATFWNATSettings::NewL( const TDesC8& aDomain, |
|
60 TNATFWNATSettings aSettings) |
|
61 { |
|
62 CNATFWNATSettings* self = CNATFWNATSettings::NewLC(aDomain,aSettings); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CNATFWNATSettings::NewLC |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C CNATFWNATSettings* CNATFWNATSettings::NewLC( const TDesC8& aDomain, |
|
72 TNATFWNATSettings aSettings) |
|
73 { |
|
74 CNATFWNATSettings* self = new(ELeave)CNATFWNATSettings(aSettings); |
|
75 CleanupStack::PushL(self); |
|
76 self->ConstructL(aDomain); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CNATFWNATSettings::CNATFWNATSettings |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CNATFWNATSettings::CNATFWNATSettings(TNATFWNATSettings aSettings) : |
|
85 iSettings(aSettings) |
|
86 { |
|
87 iSettings = aSettings; |
|
88 iLatestConnectedSTUNServerPort = KLatestConnectedStunServerPort; |
|
89 iLatestConnectedTURNServerPort = KLatestConnectedTurnServerPort; |
|
90 iUDPRefreshInterval = KDefaultUDPRefreshInterval; |
|
91 iTCPRefreshInterval = KDefaultTCPRefreshInterval; |
|
92 iSTUNRetransmitTimer = KDefaultSTUNRetransmitTimer; |
|
93 iTURNBandwidth = KDefaultTURNBandwidth; |
|
94 iRequestedTransport = KDefaultRequestedTransport; |
|
95 iRequestedPortProps = KDefaultRequestedPortProps; |
|
96 iTURNLifeTime = KDefaultTURNLifeTime; |
|
97 // iICECanditateTimer = KDefaultICECanditateTimer; |
|
98 iUseSharedSecret = EFalse; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CNATFWNATSettings::ConstructL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CNATFWNATSettings::ConstructL(const TDesC8& aDomain) |
|
106 { |
|
107 __ASSERT_ALWAYS(aDomain.Length() > 0, User::Leave(KErrArgument)); |
|
108 |
|
109 // iCenRep = CRepository::NewL(KCRUidUNSAFProtocols); |
|
110 iLatestConnectedSTUNServerAddress = KNullDesC8().AllocL(); |
|
111 iLatestConnectedTURNServerAddress = KNullDesC8().AllocL(); |
|
112 iRequestedAddress = KNullDesC8().AllocL(); |
|
113 |
|
114 iSTUNServerSettingsArray = |
|
115 new( ELeave ) CArrayFixFlat<TNATServerSettings> ( 1 ); |
|
116 iTURNServerSettingsArray = |
|
117 new( ELeave ) CArrayFixFlat<TNATServerSettings> ( 1 ); |
|
118 |
|
119 iDomain = aDomain.AllocL(); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CNATFWNATSettings::~CNATFWNATSettings |
|
124 //--------------------------------------------------------------------------- |
|
125 // |
|
126 CNATFWNATSettings::~CNATFWNATSettings() |
|
127 { |
|
128 delete iRequestedAddress; |
|
129 delete iDomain; |
|
130 delete iLatestConnectedSTUNServerAddress; |
|
131 delete iLatestConnectedTURNServerAddress; |
|
132 |
|
133 delete iSTUNServerSettingsArray; |
|
134 delete iTURNServerSettingsArray; |
|
135 |
|
136 /* if (iDomainKey) |
|
137 { |
|
138 // Remove settings added during runtime |
|
139 if(iCenRep) iCenRep->Delete(KUNSAFProtocolsSharedSecretMask|iDomainKey); |
|
140 } |
|
141 if(iPortField.KeyMaskForCR() != 0) |
|
142 { |
|
143 // remove if added during runtime |
|
144 iCenRep->Delete(iPortField.KeyMaskForCR()|KUNSAFProtocolsStartPortMask); |
|
145 iCenRep->Delete(iPortField.KeyMaskForCR()|KUNSAFProtocolsEndPortMask); |
|
146 } |
|
147 delete iCenRep;*/ |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CNATFWNATSettings::RetrieveIapSettings |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C TInt CNATFWNATSettings::RetrieveIapSettingsL(const TUint /*aIapId*/ ) |
|
155 { |
|
156 //iIapId = aIapId; |
|
157 //return ReadIapSettingsL(*iCenRep, aIapId); |
|
158 return KErrNone; |
|
159 } |
|
160 /* |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CNATFWNATSettings::UpdateL |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C void CNATFWNATSettings::UpdateL() |
|
166 { |
|
167 UpdateL(iSettings); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CNATFWNATSettings::UpdateL |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C void CNATFWNATSettings::UpdateL(TNATFWNATSettings aSettings) |
|
175 { |
|
176 TInt err = ReadDomainSettingsKeyL(*iCenRep, *iDomain, iDomainKey); |
|
177 if(err == KErrNone) |
|
178 { |
|
179 if((aSettings&ESTUNSettings) == ESTUNSettings) |
|
180 { |
|
181 ReadSTUNSettingsL(*iCenRep, iDomainKey); |
|
182 } |
|
183 if((aSettings&ETURNSettings) == ETURNSettings) |
|
184 { |
|
185 ReadTURNSettingsL(*iCenRep, iDomainKey); |
|
186 } |
|
187 if((aSettings&EICESettings) == EICESettings) |
|
188 { |
|
189 ReadICESettings(*iCenRep, iDomainKey); |
|
190 } |
|
191 if((aSettings&ESTUNSettings) == ESTUNSettings || |
|
192 (aSettings&ETURNSettings) == ETURNSettings) |
|
193 { |
|
194 ReadGeneralSettingsL(*iCenRep, iDomainKey); |
|
195 } |
|
196 } |
|
197 ReadIapSettingsL(*iCenRep,iIapId); |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CNATFWNATSettings::IapId |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C TUint32 CNATFWNATSettings::IapId() const |
|
205 { |
|
206 return iIapId; |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CNATFWNATSettings::Domain |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 EXPORT_C const TDesC8& CNATFWNATSettings::Domain() const |
|
214 { |
|
215 return *iDomain; |
|
216 }*/ |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CNATFWNATSettings::GetSTUNServerArrayL |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 EXPORT_C CArrayFix<TNATServerSettings>* |
|
222 CNATFWNATSettings::GetSTUNServerArrayL() const |
|
223 { |
|
224 CArrayFix<TNATServerSettings>* StunServerSettingsArray = |
|
225 new( ELeave ) CArrayFixFlat<TNATServerSettings> ( 1 ); |
|
226 TInt count = iSTUNServerSettingsArray->Count(); |
|
227 |
|
228 for ( TInt i(0); i < count; i++ ) |
|
229 { |
|
230 StunServerSettingsArray->AppendL( iSTUNServerSettingsArray->At( i ) ); |
|
231 } |
|
232 |
|
233 return StunServerSettingsArray; |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CNATFWNATSettings::GetTURNServerArrayL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C CArrayFix<TNATServerSettings>* |
|
241 CNATFWNATSettings::GetTURNServerArrayL() const |
|
242 { |
|
243 CArrayFix<TNATServerSettings>* TURNServerSettingsArray = |
|
244 new( ELeave ) CArrayFixFlat<TNATServerSettings> ( 1 ); |
|
245 TInt count = iTURNServerSettingsArray->Count(); |
|
246 |
|
247 for ( TInt i(0); i < count; i++ ) |
|
248 { |
|
249 TURNServerSettingsArray->AppendL( iTURNServerSettingsArray->At( i ) ); |
|
250 } |
|
251 |
|
252 return TURNServerSettingsArray; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CNATFWNATSettings::LatestConnectedSTUNServerAddress |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 EXPORT_C const TDesC8& CNATFWNATSettings::LatestConnectedSTUNServerAddress() const |
|
260 { |
|
261 return *iLatestConnectedSTUNServerAddress; |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CNATFWNATSettings::LatestConnectedSTUNServerPort |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 EXPORT_C TUint CNATFWNATSettings::LatestConnectedSTUNServerPort() const |
|
269 { |
|
270 return iLatestConnectedSTUNServerPort; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CNATFWNATSettings::LatestConnectedTURNServerAddress |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 EXPORT_C const TDesC8& CNATFWNATSettings::LatestConnectedTURNServerAddress() const |
|
278 { |
|
279 return *iLatestConnectedTURNServerAddress; |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CNATFWNATSettings::LatestConnectedTURNServerPort |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 EXPORT_C TUint CNATFWNATSettings::LatestConnectedTURNServerPort() const |
|
287 { |
|
288 return iLatestConnectedTURNServerPort; |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CNATFWNATSettings::UDPRefreshInterval |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 EXPORT_C TInt CNATFWNATSettings::UDPRefreshInterval() const |
|
296 { |
|
297 return iUDPRefreshInterval; |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CNATFWNATSettings::TCPRefreshInterval |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 EXPORT_C TInt CNATFWNATSettings::TCPRefreshInterval() const |
|
305 { |
|
306 return iTCPRefreshInterval; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CNATFWNATSettings::STUNRetransmitTimer |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 EXPORT_C TInt CNATFWNATSettings::STUNRetransmitTimer() const |
|
314 { |
|
315 return iSTUNRetransmitTimer; |
|
316 } |
|
317 /* |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CNATFWNATSettings::CRLFRefreshEnabledToProxy |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 EXPORT_C TBool CNATFWNATSettings::CRLFRefreshEnabledToProxy() const |
|
323 { |
|
324 return iCRLFRefreshEnabled; |
|
325 } |
|
326 */ |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CNATFWNATSettings::SharedSecretNotSupported |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 EXPORT_C TBool CNATFWNATSettings::UseSharedSecret() const |
|
332 { |
|
333 return iUseSharedSecret; |
|
334 } |
|
335 /* |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CNATFWNATSettings::BindingRequestFailed |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 EXPORT_C TBool CNATFWNATSettings::BindingRequestFailed() const |
|
341 { |
|
342 return iBindingRequestFailed; |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CNATFWNATSettings::STUNUsed |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 EXPORT_C TBool CNATFWNATSettings::STUNUsed() const |
|
350 { |
|
351 return iSTUNUsed; |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CNATFWNATSettings::TURNUsed |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 EXPORT_C TBool CNATFWNATSettings::TURNUsed() const |
|
359 { |
|
360 return iTURNUsed; |
|
361 } |
|
362 |
|
363 // ----------------------------------------------------------------------------- |
|
364 // CNATFWNATSettings::ICEUsed |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 EXPORT_C TBool CNATFWNATSettings::ICEUsed() const |
|
368 { |
|
369 return iOfferICE; |
|
370 } |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CNATFWNATSettings::TURNBandwidth |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 EXPORT_C TUint CNATFWNATSettings::TURNBandwidth() const |
|
376 { |
|
377 return iTURNBandwidth; |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CNATFWNATSettings::RequestedTransport |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 EXPORT_C TUint CNATFWNATSettings::RequestedTransport() const |
|
385 { |
|
386 return iRequestedTransport; |
|
387 } |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // CNATFWNATSettings::RequestedIPAddress |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 EXPORT_C const TDesC8& CNATFWNATSettings::RequestedAddress() const |
|
394 { |
|
395 return *iRequestedAddress; |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CNATFWNATSettings::RequestedPort |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 EXPORT_C TUint CNATFWNATSettings::RequestedPort() const |
|
403 { |
|
404 return iRequestedPort; |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CNATFWNATSettings::RequestedPortProps |
|
409 // ----------------------------------------------------------------------------- |
|
410 // |
|
411 EXPORT_C TUint CNATFWNATSettings::RequestedPortProps() const |
|
412 { |
|
413 return iRequestedPortProps; |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CNATFWNATSettings::TURNLifetime |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 EXPORT_C TUint CNATFWNATSettings::TURNLifetime() const |
|
421 { |
|
422 return iTURNLifeTime; |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CNATFWNATSettings::TURNRequestRetryTime |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 EXPORT_C TUint CNATFWNATSettings::TURNRequestRetryTime() const |
|
430 { |
|
431 return iTURNRetryTime; |
|
432 } |
|
433 |
|
434 // ----------------------------------------------------------------------------- |
|
435 // CNATFWNATSettings::TURNServerTimerVal |
|
436 // ----------------------------------------------------------------------------- |
|
437 // |
|
438 EXPORT_C TUint CNATFWNATSettings::TURNServerTimerVal() const |
|
439 { |
|
440 return iTURNServerTimerVal; |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // CNATFWNATSettings::TransitioningStateTime |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 EXPORT_C TUint CNATFWNATSettings::TransitioningStateTime() const |
|
448 { |
|
449 return iTransitioningStateTime; |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // CNATFWNATSettings::SharedSecret |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 EXPORT_C const TDesC8& CNATFWNATSettings::SharedSecret() const |
|
457 { |
|
458 return *iSharedSecret; |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CNATFWNATSettings::ActiveDestinationAddress |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 EXPORT_C const TDesC8& CNATFWNATSettings::ActiveDestinationAddress() const |
|
466 { |
|
467 return *iActiveDestinationAddress; |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CNATFWNATSettings::ActiveDestinationPort |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 EXPORT_C TUint CNATFWNATSettings::ActiveDestinationPort() const |
|
475 { |
|
476 return iActiveDestinationPort; |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CNATFWNATSettings::RelayedTransportAddress |
|
481 // ----------------------------------------------------------------------------- |
|
482 // |
|
483 EXPORT_C const TDesC8& CNATFWNATSettings::RelayedTransportAddress() const |
|
484 { |
|
485 return *iRelayedAddress; |
|
486 } |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // CNATFWNATSettings::RelayedTransportPort |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 EXPORT_C TUint CNATFWNATSettings::RelayedTransportPort() const |
|
493 { |
|
494 return iRelayedPort; |
|
495 } |
|
496 |
|
497 // ----------------------------------------------------------------------------- |
|
498 // CNATFWNATSettings::ReflexiveTransportAddress |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 EXPORT_C const TDesC8& CNATFWNATSettings::ReflexiveTransportAddress() const |
|
502 { |
|
503 return *iReflexiveAddress; |
|
504 } |
|
505 |
|
506 // ----------------------------------------------------------------------------- |
|
507 // CNATFWNATSettings::ReflexiveTransportPort |
|
508 // ----------------------------------------------------------------------------- |
|
509 // |
|
510 EXPORT_C TUint CNATFWNATSettings::ReflexiveTransportPort() const |
|
511 { |
|
512 return iReflexivePort; |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CNATFWNATSettings::TransitioningStateTimer |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 EXPORT_C TUint CNATFWNATSettings::TransitioningStateTimer() const |
|
520 { |
|
521 return iTransitioningStateTime; |
|
522 } |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // CNATFWNATSettings::SetSharedSecretL |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 EXPORT_C void CNATFWNATSettings::SetSharedSecretL(const TDesC8& aValue) |
|
529 { |
|
530 WriteL(KUNSAFProtocolsSharedSecretMask|iDomainKey,aValue); |
|
531 if(iSharedSecret) |
|
532 { |
|
533 delete iSharedSecret; |
|
534 iSharedSecret = 0; |
|
535 } |
|
536 iSharedSecret = aValue.AllocL(); |
|
537 } |
|
538 |
|
539 // ----------------------------------------------------------------------------- |
|
540 // CNATFWNATSettings::PlugInParams |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 EXPORT_C TNATFWPlugInParams CNATFWNATSettings::PlugInParams() const |
|
544 { |
|
545 return iPlugInParams; |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // CNATFWNATSettings::UsedNATProtocol |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 EXPORT_C TUint CNATFWNATSettings::UsedNATProtocol() const |
|
553 { |
|
554 return iUsedNATProtocol; |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CNATFWNATSettings::GetPortAreaL |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 EXPORT_C void CNATFWNATSettings::GetPortAreaL(TUint& aStartPort, TUint& aEndPort) |
|
562 { |
|
563 TUint portpoolStart; |
|
564 TUint portpoolEnd; |
|
565 TUint portFieldLength; |
|
566 |
|
567 if(iPortField.KeyMaskForCR() == 0) |
|
568 { |
|
569 //read port pool settings |
|
570 if(Read(*iCenRep, KUNSAFProtocolsPortPoolStartPortMask|iDomainKey, portpoolStart)==EFalse) |
|
571 { |
|
572 portpoolStart = KDefaultPortPoolStarPort; |
|
573 } |
|
574 if(Read(*iCenRep, KUNSAFProtocolsPortPoolEndPortMask|iDomainKey, portpoolEnd)==EFalse) |
|
575 { |
|
576 portpoolEnd = KDefaultPortPoolEndPort; |
|
577 } |
|
578 if(Read(*iCenRep, KUNSAFProtocolsPortFieldLengthMask|iDomainKey, portFieldLength)==EFalse) |
|
579 { |
|
580 portFieldLength = KDefaultPortFieldLength; |
|
581 } |
|
582 TNATPortPool portPool(portpoolStart, portpoolEnd); |
|
583 iPortField.SetLength(portFieldLength); |
|
584 |
|
585 //read reserved port fields to PortPool |
|
586 RArray<TUint32> keys; |
|
587 CleanupClosePushL(keys); |
|
588 TInt error = iCenRep->FindL(KUNSAFProtocolsStartPortMask, |
|
589 KUNSAFProtocolsPortFieldFieldTypeMask, |
|
590 keys); |
|
591 TUint keyCount = keys.Count(); |
|
592 |
|
593 if (error == KErrNone && keyCount > 0) |
|
594 { |
|
595 for(TUint i=0; i<keyCount; i++) |
|
596 { |
|
597 TUint32 key = keys[i]^KUNSAFProtocolsStartPortMask; |
|
598 TUint start = 0; |
|
599 TUint end = 0; |
|
600 //Start port |
|
601 Read(*iCenRep, KUNSAFProtocolsStartPortMask|key, start); |
|
602 //End port |
|
603 Read(*iCenRep, KUNSAFProtocolsEndPortMask|key, end); |
|
604 |
|
605 TNATPortField field; |
|
606 field.SetStartPort(start); |
|
607 field.SetEndPort(end); |
|
608 |
|
609 User::LeaveIfError(portPool.AppendPortField(field)); |
|
610 } |
|
611 } |
|
612 else if(error != KErrNotFound) |
|
613 { |
|
614 User::LeaveIfError(error); |
|
615 } |
|
616 CleanupStack::PopAndDestroy(&keys); |
|
617 |
|
618 //reserve port field |
|
619 if(portPool.ReserveNewPortArea(iPortField)) |
|
620 { |
|
621 //new key |
|
622 TUint32 newKey = CreateNewKeyL(*iCenRep, |
|
623 KUNSAFProtocolsStartPortMask, |
|
624 KUNSAFProtocolsPortFieldFieldTypeMask); |
|
625 //write to cr |
|
626 WriteL(KUNSAFProtocolsStartPortMask|newKey, iPortField.StartPort()); |
|
627 WriteL(KUNSAFProtocolsEndPortMask|newKey, iPortField.EndPort()); |
|
628 iPortField.SetKeyMask(newKey); |
|
629 } |
|
630 else |
|
631 { |
|
632 User::Leave(KErrOverflow ); |
|
633 } |
|
634 } |
|
635 aStartPort = iPortField.StartPort(); |
|
636 aEndPort = iPortField.EndPort(); |
|
637 } |
|
638 |
|
639 // Private Functions |
|
640 // ----------------------------------------------------------------------------- |
|
641 // CNATFWNATSettings::ReadDomainSettingsKeyL |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 TInt CNATFWNATSettings::ReadDomainSettingsKeyL( |
|
645 CRepository& aRepository, |
|
646 const TDesC8& aDomain, |
|
647 TUint32& aDomainKey) |
|
648 { |
|
649 RArray<TUint32> keys; |
|
650 CleanupClosePushL(keys); |
|
651 TInt err = aRepository.FindEqL( KUNSAFProtocolsDomainMask, |
|
652 KUNSAFProtocolsFieldTypeMask, |
|
653 aDomain, |
|
654 keys); |
|
655 TInt count = keys.Count(); |
|
656 if (err == KErrNone && count == 1) |
|
657 { |
|
658 aDomainKey = (KUNSAFProtocolsDomainMask^(keys[0])); |
|
659 } |
|
660 if(count > 1) |
|
661 { |
|
662 err = KErrCorrupt; |
|
663 } |
|
664 CleanupStack::PopAndDestroy(&keys); |
|
665 return err; |
|
666 } |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CNATFWNATSettings::ReadGeneralSettingsL |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 void CNATFWNATSettings::ReadGeneralSettingsL( |
|
673 CRepository& aRepository, |
|
674 TUint32 aDomainKey) |
|
675 { |
|
676 HBufC8* tempBuf = NULL; |
|
677 |
|
678 //Plug-in params |
|
679 RArray<TUint32> plugInkeys; |
|
680 CleanupClosePushL(plugInkeys); |
|
681 TInt error = aRepository.FindL(KUNSAFProtocolsPlugInIdMask|aDomainKey, |
|
682 KUNSAFProtocolsSubTableFieldTypeMask, |
|
683 plugInkeys); |
|
684 TUint keyCount = plugInkeys.Count(); |
|
685 if (error == KErrNone && keyCount > 0) |
|
686 { |
|
687 for(TUint i=0; i<keyCount; i++) |
|
688 { |
|
689 TUint32 key = plugInkeys[i]^KUNSAFProtocolsPlugInIdMask; |
|
690 //Plug-in id |
|
691 if(Read(aRepository, KUNSAFProtocolsPlugInIdMask|key, iPlugInParams.iPlugInId)) |
|
692 { |
|
693 iPlugInParams.iPlugInId = 0; |
|
694 } |
|
695 //Plug-in service id |
|
696 if(Read(aRepository, |
|
697 KUNSAFProtocolsPlugInServiceIdMask|key, |
|
698 iPlugInParams.iPlugInServiceId)) |
|
699 { |
|
700 iPlugInParams.iPlugInServiceId = 0; |
|
701 } |
|
702 } |
|
703 } |
|
704 else if(error == KErrNotFound) |
|
705 { |
|
706 iPlugInParams.iPlugInId = 0; |
|
707 iPlugInParams.iPlugInServiceId = 0; |
|
708 } |
|
709 else |
|
710 { |
|
711 User::LeaveIfError(error); |
|
712 } |
|
713 CleanupStack::PopAndDestroy(&plugInkeys); |
|
714 |
|
715 |
|
716 // TURNUsed |
|
717 ReadBoolValue(aRepository, |
|
718 KUNSAFProtocolsTURNUsedMask|aDomainKey, |
|
719 iTURNUsed); |
|
720 // STUNUsed |
|
721 ReadBoolValue(aRepository, |
|
722 KUNSAFProtocolsSTUNUsedMask|aDomainKey, |
|
723 iSTUNUsed); |
|
724 // OfferIce |
|
725 ReadBoolValue(aRepository, |
|
726 KUNSAFProtocolsOfferICEMask|aDomainKey, |
|
727 iOfferICE); |
|
728 |
|
729 // Shared secret support |
|
730 ReadBoolValue(aRepository, |
|
731 KUNSAFProtocolsDomainSharedSecretNotSupportedMask|aDomainKey, |
|
732 iSharedSecretNotSupported); |
|
733 // Latest binding request status |
|
734 ReadBoolValue(aRepository, |
|
735 KUNSAFProtocolsDomainBindingRequestFailedMask|aDomainKey, |
|
736 iBindingRequestFailed); |
|
737 // Shared secret |
|
738 if(ReadL(aRepository, KUNSAFProtocolsSharedSecretMask|aDomainKey, &tempBuf)) |
|
739 { |
|
740 if(iSharedSecret) delete iSharedSecret; |
|
741 iSharedSecret = tempBuf; |
|
742 } |
|
743 else{ delete tempBuf; } |
|
744 } |
|
745 |
|
746 // ----------------------------------------------------------------------------- |
|
747 // CNATFWNATSettings::ReadServerSettingsL |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 void CNATFWNATSettings::ReadServerSettingsL( |
|
751 CRepository& aRepository, |
|
752 const TUint32 aServerKeyMask, |
|
753 TServerSettings aDefaultSettings, |
|
754 RPointerArray<CNATServerSettings>& aServerSettingsArray ) |
|
755 { |
|
756 RArray<TUint32> serverKeys; |
|
757 CleanupClosePushL(serverKeys); |
|
758 aServerSettingsArray.ResetAndDestroy(); |
|
759 TServerSettings settings; |
|
760 |
|
761 //finding server keys by using address |
|
762 TInt error = aRepository.FindL( |
|
763 KUNSAFProtocolsSTUNAddressMask^KUNSAFProtocolsSTUNServerTableMask|aServerKeyMask, |
|
764 KUNSAFProtocolsSubTableFieldTypeMask, |
|
765 serverKeys); |
|
766 //read server settings |
|
767 TUint keyCount = serverKeys.Count(); |
|
768 if (error == KErrNone && keyCount > 0) |
|
769 { |
|
770 for(TUint i=0; i<keyCount; i++) |
|
771 { |
|
772 HBufC8* address = NULL; |
|
773 //address |
|
774 ReadL( |
|
775 aRepository, |
|
776 KUNSAFProtocolsSTUNAddressMask^KUNSAFProtocolsSTUNServerTableMask|serverKeys[i], |
|
777 &address); |
|
778 //port |
|
779 if(Read( |
|
780 aRepository, |
|
781 KUNSAFProtocolsSTUNPortMask^KUNSAFProtocolsSTUNServerTableMask|serverKeys[i], |
|
782 settings.iPort) == EFalse) |
|
783 { |
|
784 settings.iPort = aDefaultSettings.iPort; |
|
785 } |
|
786 //TCPTimeout |
|
787 if(Read( |
|
788 aRepository, |
|
789 KUNSAFProtocolsSTNUTCPTimeoutMask^KUNSAFProtocolsSTUNServerTableMask|serverKeys[i], |
|
790 settings.iTCPTimeout) == EFalse) |
|
791 { |
|
792 settings.iTCPTimeout = aDefaultSettings.iTCPTimeout; |
|
793 } |
|
794 //UDPTimeout |
|
795 if(Read( |
|
796 aRepository, |
|
797 KUNSAFProtocolsSTUNUDPTimeoutMask^KUNSAFProtocolsSTUNServerTableMask|serverKeys[i], |
|
798 settings.iUDPTimeout) == EFalse) |
|
799 { |
|
800 settings.iUDPTimeout = aDefaultSettings.iUDPTimeout; |
|
801 } |
|
802 //ConnectivityCheckTimeout |
|
803 if(Read( |
|
804 aRepository, |
|
805 KUNSAFProtocolsSTUNConnectivityCheckTimeoutMask^KUNSAFProtocolsSTUNServerTableMask| |
|
806 serverKeys[i], |
|
807 settings.iConnectivityCheckTimeout) == EFalse) |
|
808 { |
|
809 settings.iConnectivityCheckTimeout = aDefaultSettings.iConnectivityCheckTimeout; |
|
810 } |
|
811 //CRLFRefreshEnabled |
|
812 if(ReadBoolValue( |
|
813 aRepository, |
|
814 KUNSAFProtocolsSTUNEnableCRLFRefreshMask^KUNSAFProtocolsSTUNServerTableMask| |
|
815 serverKeys[i], |
|
816 settings.iCRLFRefreshEnabled) == EFalse) |
|
817 { |
|
818 settings.iCRLFRefreshEnabled = aDefaultSettings.iCRLFRefreshEnabled; |
|
819 } |
|
820 |
|
821 CNATServerSettings* serverSettings = CNATServerSettings::NewLC( |
|
822 *address, |
|
823 settings.iPort, |
|
824 settings.iTCPTimeout, |
|
825 settings.iUDPTimeout, |
|
826 settings.iConnectivityCheckTimeout, |
|
827 settings.iCRLFRefreshEnabled |
|
828 ); |
|
829 aServerSettingsArray.AppendL(serverSettings); |
|
830 CleanupStack::Pop(serverSettings); |
|
831 delete address; |
|
832 } |
|
833 } |
|
834 else if(error != KErrNotFound) |
|
835 { |
|
836 User::Leave(error); |
|
837 } |
|
838 CleanupStack::PopAndDestroy(&serverKeys); |
|
839 } |
|
840 |
|
841 // ----------------------------------------------------------------------------- |
|
842 // CNATFWNATSettings::ReadSTUNSettingsL |
|
843 // ----------------------------------------------------------------------------- |
|
844 // |
|
845 void CNATFWNATSettings::ReadSTUNSettingsL( |
|
846 CRepository& aRepository, |
|
847 TUint32 aDomainKey) |
|
848 { |
|
849 RArray<TUint32> addressKeys; |
|
850 HBufC8* tempBufPointer = NULL; |
|
851 CleanupClosePushL(addressKeys); |
|
852 |
|
853 // STUN Servers |
|
854 TServerSettings stunSettings; |
|
855 stunSettings.iPort = KDefaultSTUNServerPort; |
|
856 stunSettings.iTCPTimeout = KDefaultTCPTimeout; |
|
857 stunSettings.iUDPTimeout = KDefaultUDPTimeout; |
|
858 stunSettings.iConnectivityCheckTimeout = KDefaultConnectivityCheckTimeout; |
|
859 stunSettings.iCRLFRefreshEnabled = EFalse; |
|
860 |
|
861 ReadServerSettingsL( |
|
862 aRepository, |
|
863 KUNSAFProtocolsSTUNServerTableMask|aDomainKey, |
|
864 stunSettings, |
|
865 iSTUNServerSettingsArray |
|
866 ); |
|
867 |
|
868 //LatestConnectedStunServerAddress |
|
869 if(ReadL(aRepository, |
|
870 KUNSAFProtocolsLatestConnectedSTUNServerAddressMask|aDomainKey, |
|
871 &tempBufPointer)) |
|
872 { |
|
873 if(iLatestConnectedSTUNServerAddress) delete iLatestConnectedSTUNServerAddress; |
|
874 iLatestConnectedSTUNServerAddress = tempBufPointer; |
|
875 } |
|
876 else{ delete tempBufPointer; } |
|
877 //LatestConnectedStunServerPort |
|
878 if(Read(aRepository, KUNSAFProtocolsLatestConnectedSTUNServerPortMask|aDomainKey, |
|
879 iLatestConnectedSTUNServerPort)==EFalse) |
|
880 { |
|
881 iLatestConnectedSTUNServerPort = 0; |
|
882 } |
|
883 // STUN retransmit timer |
|
884 if(Read(aRepository, |
|
885 KUNSAFProtocolsSTUNRetransmitTimerMask|aDomainKey, |
|
886 iSTUNRetransmitTimer)==EFalse) |
|
887 { |
|
888 iSTUNRetransmitTimer = KDefaultSTUNRetransmitTimer; |
|
889 } |
|
890 else |
|
891 { |
|
892 } |
|
893 CleanupStack::PopAndDestroy(&addressKeys); |
|
894 } |
|
895 |
|
896 // ----------------------------------------------------------------------------- |
|
897 // CNATFWNATSettings::ReadTURNSettingsL |
|
898 // ----------------------------------------------------------------------------- |
|
899 // |
|
900 void CNATFWNATSettings::ReadTURNSettingsL( |
|
901 CRepository& aRepository, |
|
902 TUint32 aDomainKey) |
|
903 { |
|
904 RArray<TUint32> addressKeys; |
|
905 HBufC8* tempBufPointer = NULL; |
|
906 CleanupClosePushL(addressKeys); |
|
907 |
|
908 //TURN Servers |
|
909 TServerSettings turnSettings; |
|
910 turnSettings.iPort = KDefaultTURNServerPort; |
|
911 turnSettings.iTCPTimeout = KDefaultTCPTimeout; |
|
912 turnSettings.iUDPTimeout = KDefaultUDPTimeout; |
|
913 turnSettings.iConnectivityCheckTimeout = KDefaultConnectivityCheckTimeout; |
|
914 turnSettings.iCRLFRefreshEnabled = EFalse; |
|
915 |
|
916 |
|
917 ReadServerSettingsL( |
|
918 aRepository, |
|
919 KUNSAFProtocolsTURNServerTableMask|aDomainKey, |
|
920 turnSettings, |
|
921 iTURNServerSettingsArray |
|
922 ); |
|
923 |
|
924 //TURNBandwidth |
|
925 if(Read(aRepository, |
|
926 KUNSAFProtocolsTURNBandwidthMask|aDomainKey, iTURNBandwidth)==EFalse) |
|
927 { |
|
928 iTURNBandwidth = KDefaultTURNBandwidth; |
|
929 } |
|
930 //RequestedTransport |
|
931 if(Read(aRepository, KUNSAFProtocolsRequestedTransportMask|aDomainKey, |
|
932 iRequestedTransport)==EFalse) |
|
933 { |
|
934 iRequestedTransport = KDefaultRequestedTransport; |
|
935 } |
|
936 //RequestedPortProps |
|
937 if(Read(aRepository, KUNSAFProtocolsRequestedPortPropsMask|aDomainKey, |
|
938 iRequestedPortProps)==EFalse) |
|
939 { |
|
940 iRequestedPortProps = KDefaultRequestedPortProps; |
|
941 } |
|
942 //TURNLifeTime |
|
943 if(Read(aRepository, |
|
944 KUNSAFProtocolsTURNLifeTimeMask|aDomainKey, iTURNLifeTime)==EFalse) |
|
945 { |
|
946 iTURNLifeTime = KDefaultTURNLifeTime; |
|
947 } |
|
948 //TURNRetryTime |
|
949 if (Read(aRepository, |
|
950 KUNSAFProtocolsTURNRetryTimeMask|aDomainKey, iTURNRetryTime)==EFalse) |
|
951 { |
|
952 iTURNRetryTime = KDefaultTURNRetryTime; |
|
953 } |
|
954 //TURNServerTimerVal |
|
955 if(Read(aRepository, KUNSAFProtocolsTURNServerTimerValMask|aDomainKey, |
|
956 iTURNServerTimerVal)==EFalse) |
|
957 { |
|
958 iTURNServerTimerVal = KDefaultTURNServerTimerVal; |
|
959 } |
|
960 //TransitioningStateTime |
|
961 if(Read(aRepository, KUNSAFProtocolsTransitioningStateTimeMask|aDomainKey, |
|
962 iTransitioningStateTime)==EFalse) |
|
963 { |
|
964 iTransitioningStateTime = KDefaultTransitioningStateTime; |
|
965 } |
|
966 //RequestedAddress |
|
967 if(ReadL(aRepository, |
|
968 KUNSAFProtocolsRequestedAdressMask|aDomainKey, &tempBufPointer)) |
|
969 { |
|
970 if(iRequestedAddress) delete iRequestedAddress; |
|
971 iRequestedAddress = tempBufPointer; |
|
972 } |
|
973 else{ delete tempBufPointer; } |
|
974 //RequestedPort |
|
975 if(Read(aRepository, |
|
976 KUNSAFProtocolsRequestedPortMask|aDomainKey, iRequestedPort)==EFalse) |
|
977 { |
|
978 iRequestedPort = 0; |
|
979 } |
|
980 //ActiveDestinationAddress |
|
981 if(ReadL(aRepository, |
|
982 KUNSAFProtocolsActiveDestinationAddressMask|aDomainKey, &tempBufPointer)) |
|
983 { |
|
984 if(iActiveDestinationAddress) delete iActiveDestinationAddress; |
|
985 iActiveDestinationAddress = tempBufPointer; |
|
986 } |
|
987 else{ delete tempBufPointer; } |
|
988 //ActiveDestinationPort |
|
989 if (Read(aRepository, |
|
990 KUNSAFProtocolsActiveDestinationPortMask|aDomainKey, |
|
991 iActiveDestinationPort)==EFalse) |
|
992 { |
|
993 iActiveDestinationPort = 0; |
|
994 } |
|
995 //RelayedAddress |
|
996 if(ReadL(aRepository, KUNSAFProtocolsRelayedAddressMask|aDomainKey, &tempBufPointer)) |
|
997 { |
|
998 if(iRelayedAddress) delete iRelayedAddress; |
|
999 iRelayedAddress = tempBufPointer; |
|
1000 } |
|
1001 else{ delete tempBufPointer; } |
|
1002 //RelayedPort |
|
1003 if(Read(aRepository, KUNSAFProtocolsRelayedPortMask|aDomainKey, iRelayedPort)==EFalse) |
|
1004 { |
|
1005 iRelayedPort = 0; |
|
1006 } |
|
1007 //ReflexiveAddress |
|
1008 if(ReadL(aRepository, KUNSAFProtocolsReflexiveAddressMask|aDomainKey, &tempBufPointer)) |
|
1009 { |
|
1010 if(iReflexiveAddress) delete iReflexiveAddress; |
|
1011 iReflexiveAddress = tempBufPointer; |
|
1012 } |
|
1013 else{ delete tempBufPointer; } |
|
1014 //ReflexivePort |
|
1015 if(Read(aRepository, KUNSAFProtocolsReflexivePorMask|aDomainKey, iReflexivePort)==EFalse) |
|
1016 { |
|
1017 iReflexivePort = 0; |
|
1018 } |
|
1019 //LatestConnectedTURNServerAddress |
|
1020 if(ReadL(aRepository, |
|
1021 KUNSAFProtocolsLatestConnectedTURNServerAddressMask|aDomainKey, |
|
1022 &tempBufPointer)) |
|
1023 { |
|
1024 if(iLatestConnectedTURNServerAddress) delete iLatestConnectedTURNServerAddress; |
|
1025 iLatestConnectedTURNServerAddress = tempBufPointer; |
|
1026 } |
|
1027 else{ delete tempBufPointer; } |
|
1028 //LatestConnectedTURNServerPort |
|
1029 if(Read(aRepository, KUNSAFProtocolsLatestConnectedTURNServerPortMask|aDomainKey, |
|
1030 iLatestConnectedTURNServerPort)==EFalse) |
|
1031 { |
|
1032 iLatestConnectedTURNServerPort = 0; |
|
1033 } |
|
1034 else |
|
1035 { |
|
1036 } |
|
1037 CleanupStack::PopAndDestroy(&addressKeys); |
|
1038 } |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // CNATFWNATSettings::ReadICESettingsL |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // |
|
1044 void CNATFWNATSettings::ReadICESettings( |
|
1045 CRepository& aRepository, |
|
1046 TUint32 aDomainKey) |
|
1047 { |
|
1048 // ICEMode setting |
|
1049 ReadBoolValue(aRepository,KUNSAFProtocolsICEFullModeUsedMask|aDomainKey, |
|
1050 iICEFullModeUsed); |
|
1051 // ChooseAnotherCandidateTimer |
|
1052 if(Read(aRepository, |
|
1053 KUNSAFProtocolsICECandidateTimerMask|aDomainKey, iICECanditateTimer)==EFalse) |
|
1054 { |
|
1055 iICECanditateTimer = KDefaultICECanditateTimer; |
|
1056 } |
|
1057 //UsedNATProtocol |
|
1058 if(Read(aRepository, |
|
1059 KUNSAFProtocolsUsedNATProtocolMask|aDomainKey, iUsedNATProtocol)==EFalse) |
|
1060 { |
|
1061 iUsedNATProtocol = KDefaultUsedNATProtocol; |
|
1062 } |
|
1063 } |
|
1064 |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // CNATFWNATSettings::ReadIapSettingsL |
|
1067 // ----------------------------------------------------------------------------- |
|
1068 // |
|
1069 TInt CNATFWNATSettings::ReadIapSettingsL( |
|
1070 CRepository& aRepository, |
|
1071 TUint32 aIapId) |
|
1072 { |
|
1073 RArray<TUint32> keys; |
|
1074 CleanupClosePushL(keys); |
|
1075 TInt err = aRepository.FindEqL(KUNSAFProtocolsIAPIdMask, |
|
1076 KUNSAFProtocolsFieldTypeMask, |
|
1077 static_cast<TInt>(aIapId), |
|
1078 keys); |
|
1079 |
|
1080 if (err == KErrNone) |
|
1081 { |
|
1082 if(keys.Count() > 1) |
|
1083 { |
|
1084 err = KErrCorrupt; |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 TUint32 key = (KUNSAFProtocolsIAPIdMask^(keys[0])); |
|
1089 key |= KUNSAFProtocolsIAPTableMask; |
|
1090 // read UDP refresh interval |
|
1091 Read(aRepository,KUNSAFProtocolsIntervalUDPMask|key, |
|
1092 iUDPRefreshInterval); |
|
1093 // read TCP refresh interval |
|
1094 Read(aRepository,KUNSAFProtocolsIntervalTCPMask|key, |
|
1095 iTCPRefreshInterval); |
|
1096 // read Retransmit interval |
|
1097 Read(aRepository,KUNSAFProtocolsSTUNRetransmitTimerMask|key, |
|
1098 iSTUNRetransmitTimer); |
|
1099 } |
|
1100 } |
|
1101 |
|
1102 CleanupStack::PopAndDestroy(&keys); |
|
1103 return err; |
|
1104 } |
|
1105 |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // CNATFWNATSettings::Read |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // |
|
1110 TBool CNATFWNATSettings::ReadL( |
|
1111 CRepository& aRepository, |
|
1112 const TUint32& aKey, |
|
1113 HBufC8** aBuf) |
|
1114 { |
|
1115 TBool found = EFalse; |
|
1116 TBuf8<1> tmp; |
|
1117 TInt actualLength = 0; |
|
1118 TInt status = aRepository.Get(aKey,tmp,actualLength); |
|
1119 |
|
1120 if ((status == KErrNone || status == KErrOverflow) && (actualLength > 0)) |
|
1121 { |
|
1122 found = ETrue; |
|
1123 HBufC8* buf = HBufC8::NewL(actualLength); |
|
1124 CleanupStack::PushL(buf); |
|
1125 TPtr8 ptr(buf->Des()); |
|
1126 User::LeaveIfError(aRepository.Get(aKey,ptr)); |
|
1127 *aBuf = buf; |
|
1128 CleanupStack::Pop(buf); |
|
1129 } |
|
1130 else |
|
1131 { |
|
1132 *aBuf = KNullDesC8().AllocL(); |
|
1133 } |
|
1134 return found; |
|
1135 } |
|
1136 |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // CNATFWNATSettings::ReadBoolValue |
|
1139 // ----------------------------------------------------------------------------- |
|
1140 // |
|
1141 TBool CNATFWNATSettings::ReadBoolValue( |
|
1142 CRepository& aRepository, |
|
1143 const TUint32& aKey, |
|
1144 TBool& aKeyValue) |
|
1145 { |
|
1146 TBool found = EFalse; |
|
1147 TInt tmp = 0; |
|
1148 if (aRepository.Get(aKey,tmp) == KErrNone) |
|
1149 { |
|
1150 aKeyValue = (tmp != 0); |
|
1151 found = ETrue; |
|
1152 } |
|
1153 return found; |
|
1154 } |
|
1155 |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // CNATFWNATSettings::Read |
|
1158 // ----------------------------------------------------------------------------- |
|
1159 // |
|
1160 TBool CNATFWNATSettings::Read( |
|
1161 CRepository& aRepository, |
|
1162 const TUint32& aKey, |
|
1163 TUint& aKeyValue) |
|
1164 { |
|
1165 TBool found = EFalse; |
|
1166 TInt tmp; |
|
1167 if (aRepository.Get(aKey,tmp) == KErrNone) |
|
1168 { |
|
1169 aKeyValue = static_cast<TUint>(tmp); |
|
1170 found = ETrue; |
|
1171 } |
|
1172 return found; |
|
1173 } |
|
1174 |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // CNATFWNATSettings::CreateNewKeyL |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // |
|
1179 TUint32 CNATFWNATSettings::CreateNewKeyL( |
|
1180 CRepository& aRepository, |
|
1181 const TUint32 aSettingKeyMask, |
|
1182 const TUint32 aField) const |
|
1183 { |
|
1184 TUint32 newKey = 0; |
|
1185 RArray<TUint32> keys; |
|
1186 CleanupClosePushL( keys ); |
|
1187 TInt err = aRepository.FindL( aSettingKeyMask, |
|
1188 aField, |
|
1189 keys ); |
|
1190 TInt keyCount = keys.Count(); |
|
1191 |
|
1192 if ( err == KErrNotFound ) |
|
1193 { |
|
1194 newKey = aField+1; |
|
1195 } |
|
1196 else |
|
1197 { |
|
1198 User::LeaveIfError( err ); |
|
1199 if ( keyCount == 0 ) |
|
1200 { |
|
1201 newKey = aField+1; |
|
1202 } |
|
1203 else |
|
1204 { |
|
1205 // Find the biggest key and increment it by one |
|
1206 keys.SortUnsigned(); |
|
1207 TUint32 maxKey = aSettingKeyMask^keys[ keyCount - 1 ]; |
|
1208 newKey = aField + 1 + maxKey; |
|
1209 } |
|
1210 } |
|
1211 newKey |= aField; |
|
1212 newKey ^= aField; |
|
1213 CleanupStack::PopAndDestroy( &keys ); |
|
1214 return newKey; |
|
1215 } |
|
1216 |
|
1217 // ----------------------------------------------------------------------------- |
|
1218 // CNATFWNATSettings::WriteL |
|
1219 // ----------------------------------------------------------------------------- |
|
1220 // |
|
1221 void CNATFWNATSettings::WriteL( |
|
1222 TUint32 aFieldMask, |
|
1223 TInt aValue) |
|
1224 { |
|
1225 User::LeaveIfError( |
|
1226 iCenRep->StartTransaction( |
|
1227 CRepository::EConcurrentReadWriteTransaction)); |
|
1228 iCenRep->CleanupCancelTransactionPushL(); |
|
1229 |
|
1230 TInt tmp = 0; |
|
1231 if (iCenRep->Get(aFieldMask,tmp) == KErrNone) |
|
1232 { |
|
1233 // Update existing value |
|
1234 User::LeaveIfError(iCenRep->Set(aFieldMask,aValue)); |
|
1235 } |
|
1236 else |
|
1237 { |
|
1238 // Create new value |
|
1239 User::LeaveIfError(iCenRep->Create(aFieldMask,aValue)); |
|
1240 } |
|
1241 TUint32 dummy; |
|
1242 User::LeaveIfError(iCenRep->CommitTransaction(dummy)); |
|
1243 CleanupStack::Pop(); // transaction |
|
1244 } |
|
1245 |
|
1246 // ----------------------------------------------------------------------------- |
|
1247 // CNATFWNATSettings::WriteL |
|
1248 // ----------------------------------------------------------------------------- |
|
1249 // |
|
1250 void CNATFWNATSettings::WriteL( |
|
1251 TUint32 aFieldMask, |
|
1252 const TDesC8& aValue) |
|
1253 { |
|
1254 if(aFieldMask == KUNSAFProtocolsDomainMask) |
|
1255 { |
|
1256 User::Leave(KErrArgument); |
|
1257 } |
|
1258 User::LeaveIfError( |
|
1259 iCenRep->StartTransaction( |
|
1260 CRepository::EConcurrentReadWriteTransaction)); |
|
1261 |
|
1262 iCenRep->CleanupCancelTransactionPushL(); |
|
1263 |
|
1264 TBuf8<1> tmp; |
|
1265 TInt err = iCenRep->Get(aFieldMask,tmp); |
|
1266 if ( err == KErrNone || err == KErrOverflow) |
|
1267 { |
|
1268 // Update existing value |
|
1269 User::LeaveIfError(iCenRep->Set(aFieldMask,aValue)); |
|
1270 } |
|
1271 else |
|
1272 { |
|
1273 // Create new value |
|
1274 User::LeaveIfError(iCenRep->Create(aFieldMask,aValue)); |
|
1275 } |
|
1276 TUint32 dummy; |
|
1277 User::LeaveIfError(iCenRep->CommitTransaction(dummy)); |
|
1278 CleanupStack::Pop(); // transaction |
|
1279 }*/ |
|
1280 |
|
1281 // ----------------------------------------------------------------------------- |
|
1282 // TNATPortField::TNATPortField |
|
1283 // ----------------------------------------------------------------------------- |
|
1284 // |
|
1285 /* |
|
1286 TNATPortField::TNATPortField() |
|
1287 { |
|
1288 iCRKeyMask = 0; |
|
1289 iLength = 0; |
|
1290 iStartPort = 0; |
|
1291 iEndPort = 0; |
|
1292 } |
|
1293 */ |
|
1294 //End of file |