|
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: IKE connection |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_IKECONNECTION_H |
|
20 #define C_IKECONNECTION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <in_sock.h> |
|
24 #include <commdbconnpref.h> |
|
25 #include <extendedconnpref.h> |
|
26 #include "connobserver.h" |
|
27 #include "datatransfer.h" |
|
28 #include "ikeconnectioninterface.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CConnObserver; |
|
32 class CDataTransfer; |
|
33 class CLocalAddressResolver; |
|
34 class MIkeDebug; |
|
35 class RSocketServ; |
|
36 |
|
37 /** |
|
38 * IKE socket connection class. |
|
39 * |
|
40 * This class provides functionality for managing VPN AP's real network |
|
41 * connection. This class implements IKE socket connection interface |
|
42 * (CIkeConnectionInterface). |
|
43 * |
|
44 * This class owns data transfer object, which implements data interface |
|
45 * (MIkeDataInterface). Possible fatal data transfer errors are handled |
|
46 * in this class. |
|
47 * |
|
48 * @lib ikesocket.lib |
|
49 */ |
|
50 NONSHARABLE_CLASS( CIkeConnection ) : public CIkeConnectionInterface, |
|
51 public MDataTransferCallback, |
|
52 public MConnObserverCallback |
|
53 { |
|
54 public: |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * @param aDebug Debug trace interface |
|
58 */ |
|
59 static CIkeConnection* NewL( MIkeDebug& aDebug ); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 ~CIkeConnection(); |
|
65 |
|
66 /** |
|
67 * Opens data interface. |
|
68 * |
|
69 * @param aIkeMajorVersion IKE major version |
|
70 * @param aIpVersion IP protocol version |
|
71 * @return Data interface |
|
72 */ |
|
73 MIkeDataInterface& OpenDataInterfaceL( const TIkeMajorVersion aIkeMajorVersion, |
|
74 const TIpVersion aIpVersion ); |
|
75 |
|
76 // from base class MIkeConnectionInterface |
|
77 |
|
78 void StartConnection( const TUint32 aIapId, |
|
79 const TUint32 aSnapId, |
|
80 TRequestStatus& aStatus, |
|
81 const TBool aForcedRoaming = EFalse ); |
|
82 void CancelStartConnection(); |
|
83 void StopConnection(); |
|
84 void ResolveFQDNAddress( const TDesC& aFQDN, |
|
85 TNameEntry& aNameEntry, |
|
86 TRequestStatus& aStatus ); |
|
87 void CancelResolveFQDNAddress(); |
|
88 void NotifyDisconnect( TRequestStatus& aStatus ); |
|
89 void CancelNotifyDisconnect(); |
|
90 TUint32 IapId() const; |
|
91 TUint32 NetId() const; |
|
92 TUint32 SnapId() const; |
|
93 TInt GetLocalAddress( const TIpVersion aIpVersion, |
|
94 TInetAddr& aLocalIp ); |
|
95 |
|
96 // from base class MDataTransferCallback |
|
97 |
|
98 /** |
|
99 * Notification about fatal data transfer error. |
|
100 * |
|
101 * @param aError Error value |
|
102 * @param aErrorType Error type |
|
103 */ |
|
104 void DataTransferError( const TInt aError, |
|
105 const TErrorType aErrorType ); |
|
106 |
|
107 // from base class MConnObserverCallback |
|
108 |
|
109 /** |
|
110 * Notification about link disconnection. |
|
111 * |
|
112 * @param aStatus Link disconnection status |
|
113 */ |
|
114 void LinkDisconnected( const TInt aStatus ); |
|
115 |
|
116 private: |
|
117 |
|
118 enum TConnectionState |
|
119 { |
|
120 EIdle, |
|
121 EConnecting, |
|
122 EResolvingFQDN, |
|
123 EConnected |
|
124 }; |
|
125 |
|
126 CIkeConnection( MIkeDebug& aDebug ); |
|
127 |
|
128 void ConstructL(); |
|
129 |
|
130 /** |
|
131 * Creates connection preferences for SNAP usage. |
|
132 * @param aSnapId SNAP id |
|
133 * @param aForcedRoaming Indicates whether forced roaming is enabled or |
|
134 * disabled for SNAP |
|
135 */ |
|
136 void CreateSnapPreferencesL( const TUint32 aSnapId, |
|
137 const TBool aForcedRoaming ); |
|
138 |
|
139 /** |
|
140 * Cleans connection preferences created for SNAP usage. |
|
141 */ |
|
142 void CleanSnapPreferences(); |
|
143 |
|
144 /** |
|
145 * Updates IAP id and NET id. |
|
146 */ |
|
147 void UpdateRealIapData(); |
|
148 |
|
149 /** |
|
150 * Handles completion of asynchronous request in EConnecting state. |
|
151 */ |
|
152 void DoStateAfterConnecting(); |
|
153 |
|
154 /** |
|
155 * Handles completion of asynchronous request in EResolvingFQDN state. |
|
156 */ |
|
157 void DoStateAfterResolvingFQDN(); |
|
158 |
|
159 /** |
|
160 * Implements cancellation of connection starting. |
|
161 */ |
|
162 void DoCancelStartConnection(); |
|
163 |
|
164 /** |
|
165 * Implements cancellation of FQDN address resolving. |
|
166 */ |
|
167 void DoCancelResolveFQDNAddress(); |
|
168 |
|
169 // from base class CActive |
|
170 |
|
171 /** |
|
172 * From CActive. |
|
173 * Handles an active object's request completion event. |
|
174 */ |
|
175 void RunL(); |
|
176 |
|
177 /** |
|
178 * From CActive. |
|
179 * Implements cancellation of an active request. |
|
180 */ |
|
181 void DoCancel(); |
|
182 |
|
183 private: // data |
|
184 |
|
185 /** |
|
186 * Connection state. |
|
187 * Own. |
|
188 */ |
|
189 TConnectionState iState; |
|
190 |
|
191 /** |
|
192 * Socket server. |
|
193 * Own. |
|
194 */ |
|
195 RSocketServ iSocketServer; |
|
196 |
|
197 /** |
|
198 * Network connection. |
|
199 * Own. |
|
200 */ |
|
201 RConnection iConnection; |
|
202 |
|
203 /** |
|
204 * Host resolver. |
|
205 * Own. |
|
206 */ |
|
207 RHostResolver iResolver; |
|
208 |
|
209 /** |
|
210 * IP version. |
|
211 * Own. |
|
212 */ |
|
213 TIpVersion iIpVersion; |
|
214 |
|
215 /** |
|
216 * IAP id. |
|
217 * Own. |
|
218 */ |
|
219 TUint32 iIapId; |
|
220 |
|
221 /** |
|
222 * NET id. |
|
223 * Own. |
|
224 */ |
|
225 TUint32 iNetId; |
|
226 |
|
227 /** |
|
228 * SNAP id. |
|
229 * Own. |
|
230 */ |
|
231 TUint32 iSnapId; |
|
232 |
|
233 /** |
|
234 * Connection preferences. |
|
235 * Own. |
|
236 */ |
|
237 TCommDbConnPref iPrefs; |
|
238 |
|
239 /** |
|
240 * Extended connection preferences. |
|
241 * Own. |
|
242 */ |
|
243 TExtendedConnPref iExtendedPrefs; |
|
244 |
|
245 /** |
|
246 * Connection preferences list. |
|
247 * Own. |
|
248 */ |
|
249 TConnPrefList iConnPrefList; |
|
250 |
|
251 /** |
|
252 * Pointer to client's request status. Used for starting connection and |
|
253 * resolving FQDN address. |
|
254 * Not own. |
|
255 */ |
|
256 TRequestStatus* iClientStatus; |
|
257 |
|
258 /** |
|
259 * Pointer to client's request status. Used for requesting disconnect |
|
260 * notification. |
|
261 * Not own. |
|
262 */ |
|
263 TRequestStatus* iClientStatusNotifyDisconnect; |
|
264 |
|
265 /** |
|
266 * Data transfer object. |
|
267 * Own. |
|
268 */ |
|
269 CDataTransfer* iDataTransfer; |
|
270 |
|
271 /** |
|
272 * Link status observer. |
|
273 * Own. |
|
274 */ |
|
275 CConnObserver* iLinkObserver; |
|
276 |
|
277 /** |
|
278 * Local address resolver. |
|
279 * Own. |
|
280 */ |
|
281 CLocalAddressResolver* iLocalAddressResolver; |
|
282 |
|
283 /** |
|
284 * Debug trace interface. |
|
285 * Not own. |
|
286 */ |
|
287 MIkeDebug& iDebug; |
|
288 |
|
289 }; |
|
290 |
|
291 #endif // C_IKECONNECTION_H |