|
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 #ifndef ICECANDIDATEHANDLERDEFS_H |
|
22 #define ICECANDIDATEHANDLERDEFS_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <in_sock.h> |
|
26 |
|
27 class CNATFWPluginApi; |
|
28 |
|
29 _LIT8( KNatPluginIdNokiaStun, "nokia.stun" ); |
|
30 _LIT8( KNatPluginIdNokiaTurn, "nokia.turn" ); |
|
31 _LIT8( KNatPluginIdNokiaIce, "nokia.ice" ); |
|
32 _LIT8( KNatPluginIdNokiaHost, "nokia.host" ); |
|
33 |
|
34 _LIT8( KNatPluginTypeStun, "stun" ); |
|
35 _LIT8( KNatPluginTypeTurn, "turn" ); |
|
36 _LIT8( KNatPluginTypeIce, "ice" ); |
|
37 _LIT8( KNatPluginTypeHost, "host" ); |
|
38 |
|
39 const TInt KErrRoleConflict = 487; |
|
40 |
|
41 template <class T> |
|
42 class CleanupResetAndDestroy |
|
43 { |
|
44 |
|
45 public: |
|
46 inline static void PushL( T& aRef ); |
|
47 |
|
48 private: |
|
49 static void ResetAndDestroy( TAny *aPtr ); |
|
50 }; |
|
51 |
|
52 template <class T> |
|
53 inline void CleanupResetAndDestroyPushL( T& aRef ); |
|
54 |
|
55 template <class T> |
|
56 inline void CleanupResetAndDestroy<T>::PushL( T& aRef ) |
|
57 { CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); } |
|
58 |
|
59 template <class T> |
|
60 void CleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr ) |
|
61 { |
|
62 if ( aPtr ) |
|
63 { |
|
64 static_cast<T*>( aPtr )->ResetAndDestroy(); |
|
65 } |
|
66 } |
|
67 |
|
68 template <class T> |
|
69 inline void CleanupResetAndDestroyPushL( T& aRef ) |
|
70 { CleanupResetAndDestroy<T>::PushL( aRef ); } |
|
71 |
|
72 class TCounter |
|
73 { |
|
74 public: |
|
75 |
|
76 TCounter( TUint aStreamId ) |
|
77 : |
|
78 iStreamId( aStreamId ), |
|
79 iCount( 0 ) { } |
|
80 |
|
81 TCounter( TUint aStreamId, TInt aCount ) |
|
82 : |
|
83 iStreamId( aStreamId ), |
|
84 iCount( aCount ) { } |
|
85 |
|
86 TUint StreamId() const { return iStreamId; } |
|
87 TUint Count() const { return iCount; } |
|
88 |
|
89 TBool operator==( TInt aCount ) const |
|
90 { return ( iCount == aCount ); } |
|
91 |
|
92 TBool operator!=( TInt aCount ) const |
|
93 { return ( iCount != aCount ); } |
|
94 |
|
95 TCounter operator++( TInt ) |
|
96 { TCounter temp = *this; ++iCount; return temp; } |
|
97 |
|
98 TCounter& operator++() |
|
99 { ++iCount; return *this; } |
|
100 |
|
101 TCounter operator--( TInt ) |
|
102 { TCounter temp = *this; --iCount; return temp; } |
|
103 |
|
104 TCounter& operator--() |
|
105 { --iCount; return *this; } |
|
106 |
|
107 static TBool MatchStreamId( |
|
108 const TCounter& aCnt1, |
|
109 const TCounter& aCnt2 ) |
|
110 { |
|
111 return ( aCnt1.StreamId() == aCnt2.StreamId() ); |
|
112 } |
|
113 |
|
114 private: |
|
115 |
|
116 TCounter(); |
|
117 TUint iStreamId; |
|
118 TInt iCount; |
|
119 }; |
|
120 |
|
121 class TIceUtils |
|
122 { |
|
123 public: |
|
124 static TBool MatchAddresses( |
|
125 const TInetAddr& aAddr1, const TInetAddr& aAddr2 ) |
|
126 { |
|
127 // CmpAddr does not interpret IPv4 and IPv4-mapped/compatible addresses |
|
128 // as same even if they represent same address. Thus extra testing is |
|
129 // needed to handle that case. |
|
130 TBool isMatch = |
|
131 ( aAddr1.CmpAddr( aAddr2 ) || ( aAddr1.Address() == aAddr2.Address() |
|
132 && aAddr1.Port() == aAddr2.Port() ) ); |
|
133 return isMatch; |
|
134 } |
|
135 }; |
|
136 |
|
137 |
|
138 #endif // ICECANDIDATEHANDLERDEFS_H |