|
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: Handler of an IKE protocol plugin session |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_IKEPLUGINSESSIONHANDLER_H |
|
20 #define C_IKEPLUGINSESSIONHANDLER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "vpnmandefs.h" |
|
24 #include "ikesocketdefs.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CErrorObserver; |
|
28 class CIaChangeObserver; |
|
29 class CIkeData; |
|
30 class CIkeConnectionInterface; |
|
31 class CIkePluginSessionCloser; |
|
32 class CInternalAddress; |
|
33 class MIkeDataInterface; |
|
34 class MIkeDebug; |
|
35 class MIkePluginIf; |
|
36 class MIkePluginSessionIf; |
|
37 class TInetAddr; |
|
38 |
|
39 /** |
|
40 * IKE plugin session handler callback interface. |
|
41 * Callback interface which is used by CIkePluginSessionHandler object to |
|
42 * notify about completion of negotiate and delete session requests. |
|
43 * |
|
44 * @lib internal (kmdserver.exe) |
|
45 */ |
|
46 class MIkePluginSessionHandlerCallback |
|
47 { |
|
48 public: |
|
49 /** |
|
50 * Notifies about completion of negotiate request. |
|
51 * @param aStatus Completion status |
|
52 * @param aInternalAddress Internal address |
|
53 */ |
|
54 virtual void NegotiationStarted( TInt aStatus, |
|
55 const TVPNAddress& aInternalAddress ) = 0; |
|
56 /** |
|
57 * Notifies about completion of delete session request. |
|
58 * @param aStatus Completion status |
|
59 */ |
|
60 virtual void IkePluginSessionClosed( TInt aStatus ) = 0; |
|
61 |
|
62 /** |
|
63 * Notifies about IKE plugin session error. |
|
64 * @param aStatus Completion status |
|
65 */ |
|
66 virtual void IkePluginSessionError( TInt aStatus ) = 0; |
|
67 }; |
|
68 |
|
69 /** |
|
70 * IKE plugin session handler. |
|
71 * Provides functionality for handling IKE plugin session. |
|
72 * |
|
73 * @lib internal (kmdserver.exe) |
|
74 */ |
|
75 class CIkePluginSessionHandler : public CActive |
|
76 { |
|
77 public: |
|
78 /** |
|
79 * Two-phased constructor. |
|
80 * @param aVpnIapId VPN IAP id |
|
81 * @param aVpnNetId VPN NET id |
|
82 * @param aVpnInterfaceIndex VPN interface index |
|
83 * @param aIkeVersion IKE version |
|
84 * @param aIpVersion IP version |
|
85 * @param aDnsServerAddr DNS server address from IKE policy |
|
86 * @param aConnection IKE connection interface |
|
87 * @param aIkePlugin IKE plugin |
|
88 * @param aCallback Callback interface |
|
89 * @param aDebug Debug trace interface |
|
90 */ |
|
91 static CIkePluginSessionHandler* NewLC( TUint32 aVpnIapId, |
|
92 TUint32 aVpnNetId, |
|
93 TUint32 aVpnInterfaceIndex, |
|
94 IkeSocket::TIkeMajorVersion aIkeVersion, |
|
95 IkeSocket::TIpVersion aIpVersion, |
|
96 const TInetAddr& aDnsServerAddr, |
|
97 CIkeConnectionInterface& aConnection, |
|
98 MIkePluginIf& aIkePlugin, |
|
99 MIkePluginSessionHandlerCallback& aCallback, |
|
100 MIkeDebug& aDebug ); |
|
101 /** |
|
102 * Destructor. IKE plugin session object is deleted. |
|
103 */ |
|
104 ~CIkePluginSessionHandler(); |
|
105 |
|
106 /** |
|
107 * Starts negotiation with a remote host. |
|
108 * @param aIkeData IKE policy data |
|
109 */ |
|
110 void NegotiateWithHost( const CIkeData& aIkeData ); |
|
111 |
|
112 /** |
|
113 * Cancels negotiation request. |
|
114 */ |
|
115 void CancelNegotiateWithHost(); |
|
116 |
|
117 /** |
|
118 * Deletes session. Silent close can be requested when normal close is |
|
119 * already active. IKE plugin session object is not deleted. |
|
120 * @param aSilentClose Specified if a silent close in question (Delete |
|
121 * payloads not transmitted to remote host) |
|
122 */ |
|
123 void DeleteSession( TBool aSilentClose ); |
|
124 |
|
125 /** |
|
126 * Cancels session deletion requests. IKE/IPSec SA:s are deleted. IKE |
|
127 * plugin session object is not deleted. |
|
128 */ |
|
129 void CancelDeleteSession(); |
|
130 |
|
131 /** |
|
132 * Returns VPN IAP Id. |
|
133 * @return VPN IAP Id |
|
134 */ |
|
135 TInt VpnIapId() const; |
|
136 |
|
137 // from base class CActive |
|
138 |
|
139 /** |
|
140 * From CActive |
|
141 * Handles completion of asynchronous request. |
|
142 */ |
|
143 void RunL(); |
|
144 |
|
145 /** |
|
146 * From CActive |
|
147 * Handles cancellation of asynchronous request. |
|
148 */ |
|
149 void DoCancel(); |
|
150 |
|
151 private: |
|
152 enum TState |
|
153 { |
|
154 EIdle, |
|
155 ENegotiatingWithHost, |
|
156 ENegotiated, |
|
157 EDeletingSession |
|
158 }; |
|
159 |
|
160 CIkePluginSessionHandler( TUint32 aVpnIapId, |
|
161 IkeSocket::TIkeMajorVersion aIkeVersion, |
|
162 IkeSocket::TIpVersion aIpVersion, |
|
163 MIkePluginSessionHandlerCallback& aCallback, |
|
164 MIkeDebug& aDebug ); |
|
165 |
|
166 void ConstructL( TUint32 aVpnNetId, |
|
167 TUint32 aVpnInterfaceIndex, |
|
168 const TInetAddr& aDnsServer, |
|
169 CIkeConnectionInterface& aConnection, |
|
170 MIkePluginIf& aIkePlugin ); |
|
171 |
|
172 private: // data |
|
173 |
|
174 /** |
|
175 * State. |
|
176 * Own. |
|
177 */ |
|
178 TState iState; |
|
179 |
|
180 /** |
|
181 * VPN IAP Id. |
|
182 * Own. |
|
183 */ |
|
184 TUint32 iVpnIapId; |
|
185 |
|
186 /** |
|
187 * IKE version. |
|
188 * Own. |
|
189 */ |
|
190 IkeSocket::TIkeMajorVersion iIkeVersion; |
|
191 |
|
192 /** |
|
193 * IP version. |
|
194 * Own. |
|
195 */ |
|
196 IkeSocket::TIpVersion iIpVersion; |
|
197 |
|
198 /** |
|
199 * IKE plugin session interface. |
|
200 * Own. |
|
201 */ |
|
202 MIkePluginSessionIf* iIkePluginSession; |
|
203 |
|
204 /** |
|
205 * Internal address. |
|
206 * Own. |
|
207 */ |
|
208 TVPNAddress iInternalAddress; |
|
209 |
|
210 /** |
|
211 * IKE plugin session error observer. |
|
212 * Own. |
|
213 */ |
|
214 CErrorObserver* iErrorObserver; |
|
215 |
|
216 /** |
|
217 * Internal address change observer. |
|
218 * Own. |
|
219 */ |
|
220 CIaChangeObserver* iIaChangeObserver; |
|
221 |
|
222 /** |
|
223 * IKE data interface. |
|
224 * Not own. |
|
225 */ |
|
226 MIkeDataInterface* iIkeDataInterface; |
|
227 |
|
228 /** |
|
229 * Callback interface. |
|
230 * Not own. |
|
231 */ |
|
232 MIkePluginSessionHandlerCallback& iCallback; |
|
233 |
|
234 /** |
|
235 * Debug trace interface. |
|
236 * Not own. |
|
237 */ |
|
238 MIkeDebug& iDebug; |
|
239 }; |
|
240 |
|
241 |
|
242 #endif // C_IKEPLUGINSESSIONHANDLER_H |