|
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: Provides base class for binding services |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CBINDING_H |
|
22 #define CBINDING_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <es_sock.h> |
|
26 #include <in_sock.h> |
|
27 #include "natfwstunclientdefs.h" |
|
28 |
|
29 class CSTUNClient; |
|
30 class CBindingImplementation; |
|
31 |
|
32 /** |
|
33 * A base class for sending binding requests and |
|
34 * obtaining public IP address as seen by the STUN or TURN server. |
|
35 * Child class instances cannot be used directly |
|
36 * through base class pointer. |
|
37 * |
|
38 * @lib natfwstunclient.lib |
|
39 * @since s60 v3.2 |
|
40 */ |
|
41 class CBinding : public CBase |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Cancels a previously issued SendRequestL or AllocateRequestL. |
|
47 * |
|
48 * @since s60 v3.2 |
|
49 * @return void |
|
50 */ |
|
51 virtual void CancelRequest() = 0; |
|
52 |
|
53 /** |
|
54 * Send indication to remote address. Indications are not |
|
55 * retransmitted and responses are not expected. |
|
56 * |
|
57 * @since s60 v3.2 |
|
58 * @param aRemoteAddr Address to send to (remote agent) |
|
59 * @param aData Data to send to remote agent. Use KNullDesC8 |
|
60 * if there is no data available. |
|
61 * @param aAddFingerprint Add fingerprint attribute if true |
|
62 * @return void |
|
63 */ |
|
64 virtual void SendIndicationL( const TInetAddr& aRemoteAddr, |
|
65 const TDesC8& aData=KNullDesC8, TBool aAddFingerprint=EFalse ) = 0; |
|
66 |
|
67 /** |
|
68 * Checks whether the public address has a value set. |
|
69 * |
|
70 * @since s60 v3.2 |
|
71 * @return ETrue if the public address has been obtained, |
|
72 * otherwise EFalse. |
|
73 */ |
|
74 virtual TBool AddressResolved() const = 0; |
|
75 |
|
76 /** |
|
77 * Gets the public address for this binding as seen in public network. |
|
78 * If AddressResolved function returns EFalse, the return value of |
|
79 * this function is not defined. |
|
80 * |
|
81 * @since s60 v3.2 |
|
82 * @return server reflexive transport address |
|
83 */ |
|
84 virtual const TInetAddr& PublicAddr() const = 0; |
|
85 |
|
86 /** |
|
87 * This method should be called when receiving data |
|
88 * from the socket shared with this binding and |
|
89 * the data cannot be handled by client. |
|
90 * |
|
91 * @since s60 v3.2 |
|
92 * @param aData data received |
|
93 * @param aConsumed on return ETrue if the data was accepted, |
|
94 * otherwise EFalse. |
|
95 * @param aRemoteAddr remote address from remote address attribute |
|
96 * @return Decoded data if data is indication and not unsaf message, |
|
97 * otherwise NULL. Ownership is transferred. |
|
98 */ |
|
99 virtual HBufC8* HandleDataL( |
|
100 const TDesC8& aData, TBool& aConsumed, TInetAddr& aRemoteAddr ) = 0; |
|
101 |
|
102 /** |
|
103 * ICE specific attributes can be set for the request. |
|
104 * |
|
105 * @since s60 v3.2 |
|
106 * @param aAttributes Contains ICE specific attributes. |
|
107 * @return void |
|
108 */ |
|
109 virtual void SetICESpecificAttributes( |
|
110 const TICEAttributes& aAttributes ) = 0; |
|
111 |
|
112 /** |
|
113 * Query used stream ID |
|
114 * |
|
115 * @since s60 v3.2 |
|
116 * @return stream Id |
|
117 */ |
|
118 virtual TUint StreamId() const = 0; |
|
119 |
|
120 /** |
|
121 * Query used connection ID |
|
122 * |
|
123 * @since s60 v3.2 |
|
124 * @return connection Id |
|
125 */ |
|
126 virtual TUint ConnectionId() const = 0; |
|
127 |
|
128 /** |
|
129 * Returns alternate server transport address. |
|
130 * |
|
131 * @since s60 v3.2 |
|
132 * @return alternate server address |
|
133 */ |
|
134 virtual const TInetAddr& AlternateServerAddr() const = 0; |
|
135 |
|
136 /** |
|
137 * Returns realm value from error response. |
|
138 * |
|
139 * @since s60 v3.2 |
|
140 * @return realm from error response |
|
141 */ |
|
142 virtual const HBufC8* RealmFromResponse() const = 0; |
|
143 |
|
144 /** |
|
145 * Returns the associated CSTUNClient instance. |
|
146 * |
|
147 * @since s60 v3.2 |
|
148 * @return CSTUNClient, or NULL if the CSTUNClient has been deleted |
|
149 */ |
|
150 virtual const CSTUNClient* STUNClient() const = 0; |
|
151 |
|
152 /** |
|
153 * Returns the implementation instance. |
|
154 */ |
|
155 virtual CBindingImplementation& Implementation() = 0; |
|
156 |
|
157 /** |
|
158 * Returns a non-modifiable implementation instance. |
|
159 */ |
|
160 virtual const CBindingImplementation& Implementation() const = 0; |
|
161 |
|
162 |
|
163 protected: |
|
164 |
|
165 virtual void ConstructL( CSTUNClient& aSTUNClient, TUint aStreamId, |
|
166 TUint aConnectionId ) = 0; |
|
167 |
|
168 virtual void ConstructL( CSTUNClient& aSTUNClient, RSocket& aSocket ) = 0; |
|
169 |
|
170 protected: // Data |
|
171 |
|
172 /** |
|
173 * Pointer to binding implementation. |
|
174 * Own. |
|
175 */ |
|
176 CBindingImplementation* iImplementation; |
|
177 }; |
|
178 |
|
179 #endif // CBINDING_H |
|
180 |
|
181 // End of File |