|
1 /* |
|
2 * Copyright (c) 2005 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: Collection of utility functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef STUNUTILS_H |
|
22 #define STUNUTILS_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <in_sock.h> |
|
27 #include "natfwunsafattribute.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CNATFWUNSAFMessage; |
|
31 class CNATFWUNSAFUnknownAttributesAttribute; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Collection of general purpose utility functions, used by several parts of |
|
37 * the STUN client. |
|
38 * |
|
39 * @lib ?library |
|
40 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
41 */ |
|
42 class STUNUtils |
|
43 { |
|
44 public: // Enumerations |
|
45 |
|
46 enum TWaitPeriod |
|
47 { |
|
48 //Unit is milliseconds |
|
49 ERetryImmediately = 0, |
|
50 |
|
51 EWaitBeforeRetryDuration = 8000 |
|
52 }; |
|
53 |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Returns the address inside MAPPED-ADDRESS attribute, located in the |
|
58 * aResponse. |
|
59 * @pre aResponse.Validate() == ETrue |
|
60 * @param aResponse UNSAF Binding Response |
|
61 * @param aAddr OUT: if aResponse contained MAPPED-ADDRESS, the address |
|
62 * in the attribute is copied here |
|
63 * @return ETrue if aResponse contained MAPPED-ADDRESS, |
|
64 * EFalse otherwise |
|
65 */ |
|
66 static TBool GetMappedAddress( const CNATFWUNSAFMessage& aResponse, |
|
67 TInetAddr& aAddr ); |
|
68 |
|
69 /** |
|
70 * Gets the address inside XOR-MAPPED-ADDRESS attribute, located in the |
|
71 * aResponse. |
|
72 * @pre aResponse.Validate() == ETrue |
|
73 * @param aResponse UNSAF Binding Response |
|
74 * @param aAddr OUT: if aResponse contained XOR-MAPPED-ADDRESS, the |
|
75 * address in the attribute is copied here |
|
76 * @return ETrue if aResponse contained XOR-MAPPED-ADDRESS, |
|
77 * EFalse otherwise |
|
78 */ |
|
79 static TBool GetXorMappedAddressL( const CNATFWUNSAFMessage& aResponse, |
|
80 TInetAddr& aAddr ); |
|
81 |
|
82 /** |
|
83 * Gets the address inside RELAY-ADDRESS attribute, located in the |
|
84 * aResponse. |
|
85 * |
|
86 * @since s60 3.2 |
|
87 * @pre aResponse.Validate() == ETrue |
|
88 * @param aResponse UNSAF Binding Response |
|
89 * @param aAddr OUT: if aResponse contained RELAY-ADDRESS, the |
|
90 * address in the attribute is copied here |
|
91 * @return ETrue if aResponse contained RELAY-ADDRESS, |
|
92 * EFalse otherwise |
|
93 */ |
|
94 static TBool GetRelayAddressL( const CNATFWUNSAFMessage& aResponse, |
|
95 TInetAddr& aAddr ); |
|
96 |
|
97 /** |
|
98 * Gets the address inside TIMERVAL attribute, located in the |
|
99 * aResponse. |
|
100 * |
|
101 * @since s60 3.2 |
|
102 * @pre aResponse.Validate() == ETrue |
|
103 * @param aResponse UNSAF Binding Response |
|
104 * @param aTimerVal OUT: if aResponse contained TIMERVAL, the |
|
105 * address in the attribute is copied here |
|
106 * @return ETrue if aResponse contained TIMERVAL, |
|
107 * EFalse otherwise |
|
108 */ |
|
109 static TBool GetTimerValueL( const CNATFWUNSAFMessage& aResponse, |
|
110 TUint32& aTimerVal ); |
|
111 |
|
112 /** |
|
113 * Checks if the response code is a 5xx. |
|
114 * @param aResponseCode Response code |
|
115 * @return ETrue aResponseCode is 5xx, EFalse otherwise |
|
116 */ |
|
117 static TBool Is5xxResponse( TInt aResponseCode ); |
|
118 |
|
119 /** |
|
120 * Deletes the attributes listed in aUnknownAttr, from aMessage. |
|
121 * @param aMessage UNSAF message |
|
122 * @param aUnknownAttr UNKNOWN-ATTRIBUTES attribute, tells what |
|
123 * attributes are removed from aMessage. |
|
124 */ |
|
125 static void RemoveUnknownAttributes( CNATFWUNSAFMessage& aMessage, |
|
126 const CNATFWUNSAFUnknownAttributesAttribute& aUnknownAttr ); |
|
127 }; |
|
128 |
|
129 #endif // STUNUTILS_H |