|
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: Candidate |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CNATFWCANDIDATE_H |
|
22 #define CNATFWCANDIDATE_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <in_sock.h> |
|
26 #include "natfwconnectivityapidefs.h" |
|
27 |
|
28 /** |
|
29 * Represents candidate transport address (local/remote) for media receival. |
|
30 * |
|
31 * @lib natconfw.lib |
|
32 * @since S60 v3.2 |
|
33 */ |
|
34 class CNATFWCandidate : public CBase |
|
35 { |
|
36 |
|
37 public: |
|
38 |
|
39 /** Candidate type based on interface from which candidate is obtained. */ |
|
40 enum TCandidateType { |
|
41 /** Candidate representing private address from local interface. */ |
|
42 EHost = 1, |
|
43 |
|
44 /** Candidate representing public address allocated by a NAT as seen |
|
45 by used STUN-server. */ |
|
46 EServerReflexive = 2, |
|
47 |
|
48 /** Candidate representing public address allocated by a NAT as seen |
|
49 by the peer. */ |
|
50 EPeerReflexive = 3, |
|
51 |
|
52 /** Candidate representing public address allocated from STUN-relay |
|
53 server. */ |
|
54 ERelay = 4 |
|
55 }; |
|
56 |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 */ |
|
60 IMPORT_C static CNATFWCandidate* NewL(); |
|
61 |
|
62 /** |
|
63 * Two-phased constructor. |
|
64 */ |
|
65 IMPORT_C static CNATFWCandidate* NewLC(); |
|
66 |
|
67 /** |
|
68 * Two-phased copy constructor. |
|
69 * @param aCandidate The candidate to copy |
|
70 */ |
|
71 IMPORT_C static CNATFWCandidate* NewL( |
|
72 const CNATFWCandidate& aCandidate ); |
|
73 |
|
74 /** |
|
75 * Two-phased copy constructor. |
|
76 * @param aCandidate The candidate to copy |
|
77 */ |
|
78 IMPORT_C static CNATFWCandidate* NewLC( |
|
79 const CNATFWCandidate& aCandidate ); |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 virtual ~CNATFWCandidate(); |
|
85 |
|
86 /** |
|
87 * Returns identifier for the session where candidate belongs to. |
|
88 * |
|
89 * @since S60 v3.2 |
|
90 * @return The session identifier |
|
91 */ |
|
92 IMPORT_C TUint SessionId() const; |
|
93 |
|
94 /** |
|
95 * Sets identifier of the session where candidate belongs to. |
|
96 * |
|
97 * @since S60 v3.2 |
|
98 * @param aId The session identifier |
|
99 */ |
|
100 IMPORT_C void SetSessionId( TUint aId ); |
|
101 |
|
102 /** |
|
103 * Returns candidate stream collection identifier. |
|
104 * |
|
105 * @since S60 v3.2 |
|
106 * @return Stream collection identifier |
|
107 */ |
|
108 IMPORT_C TUint StreamCollectionId() const; |
|
109 |
|
110 /** |
|
111 * Sets candidate stream collection identifier. |
|
112 * |
|
113 * @since S60 v3.2 |
|
114 * @param aId The stream collection identifier |
|
115 */ |
|
116 IMPORT_C void SetStreamCollectionId( TUint aId ); |
|
117 |
|
118 /** |
|
119 * Returns candidate stream identifier. |
|
120 * |
|
121 * @since S60 v3.2 |
|
122 * @return Stream identifier |
|
123 */ |
|
124 IMPORT_C TUint StreamId() const; |
|
125 |
|
126 /** |
|
127 * Sets candidate stream identifier. |
|
128 * |
|
129 * @since S60 v3.2 |
|
130 * @param aId Stream identifier |
|
131 */ |
|
132 IMPORT_C void SetStreamId( TUint aId ); |
|
133 |
|
134 /** |
|
135 * Returns candidate priority. |
|
136 * |
|
137 * @since S60 v3.2 |
|
138 * @return Candidate priority |
|
139 */ |
|
140 IMPORT_C TUint Priority() const; |
|
141 |
|
142 /** |
|
143 * Sets candidate prioritity. |
|
144 * |
|
145 * @since S60 v3.2 |
|
146 * @param aPriority Candidate priority |
|
147 */ |
|
148 IMPORT_C void SetPriority( TUint aPriority ); |
|
149 |
|
150 /** |
|
151 * Returns candidate transport address. If address is not set or it is |
|
152 * available only in FQDN format, address of family KAFUnspec is returned. |
|
153 * |
|
154 * Addresses in FQDN format can be accessed using TransportDomainAddr() |
|
155 * and TransportDomainPort(). |
|
156 * |
|
157 * @since S60 v3.2 |
|
158 * @return Transport address |
|
159 */ |
|
160 IMPORT_C const TInetAddr& TransportAddr() const; |
|
161 |
|
162 /** |
|
163 * Sets candidate transport address. If the domain address is not set, it |
|
164 * will be updated as well. |
|
165 * |
|
166 * @since S60 v3.2 |
|
167 * @param aAddr The transport address |
|
168 */ |
|
169 IMPORT_C void SetTransportAddrL( const TInetAddr& aAddr ); |
|
170 |
|
171 /** |
|
172 * Gets transport address in FQDN format. If address is not set or it is |
|
173 * available only as an IP-address, an empty descriptor is returned. |
|
174 * |
|
175 * IP addresses can be accessed using TransportAddr(). |
|
176 * |
|
177 * @since S60 v3.2 |
|
178 * @return Transport address in FQDN format |
|
179 */ |
|
180 IMPORT_C const TDesC8& TransportDomainAddr() const; |
|
181 |
|
182 /** |
|
183 * Gets transport address port that is associated with the FQDN |
|
184 * |
|
185 * Port associated with an IP-address can be accessed using |
|
186 * TransportAddr(). |
|
187 * |
|
188 * @since S60 v3.2 |
|
189 * @return Port associated with the FQDN |
|
190 */ |
|
191 IMPORT_C TUint TransportDomainPort() const; |
|
192 |
|
193 /** |
|
194 * Sets candidate transport domain address either in FQDN or IP address |
|
195 * format. If the address provided represents a valid IP address, the |
|
196 * candidate's transport IP address is updated as well. |
|
197 * |
|
198 * @since S60 v3.2 |
|
199 * @param aAddr The transport address |
|
200 * @param aPort The transport address port |
|
201 */ |
|
202 IMPORT_C void SetTransportDomainAddrL( const TDesC8& aAddr, TUint aPort ); |
|
203 |
|
204 /** |
|
205 * Returns candidate transportprotocol. |
|
206 * |
|
207 * @since S60 v3.2 |
|
208 * @return Candidate transportprotocol |
|
209 */ |
|
210 IMPORT_C TUint TransportProtocol() const; |
|
211 |
|
212 /** |
|
213 * Sets candidate transport protocol. |
|
214 * |
|
215 * @since S60 v3.2 |
|
216 * @param aTransportProtocol The transport protocol |
|
217 */ |
|
218 IMPORT_C void SetTransportProtocol( |
|
219 TUint aTransportProtocol ); |
|
220 |
|
221 /** |
|
222 * Returns base transport address of the candidate. |
|
223 * |
|
224 * @since S60 v3.2 |
|
225 * @return Base of the candidate |
|
226 */ |
|
227 IMPORT_C const TInetAddr& Base() const; |
|
228 |
|
229 /** |
|
230 * Sets base transport address of the candidate. |
|
231 * |
|
232 * @since S60 v3.2 |
|
233 * @param aBase The base |
|
234 */ |
|
235 IMPORT_C void SetBase( const TInetAddr& aBase ); |
|
236 |
|
237 /** |
|
238 * Returns candidate foundation. |
|
239 * |
|
240 * @since S60 v3.2 |
|
241 * @return Foundation of the candidate |
|
242 */ |
|
243 IMPORT_C const TDesC8& Foundation() const; |
|
244 |
|
245 /** |
|
246 * Sets candidate foundation. |
|
247 * |
|
248 * @since S60 v3.2 |
|
249 * @param aFoundation The foundation |
|
250 */ |
|
251 IMPORT_C void SetFoundationL( const TDesC8& aFoundation ); |
|
252 |
|
253 /** |
|
254 * Returns type of the candidate. |
|
255 * |
|
256 * @since S60 v3.2 |
|
257 * @return The type of the candidate |
|
258 */ |
|
259 IMPORT_C CNATFWCandidate::TCandidateType Type() const; |
|
260 |
|
261 /** |
|
262 * Sets type of the candidate. |
|
263 * |
|
264 * @since S60 v3.2 |
|
265 * @param aType The candidate type |
|
266 */ |
|
267 IMPORT_C void SetType( CNATFWCandidate::TCandidateType aType ); |
|
268 |
|
269 /** |
|
270 * Returns component identifier associated with the candidate. |
|
271 * |
|
272 * @since S60 v3.2 |
|
273 * @return Component identifier |
|
274 */ |
|
275 IMPORT_C TUint ComponentId() const; |
|
276 |
|
277 /** |
|
278 * Sets component identifier for the candidate. |
|
279 * |
|
280 * @since S60 v3.2 |
|
281 * @param aComponentId The component identifier |
|
282 */ |
|
283 IMPORT_C void SetComponentId( TUint aComponentId ); |
|
284 |
|
285 /** |
|
286 * Compares foundations between candidates. |
|
287 * |
|
288 * @since S60 v3.2 |
|
289 * @param aSource Source candidate for comparison |
|
290 * @param aTarget Target candidate for comparison |
|
291 * @return ETrue if canditates are same |
|
292 */ |
|
293 IMPORT_C static TBool CompareFoundations( const CNATFWCandidate& aSource, |
|
294 const CNATFWCandidate& aTarget ); |
|
295 |
|
296 /** |
|
297 * Implements TLinearOrder using priority value in comparison. |
|
298 * |
|
299 * @since S60 v3.2 |
|
300 * @param aC1 Candidate one |
|
301 * @param aC2 Candidate two |
|
302 * @return aC1.Priority - aC2.Priority |
|
303 */ |
|
304 IMPORT_C static TInt PriorityOrder( const CNATFWCandidate& aC1, |
|
305 const CNATFWCandidate& aC2 ); |
|
306 |
|
307 /** |
|
308 * Makes a copy of given candidate. |
|
309 * |
|
310 * @since S60 v3.2 |
|
311 * @param aCandidate The candidate to copy |
|
312 */ |
|
313 IMPORT_C void CopyL( const CNATFWCandidate& aCandidate ); |
|
314 |
|
315 IMPORT_C TBool operator==(const CNATFWCandidate& aCandidate) const; |
|
316 |
|
317 IMPORT_C TBool operator!=(const CNATFWCandidate& aCandidate) const; |
|
318 |
|
319 private: |
|
320 |
|
321 CNATFWCandidate(); |
|
322 void ConstructL(); |
|
323 void ConstructL( const CNATFWCandidate& aCa ); |
|
324 |
|
325 private: // data |
|
326 |
|
327 /** |
|
328 * Session identifier |
|
329 */ |
|
330 TUint iSessionId; |
|
331 |
|
332 /** |
|
333 * Stream identifier |
|
334 */ |
|
335 TUint iStreamId; |
|
336 |
|
337 /** |
|
338 * Stream collection identifier |
|
339 */ |
|
340 TUint iStreamCollectionId; |
|
341 |
|
342 /** |
|
343 * Component identifier |
|
344 */ |
|
345 TUint iComponentId; |
|
346 |
|
347 /** |
|
348 * Type of the candidate |
|
349 */ |
|
350 TCandidateType iType; |
|
351 |
|
352 /** |
|
353 * Candidate priority |
|
354 */ |
|
355 TUint iPriority; |
|
356 |
|
357 /** |
|
358 * Candidate transport address |
|
359 */ |
|
360 TInetAddr iTransportAddr; |
|
361 |
|
362 /** |
|
363 * Candidate transport domain address |
|
364 */ |
|
365 RBuf8 iTransportDomainAddr; |
|
366 |
|
367 /** |
|
368 * Candidate transport domain port |
|
369 */ |
|
370 TUint iTransportDomainPort; |
|
371 |
|
372 /** |
|
373 * Transport protocol |
|
374 */ |
|
375 TUint iTransportProtocol; |
|
376 |
|
377 /** |
|
378 * Foundation of the candidate |
|
379 */ |
|
380 RBuf8 iFoundation; |
|
381 |
|
382 /** |
|
383 * Base of the candidate |
|
384 */ |
|
385 TInetAddr iBase; |
|
386 }; |
|
387 |
|
388 #endif // CNATFWCANDIDATE_H |