|
1 /* |
|
2 * Copyright (c) 2007 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 "natfwcandidate.h" |
|
22 #include "natfwcandidatepair.h" |
|
23 #include "mnatfwpluginobserver.h" |
|
24 #include "natfwcredentials.h" |
|
25 #include "cicecheckhandler.h" |
|
26 #include "cicesessiondata.h" |
|
27 #include "cicechecklist.h" |
|
28 #include "ciceconnectivitycheck.h" |
|
29 #include "natfwstunsrvclientsession.h" |
|
30 #include "icecandidatehandlerlogs.h" |
|
31 |
|
32 const TInt KMsToUsFactor = 1000; |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 CIceCheckHandler::CIceCheckHandler( |
|
37 CIceSessionData& aSessionData, |
|
38 MNcmConnectionMultiplexer& aMultiplexer, |
|
39 CIceConnectionHandler& aConnHandler, |
|
40 MIceNatPluginEventObs& aEventObserver ) |
|
41 : |
|
42 iSessionData( aSessionData ), |
|
43 iMultiplexer( aMultiplexer ), |
|
44 iConnHandler( aConnHandler ), |
|
45 iEventObserver( aEventObserver ) |
|
46 { |
|
47 } |
|
48 |
|
49 |
|
50 void CIceCheckHandler::ConstructL() |
|
51 { |
|
52 iStunSrv = CNATFWSTUNSrvClientSession::NewL( *this, iMultiplexer ); |
|
53 } |
|
54 |
|
55 |
|
56 CIceCheckHandler* CIceCheckHandler::NewL( |
|
57 CIceSessionData& aSessionData, |
|
58 MNcmConnectionMultiplexer& aMultiplexer, |
|
59 CIceConnectionHandler& aConnHandler, |
|
60 MIceNatPluginEventObs& aEventObserver ) |
|
61 { |
|
62 CIceCheckHandler* self |
|
63 = CIceCheckHandler::NewLC( |
|
64 aSessionData, aMultiplexer, aConnHandler, aEventObserver ); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 CIceCheckHandler* CIceCheckHandler::NewLC( |
|
71 CIceSessionData& aSessionData, |
|
72 MNcmConnectionMultiplexer& aMultiplexer, |
|
73 CIceConnectionHandler& aConnHandler, |
|
74 MIceNatPluginEventObs& aEventObserver ) |
|
75 { |
|
76 CIceCheckHandler* self |
|
77 = new( ELeave ) CIceCheckHandler( |
|
78 aSessionData, aMultiplexer, aConnHandler, aEventObserver ); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 CIceCheckHandler::~CIceCheckHandler() |
|
86 { |
|
87 iCheckLists.ResetAndDestroy(); |
|
88 delete iStunSrv; |
|
89 iCurCredentials.ResetAndDestroy(); |
|
90 iBufferedChecks.Close(); |
|
91 } |
|
92 |
|
93 |
|
94 // Non-derived function |
|
95 |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CIceCheckHandler::SetCredentialsL |
|
99 // Local credentials are needed for incoming request authentication and |
|
100 // must be set before starting connectivity checks. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CIceCheckHandler::SetCredentialsL( |
|
104 const CNATFWCredentials& aCredentials ) |
|
105 { |
|
106 if ( CNATFWCredentials::EInbound == aCredentials.Direction() ) |
|
107 { |
|
108 UpdateStunServerParamsL(); |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CIceCheckHandler::PerformConnectivityChecksL |
|
115 // Start perform connectivity checks. |
|
116 // Timer value depends on number of active check lists (initially one). |
|
117 // As an optimization ICE starts with one active check list and continue |
|
118 // with activation of other lists when certain results are got from first |
|
119 // check list. |
|
120 // Order of media streams is concluded from the order in which fetchcandidates |
|
121 // has been called. |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CIceCheckHandler::PerformConnectivityChecksL() |
|
125 { |
|
126 __ICEDP( "CIceCheckHandler::PerformConnectivityChecksL" ) |
|
127 __ASSERT_ALWAYS( iSessionData.Role(), User::Leave( KErrNotReady ) ); |
|
128 |
|
129 if ( !iState ) |
|
130 { |
|
131 FormChecklistsL(); |
|
132 UpdateStunServerParamsL(); |
|
133 |
|
134 // Activate first check list |
|
135 TTimeIntervalMicroSeconds32 interval |
|
136 = iSessionData.TaTimerValue() * KMsToUsFactor |
|
137 * ( NumOfActiveCheckLists() + 1 ); |
|
138 iCheckLists[0]->InitializeCheckListL(); |
|
139 iCheckLists[0]->StartPerformChecksL( interval ); |
|
140 |
|
141 SetState( EIceRunning ); |
|
142 ExecuteBufferedTriggeredChecksL(); |
|
143 } |
|
144 else |
|
145 { |
|
146 // Either new collection is added or ICE is restarted for some stream |
|
147 HandleNewCollectionsL(); |
|
148 HandleIceRestartsL(); |
|
149 UpdateStunServerParamsL(); |
|
150 |
|
151 SetState( EIceRunning ); |
|
152 } |
|
153 } |
|
154 |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CIceCheckHandler::UpdateIceProcessingL |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CIceCheckHandler::UpdateIceProcessingL( |
|
161 RPointerArray<CNATFWCandidatePair>& aPeerSelectedPairs ) |
|
162 { |
|
163 __ICEDP( "CIceCheckHandler::UpdateIceProcessingL, PEERSELECTEDCANDS" ) |
|
164 __ASSERT_DEBUG( 0 != aPeerSelectedPairs.Count(), |
|
165 User::Leave( KErrArgument ) ); |
|
166 |
|
167 RPointerArray<CIceCheckList> updatedLists; |
|
168 CleanupClosePushL( updatedLists ); |
|
169 |
|
170 // Find and update affected check lists |
|
171 TInt selectedPairCount( aPeerSelectedPairs.Count() ); |
|
172 for ( TInt i( 0 ); i < selectedPairCount; ++i ) |
|
173 { |
|
174 TUint streamCollId( |
|
175 aPeerSelectedPairs[i]->LocalCandidate().StreamCollectionId() ); |
|
176 CIceCheckList* checkList = ChecklistByCollectionIdL( streamCollId ); |
|
177 if ( KErrNotFound == updatedLists.Find( checkList ) |
|
178 && CIceCheckList::EIceCheckListRunning == checkList->State() ) |
|
179 { |
|
180 // Checklist ignores candidates for the other collections |
|
181 checkList->UpdateCheckListL( aPeerSelectedPairs ); |
|
182 updatedLists.AppendL( checkList ); |
|
183 } |
|
184 } |
|
185 |
|
186 CleanupStack::PopAndDestroy( &updatedLists ); |
|
187 } |
|
188 |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CIceCheckHandler::UpdateIceProcessingL |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CIceCheckHandler::UpdateIceProcessingL( |
|
195 RPointerArray<CNATFWCandidate>& aRemoteCands ) |
|
196 { |
|
197 __ICEDP( "CIceCheckHandler::UpdateIceProcessingL, REMOTECANDS" ) |
|
198 __ASSERT_DEBUG( 0 != aRemoteCands.Count(), User::Leave( KErrArgument ) ); |
|
199 |
|
200 RPointerArray<CIceCheckList> updatedLists; |
|
201 CleanupClosePushL( updatedLists ); |
|
202 |
|
203 // Find and update affected check lists |
|
204 TInt remoteCandsCount( aRemoteCands.Count() ); |
|
205 for ( TInt i( 0 ); i < remoteCandsCount; ++i ) |
|
206 { |
|
207 TUint streamCollId( aRemoteCands[i]->StreamCollectionId() ); |
|
208 CIceCheckList* checkList = ChecklistByCollectionIdL( streamCollId ); |
|
209 if ( KErrNotFound == updatedLists.Find( checkList ) |
|
210 && CIceCheckList::EIceCheckListRunning == checkList->State() ) |
|
211 { |
|
212 // Checklist ignores candidates for the other collections |
|
213 checkList->UpdateCheckListL( aRemoteCands ); |
|
214 updatedLists.AppendL( checkList ); |
|
215 } |
|
216 } |
|
217 |
|
218 CleanupStack::PopAndDestroy( &updatedLists ); |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CIceCheckHandler::CleanupCollectionData |
|
224 // Session data must be updated before coming here. |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CIceCheckHandler::CleanupCollectionData( TUint aCollectionId ) |
|
228 { |
|
229 __ICEDP( "CIceCheckHandler::CleanupCollectionData" ) |
|
230 |
|
231 if ( EIceRunning == iState || EIceCompleted == iState ) |
|
232 { |
|
233 CIceCheckList* checkList = ChecklistByCollectionId( aCollectionId ); |
|
234 if ( checkList ) |
|
235 { |
|
236 TInt ind( iCheckLists.Find( checkList ) ); |
|
237 delete iCheckLists[ind]; |
|
238 iCheckLists.Remove( ind ); |
|
239 } |
|
240 |
|
241 TRAP_IGNORE( UpdateStunServerParamsL() ) |
|
242 } |
|
243 } |
|
244 |
|
245 // Derived function |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // From class MNATFWStunSrvObserver. |
|
249 // Entity which first receives incoming message must set aPeerAddr either to |
|
250 // the same as aFromAddr or to REMOTE-ADDR from data indication. |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CIceCheckHandler::STUNRequestReceivedL( const TInetAddr& aLocalAddr, |
|
254 const TInetAddr& aFromAddr, const TInetAddr& aPeerAddr, |
|
255 TUint aPriority, TBool aRemoteFavored ) |
|
256 { |
|
257 if ( EIceRunning == iState || EIceCompleted == iState ) |
|
258 { |
|
259 __ICEDP_INT1( "CIceCheckHandler::STUNRequestReceivedL, FAVORED:", |
|
260 aRemoteFavored ) |
|
261 |
|
262 const CNATFWCandidate* hostCand |
|
263 = iSessionData.FindLocalCandidate( aLocalAddr ); |
|
264 __ASSERT_ALWAYS( NULL != hostCand, User::Leave( KErrNotFound ) ); |
|
265 |
|
266 CIceCheckList* checkList |
|
267 = ChecklistByCollectionIdL( hostCand->StreamCollectionId() ); |
|
268 |
|
269 checkList->STUNRequestReceivedL( |
|
270 aLocalAddr, aFromAddr, aPeerAddr, aPriority, aRemoteFavored ); |
|
271 } |
|
272 else |
|
273 { |
|
274 __ICEDP( "CIceCheckHandler::STUNRequestReceivedL, BUFFERING" ) |
|
275 |
|
276 // Must buffer triggered checks until remote credentials are known |
|
277 TIceTriggeredCheckInfo check( aLocalAddr, aFromAddr, aPeerAddr, |
|
278 aPriority, aRemoteFavored ); |
|
279 iBufferedChecks.AppendL( check ); |
|
280 } |
|
281 } |
|
282 |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // CIceCheckHandler::RoleChangeNeeded |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 void CIceCheckHandler::RoleChangeNeeded( TNATFWIceRole aDesiredRole ) |
|
289 { |
|
290 __ICEDP( "CIceCheckHandler::RoleChangeNeeded" ) |
|
291 |
|
292 TNATFWIceRole currentRole = iSessionData.Role(); |
|
293 if ( currentRole != aDesiredRole ) |
|
294 { |
|
295 iSessionData.SetRole( aDesiredRole ); |
|
296 |
|
297 // pair priorities must be recomputed (ICE-17, section 7.2.1.1.) |
|
298 TInt numOfCheckLists( iCheckLists.Count() ); |
|
299 for ( TInt i( 0 ); i < numOfCheckLists; ++i ) |
|
300 { |
|
301 iCheckLists[i]->RecomputePairPriorities(); |
|
302 } |
|
303 } |
|
304 else |
|
305 { |
|
306 __ICEDP( "CIceCheckHandler::RoleChangeNeeded, ALREADY CHANGED" ) |
|
307 } |
|
308 } |
|
309 |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // CIceCheckHandler::ChecklistCompletedL |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 void CIceCheckHandler::ChecklistCompletedL( |
|
316 const CIceCheckList& aCheckList, |
|
317 const RPointerArray<CNATFWCandidatePair>& aSelectedPairs ) |
|
318 { |
|
319 __ICEDP( "CIceCheckHandler::ChecklistCompletedL, SUCCESS" ) |
|
320 |
|
321 TInt numOfSelectedPairs( aSelectedPairs.Count() ); |
|
322 __ASSERT_DEBUG( numOfSelectedPairs, User::Leave( KErrArgument ) ); |
|
323 |
|
324 UpdateICEProcessingStateL( aCheckList ); |
|
325 for ( TInt i( 0 ); i < numOfSelectedPairs; ++i ) |
|
326 { |
|
327 TUint streamId( aSelectedPairs[i]->LocalCandidate().StreamId() ); |
|
328 iEventObserver.PluginEventOccured( NULL, streamId, |
|
329 MIceNatPluginEventObs::ECandidatePairFound, |
|
330 KErrNone, aSelectedPairs[i] ); |
|
331 |
|
332 iEventObserver.PluginEventOccured( NULL, streamId, |
|
333 MIceNatPluginEventObs::EConnChecksCompleted, |
|
334 KErrNone, NULL ); |
|
335 } |
|
336 } |
|
337 |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // CIceCheckHandler::ChecklistCompletedL |
|
341 // Check list has failed, post error events for the components. |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 void CIceCheckHandler::ChecklistCompletedL( |
|
345 const CIceCheckList& aCheckList, |
|
346 const RArray<TUint>& aFailedComps, |
|
347 TInt aErrCode ) |
|
348 { |
|
349 __ICEDP( "CIceCheckHandler::ChecklistCompletedL, FAIL" ) |
|
350 |
|
351 TInt numOfFailedComps( aFailedComps.Count() ); |
|
352 __ASSERT_DEBUG( numOfFailedComps, User::Leave( KErrArgument ) ); |
|
353 |
|
354 UpdateICEProcessingStateL( aCheckList ); |
|
355 for ( TInt i( 0 ); i < numOfFailedComps; ++i ) |
|
356 { |
|
357 iEventObserver.PluginEventOccured( NULL, aFailedComps[i], |
|
358 MIceNatPluginEventObs::EConnChecksCompleted, |
|
359 aErrCode, NULL ); |
|
360 } |
|
361 } |
|
362 |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CIceCheckHandler::UpdateICEProcessingStateL |
|
366 // Update ICE processing state. |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CIceCheckHandler::UpdateICEProcessingStateL( |
|
370 const CIceCheckList& aCheckList ) |
|
371 { |
|
372 __ICEDP( "CIceCheckHandler::UpdateICEProcessingStateL" ) |
|
373 |
|
374 TBool processingCompleted( ETrue ); |
|
375 TInt numOfCheckLists( iCheckLists.Count() ); |
|
376 |
|
377 for ( TInt i( 0 ); i < numOfCheckLists; ++i ) |
|
378 { |
|
379 if ( CIceCheckList::EIceCheckListCompleted != iCheckLists[i]->State() |
|
380 && CIceCheckList::EIceCheckListFailed != iCheckLists[i]->State() ) |
|
381 { |
|
382 processingCompleted = EFalse; |
|
383 } |
|
384 } |
|
385 |
|
386 if ( processingCompleted ) |
|
387 { |
|
388 SetState( EIceCompleted ); |
|
389 } |
|
390 else |
|
391 { |
|
392 // ICE-15, 7.1.2.3. Check List and Timer State Updates |
|
393 UnFreezeCheckListsL( aCheckList, KNullDesC8 ); |
|
394 } |
|
395 } |
|
396 |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // CIceCheckHandler::UnFreezeCheckListsL |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 void CIceCheckHandler::UnFreezeCheckListsL( |
|
403 const CIceCheckList& aExcludedList, const TDesC8& aFoundation ) |
|
404 { |
|
405 __ICEDP( "CIceCheckHandler::UnFreezeCheckListsL" ) |
|
406 |
|
407 TInt count( iCheckLists.Count() ); |
|
408 for ( TInt i( 0 ); i < count; ++i ) |
|
409 { |
|
410 // Do not update same checklist which reported event |
|
411 if ( iCheckLists[i] != &aExcludedList ) |
|
412 { |
|
413 aFoundation.Length() |
|
414 ? iCheckLists[i]->InitializeCheckListL( aFoundation ) |
|
415 : iCheckLists[i]->InitializeCheckListL(); |
|
416 |
|
417 iCheckLists[i]->StartPerformChecksL( |
|
418 TTimeIntervalMicroSeconds32( |
|
419 iSessionData.TaTimerValue() * KMsToUsFactor |
|
420 * ( NumOfActiveCheckLists() + 1 ) ) ); |
|
421 } |
|
422 } |
|
423 } |
|
424 |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CIceCheckHandler::ComponentsHaveValidPairsL |
|
428 // ICE 7.1.2, Change state of first check in other check lists |
|
429 // to waiting if it is in frozen state and foundation is the same. |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 void CIceCheckHandler::ComponentsHaveValidPairsL( |
|
433 const CIceCheckList& aCheckList, const TDesC8& aFoundation ) |
|
434 { |
|
435 __ICEDP( "CIceCheckHandler::ComponentsHaveValidPairsL" ) |
|
436 |
|
437 UnFreezeCheckListsL( aCheckList, aFoundation ); |
|
438 } |
|
439 |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 // CIceCheckHandler::FormChecklistsL |
|
443 // Checklists must be in the same order than media lines in SDP. This is |
|
444 // guaranteed if client has called fetchcandidates in correct order. |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 void CIceCheckHandler::FormChecklistsL() |
|
448 { |
|
449 __ICEDP( "CIceCheckHandler::FormChecklistsL" ) |
|
450 |
|
451 RArray<TUint> streamCollIds; |
|
452 CleanupClosePushL( streamCollIds ); |
|
453 iSessionData.GetStreamCollectionIdsL( streamCollIds ); |
|
454 __ASSERT_ALWAYS( streamCollIds.Count(), User::Leave( KErrNotReady ) ); |
|
455 |
|
456 TInt numOfChecklists( streamCollIds.Count() ); |
|
457 for ( TInt i = 0; i < numOfChecklists; ++i ) |
|
458 { |
|
459 CIceCheckList* checklist |
|
460 = CIceCheckList::NewLC( |
|
461 *this, streamCollIds[i], |
|
462 iSessionData, iConnHandler ); |
|
463 iCheckLists.AppendL( checklist ); |
|
464 CleanupStack::Pop( checklist ); |
|
465 } |
|
466 |
|
467 CleanupStack::PopAndDestroy( &streamCollIds ); |
|
468 } |
|
469 |
|
470 |
|
471 // --------------------------------------------------------------------------- |
|
472 // CIceCheckHandler::ChecklistByCollectionId |
|
473 // --------------------------------------------------------------------------- |
|
474 // |
|
475 CIceCheckList* CIceCheckHandler::ChecklistByCollectionId( |
|
476 TUint aStreamCollId ) |
|
477 { |
|
478 TInt count( iCheckLists.Count() ); |
|
479 for ( TInt i = 0; i < count; ++i ) |
|
480 { |
|
481 if ( iCheckLists[i]->StreamCollectionId() == aStreamCollId ) |
|
482 { |
|
483 return iCheckLists[i]; |
|
484 } |
|
485 } |
|
486 |
|
487 return NULL; |
|
488 } |
|
489 |
|
490 |
|
491 // --------------------------------------------------------------------------- |
|
492 // CIceCheckHandler::ChecklistByCollectionIdL |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 CIceCheckList* CIceCheckHandler::ChecklistByCollectionIdL( |
|
496 TUint aStreamCollId ) |
|
497 { |
|
498 CIceCheckList* checkList = ChecklistByCollectionId( aStreamCollId ); |
|
499 if ( !checkList ) |
|
500 { |
|
501 User::Leave( KErrNotFound ); |
|
502 } |
|
503 |
|
504 return checkList; |
|
505 } |
|
506 |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // CIceCheckHandler::SetState |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
|
512 void CIceCheckHandler::SetState( TIceProcessingState aState ) |
|
513 { |
|
514 __ICEDP( "CIceCheckHandler::SetState" ) |
|
515 |
|
516 iState = aState; |
|
517 } |
|
518 |
|
519 |
|
520 // --------------------------------------------------------------------------- |
|
521 // CIceCheckHandler::HandleNewCollectionsL |
|
522 // --------------------------------------------------------------------------- |
|
523 // |
|
524 void CIceCheckHandler::HandleNewCollectionsL() |
|
525 { |
|
526 __ICEDP( "CIceCheckHandler::HandleNewCollectionsL" ) |
|
527 |
|
528 RArray<TUint> streamCollIds; |
|
529 CleanupClosePushL( streamCollIds ); |
|
530 iSessionData.GetStreamCollectionIdsL( streamCollIds ); |
|
531 TInt numOfCollections( streamCollIds.Count() ); |
|
532 __ASSERT_ALWAYS( numOfCollections, User::Leave( KErrNotReady ) ); |
|
533 |
|
534 for ( TInt i( 0 ); i < numOfCollections; ++i ) |
|
535 { |
|
536 if ( NULL == ChecklistByCollectionId( streamCollIds[i] ) ) |
|
537 { |
|
538 CIceCheckList* checklist |
|
539 = CIceCheckList::NewLC( |
|
540 *this, streamCollIds[i], |
|
541 iSessionData, iConnHandler ); |
|
542 iCheckLists.AppendL( checklist ); |
|
543 CleanupStack::Pop( checklist ); |
|
544 |
|
545 TTimeIntervalMicroSeconds32 interval = |
|
546 iSessionData.TaTimerValue() * KMsToUsFactor |
|
547 * ( NumOfActiveCheckLists() + 1 ); |
|
548 checklist->InitializeCheckListL(); |
|
549 checklist->StartPerformChecksL( interval ); |
|
550 } |
|
551 } |
|
552 |
|
553 CleanupStack::PopAndDestroy( &streamCollIds ); |
|
554 } |
|
555 |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // CIceCheckHandler::HandleIceRestartsL |
|
559 // --------------------------------------------------------------------------- |
|
560 // |
|
561 void CIceCheckHandler::HandleIceRestartsL() |
|
562 { |
|
563 __ICEDP( "CIceCheckHandler::HandleIceRestartsL" ) |
|
564 |
|
565 TInt numOfCurCredentials( iCurCredentials.Count() ); |
|
566 __ASSERT_DEBUG( numOfCurCredentials, User::Leave( KErrNotReady ) ); |
|
567 |
|
568 RPointerArray<CIceCheckList> updatedLists; |
|
569 CleanupClosePushL( updatedLists ); |
|
570 |
|
571 for ( TInt i( 0 ); i < numOfCurCredentials; ++i ) |
|
572 { |
|
573 CNATFWCredentials* entry = iCurCredentials[i]; |
|
574 const CNATFWCredentials* storedId = iSessionData.Credentials( |
|
575 entry->StreamId(), entry->Direction() ); |
|
576 |
|
577 if ( storedId && ( *storedId != *entry ) ) |
|
578 { |
|
579 CIceCheckList* checkList = ChecklistByCollectionIdL( |
|
580 storedId->StreamCollectionId() ); |
|
581 |
|
582 if ( KErrNotFound == updatedLists.Find( checkList ) ) |
|
583 { |
|
584 TTimeIntervalMicroSeconds32 interval |
|
585 = iSessionData.TaTimerValue() * KMsToUsFactor |
|
586 * ( NumOfActiveCheckLists() + 1 ); |
|
587 |
|
588 checkList->RestartCheckListL( interval ); |
|
589 updatedLists.AppendL( checkList ); |
|
590 } |
|
591 } |
|
592 } |
|
593 |
|
594 CleanupStack::PopAndDestroy( &updatedLists ); |
|
595 } |
|
596 |
|
597 |
|
598 // --------------------------------------------------------------------------- |
|
599 // CIceCheckHandler::NumOfActiveCheckLists |
|
600 // --------------------------------------------------------------------------- |
|
601 // |
|
602 TInt CIceCheckHandler::NumOfActiveCheckLists() |
|
603 { |
|
604 TInt count( 0 ); |
|
605 TInt numOfChecklists( iCheckLists.Count() ); |
|
606 for ( TInt i( 0 ); i < numOfChecklists; ++i ) |
|
607 { |
|
608 if ( CIceCheckList::EIceCheckListRunning == iCheckLists[i]->State() ) |
|
609 { |
|
610 count++; |
|
611 } |
|
612 } |
|
613 |
|
614 return count; |
|
615 } |
|
616 |
|
617 |
|
618 // --------------------------------------------------------------------------- |
|
619 // CIceCheckHandler::UpdateStunServerParamsL |
|
620 // --------------------------------------------------------------------------- |
|
621 // |
|
622 void CIceCheckHandler::UpdateStunServerParamsL() |
|
623 { |
|
624 const RPointerArray<CNATFWCredentials>& credentials |
|
625 = iSessionData.Credentials(); |
|
626 TInt count( credentials.Count() ); |
|
627 __ICEDP_INT1( "CIceCheckHandler::UpdateStunServerParamsL, IDENT_COUNT:", |
|
628 count ) |
|
629 |
|
630 iStunSrv->RemoveAuthenticationParamsL( iCurCredentials ); |
|
631 iCurCredentials.ResetAndDestroy(); |
|
632 for ( TInt i( 0 ); i < count; ++i ) |
|
633 { |
|
634 CNATFWCredentials* credential |
|
635 = CNATFWCredentials::NewLC( *credentials[i] ); |
|
636 iCurCredentials.AppendL( credential ); |
|
637 CleanupStack::Pop( credential ); |
|
638 } |
|
639 |
|
640 iStunSrv->AddAuthenticationParamsL( iCurCredentials ); |
|
641 iStunSrv->SetRoleL( iSessionData.Role(), iSessionData.TieBreaker() ); |
|
642 } |
|
643 |
|
644 |
|
645 // --------------------------------------------------------------------------- |
|
646 // CIceCheckHandler::ExecuteBufferedTriggeredChecksL |
|
647 // --------------------------------------------------------------------------- |
|
648 // |
|
649 void CIceCheckHandler::ExecuteBufferedTriggeredChecksL() |
|
650 { |
|
651 TInt count( iBufferedChecks.Count() ); |
|
652 for ( TInt i( 0 ); i < count; ++i ) |
|
653 { |
|
654 TIceTriggeredCheckInfo& check( iBufferedChecks[i] ); |
|
655 STUNRequestReceivedL( check.LocalAddr(), check.FromAddr(), |
|
656 check.PeerAddr(), check.Priority(), check.IsRemoteFavored() ); |
|
657 } |
|
658 |
|
659 iBufferedChecks.Reset(); |
|
660 } |