|
1 /* |
|
2 * Copyright (c) 2002 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: Wlan adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __NSMLWLANADAPTER_H__ |
|
21 #define __NSMLWLANADAPTER_H__ |
|
22 |
|
23 |
|
24 // ----------------------------------------------------------------------------------------------- |
|
25 // Includes |
|
26 // ----------------------------------------------------------------------------------------------- |
|
27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
28 #include <commsdat_partner.h> |
|
29 #endif |
|
30 #include <utf.h> |
|
31 #include <commdb.h> |
|
32 #include <EapSettings.h> |
|
33 #include "smldmadapter.h" |
|
34 #include "nsmlconstants.h" |
|
35 #include "NSmlWlanSettings.h" |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------------------------- |
|
39 // Constants |
|
40 // ----------------------------------------------------------------------------------------------- |
|
41 const TInt KNSmlWepKeyGranularity = 4; |
|
42 const TInt KNSmlMaxURISegLen = 32; |
|
43 const TInt KExpandedEAPIdLength = 8; |
|
44 const TInt KNsmlSubjectKeyIdLength = 255; |
|
45 |
|
46 _LIT8( KNSmlWLanAdapterDDFversion, "1.0" ); |
|
47 _LIT16( KNSmlWLanServiceTable, "WLANServiceTable" ); |
|
48 _LIT8( KNSmlWLanId, "Id" ); |
|
49 _LIT8( KNSmlWLanName, "Name" ); |
|
50 _LIT8( KNSmlWLanHidden, "Hidden" ); |
|
51 _LIT8( KNSmlWLanReadOnly, "ReadOnly" ); |
|
52 _LIT8( KNSmlWLanServiceId, "ServiceID" ); |
|
53 _LIT8( KNSmlWLanNetworkMode, "NetworkMode" ); |
|
54 _LIT8( KNSmlWLanConnectionMode, "WlanConnectionMode" ); |
|
55 _LIT8( KNSmlWLanSsid, "SSID" ); |
|
56 _LIT8( KNSmlWLanUsedSsid, "UsedSSID" ); |
|
57 _LIT8( KNSmlWLanSsidHidden, "SSIDHidden" ); |
|
58 _LIT8( KNSmlWLanUseWPAPSK, "UseWPAPSK" ); |
|
59 _LIT8( KNSmlWLanEnablePSK, "EnablePSK" ); |
|
60 _LIT8( KNSmlWLanWepKey1, "WEPKey1InHex" ); |
|
61 _LIT8( KNSmlWLanWepKey2, "WEPKey2InHex" ); |
|
62 _LIT8( KNSmlWLanWepKey3, "WEPKey3InHex" ); |
|
63 _LIT8( KNSmlWLanWepKey4, "WEPKey4InHex" ); |
|
64 _LIT8( KNSmlWLanWepIndex, "WEPKeyIndex" ); |
|
65 _LIT8( KNSmlWLanWepKey, "WEPKey" ); |
|
66 _LIT8( KNSmlWLanSecurityMode, "SecurityMode" ); |
|
67 _LIT8( KNSmlWLanWpaAuthMode, "WPAAuthMode" ); |
|
68 _LIT8( KNSmlWLanWpaPreSharedKey, "WPAPreSharedKey" ); |
|
69 _LIT8( KNSmlWLanEapList, "WLANEAPList" ); |
|
70 _LIT8( KNSmlWLanAuthMode, "WEPAuthMode" ); |
|
71 _LIT8( KNSmlWLanWepKeyId, "WEPKeyID" ); |
|
72 _LIT8( KNSmlWLanWepKeyData, "Data" ); |
|
73 _LIT8( KNSmlWLanNodeName, "WLAN" ); |
|
74 |
|
75 _LIT8( KNSmlEmpty, "" ); |
|
76 #define KNSmlWLanDefaultSSID _S("Net1") |
|
77 |
|
78 _LIT8( KNSmlWLan, "/WLAN" ); |
|
79 _LIT8( KNSmlNAPDefWlanNode,"Name/NAPID/Bearer/IPAddrFromServer/IfNetworks/NAPAddr/NAPAddrTy/IPDNSAddrFromServer/DNSAddr/DefGW/NetworkMask/Networks/IAPService"); |
|
80 |
|
81 _LIT8( KNSmlWLanListOfLeafs, "SSID/UsedSSID/SSIDHidden/NetworkMode/SecurityMode/WPAPreSharedKey/UseWPAPSK/WEPKey/WEPKeyIndex/WLANEAPList/WEPAuthMode/EAP/SecondarySSID" ); |
|
82 |
|
83 _LIT8( KNSmlWLanListOfSecondaryLeafs, "SSID/UsedSSID" ); |
|
84 _LIT8( KNSmlWLanListOfWepKeys, "1/2/3/4" ); |
|
85 _LIT8( KNSmlWLanListOfWepKeyLeafs, "WEPKeyID/Data" ); |
|
86 _LIT8( KNSmlWLanAllowUnsecure8, "allow unsecure" ); |
|
87 _LIT8( KNSmlWLanWep8, "WEP" ); |
|
88 _LIT8( KNSmlWLan8021x8, "802.1X" ); |
|
89 _LIT8( KNSmlWLanWpa8, "WPA" ); |
|
90 _LIT8( KNSmlWLanWpa28, "WPA2" ); |
|
91 _LIT8( KNSmlWLanWpaPreSharedKey8, "WPA pre-shared key" ); |
|
92 _LIT8( KNSmlWLanAdHoc8, "ADHOC" ); |
|
93 _LIT8( KNSmlWLanInfrastructure8, "Infrastructure" ); |
|
94 _LIT8( KNSmlMimeType, "text/plain" ); |
|
95 |
|
96 |
|
97 #ifdef FF_WLAN_EXTENSIONS |
|
98 _LIT8( KNSmlWLanListOfEAPLeafs, "EAPType/Username/Password/Realm/UsePseudonym/VerifyCertRealm/RequireClientAuthentication/SessionValidityTime/CipherSuite/AllowPEAPv0/AllowPEAPv1/AllowPEAPv2/Certificate/AuthProvMode/UnauthProvMode/PACGroupRef/WarnADHPNoPAC/WarnADHPNoMatchPAC/WarnNotDefaultSrv" ); |
|
99 #else |
|
100 _LIT8( KNSmlWLanListOfEAPLeafs, "EAPType/Username/Password/Realm/UsePseudonym/VerifyCertRealm/RequireClientAuthentication/SessionValidityTime/CipherSuite/AllowPEAPv0/AllowPEAPv1/AllowPEAPv2/Certificate" ); |
|
101 #endif |
|
102 |
|
103 _LIT8( KNSmlWLanListOfCertificateLeafs, "IssuerName/SubjectName/CertType/SerialNumber/SubjectKeyId/Fingerprint" ); |
|
104 |
|
105 _LIT8( KNSmlWLanSecSsid, "SecondarySSID" ); |
|
106 _LIT8( KNSmlWLanEap, "EAP" ); |
|
107 _LIT8( KNSmlWLanEapType, "EAPType" ); |
|
108 _LIT8( KNSmlWLanUsername, "Username" ); |
|
109 _LIT8( KNSmlWLanPassword, "Password" ); |
|
110 _LIT8( KNSmlWLanRealm, "Realm" ); |
|
111 _LIT8( KNSmlWLanUsePseudonym, "UsePseudonym" ); |
|
112 _LIT8( KNSmlWLanEncapsulation, "Encapsulation" ); |
|
113 _LIT8( KNSmlWLanVerifyCertRealm, "VerifyCertRealm" ); |
|
114 _LIT8( KNSmlWLanRequireClientAuthentication, "RequireClientAuthentication" ); |
|
115 _LIT8( KNSmlWLanSessionValidityTime, "SessionValidityTime" ); |
|
116 _LIT8( KNSmlWLanCipherSuite, "CipherSuite" ); |
|
117 _LIT8( KNSmlWLanAllowPEAPv0, "AllowPEAPv0" ); |
|
118 _LIT8( KNSmlWLanAllowPEAPv1, "AllowPEAPv1" ); |
|
119 _LIT8( KNSmlWLanAllowPEAPv2, "AllowPEAPv2" ); |
|
120 #ifdef FF_WLAN_EXTENSIONS |
|
121 _LIT8( KNSmlWLanAuthProvMode, "AuthProvMode" ); |
|
122 _LIT8( KNSmlWLanUnauthProvMode, "UnauthProvMode" ); |
|
123 _LIT8( KNSmlWLanPACGroupRef, "PACGroupRef" ); |
|
124 _LIT8( KNSmlWLanWarnADHPNoPAC, "WarnADHPNoPAC" ); |
|
125 _LIT8( KNSmlWLanWarnADHPNoMatchPAC, "WarnADHPNoMatchPAC" ); |
|
126 _LIT8( KNSmlWLanWarnNotDefaultSrv, "WarnNotDefaultSrv" ); |
|
127 #endif |
|
128 _LIT8( KNSmlWLanCertificate, "Certificate" ); |
|
129 _LIT8( KNSmlWLanIssuerName, "IssuerName" ); |
|
130 _LIT8( KNSmlWLanSubjectName, "SubjectName" ); |
|
131 _LIT8( KNSmlWLanCertType, "CertType" ); |
|
132 _LIT8( KNSmlWLanSerialNumber, "SerialNumber" ); |
|
133 _LIT8( KNSmlWLanSubjectKeyId, "SubjectKeyId" ); |
|
134 _LIT8( KNSmlWLanFingerprint, "Fingerprint" ); |
|
135 |
|
136 _LIT8(KTrue, "True"); |
|
137 _LIT8(KFalse, "False"); |
|
138 _LIT8(KTtrue, "true"); |
|
139 _LIT8(KFfalse, "false"); |
|
140 _LIT8(KSlash, "/"); |
|
141 _LIT8(KDash, "-"); |
|
142 _LIT8(KNSmlWLanEapId, "EAPId" ); |
|
143 |
|
144 _LIT8(KSuitesDefault, "-010,-022,-019,-047,-050,-051,-004,-005"); |
|
145 |
|
146 const TUint RSA_3DES_SHA = 10; |
|
147 const TUint DHE_RSA_3DES_SHA = 22; |
|
148 const TUint DHE_DSS_3DES_SHA = 19; |
|
149 const TUint RSA_AES_SHA = 47; // ? |
|
150 const TUint DHE_RSA_AES_SHA = 50; // ? |
|
151 const TUint DHE_DSS_AES_SHA = 51; // ? |
|
152 const TUint RSA_RC4_MD5 = 4; |
|
153 const TUint RSA_RC4_SHA = 5; |
|
154 const TUint NUMBER_OF_CIPHERSUITES = 8; |
|
155 |
|
156 _LIT8(KEAPSIM, "EAP-SIM"); |
|
157 _LIT8(KEAPAKA, "EAP-AKA"); |
|
158 _LIT8(KEAPTLS, "EAP-TLS"); |
|
159 _LIT8(KEAPPEAP, "EAP-PEAP"); |
|
160 _LIT8(KEAPTTLS, "EAP-TTLS"); |
|
161 _LIT8(KEAPLEAP, "EAP-LEAP"); |
|
162 _LIT8(KEAPMSCHAPV2, "EAP-MSCHAPV2"); |
|
163 _LIT8(KMSCHAPV2, "MSCHAPV2"); |
|
164 _LIT8(KEAPGTC, "EAP-GTC"); |
|
165 _LIT8(KEAPFAST, "EAP-FAST"); |
|
166 _LIT8(KEAPTTLSPAP, "EAP-TTLSPAP"); |
|
167 |
|
168 |
|
169 const TUint8 KEapNoneId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
170 const TUint8 KEapTlsTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d}; |
|
171 const TUint8 KEapGtcTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06}; |
|
172 const TUint8 KEapLeapTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11}; |
|
173 const TUint8 KEapSimTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12}; |
|
174 const TUint8 KEapTtlsTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15}; |
|
175 const TUint8 KEapAkaTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17}; |
|
176 const TUint8 KEapPeapTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19}; |
|
177 const TUint8 KEapMschapv2TypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A}; |
|
178 const TUint8 KEapSecuridTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}; |
|
179 const TUint8 KEapFastTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B}; |
|
180 const TUint8 KMschapv2TypeId[] = {0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x63}; |
|
181 const TUint8 KTtlspapTypeId[] = {0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x62}; |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 // ----------------------------------------------------------------------------------------------- |
|
187 // Structures |
|
188 // ----------------------------------------------------------------------------------------------- |
|
189 struct TNSmlWepKeyBufferElement |
|
190 { |
|
191 HBufC8* iUri; |
|
192 HBufC8* iData; |
|
193 TInt iWepKeyId; |
|
194 TInt iIdStatusRef; |
|
195 //TInt iUseWPAPSK; |
|
196 TInt iDataStatusRef; |
|
197 TInt iNodeStatusRef; |
|
198 TInt iLengthStatusRef; |
|
199 TBool iExecuted; |
|
200 TBool iDataSet; |
|
201 TInt iLuid; |
|
202 }; |
|
203 |
|
204 struct TNSmlSecondarySSIDBufferElement |
|
205 { |
|
206 HBufC8* iUri; |
|
207 TBuf<KMaxTextLength> ScannedId; |
|
208 TBuf<KMaxTextLength> UsedId; |
|
209 TInt wlanLuid; |
|
210 TBool iExecuted; |
|
211 }; |
|
212 |
|
213 struct TNSmlEAPBufferElement |
|
214 { |
|
215 EAPSettings* iEAPSettings; |
|
216 EAPSettings::TEapType iEncapsulatingEAPId; |
|
217 RArray<TInt> iStatusRefArray; |
|
218 TInt iWLANServiceId; |
|
219 }; |
|
220 |
|
221 // ----------------------------------------------------------------------------------------------- |
|
222 // Enumerations |
|
223 // ----------------------------------------------------------------------------------------------- |
|
224 enum TConnectionMode |
|
225 { |
|
226 EAdhoc = 0, |
|
227 EInfrastructure = 1 |
|
228 }; |
|
229 |
|
230 enum TWLanSecurityMode |
|
231 { |
|
232 EAllowUnsecure = 1, |
|
233 EWep = 2, |
|
234 EWlan8021x = 4, |
|
235 EWpa = 8, |
|
236 EWpa2 = 16 |
|
237 }; |
|
238 |
|
239 enum TWepAuthenticationMode |
|
240 { |
|
241 EOpen = 0, |
|
242 EShared = 1 |
|
243 }; |
|
244 |
|
245 // ------------------------------------------------------------------------------------------------ |
|
246 // CNSmlWLanAdapter |
|
247 // ------------------------------------------------------------------------------------------------ |
|
248 class CNSmlWLanAdapter : public CSmlDmAdapter |
|
249 { |
|
250 public: |
|
251 static CNSmlWLanAdapter* NewL( MSmlDmCallback* aDmCallback, CCommsDatabase& aDatabase ); |
|
252 static CNSmlWLanAdapter* NewLC( MSmlDmCallback* aDmCallback, CCommsDatabase& aDatabase ); |
|
253 void ConstructL( CCommsDatabase& aDatabase ); |
|
254 virtual ~CNSmlWLanAdapter(); |
|
255 |
|
256 // Adapter interface |
|
257 void DDFVersionL( CBufBase& aDDFVersion ); |
|
258 void DDFStructureL( MSmlDmDDFObject& aDDF ); |
|
259 void AddLeafObjectL( const TDesC8& aURI, |
|
260 const TDesC8& aParentLUID, |
|
261 const TDesC8& aObject, |
|
262 const TDesC8& aType, |
|
263 const TInt aStatusRef ); |
|
264 void UpdateLeafObjectL( const TDesC8& aURI, |
|
265 const TDesC8& aLUID, |
|
266 const TDesC8& aObject, |
|
267 const TDesC8& aType, |
|
268 const TInt aStatusRef ); |
|
269 void UpdateLeafObjectL( const TDesC8& aURI, |
|
270 const TDesC8& aLUID, |
|
271 RWriteStream*& aStream, |
|
272 const TDesC8& aType, |
|
273 TInt aStatusRef ); |
|
274 void DeleteObjectL( const TDesC8& aURI, |
|
275 const TDesC8& aLUID, |
|
276 const TInt aStatusRef ); |
|
277 void FetchLeafObjectL( const TDesC8& aURI, |
|
278 const TDesC8& aLUID, |
|
279 const TDesC8& aType, |
|
280 const TInt aResultsRef, |
|
281 const TInt aStatusRef ); |
|
282 void FetchLeafObjectSizeL( const TDesC8& aURI, |
|
283 const TDesC8& aLUID, |
|
284 const TDesC8& aType, |
|
285 TInt aResultsRef, |
|
286 TInt aStatusRef ); |
|
287 |
|
288 void ChildURIListL( const TDesC8& aURI, |
|
289 const TDesC8& aLUID, |
|
290 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
291 const TInt aResultsRef, |
|
292 const TInt aStatusRef ); |
|
293 void AddNodeObjectL( const TDesC8& aURI, |
|
294 const TDesC8& aParentLUID, |
|
295 const TInt aStatusRef ); |
|
296 void ExecuteCommandL( const TDesC8& aURI, |
|
297 const TDesC8& aLUID, |
|
298 const TDesC8& aArgument, |
|
299 const TDesC8& aType, |
|
300 TInt aStatusRef ); |
|
301 void ExecuteCommandL( const TDesC8& aURI, |
|
302 const TDesC8& aLUID, |
|
303 RWriteStream*& aStream, |
|
304 const TDesC8& aType, |
|
305 TInt aStatusRef ); |
|
306 void CopyCommandL( const TDesC8& aTargetURI, |
|
307 const TDesC8& aTargetLUID, |
|
308 const TDesC8& aSourceURI, |
|
309 const TDesC8& aSourceLUID, |
|
310 const TDesC8& aType, |
|
311 TInt aStatusRef ); |
|
312 void StartAtomicL(); |
|
313 void CommitAtomicL(); |
|
314 void RollbackAtomicL(); |
|
315 TBool StreamingSupport( TInt& aItemSize ); |
|
316 void StreamCommittedL(); |
|
317 void CompleteOutstandingCmdsL(); |
|
318 CSmlDmAdapter::TError FetchLeafObjectL( const TDesC8& aURI, |
|
319 const TDesC8& aLUID, |
|
320 const TDesC8& aType, |
|
321 CBufBase& aObject ); |
|
322 |
|
323 private: |
|
324 CNSmlWLanAdapter(TAny* aEcomArguments); |
|
325 void FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
326 TSmlDmAccessTypes aAccTypes, |
|
327 MSmlDmDDFObject::TOccurence aOccurrence, |
|
328 MSmlDmDDFObject::TScope aScope, |
|
329 MSmlDmDDFObject::TDFFormat aFormat, |
|
330 const TDesC8& aDescription ); |
|
331 HBufC* IntToDesLC(const TInt aLuid); |
|
332 HBufC8* IntToDes8LC(const TInt aLuid); |
|
333 TInt DesToInt(const TDesC8& aLuid); |
|
334 TInt GetIdFromLuid( const TDesC8& aLuid ); |
|
335 TUint32 GetSecSSIDFromUriL(const TDesC8& aUri ); |
|
336 TInt GetEAPIdFromUri( const TDesC8& aUri ); |
|
337 TInt GetCertificateIdFromUri( const TDesC8& aUri ); |
|
338 TInt GetWepKeyIdFromLuid( const TDesC8& aLuid ); |
|
339 TInt GetWepKeyIdFromUri( const TDesC8& aUri ); |
|
340 TInt NumOfUriSegs( const TDesC8& aUri ); |
|
341 TPtrC8 GetLastUriSeg(const TDesC8& aURI); |
|
342 TPtrC8 RemoveLastUriSeg(const TDesC8& aURI); |
|
343 void ExecuteBufferL( TBool aFinal = EFalse ); |
|
344 TDesC8& ConvertTo8LC( const TDesC& aSource ); |
|
345 TDesC16& ConvertTo16LC( const TDesC8& aSource ); |
|
346 void DesToBufferL(CBufBase& aTo, const TDesC& aFrom); |
|
347 void FillCipherSuiteBufferL(CBufBase& aBuffer); |
|
348 void FillCipherSuitesL(const TDesC8& aObject, const TInt aLuid); |
|
349 void ConvertEAPStringToIds( const TDesC8& aEAPString, TDes8& aExpandedId, EAPSettings::TEapType& aId); |
|
350 TInt GetServiceIdFromUriL( const TDesC8& aURI); |
|
351 TInt GetEncapsEAPIdFromUri( const TDesC8& aUri ); |
|
352 void ResetEAPStructL(); |
|
353 void DeleteEAPStructL(); |
|
354 |
|
355 MSmlDmCallback* iCallBack; |
|
356 CWlanSettings* iWlanSettings; |
|
357 CArrayFixFlat<TNSmlWepKeyBufferElement> *iBuffer; |
|
358 TWlanSettings *iSettings; |
|
359 EAPSettings* iEAPSettings; |
|
360 RPointerArray<TNSmlSecondarySSIDBufferElement> iSecondaryBuffer; |
|
361 RPointerArray<TNSmlEAPBufferElement> iEAPBuffer; |
|
362 |
|
363 }; |
|
364 |
|
365 #endif __NSMLWLANADAPTER_H__ |