|
1 /* |
|
2 * Copyright (c) 2008-2009 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: VPN connection specific structures |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_VPNCONNECTION_H |
|
20 #define C_VPNCONNECTION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <in_sock.h> |
|
24 #include "vpnmandefs.h" |
|
25 #include "disconnectionobserver.h" |
|
26 #include "eventmediatorapi.h" |
|
27 #include "ikepluginsessionhandler.h" |
|
28 #include "ikesocketdefs.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CIkeConnectionInterface; |
|
32 class CIkeData; |
|
33 class CIkePluginSessionInterface; |
|
34 class CKmdServer; |
|
35 class MIkeDebug; |
|
36 |
|
37 /** |
|
38 * VPN connection. |
|
39 * VPN connection class provides VPN connection specific functionality for |
|
40 * managing real network connection and connection with remote IKE host. |
|
41 * |
|
42 * @lib internal (kmdserver.exe) |
|
43 */ |
|
44 class CVpnConnection : public CBase, |
|
45 public MDisconnectionObserverCallback, |
|
46 public MIkePluginSessionHandlerCallback |
|
47 { |
|
48 public: |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 * @param aVpnIapId VPN IAP Id |
|
52 * @param aServer KMD server |
|
53 * @param aDebug Debug trace interface |
|
54 */ |
|
55 static CVpnConnection* NewLC( TUint32 aVpnIapId, |
|
56 CKmdServer& aServer, |
|
57 MIkeDebug& aDebug ); |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 ~CVpnConnection(); |
|
62 |
|
63 /** |
|
64 * Starts real network connection. |
|
65 * @param aStatus Completion status (returned) |
|
66 */ |
|
67 void StartRealConnection( TRequestStatus& aStatus ); |
|
68 |
|
69 /** |
|
70 * Cancels connection starting. |
|
71 */ |
|
72 void CancelStartRealConnection(); |
|
73 |
|
74 /** |
|
75 * Resolves an IP address from FQDN address. |
|
76 * @param aFqdn FQDN address |
|
77 * @param aNameEntry Result of name resolution (returned) |
|
78 * @param aStatus Completion status (returned) |
|
79 */ |
|
80 void ResolveAddress( const TDesC& aFqdn, |
|
81 TNameEntry& aNameEntry, |
|
82 TRequestStatus& aStatus ); |
|
83 |
|
84 /** |
|
85 * Cancels resolving. |
|
86 */ |
|
87 void CancelResolveAddress(); |
|
88 |
|
89 /** |
|
90 * Starts negotiation with a remote host. |
|
91 * @param aIkeData IKE policy data |
|
92 * @param aVpnInterfaceIndex |
|
93 * @param aIpVersion IP version |
|
94 * @param aInternalAddress Internal address (returned) |
|
95 * @param aStatus Completion status (returned) |
|
96 */ |
|
97 void NegotiateWithHost( CIkeData& aIkeData, |
|
98 TUint32 aVpnInterfaceIndex, |
|
99 IkeSocket::TIpVersion aIpVersion, |
|
100 TVPNAddress& aInternalAddress, |
|
101 TRequestStatus& aStatus ); |
|
102 |
|
103 /** |
|
104 * Cancels negotiation. |
|
105 */ |
|
106 void CancelNegotiateWithHost(); |
|
107 |
|
108 /** |
|
109 * Stops VPN connection. |
|
110 * @param aSilentClose Specified if a silent close in question (Delete |
|
111 * payloads not transmitted to remote host) |
|
112 * @param aStatus Completion status (returned) |
|
113 */ |
|
114 void StopVpnConnection( TBool aSilentClose, |
|
115 TRequestStatus& aStatus ); |
|
116 |
|
117 /** |
|
118 * Cancels VPN connection stopping. VPN connection is stopped silently. |
|
119 */ |
|
120 void CancelStopVpnConnection(); |
|
121 |
|
122 /** |
|
123 * Gets local IP address of real network interface. |
|
124 * |
|
125 * @param aIpVersion IP version of local IP address |
|
126 * @param aLocalIp Local IP address (returned) |
|
127 * @return Error status. KErrNotFound if address is not found. |
|
128 */ |
|
129 TInt GetLocalAddress( const IkeSocket::TIpVersion aIpVersion, |
|
130 TInetAddr& aLocalIp ); |
|
131 |
|
132 /** |
|
133 * Returns VPN IAP Id. |
|
134 * @return VPN IAP Id |
|
135 */ |
|
136 TInt VpnIapId() const; |
|
137 |
|
138 /** |
|
139 * Returns real IAP Id. |
|
140 * @return Real IAP Id |
|
141 */ |
|
142 TInt RealIapId() const; |
|
143 |
|
144 /** |
|
145 * Returns real NET Id. |
|
146 * @return Real NET Id |
|
147 */ |
|
148 TInt RealNetId() const; |
|
149 |
|
150 // from base class MDisconnectionObserverCallback |
|
151 |
|
152 /** |
|
153 * Notification about link disconnection. VPN connection is stopped silently. |
|
154 * @param aStatus Completion status |
|
155 */ |
|
156 void DisconnectIndication( TInt aStatus ); |
|
157 |
|
158 // from base class MIkePluginSessionHandlerCallback |
|
159 |
|
160 /** |
|
161 * From MIkePluginSessionHandlerCallback |
|
162 * Notification about completion of negotiate request. |
|
163 * @param aStatus Completion status |
|
164 * @param aInternalAddress Internal address. |
|
165 */ |
|
166 void NegotiationStarted( TInt aStatus, |
|
167 const TVPNAddress& aInternalAddress ); |
|
168 /** |
|
169 * From MIkePluginSessionHandlerCallback |
|
170 * Notification about completion of delete session request. Real |
|
171 * network connection is closed. |
|
172 * @param aStatus Completion status |
|
173 */ |
|
174 void IkePluginSessionClosed( TInt aStatus ); |
|
175 |
|
176 /** |
|
177 * From MIkePluginSessionHandlerCallback |
|
178 * Notification about IKE plugin session error. |
|
179 * @param aStatus Completion status |
|
180 */ |
|
181 void IkePluginSessionError( TInt aStatus ); |
|
182 |
|
183 |
|
184 private: |
|
185 CVpnConnection( TUint32 aVpnIapId, |
|
186 CKmdServer& aServer, |
|
187 MIkeDebug& aDebug ); |
|
188 void ConstructL(); |
|
189 |
|
190 /** |
|
191 * Cancels negotiation.. |
|
192 */ |
|
193 void DoCancelNegotiateWithHost(); |
|
194 |
|
195 /** |
|
196 * Stops VPN connection. |
|
197 */ |
|
198 void DoStopVpnConnection( TBool aSilentClose ); |
|
199 |
|
200 /** |
|
201 * Cancels VPN connection stopping. VPN connection is stopped silently. |
|
202 */ |
|
203 void DoCancelStopVpnConnection(); |
|
204 |
|
205 /** |
|
206 * Deletes IKE plugin session. |
|
207 * @param aSilentClose Specified if a silent close in question (Delete |
|
208 * payloads not transmitted to remote host) |
|
209 */ |
|
210 void DoDeleteSession( TBool aSilentClose ); |
|
211 |
|
212 /** |
|
213 * Cancels session deletion. |
|
214 */ |
|
215 void DoCancelDeleteSession(); |
|
216 |
|
217 /** |
|
218 * Stops real network connection. |
|
219 * @param aStatus Disconnect event status to be reported. |
|
220 */ |
|
221 void DoStopRealConnection( TInt aStatus ); |
|
222 |
|
223 /** |
|
224 * Reports disconnect event via Event Mediator API. |
|
225 * @param aStatus Completion status |
|
226 */ |
|
227 void DoReportDisconnectEvent( TInt aStatus ); |
|
228 |
|
229 private: // data |
|
230 |
|
231 /** |
|
232 * KMD server. |
|
233 * Not own. |
|
234 */ |
|
235 CKmdServer& iServer; |
|
236 |
|
237 /** |
|
238 * IKE version. |
|
239 * Own. |
|
240 */ |
|
241 TInt iIkeVersion; |
|
242 |
|
243 /** |
|
244 * VPN IAP id. |
|
245 * Own. |
|
246 */ |
|
247 TUint32 iVpnIapId; |
|
248 |
|
249 /** |
|
250 * VPN NET id. |
|
251 * Own. |
|
252 */ |
|
253 TUint32 iVpnNetId; |
|
254 |
|
255 /** |
|
256 * Real IAP id. |
|
257 * Own. |
|
258 */ |
|
259 TInt iRealIapId; |
|
260 |
|
261 /** |
|
262 * Real NET id. |
|
263 * Own. |
|
264 */ |
|
265 TInt iRealSnapId; |
|
266 |
|
267 /** |
|
268 * Informs if disconnect event has been received. |
|
269 * Own. |
|
270 */ |
|
271 TInt iDisconnectEventReceived; |
|
272 |
|
273 /** |
|
274 * Disconnection status. |
|
275 * Own. |
|
276 */ |
|
277 TInt iDisconnectionStatus; |
|
278 |
|
279 /** |
|
280 * IKE connection interface. |
|
281 * Own. |
|
282 */ |
|
283 CIkeConnectionInterface* iIkeConnection; |
|
284 |
|
285 /** |
|
286 * Disconnection observer. |
|
287 * Own. |
|
288 */ |
|
289 CDisconnectionObserver* iDisconnectionObserver; |
|
290 |
|
291 /** |
|
292 * IKE plugin session handler. |
|
293 * Not own. |
|
294 */ |
|
295 CIkePluginSessionHandler* iIkePluginSessionHandler; |
|
296 |
|
297 /** |
|
298 * Event mediator. |
|
299 * Own. |
|
300 */ |
|
301 REventMediator iEventMediator; |
|
302 |
|
303 /** |
|
304 * Client's request status for starting of negotiation. |
|
305 * Not own. |
|
306 */ |
|
307 TRequestStatus* iClientStatusNegotiate; |
|
308 |
|
309 /** |
|
310 * Client's internal address. |
|
311 * Not own. |
|
312 */ |
|
313 TVPNAddress* iClientInternalAddress; |
|
314 |
|
315 /** |
|
316 * Client's request status for VPN connection's stopping. |
|
317 * Not own. |
|
318 */ |
|
319 TRequestStatus* iClientStatusStopVpnConnection; |
|
320 |
|
321 /** |
|
322 * Debug trace interface. |
|
323 * Not own. |
|
324 */ |
|
325 MIkeDebug& iDebug; |
|
326 }; |
|
327 |
|
328 #endif // C_VPNCONNECTION_H |