|
1 /* |
|
2 * Copyright (c) 2006-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 "stunassert.h" |
|
22 #include "natfwstunrelaybinding.h" |
|
23 #include "cstunrelaybindingimplementation.h" |
|
24 #include "natfwstunclient.h" |
|
25 #include "cstunclientimplementation.h" |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CSTUNRelayBinding::NewL |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CSTUNRelayBinding* CSTUNRelayBinding::NewL( CSTUNClient& aSTUNClient, |
|
34 TUint aStreamId, |
|
35 TUint aConnectionId ) |
|
36 { |
|
37 __ASSERT_ALWAYS( aSTUNClient.IsInitialized(), User::Leave( KErrNotReady ) ); |
|
38 CSTUNRelayBinding* self = CSTUNRelayBinding::NewLC( aSTUNClient, |
|
39 aStreamId, |
|
40 aConnectionId ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CSTUNRelayBinding::NewLC |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CSTUNRelayBinding* CSTUNRelayBinding::NewLC( CSTUNClient& aSTUNClient, |
|
50 TUint aStreamId, |
|
51 TUint aConnectionId ) |
|
52 { |
|
53 CSTUNRelayBinding* self = new ( ELeave ) CSTUNRelayBinding(); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( aSTUNClient, aStreamId, aConnectionId ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CSTUNRelayBinding::CSTUNRelayBinding |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CSTUNRelayBinding::CSTUNRelayBinding() |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CSTUNRelayBinding::CSTUNRelayBinding |
|
69 // Dummy implementation, as copy constructor is declared private and not used. |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CSTUNRelayBinding::CSTUNRelayBinding( const CBinding& /*aBinding*/ ) |
|
73 { |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CSTUNRelayBinding::ConstructL - overloaded |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CSTUNRelayBinding::ConstructL( CSTUNClient& aSTUNClient, |
|
81 TUint aStreamId, |
|
82 TUint aConnectionId ) |
|
83 { |
|
84 __ASSERT_ALWAYS( aSTUNClient.Implementation().MultiplexerInstance(), |
|
85 User::Leave( KErrBadHandle ) ); |
|
86 iImplementation = |
|
87 CSTUNRelayBindingImplementation::NewL( *this, |
|
88 aSTUNClient.Implementation(), |
|
89 aStreamId, |
|
90 aConnectionId, |
|
91 aSTUNClient.Implementation().MultiplexerInstance() ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CSTUNRelayBinding::ConstructL - dummy implementation - not used |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CSTUNRelayBinding::ConstructL( CSTUNClient& /*aSTUNClient*/, |
|
99 RSocket& /*aSocket*/ ) |
|
100 { |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CSTUNRelayBinding::~CSTUNRelayBinding |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C CSTUNRelayBinding::~CSTUNRelayBinding() |
|
108 { |
|
109 delete iImplementation; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CSTUNRelayBinding::CancelRequest |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C void CSTUNRelayBinding::CancelRequest() |
|
117 { |
|
118 Implementation().CancelRequest(); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CSTUNRelayBinding::AllocateRequestL |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C void CSTUNRelayBinding::AllocateRequestL( TUint aRtoValue ) |
|
126 { |
|
127 Implementation().AllocateRequestL( aRtoValue ); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CSTUNRelayBinding::AddressResolved |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 EXPORT_C TBool CSTUNRelayBinding::AddressResolved() const |
|
135 { |
|
136 return Implementation().AddressResolved(); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CSTUNRelayBinding::PublicAddr |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C const TInetAddr& CSTUNRelayBinding::PublicAddr() const |
|
144 { |
|
145 return Implementation().PublicAddr(); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CSTUNRelayBinding::RelayAddr |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C const TInetAddr& CSTUNRelayBinding::RelayAddr() const |
|
153 { |
|
154 return Implementation().RelayAddr(); |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CSTUNRelayBinding::HandleDataL |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C HBufC8* CSTUNRelayBinding::HandleDataL( const TDesC8& aData, |
|
162 TBool& aConsumed, TInetAddr& aRemoteAddr ) |
|
163 { |
|
164 return Implementation().HandleDataL( aData, aConsumed, aRemoteAddr ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CSTUNRelayBinding::SetICESpecificAttributes |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C void CSTUNRelayBinding::SetICESpecificAttributes( |
|
172 const TICEAttributes& aAttributes ) |
|
173 { |
|
174 Implementation().SetICESpecificAttributes( aAttributes ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CSTUNRelayBinding::SetActiveDestinationRequestL |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C void CSTUNRelayBinding::SetActiveDestinationRequestL( |
|
182 const TInetAddr& aRemoteAddr, TUint32& aTimerValue ) |
|
183 { |
|
184 Implementation().SetActiveDestinationRequestL( aRemoteAddr, aTimerValue ); |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CSTUNRelayBinding::SendIndicationL |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C void CSTUNRelayBinding::SendIndicationL( |
|
192 const TInetAddr& aRemoteAddr, const TDesC8& aData, TBool aAddFingerprint ) |
|
193 { |
|
194 Implementation().SendIndicationL( aRemoteAddr, aData, aAddFingerprint ); |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CSTUNRelayBinding::ConnectRequestL |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C void CSTUNRelayBinding::ConnectRequestL( const TInetAddr& aRemoteAddr ) |
|
202 { |
|
203 Implementation().ConnectRequestL( aRemoteAddr ); |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CSTUNRelayBinding::StreamId |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C TUint CSTUNRelayBinding::StreamId() const |
|
211 { |
|
212 return Implementation().StreamId(); |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CSTUNRelayBinding::ConnectionId |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 EXPORT_C TUint CSTUNRelayBinding::ConnectionId() const |
|
220 { |
|
221 return Implementation().ConnectionId(); |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CSTUNRelayBinding::STUNClient |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C const CSTUNClient* CSTUNRelayBinding::STUNClient() const |
|
229 { |
|
230 return Implementation().STUNClient(); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CSTUNRelayBinding::AlternateServerAddr |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C const TInetAddr& CSTUNRelayBinding::AlternateServerAddr() const |
|
238 { |
|
239 return Implementation().AlternateServerAddr(); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CSTUNRelayBinding::RealmFromResponse |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 EXPORT_C const HBufC8* CSTUNRelayBinding::RealmFromResponse() const |
|
247 { |
|
248 return Implementation().RealmFromResponse(); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CSTUNRelayBinding::Implementation |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 CBindingImplementation& CSTUNRelayBinding::Implementation() |
|
256 { |
|
257 __TEST_INVARIANT; |
|
258 |
|
259 return *iImplementation; |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------------------------- |
|
263 // CSTUNRelayBinding::Implementation |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 const CBindingImplementation& CSTUNRelayBinding::Implementation() const |
|
267 { |
|
268 __TEST_INVARIANT; |
|
269 |
|
270 return *iImplementation; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CSTUNRelayBinding::__DbgTestInvariant |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void CSTUNRelayBinding::__DbgTestInvariant() const |
|
278 { |
|
279 #if defined(_DEBUG) |
|
280 if ( !iImplementation ) |
|
281 { |
|
282 User::Invariant(); |
|
283 } |
|
284 #endif |
|
285 } |