|
1 /* |
|
2 * Copyright (c) 2002-2010 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 the License "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: Server class of wlan engine |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 96 % |
|
20 */ |
|
21 |
|
22 #include <e32def.h> |
|
23 #include <e32std.h> |
|
24 #include <featmgr.h> |
|
25 #include <in_sock.h> |
|
26 #include <bldvariant.hrh> // for feature definitions |
|
27 |
|
28 #include "wlmserver.h" |
|
29 #include "wlmdriverif.h" |
|
30 #include "wlmsession.h" |
|
31 #include "wlanconversionutil.h" |
|
32 #include "core_server_factory.h" |
|
33 #include "core_tools.h" |
|
34 #include "core_type_list.h" |
|
35 #include "wlaneapolclient.h" |
|
36 #include "wlangenericplugin.h" |
|
37 #include "wlanssidlistdb.h" |
|
38 #include "wlandevicesettingsinternalcrkeys.h" |
|
39 #include "wlanbgscan.h" |
|
40 #include "wlantimerservices.h" |
|
41 #include "am_debug.h" |
|
42 |
|
43 /** Panic codes for WlanEngine */ |
|
44 const TInt KWlmPanicCleanupStackCreationFailed = 1; |
|
45 const TInt KWlmPanicOpenSemaforeFailed = 2; |
|
46 const TInt KWlmPanicCreationOfSchedulerFailed = 3; |
|
47 /** Panic category of WlanEngine */ |
|
48 _LIT( KWlmModuleName, "WLANSRV" ); |
|
49 |
|
50 /** Constants for sanity checks */ |
|
51 const i32_t MAX_RCP_BOUNDARY = 255; |
|
52 const i32_t MAX_HYSTERESIS = 255; |
|
53 const u8_t MAX_USER_PRIORITY = 7; |
|
54 |
|
55 /** The number of hours after which the domain information expires. */ |
|
56 const TInt KWlmDomainInfoExpire = 5; |
|
57 /** Operator MCC codes for North America, Canada, Taiwan, Brazil, Argentina, Mexico and Colombia. */ |
|
58 const TUint KWlmOperatorMccNATable[] = { 302, 310, 311, 312, 313, 314, 315, 316, 332, 466, 724, 722, 334, 732 }; |
|
59 /** The amount of operator MCC codes for North America, Canada, Taiwan, Brazil, Argentina, Mexico and Colombia. */ |
|
60 const TUint KWlmOperatorMccNATableLength = 14; |
|
61 |
|
62 /** AP country information codes for North America, Canada, Taiwan, Brazil, Argentina, Mexico and Colombia |
|
63 are defined in core_types.h. */ |
|
64 |
|
65 /** Timestamp is stored in CenRep in minutes, constant for converterting this to microseconds */ |
|
66 const TUint KWlmTimestampInCenrep = 60000000; |
|
67 |
|
68 /** WLAN region values in CenRep */ |
|
69 const TInt KWlmRegionUnknown = 0; |
|
70 const TInt KWlmRegionETSI = 1; |
|
71 const TInt KWlmRegionFCC = 2; |
|
72 |
|
73 /** Valid range for cache lifetime in scan requests (in seconds). */ |
|
74 const TInt KWlmMaxScanCacheLifetime = 60; |
|
75 const TInt KWlmMinScanCacheLifetime = 0; |
|
76 const TInt KWlmDefaultScanCacheLifetime = -1; |
|
77 |
|
78 /** Valid range for maximum scan delay in scan requests (in seconds). */ |
|
79 const TUint KWlmMaxScanDelay = 1200; |
|
80 |
|
81 /** Infinite scan delay in GetAvailableIaps and GetScanResult. */ |
|
82 const TUint KWlmInfiniteScanDelay = 0xFFFFFFFF; |
|
83 |
|
84 /** Granularity for WLAN SSID lists. */ |
|
85 const TUint KWlanSsidListGranularity = 100; |
|
86 |
|
87 /** Bitmask of WLAN features enabled at compile-time. */ |
|
88 const TUint KWlanStaticFeatures = |
|
89 CWlmServer::EWlanFeaturePowerSaveTest | |
|
90 CWlmServer::EWlanFeature802dot11k; |
|
91 |
|
92 // ============================ MEMBER FUNCTIONS =============================== |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CWlmServer::CWlmServer |
|
96 // C++ default constructor can NOT contain any code, that |
|
97 // might leave. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CWlmServer::CWlmServer() : |
|
101 CServer2( CActive::EPriorityStandard ), |
|
102 iCoreServer( NULL ), |
|
103 iDriverIf( NULL ), |
|
104 iSupportedFeatures( KWlanStaticFeatures ), |
|
105 iScanSchedulingTimer( NULL ), |
|
106 iCache( NULL ), |
|
107 iConfiguredCacheLifetime( 0 ), |
|
108 iPlatform( NULL ), |
|
109 iConnectionState( EWlanStateNotConnected ), |
|
110 iPrevConnectionState( EWlanStateNotConnected ), |
|
111 iIsRoaming( EFalse ), |
|
112 iPrevRcpiValue( 0 ), |
|
113 iRegion( EFCC ), |
|
114 iTimeofDomainQuery( 0 ), |
|
115 iClientSessionCount( 0 ), |
|
116 iRequestIdCounter( KWlanExtCmdBase ), |
|
117 iSessionIdCounter( 0 ), |
|
118 iCoreAsynchCb( NULL ), |
|
119 iCoreAsynchCbId( 0 ), |
|
120 iCoreAsynchCbStatus( core_error_ok ), |
|
121 iIsStartupComplete( EFalse ), |
|
122 iEapolClient( NULL ), |
|
123 iEapolHandler( NULL ), |
|
124 iScanSchedulingTimerExpiration( 0 ), |
|
125 iRequestTriggeringScanning( 0 ), |
|
126 iCoreHandlingScanRequest( EFalse ), |
|
127 iPowerSaveMode( EWlanPowerSaveAutomatic ), |
|
128 iPowerSaveEnabled( EFalse ), |
|
129 iSsidListDb( NULL ), |
|
130 iShowBrokenPowerSaveNote( ETrue ), |
|
131 iBrokenPowerSaveNotifierWaiter( NULL ), |
|
132 iBgScanProvider( NULL ), |
|
133 iTimerServices( NULL ) |
|
134 { |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CWlmServer::ConstructL |
|
139 // Symbian 2nd phase constructor can leave. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CWlmServer::ConstructL() |
|
143 { |
|
144 DEBUG( "CWlmServer::ConstructL()" ); |
|
145 User::LeaveIfError( User::RenameThread( KWLMDataServerName ) ); |
|
146 StartL( KWLMDataServerName ); |
|
147 |
|
148 // Consult FeatureManager whether startup is allowed |
|
149 FeatureManager::InitializeLibL(); |
|
150 if( !FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) ) |
|
151 { |
|
152 DEBUG("ERROR: FeatureManager forbids starting of WlanServer"); |
|
153 FeatureManager::UnInitializeLib(); |
|
154 User::Leave( KErrNotSupported ); |
|
155 } |
|
156 |
|
157 if( FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi ) ) |
|
158 { |
|
159 iSupportedFeatures |= EWlanFeatureWapi; |
|
160 } |
|
161 |
|
162 DEBUG1( "CWlmServer::ConstructL() - supported WLAN features: 0x%08X", |
|
163 iSupportedFeatures ); |
|
164 FeatureManager::UnInitializeLib(); |
|
165 |
|
166 // Create Driver Interface |
|
167 iDriverIf = CWlmDriverIf::NewL(); |
|
168 |
|
169 // Get Mac Address |
|
170 TMacAddress mac( KZeroMacAddr ); |
|
171 iDriverIf->GetMacAddress( mac ); |
|
172 |
|
173 // Test its authenticity |
|
174 // If failure -> not starting the server |
|
175 const TMacAddress KDeadBeefMacAddr = {{ 0x00, 0xE0, 0xDE, 0xAD, 0xBE, 0xEF }}; |
|
176 if( mac == KZeroMacAddr || mac == KDeadBeefMacAddr ) |
|
177 { |
|
178 DEBUG("ERROR: MAC Address not acceptable -> Forbidden to start WlanServer"); |
|
179 User::Leave( KErrNotSupported ); |
|
180 } |
|
181 core_mac_address_s core_mac( ZERO_MAC_ADDR ); |
|
182 TWlanConversionUtil::ConvertMacAddress( core_mac, mac ); |
|
183 |
|
184 // Get Device Settings |
|
185 CWlanDeviceSettings::SWlanDeviceSettings deviceSettings; |
|
186 GetWlanSettingsL( deviceSettings ); |
|
187 SetCachedRegion(deviceSettings.region, deviceSettings.regionTimestamp); |
|
188 core_device_settings_s coreSettings; // core needs the settings here |
|
189 TWlanConversionUtil::ConvertDeviceSettings( coreSettings, deviceSettings ); |
|
190 |
|
191 // Create core server |
|
192 User::LeaveIfNull( iCoreServer = core_server_factory_c::instance( |
|
193 *this, |
|
194 *iDriverIf, |
|
195 coreSettings, |
|
196 core_mac, |
|
197 TWlanConversionUtil::ConvertFeatureFlags( iSupportedFeatures ) ) ); |
|
198 iCoreServer->disable_wlan( KWlanIntCmdDisableWlan ); |
|
199 |
|
200 // Create scan timer |
|
201 DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" ); |
|
202 iScanSchedulingTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
203 |
|
204 // Create scan cache |
|
205 iCache = CWlanScanResultCache::NewL(); |
|
206 iConfiguredCacheLifetime = deviceSettings.scanExpirationTimer; |
|
207 |
|
208 // Create a callback for asynchronous core requests |
|
209 TCallBack callback( HandleCoreAsynchCb, this ); |
|
210 iCoreAsynchCb = new (ELeave) CAsyncCallBack( |
|
211 callback, CActive::EPriorityStandard ); |
|
212 |
|
213 // Create SSID list storage. |
|
214 iSsidListDb = CWlanSsidListDb::NewL(); |
|
215 |
|
216 // Initialise Broken Power Save Note handling |
|
217 TCallBack cb( HandleBrokenPowerSaveNoteClosed, this ); |
|
218 iBrokenPowerSaveNotifierWaiter = CWlanCbWaiter::NewL( cb ); |
|
219 |
|
220 iTimerServices = CWlanTimerServices::NewL(); |
|
221 |
|
222 iBgScanProvider = CWlanBgScan::NewL( static_cast<MWlanScanResultProvider&>( *this ), *iTimerServices ); |
|
223 |
|
224 // Initialize Platform interface and publish mac address |
|
225 iPlatform = CWlmPlatform::NewL( *this ); |
|
226 iPlatform->Initialize(); |
|
227 TInt err = iPlatform->PublishMacAddress( mac ); |
|
228 if( err ) |
|
229 { |
|
230 DEBUG1( "ERROR publishing MAC address: %d", err ); |
|
231 } |
|
232 |
|
233 iGenericWlanPlugin.StartPlugins(); |
|
234 |
|
235 DEBUG( "CWlmServer::ConstructL() - done" ); |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CWlmServer::NewL |
|
240 // Two-phased constructor. |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 EXPORT_C CWlmServer* CWlmServer::NewL() |
|
244 { |
|
245 CWlmServer* self = new( ELeave ) CWlmServer; |
|
246 CleanupStack::PushL( self ); |
|
247 self->ConstructL(); |
|
248 CleanupStack::Pop( self ); |
|
249 return self; |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CWlmServer::~CWlmServer |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 CWlmServer::~CWlmServer() |
|
257 { |
|
258 // Close all open sessions |
|
259 CWlmSession* session = NULL; |
|
260 iSessionIter.SetToFirst(); |
|
261 while( (session = static_cast<CWlmSession*>(iSessionIter++)) != NULL ) |
|
262 { |
|
263 delete session; |
|
264 } |
|
265 |
|
266 iGenericWlanPlugin.StopPlugins(); |
|
267 |
|
268 delete iCoreServer; |
|
269 delete iDriverIf; |
|
270 iNotificationArray.Close(); |
|
271 delete iCache; |
|
272 delete iPlatform; |
|
273 iRequestMap.Close(); |
|
274 delete iCoreAsynchCb; |
|
275 delete iScanSchedulingTimer; |
|
276 delete iSsidListDb; |
|
277 delete iBrokenPowerSaveNotifierWaiter; |
|
278 iBrokenPowerSaveNotifier.Close(); |
|
279 |
|
280 if ( iEapolClient ) |
|
281 { |
|
282 delete iEapolClient; |
|
283 iEapolClient = NULL; |
|
284 } |
|
285 iEapolHandler = NULL; |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CWlmServer::StartServerThread |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 EXPORT_C TInt CWlmServer::StartServerThread() |
|
293 { |
|
294 DEBUG( "CWlmServer::StartServerThread()" ); |
|
295 |
|
296 __UHEAP_MARK; |
|
297 |
|
298 // Create cleanup stack |
|
299 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
300 __ASSERT_ALWAYS( |
|
301 cleanup, |
|
302 User::Panic( KWlmModuleName, KWlmPanicCleanupStackCreationFailed ) |
|
303 ); |
|
304 |
|
305 // Open handle to semaphore |
|
306 RSemaphore started; |
|
307 TInt err = started.OpenGlobal( KWLMServerSemaphore, EOwnerProcess ); |
|
308 __ASSERT_ALWAYS( |
|
309 err == KErrNone, |
|
310 User::Panic( KWlmModuleName, KWlmPanicOpenSemaforeFailed ) |
|
311 ); |
|
312 |
|
313 // Create active scheduler |
|
314 CWlmServer* server = NULL; |
|
315 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
316 if ( scheduler ) |
|
317 { |
|
318 // Install scheduler |
|
319 CActiveScheduler::Install( scheduler ); |
|
320 |
|
321 // Create server |
|
322 TRAP( err, server = CWlmServer::NewL() ); |
|
323 |
|
324 if ( err != KErrNone ) |
|
325 { |
|
326 DEBUG1( "CWlmServer::NewL leaved with code %d", err ); |
|
327 } |
|
328 } |
|
329 else |
|
330 { |
|
331 User::Panic( KWlmModuleName, KWlmPanicCreationOfSchedulerFailed ); |
|
332 } |
|
333 |
|
334 // Signal calling process that we've started via semaphore |
|
335 started.Signal(); |
|
336 started.Close(); |
|
337 |
|
338 // Start the active Scheduler (if there are no errors) |
|
339 if ( err == KErrNone ) |
|
340 { |
|
341 DEBUG( "CWlmServer Starting scheduler..." ); |
|
342 CActiveScheduler::Start(); |
|
343 } |
|
344 |
|
345 // Note that CActiveScheduler::Start() will not return until the scheduler |
|
346 // is stopped in CWlmServer::SessionClosed(). This is because we don't |
|
347 // belong to an active object, so there's no RunL() to be called. |
|
348 |
|
349 // Delete all objects |
|
350 delete server; |
|
351 delete CActiveScheduler::Current(); |
|
352 delete cleanup; |
|
353 |
|
354 // Clean up Ecom framework |
|
355 REComSession::FinalClose(); |
|
356 |
|
357 __UHEAP_MARKEND; |
|
358 |
|
359 return err; |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // CWlmServer::GetWlanSettingsL |
|
364 // --------------------------------------------------------- |
|
365 // |
|
366 void CWlmServer::GetWlanSettingsL( |
|
367 CWlanDeviceSettings::SWlanDeviceSettings& aSettings ) |
|
368 { |
|
369 DEBUG( "CWlmServer::GetWlanSettingsL()" ); |
|
370 CWlanDeviceSettings* db = CWlanDeviceSettings::NewL(); |
|
371 CleanupStack::PushL( db ); |
|
372 db->ReadL( aSettings ); |
|
373 CleanupStack::PopAndDestroy( db ); |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------- |
|
377 // CWlmServer::GetIapSettingsL |
|
378 // --------------------------------------------------------- |
|
379 // |
|
380 void CWlmServer::GetIapSettingsL( |
|
381 const TUint32 aLanServiceId, |
|
382 SWLANSettings& aWlanSettings, |
|
383 RArray<TWlanSecondarySsid>& aSecondaryList ) |
|
384 { |
|
385 DEBUG( "CWlmServer::GetIapSettingsL()" ); |
|
386 |
|
387 CWLanSettings* wlanset = new(ELeave) CWLanSettings; |
|
388 CleanupStack::PushL( wlanset ); |
|
389 |
|
390 User::LeaveIfError( wlanset->Connect() ); |
|
391 User::LeaveIfError( |
|
392 wlanset->GetWlanSettingsForService( aLanServiceId, aWlanSettings ) ); |
|
393 User::LeaveIfError( |
|
394 wlanset->GetSecondarySsidsForService( aWlanSettings.Id, aSecondaryList ) ); |
|
395 |
|
396 DEBUG3( "- connMode == %d, securityMode == %d, # of secondary SSIDs == %d", |
|
397 aWlanSettings.ConnectionMode, |
|
398 aWlanSettings.SecurityMode, |
|
399 aSecondaryList.Count() ); |
|
400 |
|
401 wlanset->Disconnect(); |
|
402 CleanupStack::PopAndDestroy( wlanset ); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------- |
|
406 // CWlmServer::NewSessionL |
|
407 // --------------------------------------------------------- |
|
408 // |
|
409 CSession2* CWlmServer::NewSessionL( |
|
410 const TVersion& /*aVersion*/, |
|
411 const RMessage2& /*aMessage*/ ) const |
|
412 { |
|
413 DEBUG( "CWlmServer::NewSessionL()" ); |
|
414 CWlmSession* session = |
|
415 CWlmSession::NewL( |
|
416 const_cast<CWlmServer&>(*this) ); |
|
417 return session; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------- |
|
421 // CWlmServer::NotifyAdd |
|
422 // --------------------------------------------------------- |
|
423 // |
|
424 void CWlmServer::NotifyAdd( |
|
425 CNotificationBase& aNotification ) |
|
426 { |
|
427 DEBUG( "CWlmServer::NotifyAdd()" ); |
|
428 iNotificationArray.Insert( &aNotification, 0 ); |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------- |
|
432 // CWlmServer::NotifyRemove |
|
433 // --------------------------------------------------------- |
|
434 // |
|
435 void CWlmServer::NotifyRemove( |
|
436 CNotificationBase& aNotification ) |
|
437 { |
|
438 DEBUG( "CWlmServer::NotifyRemove()" ); |
|
439 TInt index = iNotificationArray.Find( &aNotification ); |
|
440 iNotificationArray.Remove( index ); |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------- |
|
444 // CWlmServer::Connect |
|
445 // --------------------------------------------------------- |
|
446 // |
|
447 void CWlmServer::Connect( |
|
448 TUint aSessionId, |
|
449 const RMessage2& aMessage ) |
|
450 { |
|
451 DEBUG( "CWlmServer::Connect()" ); |
|
452 |
|
453 // Get WlanSettings and secondarySSID list |
|
454 // (lanServiceId specifies the table row in wlansettings) |
|
455 SWLANSettings iapData; |
|
456 RArray<TWlanSecondarySsid> secondarySsidList; |
|
457 TInt lanServiceId = aMessage.Int0(); |
|
458 TRAPD( err, GetIapSettingsL( lanServiceId, iapData, secondarySsidList ) ) ; |
|
459 if( err != KErrNone ) |
|
460 { |
|
461 DEBUG1( "CWlmServer::Connect() - GetIapSettingsL leaved with %d", |
|
462 err ); |
|
463 secondarySsidList.Close(); |
|
464 aMessage.Complete( err ); |
|
465 |
|
466 return; |
|
467 } |
|
468 |
|
469 DEBUG4( "CWlmServer::Connect() - SecurityMode: %u, WPAKeyLength: %u, EnableWpaPsk: %u, PresharedKeyFormat: %u", |
|
470 iapData.SecurityMode, iapData.WPAKeyLength, iapData.EnableWpaPsk, iapData.PresharedKeyFormat ); |
|
471 |
|
472 // Check whether WAPI is supported |
|
473 if( iapData.SecurityMode == Wapi && |
|
474 !( iSupportedFeatures & EWlanFeatureWapi ) ) |
|
475 { |
|
476 DEBUG( "CWlmServer::Connect() - WAPI is not supported" ); |
|
477 |
|
478 secondarySsidList.Close(); |
|
479 aMessage.Complete( KErrNotSupported ); |
|
480 |
|
481 return; |
|
482 } |
|
483 |
|
484 // Get override setting from message parameter |
|
485 TWLMOverrideSettings override = { 0 }; |
|
486 TPckg<TWLMOverrideSettings> inData( override ); |
|
487 err = aMessage.Read( 1, inData ); |
|
488 if( err ) |
|
489 { |
|
490 secondarySsidList.Close(); |
|
491 aMessage.Complete( err ); |
|
492 |
|
493 return; |
|
494 } |
|
495 |
|
496 // Type conversion |
|
497 core_iap_data_s* coreIapData = new core_iap_data_s; |
|
498 if( !coreIapData ) |
|
499 { |
|
500 secondarySsidList.Close(); |
|
501 aMessage.Complete( KErrNoMemory ); |
|
502 |
|
503 return; |
|
504 } |
|
505 |
|
506 // Find out whether IP address should be static or dhcp |
|
507 CLanSettings lanSettingsClient; |
|
508 err = lanSettingsClient.Connect(); |
|
509 if( err ) |
|
510 { |
|
511 secondarySsidList.Close(); |
|
512 delete coreIapData; |
|
513 aMessage.Complete( err ); |
|
514 |
|
515 return; |
|
516 } |
|
517 SLanSettings lanSettings; |
|
518 lanSettingsClient.GetLanSettings( lanServiceId, lanSettings ); |
|
519 lanSettingsClient.Disconnect(); |
|
520 |
|
521 TWlanConversionUtil::ConvertIapSettings( |
|
522 *coreIapData, |
|
523 iapData, |
|
524 lanSettings.AddrFromServer, |
|
525 override ); |
|
526 |
|
527 // |
|
528 // Handle secondary SSID list |
|
529 // |
|
530 core_type_list_c<core_ssid_entry_s>* coreSsidList = NULL; |
|
531 |
|
532 if( iapData.SSID.Length() && |
|
533 ( iapData.UsedSSID.Length() || secondarySsidList.Count() ) ) |
|
534 { |
|
535 DEBUG( "CWlmServer::Connect() - secondary SSIDs defined" ); |
|
536 |
|
537 coreSsidList = new core_type_list_c<core_ssid_entry_s>(); |
|
538 if( !coreSsidList ) |
|
539 { |
|
540 secondarySsidList.Close(); |
|
541 delete coreIapData; |
|
542 aMessage.Complete( KErrNoMemory ); |
|
543 |
|
544 return; |
|
545 } |
|
546 coreSsidList->clear(); |
|
547 |
|
548 core_ssid_entry_s* entry = new core_ssid_entry_s; |
|
549 if ( !entry ) |
|
550 { |
|
551 secondarySsidList.Close(); |
|
552 delete coreIapData; |
|
553 delete coreSsidList; |
|
554 aMessage.Complete( KErrNoMemory ); |
|
555 |
|
556 return; |
|
557 } |
|
558 |
|
559 entry->id = coreIapData->id; |
|
560 TWlanConversionUtil::ConvertSSID( entry->ssid, iapData.SSID ); |
|
561 if( iapData.UsedSSID.Length() ) |
|
562 { |
|
563 TWlanConversionUtil::ConvertSSID( entry->used_ssid, iapData.UsedSSID ); |
|
564 } |
|
565 else |
|
566 { |
|
567 entry->used_ssid = entry->ssid; |
|
568 } |
|
569 coreSsidList->append( entry ); |
|
570 |
|
571 for( TInt idx( 0 ); idx < secondarySsidList.Count(); ++idx ) |
|
572 { |
|
573 entry = new core_ssid_entry_s; |
|
574 if ( !entry ) |
|
575 { |
|
576 secondarySsidList.Close(); |
|
577 delete coreIapData; |
|
578 delete coreSsidList; |
|
579 aMessage.Complete( KErrNoMemory ); |
|
580 |
|
581 return; |
|
582 } |
|
583 |
|
584 TWlanConversionUtil::ConvertSSID( |
|
585 entry->ssid, secondarySsidList[idx].ssid ); |
|
586 if ( secondarySsidList[idx].usedSsid.Length() ) |
|
587 { |
|
588 TWlanConversionUtil::ConvertSSID( |
|
589 entry->used_ssid, secondarySsidList[idx].usedSsid ); |
|
590 } |
|
591 else |
|
592 { |
|
593 TWlanConversionUtil::ConvertSSID( |
|
594 entry->used_ssid, iapData.SSID ); |
|
595 } |
|
596 coreSsidList->append( entry ); |
|
597 } |
|
598 |
|
599 DEBUG1( "CWlmServer::Connect() - secondary SSID count %u", |
|
600 coreSsidList->count() ); |
|
601 } |
|
602 else |
|
603 { |
|
604 DEBUG( "CWlmServer::Connect() - no secondary SSIDs defined" ); |
|
605 } |
|
606 secondarySsidList.Close(); |
|
607 |
|
608 // Connection status |
|
609 core_connect_status_e* connectionStatus = new core_connect_status_e; |
|
610 if( !connectionStatus ) |
|
611 { |
|
612 secondarySsidList.Close(); |
|
613 delete coreIapData; |
|
614 delete coreSsidList; |
|
615 aMessage.Complete( KErrNoMemory ); |
|
616 return; |
|
617 } |
|
618 *connectionStatus = core_connect_undefined; |
|
619 |
|
620 TInt ret = GetCurrentIapId( |
|
621 static_cast<TUint>(lanServiceId), |
|
622 *coreIapData ); |
|
623 |
|
624 if ( ret != KErrNone ) |
|
625 { |
|
626 secondarySsidList.Close(); |
|
627 delete coreIapData; |
|
628 delete coreSsidList; |
|
629 aMessage.Complete( ret ); |
|
630 return; |
|
631 } |
|
632 |
|
633 // create mapping |
|
634 SRequestMapEntry mapEntry; |
|
635 mapEntry.iMessage = aMessage; |
|
636 mapEntry.iFunction = EJoinByProfileId; |
|
637 mapEntry.iRequestId = iRequestIdCounter++; |
|
638 mapEntry.iSessionId = aSessionId; |
|
639 mapEntry.iParam0 = coreIapData; |
|
640 mapEntry.iParam1 = coreSsidList; |
|
641 mapEntry.iParam2 = connectionStatus; |
|
642 iRequestMap.Append( mapEntry ); |
|
643 |
|
644 iCoreServer->connect( |
|
645 mapEntry.iRequestId, |
|
646 *coreIapData, |
|
647 *connectionStatus, |
|
648 coreSsidList ); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------- |
|
652 // CWlmServer::CancelConnect |
|
653 // --------------------------------------------------------- |
|
654 // |
|
655 void CWlmServer::CancelConnect( |
|
656 TUint /* aSessionId */, |
|
657 const RMessage2& aMessage ) |
|
658 { |
|
659 DEBUG( "CWlmServer::CancelConnect()" ); |
|
660 |
|
661 aMessage.Complete( KErrNone ); |
|
662 } |
|
663 |
|
664 // --------------------------------------------------------- |
|
665 // CWlmServer::GetCurrentBSSID |
|
666 // --------------------------------------------------------- |
|
667 // |
|
668 void CWlmServer::GetCurrentBSSID( |
|
669 TUint /* aSessionId */, |
|
670 const RMessage2& aMessage ) |
|
671 { |
|
672 DEBUG( "CWlmServer::GetCurrentBSSID()" ); |
|
673 |
|
674 core_mac_address_s coreBssid( ZERO_MAC_ADDR ); |
|
675 core_error_e ret = iCoreServer->get_current_bssid( coreBssid ); |
|
676 if ( ret != core_error_ok ) |
|
677 { |
|
678 DEBUG1( "CWlmServer::GetCurrentBSSID() - get_current_bssid() failed with %u", |
|
679 ret ); |
|
680 } |
|
681 |
|
682 TMacPckg bssid; |
|
683 TWlanConversionUtil::ConvertMacAddress( |
|
684 bssid.data, |
|
685 coreBssid ); |
|
686 TPckg<TMacPckg> outPckg( bssid ); |
|
687 aMessage.Write( 0, outPckg ); |
|
688 aMessage.Complete( |
|
689 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
690 } |
|
691 |
|
692 // --------------------------------------------------------- |
|
693 // CWlmServer::GetCurrentRCPI |
|
694 // --------------------------------------------------------- |
|
695 // |
|
696 void CWlmServer::GetCurrentRCPI( |
|
697 TUint aSessionId, |
|
698 const RMessage2& aMessage ) |
|
699 { |
|
700 DEBUG( "CWlmServer::GetCurrentRCPI()" ); |
|
701 |
|
702 if ( IsRoaming() ) |
|
703 { |
|
704 DEBUG1( "CWlmServer::GetCurrentRCPI() - roam in progress, returning a cached value (%u)", |
|
705 iPrevRcpiValue ); |
|
706 |
|
707 TPckg<TUint32> outPckg( iPrevRcpiValue ); |
|
708 aMessage.Write( 0, outPckg ); |
|
709 aMessage.Complete( KErrNone ); |
|
710 |
|
711 return; |
|
712 } |
|
713 |
|
714 // create mapping |
|
715 SRequestMapEntry mapEntry; |
|
716 mapEntry.iMessage = aMessage; |
|
717 mapEntry.iFunction = EGetCurrentRSSI; |
|
718 mapEntry.iRequestId = iRequestIdCounter++; |
|
719 mapEntry.iSessionId = aSessionId; |
|
720 TUint32* tmp = new TUint32; |
|
721 if( tmp == NULL ) |
|
722 { |
|
723 aMessage.Complete( KErrNoMemory ); |
|
724 return; |
|
725 } |
|
726 mapEntry.iParam0 = tmp; |
|
727 iRequestMap.Append( mapEntry ); |
|
728 |
|
729 // pass request to core |
|
730 iCoreServer->get_current_rcpi( |
|
731 mapEntry.iRequestId, |
|
732 *tmp ); |
|
733 } |
|
734 |
|
735 // --------------------------------------------------------- |
|
736 // CWlmServer::GetCurrentSSID |
|
737 // --------------------------------------------------------- |
|
738 // |
|
739 void CWlmServer::GetCurrentSSID( |
|
740 TUint /* aSessionId */, |
|
741 const RMessage2& aMessage ) |
|
742 { |
|
743 DEBUG( "CWlmServer::GetCurrentSSID()" ); |
|
744 |
|
745 core_ssid_s coreSsid( BROADCAST_SSID ); |
|
746 core_error_e ret = iCoreServer->get_current_ssid( coreSsid ); |
|
747 if ( ret != core_error_ok ) |
|
748 { |
|
749 DEBUG1( "CWlmServer::GetCurrentSSID() - get_current_ssid() failed with %u", |
|
750 ret ); |
|
751 } |
|
752 |
|
753 TSSID ssid = { 0 }; |
|
754 TWlanConversionUtil::ConvertSSID( |
|
755 ssid, |
|
756 coreSsid ); |
|
757 TPckg<TSSID> outPckg( ssid ); |
|
758 aMessage.Write( 0, outPckg ); |
|
759 aMessage.Complete( |
|
760 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------- |
|
764 // CWlmServer::GetCurrentSecurityMode |
|
765 // --------------------------------------------------------- |
|
766 // |
|
767 void CWlmServer::GetCurrentSecurityMode( |
|
768 TUint /* aSessionId */, |
|
769 const RMessage2& aMessage ) |
|
770 { |
|
771 DEBUG( "CWlmServer::GetCurrentSecurityMode()" ); |
|
772 |
|
773 core_connection_security_mode_e coreMode( core_connection_security_mode_open ); |
|
774 core_error_e ret = iCoreServer->get_current_security_mode( coreMode ); |
|
775 if ( ret != core_error_ok ) |
|
776 { |
|
777 DEBUG1( "CWlmServer::GetCurrentSecurityMode() - get_current_security_mode() failed with %u", |
|
778 ret ); |
|
779 } |
|
780 |
|
781 TWlanSecurity mode( |
|
782 TWlanConversionUtil::ConvertSecurityMode( coreMode ) ); |
|
783 TPckg<TWlanSecurity> outPckg( mode ); |
|
784 aMessage.Write( 0, outPckg ); |
|
785 aMessage.Complete( |
|
786 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
787 } |
|
788 |
|
789 // --------------------------------------------------------- |
|
790 // CWlmServer::AddBssidToRoguelist |
|
791 // --------------------------------------------------------- |
|
792 // |
|
793 void CWlmServer::AddBssidToRoguelist( |
|
794 TUint /* aSessionId */, |
|
795 const RMessage2& aMessage ) |
|
796 { |
|
797 DEBUG( "CWlmServer::AddBssidToRoguelist()" ); |
|
798 |
|
799 TMacAddress bssid( KZeroMacAddr ); |
|
800 TPckg<TMacAddress> inPckg( bssid ); |
|
801 TInt err( aMessage.Read( 0, inPckg ) ); |
|
802 if( err != KErrNone ) |
|
803 { |
|
804 aMessage.Complete( err ); |
|
805 return; |
|
806 } |
|
807 |
|
808 core_mac_address_s coreBssid( ZERO_MAC_ADDR ); |
|
809 TWlanConversionUtil::ConvertMacAddress( |
|
810 coreBssid, |
|
811 bssid ); |
|
812 |
|
813 core_error_e ret = iCoreServer->add_bssid_to_rogue_list( coreBssid ); |
|
814 if ( ret != core_error_ok ) |
|
815 { |
|
816 DEBUG1( "CWlmServer::AddBssidToRoguelist() - add_bssid_to_rogue_list() failed with %u", |
|
817 ret ); |
|
818 } |
|
819 |
|
820 aMessage.Complete( |
|
821 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
822 } |
|
823 |
|
824 // --------------------------------------------------------- |
|
825 // CWlmServer::UpdateRcpNotificationBoundary |
|
826 // --------------------------------------------------------- |
|
827 // |
|
828 void CWlmServer::UpdateRcpNotificationBoundary( |
|
829 TUint /* aSessionId */, |
|
830 const RMessage2& aMessage ) |
|
831 { |
|
832 DEBUG( "CWlmServer::UpdateRcpNotificationBoundary()" ); |
|
833 |
|
834 i32_t rcp_boundary = aMessage.Int0(); |
|
835 i32_t hysteresis = aMessage.Int1(); |
|
836 |
|
837 if ( rcp_boundary < 0 || rcp_boundary > MAX_RCP_BOUNDARY || |
|
838 hysteresis < 0 || hysteresis > MAX_HYSTERESIS ) |
|
839 { |
|
840 aMessage.Complete( KErrArgument ); |
|
841 return; |
|
842 } |
|
843 |
|
844 core_error_e ret = iCoreServer->set_rcp_level_notification_boundary( |
|
845 rcp_boundary, |
|
846 hysteresis ); |
|
847 if ( ret != core_error_ok ) |
|
848 { |
|
849 DEBUG1( "CWlmServer::UpdateRcpNotificationBoundary() - set_rcp_level_notification_boundary() failed with %u", |
|
850 ret ); |
|
851 } |
|
852 |
|
853 aMessage.Complete( |
|
854 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
855 } |
|
856 |
|
857 // --------------------------------------------------------- |
|
858 // CWlmServer::ConfigureMulticastGroup |
|
859 // --------------------------------------------------------- |
|
860 // |
|
861 void CWlmServer::ConfigureMulticastGroup( |
|
862 TUint /* aSessionId */, |
|
863 const RMessage2& aMessage ) |
|
864 { |
|
865 DEBUG( "CWlmServer::ConfigureMulticastGroup()" ); |
|
866 |
|
867 bool_t join; |
|
868 if( aMessage.Int1() == KSoIp6JoinGroup ) |
|
869 { |
|
870 join = true_t; |
|
871 } |
|
872 else |
|
873 { |
|
874 join = false_t; |
|
875 } |
|
876 |
|
877 TMacAddress adaptMac( KZeroMacAddr ); |
|
878 TPckg<TMacAddress> inPckg( adaptMac ); |
|
879 TInt ret( aMessage.Read( 0, inPckg ) ); |
|
880 if( ret != KErrNone ) |
|
881 { |
|
882 aMessage.Complete( ret ); |
|
883 return; |
|
884 } |
|
885 |
|
886 if( !IsGroupBitSet( adaptMac ) ) |
|
887 { |
|
888 aMessage.Complete( KErrArgument ); |
|
889 return; |
|
890 } |
|
891 |
|
892 if( iConnectionState == EWlanStateNotConnected ) |
|
893 { |
|
894 aMessage.Complete( KErrNotReady ); |
|
895 return; |
|
896 } |
|
897 |
|
898 core_mac_address_s core_mac; |
|
899 TWlanConversionUtil::ConvertMacAddress( core_mac, adaptMac ); |
|
900 |
|
901 core_error_e err = iCoreServer->configure_multicast_group( |
|
902 join, |
|
903 core_mac ); |
|
904 if ( err != core_error_ok ) |
|
905 { |
|
906 DEBUG1( "CWlmServer::ConfigureMulticastGroup() - configure_multicast_group() failed with %u", |
|
907 err ); |
|
908 } |
|
909 |
|
910 aMessage.Complete( |
|
911 TWlanConversionUtil::ConvertErrorCode( err ) ); |
|
912 } |
|
913 |
|
914 // --------------------------------------------------------- |
|
915 // CWlmServer::GetCurrentSystemMode |
|
916 // --------------------------------------------------------- |
|
917 // |
|
918 void CWlmServer::GetCurrentSystemMode( |
|
919 TUint /* aSessionId */, |
|
920 const RMessage2& aMessage ) |
|
921 { |
|
922 DEBUG( "CWlmServer::GetCurrentSystemMode()" ); |
|
923 |
|
924 TPckg<TWlanSystemMode> outPckg( iPlatform->GetCurrentSystemMode() ); |
|
925 TInt ret( aMessage.Write( 0, outPckg ) ); |
|
926 aMessage.Complete( ret ); |
|
927 } |
|
928 |
|
929 // --------------------------------------------------------- |
|
930 // CWlmServer::GetCurrentState |
|
931 // --------------------------------------------------------- |
|
932 // |
|
933 TWlanConnectionState CWlmServer::GetCurrentState() |
|
934 { |
|
935 DEBUG( "CWlmServer::GetCurrentState()" ); |
|
936 |
|
937 return iConnectionState; |
|
938 } |
|
939 |
|
940 // --------------------------------------------------------- |
|
941 // CWlmServer::GetConnectionState |
|
942 // --------------------------------------------------------- |
|
943 // |
|
944 void CWlmServer::GetConnectionState( |
|
945 TUint /* aSessionId */, |
|
946 const RMessage2& aMessage ) |
|
947 { |
|
948 DEBUG( "CWlmServer::GetConnectionState()" ); |
|
949 |
|
950 /** |
|
951 * Do not return EWlanStateSearchingAP to the clients. |
|
952 */ |
|
953 TWlanConnectionState state( iConnectionState ); |
|
954 if ( iConnectionState == EWlanStateSearchingAP ) |
|
955 { |
|
956 state = iPrevConnectionState; |
|
957 } |
|
958 |
|
959 TPckg<TWlanConnectionState> outPckg( state ); |
|
960 aMessage.Write( 0, outPckg ); |
|
961 aMessage.Complete( KErrNone ); |
|
962 } |
|
963 |
|
964 // --------------------------------------------------------- |
|
965 // CWlmServer::GetScanResult |
|
966 // --------------------------------------------------------- |
|
967 // |
|
968 void CWlmServer::GetScanResult( |
|
969 TUint aSessionId, |
|
970 const RMessage2& aMessage ) |
|
971 { |
|
972 DEBUG( "CWlmServer::GetScanResult()" ); |
|
973 |
|
974 // Read SSID argument |
|
975 TSSID ssid = { 0 }; |
|
976 TPckg<TSSID> inPckg( ssid ); |
|
977 if( aMessage.Read( 1, inPckg ) != KErrNone ) |
|
978 { |
|
979 DEBUG( "CWlmServer::GetScanResult() - unable to read SSID parameter" ); |
|
980 |
|
981 aMessage.Complete( KErrArgument ); |
|
982 |
|
983 return; |
|
984 } |
|
985 |
|
986 if( ssid.ssidLength > MAX_SSID_LEN ) |
|
987 { |
|
988 DEBUG1( "CWlmServer::GetScanResult() - invalid SSID length (%u)", |
|
989 ssid.ssidLength ); |
|
990 |
|
991 aMessage.Complete( KErrArgument ); |
|
992 |
|
993 return; |
|
994 } |
|
995 |
|
996 // Read cacheLifetime and maxDelay arguments |
|
997 TScanScheduling scanScheduling = { KWlmDefaultScanCacheLifetime, 0 }; |
|
998 TPckg<TScanScheduling> scanSchedulingBuf( scanScheduling ); |
|
999 if( aMessage.Read( 3, scanSchedulingBuf ) != KErrNone ) |
|
1000 { |
|
1001 DEBUG( "CWlmServer::GetScanResult() - unable to read lifetime/delay parameters" ); |
|
1002 |
|
1003 aMessage.Complete( KErrArgument ); |
|
1004 |
|
1005 return; |
|
1006 } |
|
1007 |
|
1008 // Check that parameters have valid ranges |
|
1009 CheckScanSchedulingParameters( |
|
1010 scanScheduling.cacheLifetime, |
|
1011 scanScheduling.maxDelay ); |
|
1012 |
|
1013 // Update the scan scheduling parameters to values that are going be used |
|
1014 aMessage.Write( 3, scanSchedulingBuf ); |
|
1015 |
|
1016 // Only check for valid cache if maxDelay is zero |
|
1017 if( scanScheduling.maxDelay == 0 ) |
|
1018 { |
|
1019 // If not direct scan, try getting cached results and settle for them |
|
1020 // if they exist |
|
1021 ScanList* cacheList = iCache->GetScanList( ( scanScheduling.cacheLifetime == 0 ? 1 : scanScheduling.cacheLifetime ) ); |
|
1022 if( !ssid.ssidLength && cacheList ) |
|
1023 { |
|
1024 // Just return cached results |
|
1025 |
|
1026 TDynamicScanList dynamicScanList; |
|
1027 dynamicScanList.count = cacheList->Count(); |
|
1028 dynamicScanList.size = cacheList->Size(); |
|
1029 |
|
1030 TPckg<TDynamicScanList> pckgDynamicScanList( dynamicScanList ); |
|
1031 TPtr8 ptrScanList( |
|
1032 cacheList->Data(), |
|
1033 cacheList->Size(), |
|
1034 cacheList->Size() ); |
|
1035 |
|
1036 DEBUG2( "CWlmServer::GetScanResult() - returning cached results, scan list count is %u, size is %u", |
|
1037 cacheList->Count(), cacheList->Size() ); |
|
1038 |
|
1039 aMessage.Write( 0, ptrScanList ); |
|
1040 aMessage.Write( 2, pckgDynamicScanList ); |
|
1041 aMessage.Complete( KErrNone ); |
|
1042 |
|
1043 return; |
|
1044 } |
|
1045 } |
|
1046 |
|
1047 // If direct scan, or cached results were too old, perform scan |
|
1048 core_ssid_s* coreSsid = new core_ssid_s; |
|
1049 if( !coreSsid ) |
|
1050 { |
|
1051 DEBUG( "CWlmServer::GetScanResult() - unable to instantiate core_ssid_s" ); |
|
1052 |
|
1053 aMessage.Complete( KErrNoMemory ); |
|
1054 |
|
1055 return; |
|
1056 } |
|
1057 |
|
1058 TWlanConversionUtil::ConvertSSID( |
|
1059 *coreSsid, |
|
1060 ssid ); |
|
1061 |
|
1062 ScanList* scanList = new ScanList( KWlmScanListMaxSize ); |
|
1063 if( !scanList ) |
|
1064 { |
|
1065 DEBUG( "CWlmServer::GetScanResult() - unable to instantiate ScanList" ); |
|
1066 |
|
1067 delete coreSsid; |
|
1068 aMessage.Complete( KErrNoMemory ); |
|
1069 |
|
1070 return; |
|
1071 } |
|
1072 |
|
1073 TTime* scanTime( NULL ); |
|
1074 if( scanScheduling.maxDelay != KWlmInfiniteScanDelay ) |
|
1075 { |
|
1076 scanTime = new TTime( |
|
1077 CalculateScanStartTime( scanScheduling.maxDelay ).Int64() ); |
|
1078 if( !scanTime ) |
|
1079 { |
|
1080 DEBUG( "CWlmServer::GetScanResult() - unable to instantiate TTime" ); |
|
1081 |
|
1082 delete coreSsid; |
|
1083 delete scanList; |
|
1084 aMessage.Complete( KErrNoMemory ); |
|
1085 |
|
1086 return; |
|
1087 } |
|
1088 } |
|
1089 #ifdef _DEBUG |
|
1090 else |
|
1091 { |
|
1092 DEBUG( "CWlmServer::GetScanResult() - Infinite maxDelay, request will not be triggering any scans" ); |
|
1093 } |
|
1094 |
|
1095 if( coreSsid->length ) |
|
1096 { |
|
1097 DEBUG1S( "CWlmServer::GetScanResult() - performing a direct scan with SSID: ", |
|
1098 coreSsid->length, &coreSsid->ssid[0] ); |
|
1099 } |
|
1100 else |
|
1101 { |
|
1102 DEBUG( "CWlmServer::GetScanResult() - performing a broadcast scan" ); |
|
1103 } |
|
1104 #endif // DEBUG |
|
1105 |
|
1106 // create mapping |
|
1107 SRequestMapEntry mapEntry; |
|
1108 mapEntry.iMessage = aMessage; |
|
1109 mapEntry.iFunction = EGetScanResults; |
|
1110 mapEntry.iRequestId = iRequestIdCounter++; |
|
1111 mapEntry.iSessionId = aSessionId; |
|
1112 mapEntry.iParam0 = scanList; |
|
1113 mapEntry.iParam1 = coreSsid; |
|
1114 mapEntry.iTime = scanTime; |
|
1115 iRequestMap.Append( mapEntry ); |
|
1116 |
|
1117 // Scan scheduling timer needs to be set again if this request needs the results earlier or |
|
1118 // if this is the only timed pending request |
|
1119 if( scanTime != NULL && ( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration ) ) |
|
1120 { |
|
1121 UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId ); |
|
1122 } |
|
1123 } |
|
1124 |
|
1125 // --------------------------------------------------------- |
|
1126 // CWlmServer::IsOnlyTimedScanRequestInRequestMap |
|
1127 // --------------------------------------------------------- |
|
1128 // |
|
1129 TBool CWlmServer::IsOnlyTimedScanRequestInRequestMap( |
|
1130 const SRequestMapEntry& aMapEntry ) const |
|
1131 { |
|
1132 DEBUG( "CWlmServer::IsOnlyTimedScanRequestInRequestMap()" ); |
|
1133 |
|
1134 // go through all the requests in the map |
|
1135 for(TInt index = 0; index < iRequestMap.Count(); index++) |
|
1136 { |
|
1137 // look for timed scan requests |
|
1138 if( IsPendingTimedScanRequest( index ) ) |
|
1139 { |
|
1140 // if the request ids don't match there are other scan requests |
|
1141 if( iRequestMap[index].iRequestId != aMapEntry.iRequestId ) |
|
1142 { |
|
1143 DEBUG( "CWlmServer::IsOnlyTimedScanRequestInRequestMap() - other timed scan requests found" ); |
|
1144 return EFalse; |
|
1145 } |
|
1146 } |
|
1147 } |
|
1148 |
|
1149 DEBUG( "CWlmServer::IsOnlyTimedScanRequestInRequestMap() - no other timed scan requests found" ); |
|
1150 |
|
1151 return ETrue; |
|
1152 } |
|
1153 |
|
1154 // --------------------------------------------------------- |
|
1155 // CWlmServer::CancelGetScanResult |
|
1156 // --------------------------------------------------------- |
|
1157 // |
|
1158 void CWlmServer::CancelGetScanResult( |
|
1159 TUint aSessionId, |
|
1160 const RMessage2& aMessage ) |
|
1161 { |
|
1162 DEBUG( "CWlmServer::CancelGetScanResult()" ); |
|
1163 |
|
1164 CancelExternalRequest( |
|
1165 aSessionId, |
|
1166 EGetScanResults ); |
|
1167 |
|
1168 aMessage.Complete( KErrNone ); |
|
1169 } |
|
1170 |
|
1171 // --------------------------------------------------------- |
|
1172 // CWlmServer::GetAvailableIaps |
|
1173 // --------------------------------------------------------- |
|
1174 // |
|
1175 void CWlmServer::GetAvailableIaps( |
|
1176 TUint aSessionId, |
|
1177 const RMessage2& aMessage ) |
|
1178 { |
|
1179 DEBUG( "CWlmServer::GetAvailableIaps()" ); |
|
1180 |
|
1181 // Read cacheLifetime and maxDelay arguments |
|
1182 TPckgBuf<TInt> cacheLifetimePckg( KWlmDefaultScanCacheLifetime ); |
|
1183 TPckgBuf<TUint> maxDelayPckg( 0 ); |
|
1184 if( aMessage.Read( 1, cacheLifetimePckg ) != KErrNone ) |
|
1185 { |
|
1186 DEBUG( "CWlmServer::GetAvailableIaps() - unable to read lifetime parameter" ); |
|
1187 |
|
1188 aMessage.Complete( KErrArgument ); |
|
1189 |
|
1190 return; |
|
1191 } |
|
1192 |
|
1193 if( aMessage.Read( 2, maxDelayPckg ) != KErrNone ) |
|
1194 { |
|
1195 DEBUG( "CWlmServer::GetAvailableIaps() - unable to read delay parameter" ); |
|
1196 |
|
1197 aMessage.Complete( KErrArgument ); |
|
1198 |
|
1199 return; |
|
1200 } |
|
1201 |
|
1202 // Check that parameters have valid ranges |
|
1203 CheckScanSchedulingParameters( |
|
1204 cacheLifetimePckg(), |
|
1205 maxDelayPckg() ); |
|
1206 |
|
1207 //Update the scan scheduling parameters to values that are going be used |
|
1208 aMessage.Write( 1, cacheLifetimePckg ); |
|
1209 aMessage.Write( 2, maxDelayPckg ); |
|
1210 |
|
1211 /** |
|
1212 * See if cached IAP availability information is available. |
|
1213 */ |
|
1214 RArray<TWlanLimitedIapData> iapList; |
|
1215 RArray<TUint>* list = iCache->AvailableIaps( |
|
1216 iapList, |
|
1217 ( cacheLifetimePckg() == 0 ? 1 : cacheLifetimePckg() ) ); |
|
1218 |
|
1219 // Only complete with valid cache if maxDelay is zero |
|
1220 if( list && maxDelayPckg() == 0 ) |
|
1221 { |
|
1222 |
|
1223 TWlmAvailableIaps tmp; |
|
1224 const TInt listCount( |
|
1225 Min( list->Count(), KWlmMaxAvailableIaps ) ); |
|
1226 |
|
1227 DEBUG1( "CWlmServer::GetAvailableIaps() - using cached IAP list, list contains %d IAP(s)", listCount ); |
|
1228 |
|
1229 TInt listIdx( 0 ); |
|
1230 |
|
1231 while( listIdx < listCount ) |
|
1232 { |
|
1233 tmp.iaps[ listIdx ] = (*list)[listIdx]; |
|
1234 ++listIdx; |
|
1235 } |
|
1236 tmp.count = listCount; |
|
1237 TPckg<TWlmAvailableIaps> outPckg( tmp ); |
|
1238 aMessage.Write( 0, outPckg ); |
|
1239 aMessage.Complete( KErrNone ); |
|
1240 iapList.Close(); |
|
1241 |
|
1242 return; |
|
1243 } |
|
1244 |
|
1245 /** |
|
1246 * If maxDelay is not infinite, background scanning isn't enabled |
|
1247 * and there are no WLAN IAPs defined, scanning isn't needed at all. |
|
1248 */ |
|
1249 if ( maxDelayPckg() != KWlmInfiniteScanDelay && |
|
1250 !iBgScanProvider->IsBgScanEnabled() && |
|
1251 !iapList.Count() ) |
|
1252 { |
|
1253 DEBUG( "CWlmServer::GetAvailableIaps() - no WLAN IAPs defined, skipping scanning" ); |
|
1254 |
|
1255 TWlmAvailableIaps tmp = { 0 }; |
|
1256 TPckg<TWlmAvailableIaps> outPckg( tmp ); |
|
1257 aMessage.Write( 0, outPckg ); |
|
1258 aMessage.Complete( KErrNone ); |
|
1259 iapList.Close(); |
|
1260 |
|
1261 return; |
|
1262 } |
|
1263 |
|
1264 // Create list for WLAN IAP data |
|
1265 core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>; |
|
1266 if( iapDataList == NULL ) |
|
1267 { |
|
1268 DEBUG( "CWlmServer::GetAvailableIaps() - unable to instance core_iap_data_s list" ); |
|
1269 |
|
1270 aMessage.Complete( KErrNoMemory ); |
|
1271 iapList.Close(); |
|
1272 |
|
1273 return; |
|
1274 } |
|
1275 |
|
1276 // Create list for secondary SSID data |
|
1277 core_type_list_c<core_ssid_entry_s>* iapSsidList = new core_type_list_c<core_ssid_entry_s>; |
|
1278 if ( iapSsidList == NULL ) |
|
1279 { |
|
1280 DEBUG( "CWlmServer::GetAvailableIaps() - unable to instance core_ssid_entry_s list" ); |
|
1281 |
|
1282 aMessage.Complete( KErrNoMemory ); |
|
1283 delete iapDataList; |
|
1284 iapList.Close(); |
|
1285 |
|
1286 return; |
|
1287 } |
|
1288 |
|
1289 // Convert IAP data |
|
1290 TInt ret = GetIapDataList( |
|
1291 *iapDataList, |
|
1292 *iapSsidList, |
|
1293 iapList ); |
|
1294 if ( ret != KErrNone ) |
|
1295 { |
|
1296 DEBUG1( "CWlmServer::GetAvailableIaps() - unable to convert IAP data (%d)", |
|
1297 ret ); |
|
1298 |
|
1299 aMessage.Complete( ret ); |
|
1300 delete iapDataList; |
|
1301 delete iapSsidList; |
|
1302 iapList.Close(); |
|
1303 |
|
1304 return; |
|
1305 } |
|
1306 |
|
1307 iapList.Close(); |
|
1308 |
|
1309 // Create output list |
|
1310 core_type_list_c<u32_t>* iapIdList = new core_type_list_c<u32_t>; |
|
1311 if( iapIdList == NULL ) |
|
1312 { |
|
1313 aMessage.Complete( KErrNoMemory ); |
|
1314 delete iapDataList; |
|
1315 delete iapSsidList; |
|
1316 return; |
|
1317 } |
|
1318 |
|
1319 // Create ScanList |
|
1320 ScanList* scanList = new ScanList( KWlmScanListMaxSize ); |
|
1321 if( scanList == NULL ) |
|
1322 { |
|
1323 aMessage.Complete( KErrNoMemory ); |
|
1324 delete iapDataList; |
|
1325 delete iapSsidList; |
|
1326 delete iapIdList; |
|
1327 return; |
|
1328 } |
|
1329 |
|
1330 TTime* scanTime( NULL ); |
|
1331 if( maxDelayPckg() != KWlmInfiniteScanDelay ) |
|
1332 { |
|
1333 scanTime = new TTime( |
|
1334 CalculateScanStartTime( maxDelayPckg() ).Int64() ); |
|
1335 if( !scanTime ) |
|
1336 { |
|
1337 DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TTime" ); |
|
1338 |
|
1339 aMessage.Complete( KErrNoMemory ); |
|
1340 delete iapDataList; |
|
1341 delete iapSsidList; |
|
1342 delete iapIdList; |
|
1343 delete scanList; |
|
1344 |
|
1345 return; |
|
1346 } |
|
1347 } |
|
1348 #ifdef _DEBUG |
|
1349 else |
|
1350 { |
|
1351 DEBUG( "CWlmServer::GetAvailableIaps() - Infinite maxDelay, request will not be triggering any scans" ); |
|
1352 } |
|
1353 #endif |
|
1354 |
|
1355 // create mapping |
|
1356 SRequestMapEntry mapEntry; |
|
1357 mapEntry.iMessage = aMessage; |
|
1358 mapEntry.iFunction = EGetAvailableIaps; |
|
1359 mapEntry.iRequestId = iRequestIdCounter++; |
|
1360 mapEntry.iSessionId = aSessionId; |
|
1361 mapEntry.iParam0 = iapDataList; |
|
1362 mapEntry.iParam1 = iapIdList; |
|
1363 mapEntry.iParam2 = scanList; |
|
1364 mapEntry.iParam3 = iapSsidList; |
|
1365 mapEntry.iTime = scanTime; |
|
1366 iRequestMap.Append( mapEntry ); |
|
1367 |
|
1368 // Scan scheduling timer needs to be set again if this request needs the results earlier or |
|
1369 // if this is the only timed pending request |
|
1370 if( scanTime != NULL && ( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration ) ) |
|
1371 { |
|
1372 UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId ); |
|
1373 } |
|
1374 } |
|
1375 |
|
1376 // --------------------------------------------------------- |
|
1377 // CWlmServer::CancelGetAvailableIaps |
|
1378 // --------------------------------------------------------- |
|
1379 // |
|
1380 void CWlmServer::CancelGetAvailableIaps( |
|
1381 TUint aSessionId, |
|
1382 const RMessage2& aMessage ) |
|
1383 { |
|
1384 DEBUG( "CWlmServer::CancelGetAvailableIaps()" ); |
|
1385 |
|
1386 CancelExternalRequest( |
|
1387 aSessionId, |
|
1388 EGetAvailableIaps ); |
|
1389 |
|
1390 aMessage.Complete( KErrNone ); |
|
1391 } |
|
1392 |
|
1393 // --------------------------------------------------------- |
|
1394 // CWlmServer::ReleaseComplete |
|
1395 // --------------------------------------------------------- |
|
1396 // |
|
1397 void CWlmServer::ReleaseComplete( |
|
1398 TUint aSessionId, |
|
1399 const RMessage2& aMessage ) |
|
1400 { |
|
1401 DEBUG( "CWlmServer::ReleaseComplete()" ); |
|
1402 |
|
1403 // Data pipe should now be disconnected |
|
1404 // -> safe to disconnect the management pipe. |
|
1405 |
|
1406 // create mapping |
|
1407 SRequestMapEntry mapEntry; |
|
1408 mapEntry.iMessage = aMessage; |
|
1409 mapEntry.iFunction = EReset; |
|
1410 mapEntry.iRequestId = iRequestIdCounter++; |
|
1411 mapEntry.iSessionId = aSessionId; |
|
1412 iRequestMap.Append( mapEntry ); |
|
1413 |
|
1414 // pass request to core |
|
1415 if( iPlatform->IsWlanDisabled() ) |
|
1416 { |
|
1417 // Disable will release a possible connection |
|
1418 iCoreServer->disable_wlan( mapEntry.iRequestId ); |
|
1419 } |
|
1420 else |
|
1421 { |
|
1422 iCoreServer->release( mapEntry.iRequestId ); |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 // --------------------------------------------------------- |
|
1427 // CWlmServer::NotifySessionCreated |
|
1428 // --------------------------------------------------------- |
|
1429 // |
|
1430 TUint CWlmServer::NotifySessionCreated() |
|
1431 { |
|
1432 DEBUG( "CWlmServer::NotifySessionCreated()" ); |
|
1433 ++iClientSessionCount; |
|
1434 |
|
1435 return ++iSessionIdCounter; |
|
1436 } |
|
1437 |
|
1438 // --------------------------------------------------------- |
|
1439 // CWlmServer::NotifySessionClosed |
|
1440 // --------------------------------------------------------- |
|
1441 // |
|
1442 void CWlmServer::NotifySessionClosed( |
|
1443 TUint aSessionId ) |
|
1444 { |
|
1445 DEBUG( "CWlmServer::NotifySessionClosed()" ); |
|
1446 for( TInt i( 0 ); i < iRequestMap.Count(); i++ ) |
|
1447 { |
|
1448 if( iRequestMap[i].iSessionId == aSessionId ) |
|
1449 { |
|
1450 DEBUG( "CWlmServer::NotifySessionClosed() - corresponding request found" ); |
|
1451 iRequestMap[i].iSessionId = 0; |
|
1452 } |
|
1453 } |
|
1454 |
|
1455 --iClientSessionCount; |
|
1456 } |
|
1457 |
|
1458 // --------------------------------------------------------- |
|
1459 // CWlmServer::NotifyChangedSettings |
|
1460 // --------------------------------------------------------- |
|
1461 // |
|
1462 void CWlmServer::NotifyChangedSettings( |
|
1463 TUint /* aSessionId */, |
|
1464 const RMessage2& aMessage ) |
|
1465 { |
|
1466 DEBUG( "CWlmServer::NotifyChangedSettings()" ); |
|
1467 |
|
1468 aMessage.Complete( |
|
1469 UpdateWlanSettings() ); |
|
1470 } |
|
1471 |
|
1472 // --------------------------------------------------------- |
|
1473 // CWlmServer::UpdateWlanSettings |
|
1474 // --------------------------------------------------------- |
|
1475 // |
|
1476 TInt CWlmServer::UpdateWlanSettings() |
|
1477 { |
|
1478 DEBUG( "CWlmServer::UpdateWlanSettings()" ); |
|
1479 |
|
1480 CWlanDeviceSettings::SWlanDeviceSettings settings = { 0 }; |
|
1481 TRAPD( err, GetWlanSettingsL( settings ) ); |
|
1482 if( err != KErrNone ) |
|
1483 { |
|
1484 DEBUG1( "CWlmServer::UpdateWlanSettings() - GetWlanSettingsL leaved with code %d", err ); |
|
1485 |
|
1486 return err; |
|
1487 } |
|
1488 |
|
1489 // Only if startup is complete, inform current settings to BgScan |
|
1490 if( iIsStartupComplete ) |
|
1491 { |
|
1492 DEBUG( "CWlmServer::UpdateWlanSettings() - notifying settings to BgScan provider" ); |
|
1493 iBgScanProviderSettings = MWlanBgScanProvider::TWlanBgScanSettings( settings.backgroundScanInterval, |
|
1494 settings.psmServerMode, |
|
1495 settings.bgScanPeakPeriodStart, |
|
1496 settings.bgScanPeakPeriodEnd, |
|
1497 settings.bgScanIntervalPeak, |
|
1498 settings.bgScanIntervalOffPeak ); |
|
1499 iBgScanProvider->NotifyChangedSettings( iBgScanProviderSettings ); |
|
1500 } |
|
1501 |
|
1502 // Keep cache lifetime for scan results up to date |
|
1503 iConfiguredCacheLifetime = settings.scanExpirationTimer; |
|
1504 |
|
1505 // Store power save enabled value |
|
1506 iPowerSaveEnabled = settings.powerMode; |
|
1507 |
|
1508 // Convert settings to core side struct |
|
1509 core_device_settings_s coreSettings; |
|
1510 TWlanConversionUtil::ConvertDeviceSettings( |
|
1511 coreSettings, |
|
1512 settings ); |
|
1513 |
|
1514 core_error_e ret = iCoreServer->update_device_settings( coreSettings ); |
|
1515 if( ret != core_error_ok ) |
|
1516 { |
|
1517 DEBUG1( "CWlmServer::UpdateWlanSettings() - update_device_settings() failed with %u", |
|
1518 ret ); |
|
1519 |
|
1520 return TWlanConversionUtil::ConvertErrorCode( ret ); |
|
1521 } |
|
1522 |
|
1523 // Store show broken power save note value |
|
1524 iShowBrokenPowerSaveNote = settings.showBrokenPowerSaveNote; |
|
1525 |
|
1526 DEBUG( "CWlmServer::UpdateWlanSettings() - returning" ); |
|
1527 |
|
1528 return KErrNone; |
|
1529 } |
|
1530 |
|
1531 // --------------------------------------------------------- |
|
1532 // CWlmServer::UpdateScanSchedulingTimer |
|
1533 // --------------------------------------------------------- |
|
1534 // |
|
1535 void CWlmServer::UpdateScanSchedulingTimer( |
|
1536 TTime aScanTime, |
|
1537 TUint aTriggeringRequestId ) |
|
1538 { |
|
1539 DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - aTriggeringRequestId = %u ", aTriggeringRequestId ); |
|
1540 |
|
1541 if( iCoreHandlingScanRequest ) |
|
1542 { |
|
1543 // Core is currently handling scanning, do not set the timer |
|
1544 DEBUG( "CWlmServer::UpdateScanSchedulingTimer() - core is currently handling scanning, do not set the timer" ); |
|
1545 |
|
1546 return; |
|
1547 } |
|
1548 |
|
1549 TTime timeNow; |
|
1550 timeNow.UniversalTime(); |
|
1551 |
|
1552 TTimeIntervalMicroSeconds difference( aScanTime.MicroSecondsFrom( timeNow ) ); |
|
1553 if( difference.Int64() < 0 ) |
|
1554 { |
|
1555 difference = TTimeIntervalMicroSeconds( 0 ); |
|
1556 } |
|
1557 TTimeIntervalMicroSeconds32 differenceMicroseconds( |
|
1558 difference.Int64() ); |
|
1559 |
|
1560 iScanSchedulingTimer->Cancel(); |
|
1561 iScanSchedulingTimerExpiration = aScanTime; |
|
1562 iRequestTriggeringScanning = aTriggeringRequestId; |
|
1563 TCallBack callback( ScanSchedulingTimerExpired, this ); |
|
1564 |
|
1565 DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - scheduling the timer to %u second(s)", |
|
1566 differenceMicroseconds.Int() / SECONDS_FROM_MICROSECONDS ); |
|
1567 |
|
1568 TTimeIntervalMicroSeconds32 intervalMicroseconds( KWlmMaxScanDelay * SECONDS_FROM_MICROSECONDS ); |
|
1569 |
|
1570 iScanSchedulingTimer->Start( |
|
1571 differenceMicroseconds, |
|
1572 intervalMicroseconds, |
|
1573 callback ); |
|
1574 |
|
1575 } |
|
1576 |
|
1577 // --------------------------------------------------------- |
|
1578 // CWlmServer::FindNextTimedScanSchedulingRequest |
|
1579 // --------------------------------------------------------- |
|
1580 // |
|
1581 TBool CWlmServer::FindNextTimedScanSchedulingRequest( |
|
1582 TUint& aTriggeringRequestIndex ) |
|
1583 { |
|
1584 DEBUG( "CWlmServer::FindNextTimedScanSchedulingRequest()" ); |
|
1585 |
|
1586 TBool pendingScanRequestsFound( EFalse ); |
|
1587 TTime closestTime = TTime( 0 ); |
|
1588 aTriggeringRequestIndex = 0; |
|
1589 |
|
1590 for(TInt i=0; i < iRequestMap.Count(); i++) |
|
1591 { |
|
1592 if( IsPendingTimedScanRequest( i ) ) |
|
1593 { |
|
1594 TTime* checkedTime = reinterpret_cast<TTime*>( iRequestMap[i].iTime ); |
|
1595 if( pendingScanRequestsFound == EFalse || closestTime > *checkedTime ) |
|
1596 { |
|
1597 closestTime = *checkedTime; |
|
1598 aTriggeringRequestIndex = i; |
|
1599 pendingScanRequestsFound = ETrue; |
|
1600 } |
|
1601 } |
|
1602 } |
|
1603 |
|
1604 if( pendingScanRequestsFound == EFalse ) |
|
1605 { |
|
1606 // clear the scan scheduling related variables |
|
1607 iRequestTriggeringScanning = KWlanIntCmdNull; |
|
1608 iScanSchedulingTimerExpiration = TTime( 0 ); |
|
1609 } |
|
1610 else |
|
1611 { |
|
1612 DEBUG1( "CWlmServer::FindNextTimedScanSchedulingRequest() - RequestIndex %u ", aTriggeringRequestIndex ); |
|
1613 } |
|
1614 |
|
1615 return pendingScanRequestsFound; |
|
1616 } |
|
1617 |
|
1618 // --------------------------------------------------------- |
|
1619 // CWlmServer::NotifyBackgroundScanDone |
|
1620 // --------------------------------------------------------- |
|
1621 // |
|
1622 void CWlmServer::NotifyBackgroundScanDone( |
|
1623 ScanList* aScanList, |
|
1624 core_type_list_c<u32_t>* aIapIdList ) |
|
1625 { |
|
1626 DEBUG( "CWlmServer::NotifyBackgroundScanDone()" ); |
|
1627 ASSERT( aScanList != NULL ); |
|
1628 ASSERT( aIapIdList != NULL ); |
|
1629 |
|
1630 // Unload the drivers immediately to conserve power. |
|
1631 if( !iPlatform->IsWlanDisabled() && |
|
1632 iConnectionState == EWlanStateNotConnected ) |
|
1633 { |
|
1634 iCoreServer->unload_drivers(); |
|
1635 } |
|
1636 |
|
1637 RArray<TWlanAvailableNetwork> networkList; |
|
1638 GetNetworkList( *aScanList, networkList ); |
|
1639 |
|
1640 // Update Cached results |
|
1641 iCache->UpdateScanList( aScanList ); |
|
1642 TBool newIaps( EFalse ); |
|
1643 TBool lostIaps( EFalse ); |
|
1644 iCache->UpdateAvailableNetworksList( |
|
1645 *aIapIdList, |
|
1646 networkList, |
|
1647 newIaps, |
|
1648 lostIaps ); |
|
1649 |
|
1650 networkList.Close(); |
|
1651 |
|
1652 UpdateAvailabilityInfo( |
|
1653 newIaps, |
|
1654 lostIaps, |
|
1655 aScanList->Count() != 0 ); |
|
1656 } |
|
1657 |
|
1658 // --------------------------------------------------------- |
|
1659 // |
|
1660 // Methods implementing abs_core_server_callback_c interface |
|
1661 // |
|
1662 // --------------------------------------------------------- |
|
1663 |
|
1664 // --------------------------------------------------------- |
|
1665 // CWlmServer::notify |
|
1666 // --------------------------------------------------------- |
|
1667 // |
|
1668 void CWlmServer::notify( |
|
1669 core_notification_e notification, |
|
1670 int_t data_len, |
|
1671 const u8_t* data ) |
|
1672 { |
|
1673 DEBUG2( "CWlmServer::notify (notif == %d, data_len == %u)", notification, data_len ); |
|
1674 |
|
1675 // Convert notification type |
|
1676 TWlmNotify amNotification |
|
1677 = TWlanConversionUtil::ConvertNotificationType( notification ); |
|
1678 |
|
1679 // Convert notification parameter |
|
1680 TBuf8<KMaxNotificationLength> buf; |
|
1681 if ( data_len ) |
|
1682 { |
|
1683 buf.Copy( data, data_len ); |
|
1684 |
|
1685 if ( amNotification == EWlmNotifyConnectionStateChanged ) |
|
1686 { |
|
1687 // 1st byte of notification data corresponds to connection state, |
|
1688 // which must also be converted. |
|
1689 // -> Data changes -> it must be copied |
|
1690 core_connection_state_e state |
|
1691 = static_cast<core_connection_state_e>( data[0] ); |
|
1692 buf[0] = static_cast<u8_t>( |
|
1693 TWlanConversionUtil::ConvertConnectionState( state ) ); |
|
1694 } |
|
1695 else if ( amNotification == EWlmNotifyTransmitPowerChanged ) |
|
1696 { |
|
1697 // Core uses dBm values internally, the value must be converted |
|
1698 // to mW. |
|
1699 const u32_t* value |
|
1700 = reinterpret_cast<const u32_t*>( &data[0] ); |
|
1701 TUint32 retValue |
|
1702 = TWlanConversionUtil::ConvertDecibelToMilliWatts( *value ); |
|
1703 buf.Copy( reinterpret_cast<TUint8*>( &retValue ), sizeof ( retValue ) ); |
|
1704 } |
|
1705 else if( amNotification == EWlmNotifyRcpChanged ) |
|
1706 { |
|
1707 // Data contains: |
|
1708 // 1st byte == RCP Class |
|
1709 // 2nd byte == RCP value |
|
1710 // (value is conveyed over client/server IF as 1 byte value) |
|
1711 core_rcp_class_e rcpClass = static_cast<core_rcp_class_e>( data[0] ); |
|
1712 buf[0] = static_cast<u8_t>( |
|
1713 TWlanConversionUtil::ConvertRcpClass( rcpClass ) ); |
|
1714 } |
|
1715 else if ( amNotification == EWlmNotifyTrafficStreamStatusChanged ) |
|
1716 { |
|
1717 /** |
|
1718 * The first four bytes of notification data is the stream ID, |
|
1719 * which can be passed unmodified. The fifth byte is the status |
|
1720 * of the stream, which needs to be converted. |
|
1721 */ |
|
1722 core_traffic_stream_status_e status |
|
1723 = static_cast<core_traffic_stream_status_e>( data[4] ); |
|
1724 buf[4] = static_cast<u8_t>( |
|
1725 TWlanConversionUtil::ConvertTrafficStreamStatus( status ) ); |
|
1726 } |
|
1727 else if( amNotification == EWlmNotifyAccessPointInfoChanged ) |
|
1728 { |
|
1729 /** |
|
1730 * The core data structure has to be converted to a corresponding |
|
1731 * adaptation type. |
|
1732 */ |
|
1733 const core_ap_information_s* info = |
|
1734 reinterpret_cast<const core_ap_information_s*>( &data[0] ); |
|
1735 |
|
1736 TWlanAccessPointInfo apInfo; |
|
1737 TWlanConversionUtil::ConvertApInformation( |
|
1738 apInfo, |
|
1739 *info ); |
|
1740 buf.Copy( |
|
1741 reinterpret_cast<TUint8*>( &apInfo ), |
|
1742 sizeof ( apInfo ) ); |
|
1743 } |
|
1744 else if( amNotification == EWlmNotifyAcTrafficModeChanged ) |
|
1745 { |
|
1746 core_access_class_e accessClass |
|
1747 = static_cast<core_access_class_e>( data[0] ); |
|
1748 core_access_class_traffic_mode_e trafficMode |
|
1749 = static_cast<core_access_class_traffic_mode_e>( data[1] ); |
|
1750 buf[0] = static_cast<u8_t>( |
|
1751 TWlanConversionUtil::ConvertAccessClass( accessClass ) ); |
|
1752 buf[1] = static_cast<u8_t>( |
|
1753 TWlanConversionUtil::ConvertTrafficMode( trafficMode ) ); |
|
1754 } |
|
1755 else if( amNotification == EWlmNotifyAcTrafficStatusChanged ) |
|
1756 { |
|
1757 core_access_class_e accessClass |
|
1758 = static_cast<core_access_class_e>( data[0] ); |
|
1759 core_access_class_traffic_status_e trafficStatus |
|
1760 = static_cast<core_access_class_traffic_status_e>( data[1] ); |
|
1761 buf[0] = static_cast<u8_t>( |
|
1762 TWlanConversionUtil::ConvertAccessClass( accessClass ) ); |
|
1763 buf[1] = static_cast<u8_t>( |
|
1764 TWlanConversionUtil::ConvertTrafficStatus( trafficStatus ) ); |
|
1765 } |
|
1766 } |
|
1767 |
|
1768 // Notify subscribees |
|
1769 for ( TInt i = 0; i < iNotificationArray.Count(); i++ ) |
|
1770 { |
|
1771 iNotificationArray[i]->AddNotification( amNotification, buf ); |
|
1772 } |
|
1773 |
|
1774 // Handle internal state changes / reactions |
|
1775 switch ( amNotification ) |
|
1776 { |
|
1777 case EWlmNotifyConnectionStateChanged: |
|
1778 { |
|
1779 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyConnectionStateChanged<ind> "); |
|
1780 // Cache the state to adaptation side member variable. |
|
1781 if ( iConnectionState != static_cast<TWlanConnectionState>( buf[0] ) ) |
|
1782 { |
|
1783 iPrevConnectionState = iConnectionState; |
|
1784 } |
|
1785 iConnectionState = static_cast<TWlanConnectionState>( buf[0] ); |
|
1786 |
|
1787 switch ( iConnectionState ) |
|
1788 { |
|
1789 case EWlanStateNotConnected: |
|
1790 DEBUG( "CWlmServer::notify() - STATE: EWlanStateNotConnected" ); |
|
1791 iIsRoaming = EFalse; |
|
1792 |
|
1793 // set icon to "not available" |
|
1794 SetIconState( EWlmIconStatusNotAvailable ); |
|
1795 |
|
1796 // if background scan is on, this call will cause a background scan |
|
1797 // when the background scan is completed, the icon is updated |
|
1798 iBgScanProvider->NotConnected(); |
|
1799 |
|
1800 if ( iBrokenPowerSaveNotifierWaiter->IsActive() ) |
|
1801 { |
|
1802 // cancelling the notifier will cause the iBrokenPowerSaveNotifierWaiter |
|
1803 // to be cancelled as well |
|
1804 iBrokenPowerSaveNotifier.CancelNotifier( KUidWlanPowerSaveTestNote ); |
|
1805 } |
|
1806 break; |
|
1807 case EWlanStateInfrastructure: |
|
1808 DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" ); |
|
1809 iIsRoaming = EFalse; |
|
1810 SetIconState( EWlmIconStatusConnected ); |
|
1811 break; |
|
1812 case EWlanStateSearchingAP: |
|
1813 DEBUG( "CWlmServer::notify() - STATE: EWlanStateSearchingAP" ); |
|
1814 iIsRoaming = ETrue; |
|
1815 break; |
|
1816 case EWlanStateIBSS: |
|
1817 DEBUG( "CWlmServer::notify() - STATE: EWlanStateIBSS" ); |
|
1818 iIsRoaming = EFalse; |
|
1819 // Core separates adhoc mode to secure(WEP) and non-secure. |
|
1820 // set icon according to this |
|
1821 if( static_cast<core_connection_state_e>( data[0] ) |
|
1822 == core_connection_state_secureibss ) |
|
1823 { |
|
1824 SetIconState( EWlmIconStatusConnectedSecure ); |
|
1825 } |
|
1826 else |
|
1827 { |
|
1828 SetIconState( EWlmIconStatusConnected ); |
|
1829 } |
|
1830 break; |
|
1831 case EWlanStateSecureInfra: |
|
1832 DEBUG( "CWlmServer::notify() - STATE: EWlanStateSecureInfra" ); |
|
1833 iIsRoaming = EFalse; |
|
1834 SetIconState( EWlmIconStatusConnectedSecure ); |
|
1835 break; |
|
1836 case EConnectionStateUnknown: |
|
1837 DEBUG( "CWlmServer::notify() - STATE: EConnectionStateUnknown" ); |
|
1838 break; |
|
1839 default: |
|
1840 break; |
|
1841 } |
|
1842 break; |
|
1843 } |
|
1844 case EWlmNotifyBssidChanged: |
|
1845 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyBssidChanged<ind>" ); |
|
1846 break; |
|
1847 case EWlmNotifyBssLost: |
|
1848 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyBssLost<ind>" ); |
|
1849 iIsRoaming = ETrue; |
|
1850 break; |
|
1851 case EWlmNotifyBssRegained: |
|
1852 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyBssRegained<ind>" ); |
|
1853 break; |
|
1854 case EWlmNotifyRcpiRoamAttemptStarted: |
|
1855 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyRcpiRoamAttemptStarted<ind>" ); |
|
1856 iIsRoaming = ETrue; |
|
1857 break; |
|
1858 case EWlmNotifyRcpiRoamAttemptCompleted: |
|
1859 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyRcpiRoamAttemptCompleted<ind>" ); |
|
1860 iIsRoaming = EFalse; |
|
1861 break; |
|
1862 case EWlmNotifyAcTrafficModeChanged: |
|
1863 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficModeChanged<ind>" ); |
|
1864 break; |
|
1865 case EWlmNotifyAcTrafficStatusChanged: |
|
1866 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficStatusChanged<ind>" ); |
|
1867 break; |
|
1868 case EWlmNotifyBrokenPowerSaveTestFailed: |
|
1869 DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyBrokenPowerSaveTestFailed<ind>" ); |
|
1870 |
|
1871 DEBUG1( "CWlmServer::notify() - iShowBrokenPowerSaveNote: %d", |
|
1872 static_cast<TInt>( iShowBrokenPowerSaveNote ) ); |
|
1873 |
|
1874 if ( iShowBrokenPowerSaveNote ) |
|
1875 { |
|
1876 if ( !iBrokenPowerSaveNotifierWaiter->IsActive() ) |
|
1877 { |
|
1878 TInt err = iBrokenPowerSaveNotifier.Connect(); |
|
1879 DEBUG1( "CWlmServer::notify() - iNotifier.Connect() returned %d", err ); |
|
1880 if ( err == KErrNone ) |
|
1881 { |
|
1882 iBrokenPowerSaveNotifier.StartNotifierAndGetResponse( iBrokenPowerSaveNotifierWaiter->RequestStatus(), |
|
1883 KUidWlanPowerSaveTestNote, KNullDesC8(), iBrokenPowerSaveNotifierReply ); |
|
1884 |
|
1885 iBrokenPowerSaveNotifierWaiter->IssueRequest(); |
|
1886 } |
|
1887 } |
|
1888 #ifdef _DEBUG |
|
1889 else |
|
1890 { |
|
1891 DEBUG( "CWlmServer::notify() - Notifier already active on the screen" ); |
|
1892 } |
|
1893 #endif |
|
1894 } |
|
1895 break; |
|
1896 default: |
|
1897 break; |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 // --------------------------------------------------------- |
|
1902 // CWlmServer::BrokenPowerSaveNoteClosed |
|
1903 // --------------------------------------------------------- |
|
1904 // |
|
1905 TInt CWlmServer::HandleBrokenPowerSaveNoteClosed( |
|
1906 TAny *aThisPtr ) |
|
1907 { |
|
1908 DEBUG( "CWlmServer::HandleBrokenPowerSaveNoteClosed()" ); |
|
1909 |
|
1910 CWlmServer* self = static_cast<CWlmServer*>( aThisPtr ); |
|
1911 |
|
1912 ASSERT( self ); |
|
1913 ASSERT( self->iBrokenPowerSaveNotifierWaiter ); |
|
1914 |
|
1915 // close the notifier |
|
1916 self->iBrokenPowerSaveNotifier.Close(); |
|
1917 |
|
1918 // check the request's completion status |
|
1919 TInt err = self->iBrokenPowerSaveNotifierWaiter->RequestStatus().Int(); |
|
1920 switch ( err ) |
|
1921 { |
|
1922 case KErrNotFound: |
|
1923 { |
|
1924 DEBUG( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - Notifier not found, returning" ); |
|
1925 return err; |
|
1926 } |
|
1927 case KErrCancel: |
|
1928 { |
|
1929 DEBUG( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - Notifier cancelled, returning" ); |
|
1930 return err; |
|
1931 } |
|
1932 default: |
|
1933 { |
|
1934 // flow through |
|
1935 } |
|
1936 } |
|
1937 |
|
1938 self->iShowBrokenPowerSaveNote = self->iBrokenPowerSaveNotifierReply() ? EFalse : ETrue; |
|
1939 |
|
1940 // re-use err variable |
|
1941 TRAP( err, self->StoreWlanCenRepKeyValueL( KWlanShowBrokenPowerSaveNote, self->iShowBrokenPowerSaveNote ) ); |
|
1942 if ( err != KErrNone ) |
|
1943 { |
|
1944 DEBUG1( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - failed to update CenRep, error code %d", err ); |
|
1945 return err; |
|
1946 } |
|
1947 |
|
1948 DEBUG1( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - iShowBrokenPowerSaveNote value (%d) stored to CenRep", |
|
1949 static_cast<TInt>( self->iShowBrokenPowerSaveNote ) ); |
|
1950 |
|
1951 return err; |
|
1952 } |
|
1953 |
|
1954 // --------------------------------------------------------- |
|
1955 // CWlmServer::NotifyChangedPsmSrvMode |
|
1956 // --------------------------------------------------------- |
|
1957 // |
|
1958 void CWlmServer::NotifyChangedPsmSrvMode( |
|
1959 TUint /* aSessionId */, |
|
1960 const RMessage2& aMessage ) |
|
1961 { |
|
1962 DEBUG( "CWlmServer::NotifyChangedPsmSrvMode()" ); |
|
1963 |
|
1964 TInt mode( aMessage.Int0() ); |
|
1965 TInt err( KErrNone ); |
|
1966 |
|
1967 TRAP( err, StoreWlanCenRepKeyValueL( KWlanPsmSrvMode, mode ) ); |
|
1968 if ( err != KErrNone ) |
|
1969 { |
|
1970 DEBUG1( "CWlmServer::NotifyChangedPsmSrvMode() - failed to update CenRep, error code %d", err ); |
|
1971 } |
|
1972 |
|
1973 DEBUG1( "CWlmServer::NotifyChangedPsmSrvMode() - mode %i", |
|
1974 mode ); |
|
1975 |
|
1976 aMessage.Complete( err ); |
|
1977 |
|
1978 UpdateWlanSettings(); |
|
1979 |
|
1980 } |
|
1981 |
|
1982 // --------------------------------------------------------- |
|
1983 // CWlmServer::StoreWlanCenRepKeyValue |
|
1984 // --------------------------------------------------------- |
|
1985 // |
|
1986 void CWlmServer::StoreWlanCenRepKeyValueL( const TUint32 aKey, const TInt aValue ) const |
|
1987 { |
|
1988 DEBUG( "CWlmServer::StoreWlanCenRepKeyValueL()" ); |
|
1989 |
|
1990 CWlanDeviceSettings* db = CWlanDeviceSettings::NewL(); |
|
1991 CleanupStack::PushL( db ); |
|
1992 |
|
1993 // Write setting |
|
1994 db->WriteCenRepKeyL( aKey, aValue ); |
|
1995 |
|
1996 CleanupStack::PopAndDestroy( db ); |
|
1997 db = NULL; |
|
1998 |
|
1999 } |
|
2000 |
|
2001 // --------------------------------------------------------- |
|
2002 // CWlmServer::SetCachedRegion |
|
2003 // --------------------------------------------------------- |
|
2004 // |
|
2005 void CWlmServer::SetCachedRegion( |
|
2006 TUint32 region, |
|
2007 TInt32 timestamp ) |
|
2008 { |
|
2009 DEBUG( "CWlmServer::SetCachedRegion()" ); |
|
2010 |
|
2011 if ( region == 0 || timestamp == 0 ) |
|
2012 { |
|
2013 // cached results do not exist -> iRegion remains in its original value |
|
2014 return; |
|
2015 } |
|
2016 |
|
2017 TTime currentTime(0); |
|
2018 TTimeIntervalHours difference(0); |
|
2019 TInt64 timestampInt64; |
|
2020 |
|
2021 currentTime.UniversalTime(); |
|
2022 timestampInt64 = static_cast<TInt64>(timestamp) * KWlmTimestampInCenrep; // timestamp is in minutes in CenRep |
|
2023 |
|
2024 TTime timestampMicroseconds(timestampInt64); |
|
2025 |
|
2026 TInt overflow = currentTime.HoursFrom( timestampMicroseconds, difference ); |
|
2027 if ( Abs( difference.Int() ) >= KWlmDomainInfoExpire || overflow ) |
|
2028 { |
|
2029 DEBUG( "CWlmServer::SetCachedRegion() - cached results are too old, region information is not changed" ); |
|
2030 } |
|
2031 else if ( Abs( difference.Int()) < KWlmDomainInfoExpire ) |
|
2032 { |
|
2033 DEBUG( "CWlmServer::SetCachedRegion() - cached results are valid, they are taken into use" ); |
|
2034 if ( region == KWlmRegionETSI) |
|
2035 { |
|
2036 iRegion = EETSI; |
|
2037 DEBUG( "CWlmServer::SetCachedRegion() - Region is ETSI" ); |
|
2038 } |
|
2039 else |
|
2040 { |
|
2041 iRegion = EFCC; |
|
2042 DEBUG( "CWlmServer::SetCachedRegion() - Region is FCC" ); |
|
2043 } |
|
2044 iTimeofDomainQuery = timestampMicroseconds; |
|
2045 } |
|
2046 } |
|
2047 |
|
2048 |
|
2049 // --------------------------------------------------------- |
|
2050 // CWlmServer::store_ap_country_info |
|
2051 // --------------------------------------------------------- |
|
2052 // |
|
2053 void CWlmServer::store_ap_country_info( |
|
2054 u32_t request_id, |
|
2055 const core_wlan_region_e& found_region, |
|
2056 bool_t inconsistent_info ) |
|
2057 { |
|
2058 DEBUG( "CWlmServer::store_ap_country_info()" ); |
|
2059 |
|
2060 iRegion = TWlanConversionUtil::ConvertRegion( found_region ); |
|
2061 |
|
2062 // Write the WLAN region and timestamp to CenRep if the country information from APs was not inconsistent |
|
2063 if ( !inconsistent_info ) |
|
2064 { |
|
2065 iTimeofDomainQuery.UniversalTime(); |
|
2066 |
|
2067 TInt region( KWlmRegionFCC ); |
|
2068 if ( iRegion == EETSI ) |
|
2069 { |
|
2070 region = KWlmRegionETSI; |
|
2071 } |
|
2072 |
|
2073 TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, region )); |
|
2074 if ( ret == KErrNone ) |
|
2075 { |
|
2076 TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) )); |
|
2077 if ( ret == KErrNone ) |
|
2078 { |
|
2079 DEBUG1( "CWlmServer::regulatory_domain() - stored regulatory domain is 0x%02X ", iRegion ); |
|
2080 } |
|
2081 else |
|
2082 { |
|
2083 DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region timestamp leaved with code %d,", ret ); |
|
2084 } |
|
2085 } |
|
2086 else |
|
2087 { |
|
2088 DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region leaved with code %d,", ret ); |
|
2089 } |
|
2090 } |
|
2091 // If the APs country information was inconsistent then region is selected to be ETSI |
|
2092 else |
|
2093 { |
|
2094 iRegion = EETSI; |
|
2095 iTimeofDomainQuery.UniversalTime(); |
|
2096 |
|
2097 DEBUG1( "CWlmServer::store_ap_country_info() - regulatory domain is 0x%02X", iRegion ); |
|
2098 } |
|
2099 |
|
2100 |
|
2101 // Set timers to notice if system time is changed |
|
2102 iPlatform->InitializeSystemTimeHandler(); |
|
2103 |
|
2104 iCoreAsynchCbId = request_id; |
|
2105 iCoreAsynchCbStatus = core_error_ok; |
|
2106 iCoreAsynchCb->CallBack(); |
|
2107 |
|
2108 } |
|
2109 |
|
2110 // --------------------------------------------------------- |
|
2111 // CWlmServer::get_regulatory_domain |
|
2112 // --------------------------------------------------------- |
|
2113 // |
|
2114 void CWlmServer::get_regulatory_domain( |
|
2115 u32_t request_id, |
|
2116 core_wlan_region_e& region, |
|
2117 #ifndef __WINS__ |
|
2118 bool_t& mcc_known ) |
|
2119 #else |
|
2120 bool_t& /* mcc_known */ ) |
|
2121 #endif // __WINS__ |
|
2122 { |
|
2123 DEBUG( "CWlmServer::regulatory_domain()" ); |
|
2124 |
|
2125 ASSERT( !iCoreAsynchCbId ); |
|
2126 |
|
2127 #ifndef __WINS__ |
|
2128 TTime currentTime(0); |
|
2129 TTimeIntervalHours difference(0); |
|
2130 TUint mcc( 0 ); |
|
2131 |
|
2132 currentTime.UniversalTime(); |
|
2133 mcc_known = false_t; |
|
2134 |
|
2135 TInt overflow = currentTime.HoursFrom( iTimeofDomainQuery, difference ); |
|
2136 if ( Abs( difference.Int() ) >= KWlmDomainInfoExpire || overflow ) |
|
2137 { |
|
2138 DEBUG( "CWlmServer::regulatory_domain() - cache is not valid, querying MCC" ); |
|
2139 iRegion = EETSI; |
|
2140 |
|
2141 // Query the MCC of the currently used operator. |
|
2142 TRAPD( ret, iPlatform->GetCurrentOperatorMccL( mcc ) ); |
|
2143 if ( ret == KErrNone && |
|
2144 mcc ) |
|
2145 { |
|
2146 DEBUG1( "CWlmServer::regulatory_domain() - MCC is %u", mcc ); |
|
2147 |
|
2148 mcc_known = true_t; |
|
2149 iTimeofDomainQuery.UniversalTime(); |
|
2150 |
|
2151 for ( TUint i(0); i < KWlmOperatorMccNATableLength; i++ ) |
|
2152 { |
|
2153 if ( mcc == KWlmOperatorMccNATable[i] ) |
|
2154 { |
|
2155 DEBUG( "CWlmServer::regulatory_domain() - MCC matches a US MCC" ); |
|
2156 iRegion = EFCC; |
|
2157 break; |
|
2158 } |
|
2159 } |
|
2160 // Write the WLAN region and timestamp to CenRep |
|
2161 TInt wlanRegion( KWlmRegionFCC ); |
|
2162 if ( iRegion == EETSI ) |
|
2163 { |
|
2164 wlanRegion = KWlmRegionETSI; |
|
2165 } |
|
2166 |
|
2167 TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, wlanRegion )); |
|
2168 if ( ret == KErrNone ) |
|
2169 { |
|
2170 TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) )); |
|
2171 if ( ret == KErrNone ) |
|
2172 { |
|
2173 DEBUG1( "CWlmServer::regulatory_domain() - stored regulatory domain is 0x%02X ", iRegion ); |
|
2174 } |
|
2175 else |
|
2176 { |
|
2177 DEBUG1( "CWlmServer::regulatory_domain() - attempt to store timestamp leaved with code %d,", ret ); |
|
2178 } |
|
2179 } |
|
2180 else |
|
2181 { |
|
2182 DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region leaved with code %d,", ret ); |
|
2183 } |
|
2184 |
|
2185 // Set timers to notice if system time is changed |
|
2186 iPlatform->InitializeSystemTimeHandler(); |
|
2187 |
|
2188 } |
|
2189 else |
|
2190 { |
|
2191 DEBUG1( "CWlmServer::regulatory_domain() - GetCurrentOperatorMccL leaved with code %d,", ret ); |
|
2192 iRegion = EFCC; |
|
2193 } |
|
2194 } |
|
2195 else if ( Abs( difference.Int()) < KWlmDomainInfoExpire ) |
|
2196 { |
|
2197 DEBUG( "CWlmServer::regulatory_domain() - cache valid, querying MCC" ); |
|
2198 |
|
2199 TWlanRegion currentRegion = EETSI; |
|
2200 |
|
2201 // Query the MCC of the currently used operator. |
|
2202 TRAPD( ret, iPlatform->GetCurrentOperatorMccL( mcc ) ); |
|
2203 if ( ret == KErrNone && |
|
2204 mcc ) |
|
2205 { |
|
2206 DEBUG1( "CWlmServer::regulatory_domain() - MCC is %u", mcc ); |
|
2207 |
|
2208 mcc_known = true_t; |
|
2209 iTimeofDomainQuery.UniversalTime(); |
|
2210 |
|
2211 for ( TUint i(0); i < KWlmOperatorMccNATableLength; i++ ) |
|
2212 { |
|
2213 if ( mcc == KWlmOperatorMccNATable[i] ) |
|
2214 { |
|
2215 DEBUG( "CWlmServer::regulatory_domain() - MCC matches a US MCC" ); |
|
2216 currentRegion = EFCC; |
|
2217 break; |
|
2218 } |
|
2219 } |
|
2220 |
|
2221 /* WLAN region is stored to CenRep only if it has changed, because otherwise |
|
2222 * this would cause CenRep to be written always when the drivers are loaded. |
|
2223 */ |
|
2224 if ( iRegion != currentRegion ) |
|
2225 { |
|
2226 iRegion = currentRegion; |
|
2227 |
|
2228 // Write the WLAN region and timestamp to CenRep |
|
2229 TInt wlanRegion( KWlmRegionFCC ); |
|
2230 if ( iRegion == EETSI ) |
|
2231 { |
|
2232 wlanRegion = KWlmRegionETSI; |
|
2233 } |
|
2234 |
|
2235 TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, wlanRegion )); |
|
2236 if ( ret == KErrNone ) |
|
2237 { |
|
2238 TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) )); |
|
2239 if ( ret == KErrNone ) |
|
2240 { |
|
2241 DEBUG1( "CWlmServer::regulatory_domain() - stored regulatory domain is 0x%02X ", iRegion ); |
|
2242 } |
|
2243 else |
|
2244 { |
|
2245 DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region timestamp leaved with code %d,", ret ); |
|
2246 } |
|
2247 } |
|
2248 else |
|
2249 { |
|
2250 DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region leaved with code %d,", ret ); |
|
2251 } |
|
2252 |
|
2253 // Set timers to notice if system time is changed |
|
2254 iPlatform->InitializeSystemTimeHandler(); |
|
2255 |
|
2256 } |
|
2257 else |
|
2258 { |
|
2259 iRegion = currentRegion; |
|
2260 } |
|
2261 |
|
2262 } |
|
2263 else |
|
2264 { |
|
2265 DEBUG1( "CWlmServer::regulatory_domain() - GetCurrentOperatorMccL leaved with code %d,", ret ); |
|
2266 mcc_known = true_t; |
|
2267 } |
|
2268 } |
|
2269 |
|
2270 DEBUG1( "CWlmServer::regulatory_domain() - regulatory domain is 0x%02X", iRegion ); |
|
2271 |
|
2272 region = TWlanConversionUtil::ConvertRegion( iRegion ); |
|
2273 #else // __WINS__ |
|
2274 region = core_wlan_region_fcc; |
|
2275 #endif // __WINS__ |
|
2276 |
|
2277 iCoreAsynchCbId = request_id; |
|
2278 iCoreAsynchCbStatus = core_error_ok; |
|
2279 iCoreAsynchCb->CallBack(); |
|
2280 } |
|
2281 |
|
2282 // --------------------------------------------------------- |
|
2283 // CWlmServer::request_complete |
|
2284 // --------------------------------------------------------- |
|
2285 // |
|
2286 void CWlmServer::request_complete( |
|
2287 u32_t request_id, |
|
2288 core_error_e status ) |
|
2289 { |
|
2290 DEBUG2( "CWlmServer::request_complete(%u, %d)", request_id, status ); |
|
2291 |
|
2292 #ifdef _DEBUG |
|
2293 TInt requestMapCount( iRequestMap.Count() ); |
|
2294 if( requestMapCount ) |
|
2295 { |
|
2296 DEBUG( "CWlmServer::request_complete() - current requests:" ); |
|
2297 for ( TInt idx( 0 ); idx < requestMapCount; ++idx ) |
|
2298 { |
|
2299 DEBUG2( "CWlmServer::request_complete() - ID %u, function %d", iRequestMap[idx].iRequestId, iRequestMap[idx].iFunction ); |
|
2300 } |
|
2301 } |
|
2302 #endif |
|
2303 |
|
2304 // Find correct request from the map |
|
2305 TInt idx = FindRequestIndex( request_id ); |
|
2306 |
|
2307 if( idx >= iRequestMap.Count() ) |
|
2308 { |
|
2309 DEBUG1("CWlmServer::request_complete() - completed request (ID %u) not in request map", |
|
2310 request_id ); |
|
2311 return; |
|
2312 } |
|
2313 |
|
2314 // create a copy of completed request's map entry |
|
2315 SRequestMapEntry completedMapEntry = iRequestMap[idx]; |
|
2316 |
|
2317 // If the operation was GetAvailableIaps, see if there are any SSID lists |
|
2318 // defined and update the availability results. |
|
2319 if( completedMapEntry.iFunction == EGetAvailableIaps ) |
|
2320 { |
|
2321 TRAP_IGNORE( HandleSsidListAvailabilityL( completedMapEntry ) ); |
|
2322 } |
|
2323 |
|
2324 // Complete first all the other possible request that can be completed using the same results |
|
2325 // and the actual triggering request is completed last |
|
2326 // Background scan request should be updated after all requests have been completed |
|
2327 TBool bgScanCompleted( request_id == KWlanIntCmdBackgroundScan ); |
|
2328 if( request_id == iRequestTriggeringScanning && |
|
2329 status != core_error_cancel ) |
|
2330 { |
|
2331 DEBUG( "CWlmServer::request_complete() - also additional requests can be completed" ); |
|
2332 |
|
2333 /* |
|
2334 * Request can be completed using other the results of another request if |
|
2335 * this method is related to scan scheduling and results of the triggering request can |
|
2336 * be used also to completed this request |
|
2337 * |
|
2338 * Following rules apply: |
|
2339 * - GetAvailableIaps results can be used to complete another GetAvailableIaps request, |
|
2340 * background scan request or GetScanResults request without given SSID (broadcast scan) |
|
2341 * - Background scan results can be used to complete GetAvailableIaps request or |
|
2342 * GetScanResults request without given SSID (broadcast scan) |
|
2343 * - GetScanResults request without given SSID (broadcast scan) results can be used to complete |
|
2344 * another GetScanResults request without given SSID (broadcast scan) |
|
2345 * - GetScanResults request with given SSID (direct scan) results can be used to complete |
|
2346 * another GetScanResults request with same given SSID (direct scan) |
|
2347 */ |
|
2348 |
|
2349 TInt i = 0; |
|
2350 while( i < iRequestMap.Count() ) |
|
2351 { |
|
2352 if( IsPendingScanRequest(i) && |
|
2353 iRequestMap[i].iRequestId != iRequestTriggeringScanning && |
|
2354 CanRequestBeCompleted( iRequestMap[i], completedMapEntry ) ) |
|
2355 { |
|
2356 DEBUG1( "CWlmServer::request_complete() - completing additional request (ID %u)", iRequestMap[i].iRequestId ); |
|
2357 |
|
2358 if( iRequestMap[i].iRequestId == KWlanIntCmdBackgroundScan ) |
|
2359 { |
|
2360 CompleteInternalRequest( i, status, EFalse ); |
|
2361 bgScanCompleted = ETrue; |
|
2362 } |
|
2363 else |
|
2364 { |
|
2365 CompleteExternalRequest( i, status, &completedMapEntry ); |
|
2366 if( IsSessionActive( iRequestMap[i] ) ) |
|
2367 { |
|
2368 iRequestMap[i].iMessage.Complete( |
|
2369 TWlanConversionUtil::ConvertErrorCode( status ) ); |
|
2370 } |
|
2371 iRequestMap.Remove( i ); |
|
2372 } |
|
2373 } |
|
2374 else |
|
2375 { |
|
2376 ++i; |
|
2377 } |
|
2378 } |
|
2379 } |
|
2380 |
|
2381 // clear completedMapEntry as it is not needed anymore |
|
2382 completedMapEntry = SRequestMapEntry(); |
|
2383 |
|
2384 // complete the request which Core has actually handled |
|
2385 TInt triggerIndex = FindRequestIndex( request_id ); |
|
2386 |
|
2387 DEBUG1( "CWlmServer::request_complete() - completing triggering request (ID %u)", iRequestMap[triggerIndex].iRequestId ); |
|
2388 if( request_id < KWlanExtCmdBase ) |
|
2389 { |
|
2390 CompleteInternalRequest( triggerIndex, status ); |
|
2391 } |
|
2392 else if( iRequestMap[triggerIndex].iFunction == EJoinByProfileId ) |
|
2393 { |
|
2394 core_iap_data_s* coreIapData = |
|
2395 reinterpret_cast<core_iap_data_s*>( iRequestMap[triggerIndex].iParam0 ); |
|
2396 core_type_list_c<core_ssid_entry_s>* coreSsidList = |
|
2397 reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( iRequestMap[triggerIndex].iParam1 ); |
|
2398 core_connect_status_e* connectionStatus = |
|
2399 reinterpret_cast<core_connect_status_e*>( iRequestMap[triggerIndex].iParam2 ); |
|
2400 |
|
2401 if( status == core_error_ok && IsSessionActive( iRequestMap[triggerIndex] ) ) |
|
2402 { |
|
2403 DEBUG2("CONNECT COMPLETED WITH status == %u -> adapt == %d", |
|
2404 *connectionStatus, |
|
2405 TWlanConversionUtil::ConvertConnectStatus( |
|
2406 *connectionStatus, |
|
2407 coreIapData->security_mode ) ); |
|
2408 iRequestMap[triggerIndex].iMessage.Complete( |
|
2409 TWlanConversionUtil::ConvertConnectStatus( |
|
2410 *connectionStatus, |
|
2411 coreIapData->security_mode ) ); |
|
2412 } |
|
2413 else if ( IsSessionActive( iRequestMap[triggerIndex] ) ) |
|
2414 { |
|
2415 DEBUG2("CONNECT COMPLETED WITH error == %u -> adapt == %d", |
|
2416 status, |
|
2417 TWlanConversionUtil::ConvertErrorCode( status ) ); |
|
2418 iRequestMap[triggerIndex].iMessage.Complete( |
|
2419 TWlanConversionUtil::ConvertErrorCode( status ) ); |
|
2420 } |
|
2421 else |
|
2422 { |
|
2423 DEBUG( "CWlmServer::request_complete() - session has already closed" ); |
|
2424 } |
|
2425 delete coreIapData; |
|
2426 delete coreSsidList; |
|
2427 delete connectionStatus; |
|
2428 iRequestMap.Remove( triggerIndex ); |
|
2429 } |
|
2430 else if ( iRequestMap[triggerIndex].iFunction == ERunProtectedSetup ) |
|
2431 { |
|
2432 core_iap_data_s* iapData = |
|
2433 reinterpret_cast<core_iap_data_s*>( iRequestMap[triggerIndex].iParam0 ); |
|
2434 core_type_list_c<core_iap_data_s>* iapDataList = |
|
2435 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( iRequestMap[triggerIndex].iParam1 ); |
|
2436 core_protected_setup_status_e* protectedSetupStatus = |
|
2437 reinterpret_cast<core_protected_setup_status_e*>( iRequestMap[triggerIndex].iParam2 ); |
|
2438 |
|
2439 // Convert the received credentials. |
|
2440 TWlmProtectedSetupCredentials tmp; |
|
2441 tmp.count = 0; |
|
2442 core_iap_data_s* iter = iapDataList->first(); |
|
2443 while ( iter && tmp.count < KWlmProtectedSetupMaxCount ) |
|
2444 { |
|
2445 TWlanConversionUtil::ConvertProtectedSetupCredentialAttribute( |
|
2446 tmp.credentials[tmp.count], |
|
2447 *iter ); |
|
2448 ++tmp.count; |
|
2449 iter = iapDataList->next(); |
|
2450 } |
|
2451 |
|
2452 DEBUG1( "CWlmServer::request_complete() - converted %u Protected Setup credential attributes", |
|
2453 tmp.count ); |
|
2454 |
|
2455 if( IsSessionActive( iRequestMap[triggerIndex] ) ) |
|
2456 { |
|
2457 TPckg<TWlmProtectedSetupCredentials> outPckg( tmp ); |
|
2458 iRequestMap[triggerIndex].iMessage.Write( 1, outPckg ); |
|
2459 } |
|
2460 |
|
2461 if( status == core_error_ok && IsSessionActive( iRequestMap[triggerIndex] ) ) |
|
2462 { |
|
2463 DEBUG2("PROTECTED SETUP COMPLETED WITH status == %d -> adapt == %d", |
|
2464 *protectedSetupStatus, |
|
2465 TWlanConversionUtil::ConvertProtectedSetupStatus( *protectedSetupStatus ) ); |
|
2466 iRequestMap[triggerIndex].iMessage.Complete( |
|
2467 TWlanConversionUtil::ConvertProtectedSetupStatus( *protectedSetupStatus ) ); |
|
2468 } |
|
2469 else if ( IsSessionActive( iRequestMap[triggerIndex] ) ) |
|
2470 { |
|
2471 DEBUG2("PROTECTED SETUP COMPLETED WITH error == %d -> adapt == %d", |
|
2472 status, |
|
2473 TWlanConversionUtil::ConvertErrorCode( status ) ); |
|
2474 iRequestMap[triggerIndex].iMessage.Complete( |
|
2475 TWlanConversionUtil::ConvertErrorCode( status ) ); |
|
2476 } |
|
2477 else |
|
2478 { |
|
2479 DEBUG( "CWlmServer::request_complete() - session has already closed" ); |
|
2480 } |
|
2481 |
|
2482 delete iapData; |
|
2483 delete iapDataList; |
|
2484 delete protectedSetupStatus; |
|
2485 iRequestMap.Remove( triggerIndex ); |
|
2486 } |
|
2487 else |
|
2488 { |
|
2489 CompleteExternalRequest( triggerIndex, status ); |
|
2490 if( IsSessionActive( iRequestMap[triggerIndex] ) ) |
|
2491 { |
|
2492 iRequestMap[triggerIndex].iMessage.Complete( |
|
2493 TWlanConversionUtil::ConvertErrorCode( status ) ); |
|
2494 } |
|
2495 iRequestMap.Remove( triggerIndex ); |
|
2496 } |
|
2497 |
|
2498 // Background scan request needs to be updated only after all the other request have been completed |
|
2499 // otherwise the new request will be appended to the pending list too early |
|
2500 if( bgScanCompleted ) |
|
2501 { |
|
2502 iBgScanProvider->ScanComplete(); |
|
2503 } |
|
2504 |
|
2505 TUint indexNextScan; |
|
2506 if( request_id == iRequestTriggeringScanning ) |
|
2507 { |
|
2508 iCoreHandlingScanRequest = EFalse; |
|
2509 |
|
2510 if( FindNextTimedScanSchedulingRequest( indexNextScan ) ) |
|
2511 { |
|
2512 TTime* nextScanTime = reinterpret_cast<TTime*>( iRequestMap[indexNextScan].iTime ); |
|
2513 UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId ); |
|
2514 } |
|
2515 } |
|
2516 |
|
2517 #ifdef _DEBUG |
|
2518 requestMapCount = iRequestMap.Count(); |
|
2519 if( requestMapCount ) |
|
2520 { |
|
2521 DEBUG( "CWlmServer::request_complete() - remaining requests:" ); |
|
2522 for ( TInt idx( 0 ); idx < requestMapCount; ++idx ) |
|
2523 { |
|
2524 DEBUG1( "CWlmServer::request_complete() - ID %u", iRequestMap[idx].iRequestId ); |
|
2525 DEBUG1( "CWlmServer::request_complete() - function %d", iRequestMap[idx].iFunction ); |
|
2526 } |
|
2527 } |
|
2528 #endif |
|
2529 |
|
2530 return; |
|
2531 |
|
2532 } |
|
2533 |
|
2534 // --------------------------------------------------------- |
|
2535 // CWlmServer::CanRequestBeCompleted |
|
2536 // --------------------------------------------------------- |
|
2537 // |
|
2538 TBool CWlmServer::CanRequestBeCompleted( |
|
2539 const SRequestMapEntry& aCheckedMapEntry, |
|
2540 const SRequestMapEntry& aCompletedMapEntry ) const |
|
2541 { |
|
2542 DEBUG2( "CWlmServer::CanRequestBeCompleted() - checked %u completed %u", |
|
2543 aCheckedMapEntry.iRequestId, aCompletedMapEntry.iRequestId ); |
|
2544 |
|
2545 if( aCheckedMapEntry.iRequestId == KWlanIntCmdBackgroundScan ) |
|
2546 { |
|
2547 DEBUG( "CWlmServer::CanRequestBeCompleted() - The request to be checked is background scan" ); |
|
2548 |
|
2549 if( iRequestTriggeringScanning == KWlanIntCmdBackgroundScan ) |
|
2550 { |
|
2551 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is background scan" ); |
|
2552 |
|
2553 return ETrue; |
|
2554 } |
|
2555 else if( aCompletedMapEntry.iRequestId >= KWlanExtCmdBase && |
|
2556 aCompletedMapEntry.iFunction == EGetAvailableIaps ) |
|
2557 { |
|
2558 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is GetAvailableIaps" ); |
|
2559 |
|
2560 return ETrue; |
|
2561 } |
|
2562 else |
|
2563 { |
|
2564 return EFalse; |
|
2565 } |
|
2566 } |
|
2567 else if( aCheckedMapEntry.iFunction == EGetAvailableIaps ) |
|
2568 { |
|
2569 DEBUG( "CWlmServer::CanRequestBeCompleted() - The request to be checked is GetAvailableIaps" ); |
|
2570 |
|
2571 if( iRequestTriggeringScanning == KWlanIntCmdBackgroundScan ) |
|
2572 { |
|
2573 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is background scan" ); |
|
2574 |
|
2575 return ETrue; |
|
2576 } |
|
2577 else if( aCompletedMapEntry.iRequestId >= KWlanExtCmdBase && |
|
2578 aCompletedMapEntry.iFunction == EGetAvailableIaps ) |
|
2579 { |
|
2580 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is GetAvailableIap" ); |
|
2581 |
|
2582 return ETrue; |
|
2583 } |
|
2584 else |
|
2585 { |
|
2586 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is not scan related" ); |
|
2587 |
|
2588 return EFalse; |
|
2589 } |
|
2590 } |
|
2591 else if( aCheckedMapEntry.iFunction == EGetScanResults ) |
|
2592 { |
|
2593 DEBUG( "CWlmServer::CanRequestBeCompleted() - The request to be checked is GetScanResults" ); |
|
2594 |
|
2595 core_ssid_s* triggeringSsid = reinterpret_cast<core_ssid_s*>( aCompletedMapEntry.iParam1 ); |
|
2596 core_ssid_s* checkedSsid = reinterpret_cast<core_ssid_s*>( aCheckedMapEntry.iParam1 ); |
|
2597 |
|
2598 if( checkedSsid->length == 0 && |
|
2599 aCompletedMapEntry.iRequestId == KWlanIntCmdBackgroundScan ) |
|
2600 { |
|
2601 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is background scan" ); |
|
2602 |
|
2603 return ETrue; |
|
2604 } |
|
2605 else if( aCompletedMapEntry.iRequestId >= KWlanExtCmdBase && |
|
2606 checkedSsid->length == 0 && |
|
2607 aCompletedMapEntry.iFunction == EGetAvailableIaps ) |
|
2608 { |
|
2609 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is GetAvailableIaps" ); |
|
2610 |
|
2611 return ETrue; |
|
2612 } |
|
2613 else if( aCompletedMapEntry.iRequestId >= KWlanExtCmdBase && |
|
2614 checkedSsid->length == 0 && |
|
2615 aCompletedMapEntry.iFunction == EGetScanResults && |
|
2616 triggeringSsid->length == 0 ) |
|
2617 { |
|
2618 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is GetScanResults (broadcast)" ); |
|
2619 |
|
2620 return ETrue; |
|
2621 } |
|
2622 else if( aCompletedMapEntry.iRequestId >= KWlanExtCmdBase && |
|
2623 checkedSsid->length != 0 && |
|
2624 aCompletedMapEntry.iFunction == EGetScanResults && |
|
2625 triggeringSsid->length != 0 && |
|
2626 *checkedSsid == *triggeringSsid ) |
|
2627 { |
|
2628 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is GetScanResults (direct) and both have same SSID" ); |
|
2629 |
|
2630 return ETrue; |
|
2631 } |
|
2632 else |
|
2633 { |
|
2634 DEBUG( "CWlmServer::CanRequestBeCompleted() - The triggering request is something else" ); |
|
2635 |
|
2636 return EFalse; |
|
2637 } |
|
2638 |
|
2639 } |
|
2640 return EFalse; |
|
2641 } |
|
2642 |
|
2643 // --------------------------------------------------------- |
|
2644 // CWlmServer::CompleteInternalRequest |
|
2645 // --------------------------------------------------------- |
|
2646 // |
|
2647 void CWlmServer::CompleteInternalRequest( |
|
2648 TUint32 aIndex, |
|
2649 core_error_e aStatus, |
|
2650 TBool aCompletedWasTriggering ) |
|
2651 { |
|
2652 DEBUG1( "CWlmServer::CompleteInternalRequest() - index (%d)", aIndex ); |
|
2653 |
|
2654 // Take the entry out from queue |
|
2655 SRequestMapEntry requestEntry = iRequestMap[ aIndex ]; |
|
2656 |
|
2657 iRequestMap.Remove( aIndex ); |
|
2658 |
|
2659 switch( requestEntry.iRequestId ) |
|
2660 { |
|
2661 case KWlanIntCmdBackgroundScan: |
|
2662 { |
|
2663 core_type_list_c<core_ssid_entry_s>* iapSsidList = |
|
2664 reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( requestEntry.iParam3 ); |
|
2665 delete iapSsidList; |
|
2666 iapSsidList = NULL; |
|
2667 |
|
2668 ScanList* scanList = |
|
2669 reinterpret_cast<ScanList*>( requestEntry.iParam2 ); |
|
2670 core_type_list_c<u32_t>* idList = |
|
2671 reinterpret_cast<core_type_list_c<u32_t>*>( requestEntry.iParam1 ); |
|
2672 |
|
2673 core_type_list_c<core_iap_data_s>* iapDataList = |
|
2674 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( requestEntry.iParam0 ); |
|
2675 delete iapDataList; |
|
2676 iapDataList = NULL; |
|
2677 |
|
2678 TTime* completedScanTime = reinterpret_cast<TTime*>( requestEntry.iTime ); |
|
2679 delete completedScanTime; |
|
2680 completedScanTime = NULL; |
|
2681 |
|
2682 if( aCompletedWasTriggering ) |
|
2683 { |
|
2684 DEBUG( "CWlmServer::CompleteInternalRequest() - this request was handled by core" ); |
|
2685 |
|
2686 if( aStatus == core_error_ok ) |
|
2687 { |
|
2688 NotifyBackgroundScanDone( scanList, idList ); |
|
2689 // cache takes the ownership of the scanList |
|
2690 scanList = NULL; |
|
2691 } |
|
2692 } |
|
2693 else |
|
2694 { |
|
2695 DEBUG( "CWlmServer::CompleteInternalRequest() - this request was not handled by core" ); |
|
2696 } |
|
2697 |
|
2698 delete scanList; |
|
2699 scanList = NULL; |
|
2700 delete idList; |
|
2701 idList = NULL; |
|
2702 |
|
2703 break; |
|
2704 } |
|
2705 case KWlanIntCmdNull: // Fall through on purpose |
|
2706 default: |
|
2707 break; |
|
2708 // not interested in rest of the internal request completions |
|
2709 } |
|
2710 } |
|
2711 |
|
2712 // --------------------------------------------------------- |
|
2713 // CWlmServer::CompleteExternalRequest |
|
2714 // --------------------------------------------------------- |
|
2715 // |
|
2716 void CWlmServer::CompleteExternalRequest( |
|
2717 TUint32 aIndex, |
|
2718 core_error_e aStatus, |
|
2719 SRequestMapEntry* aTriggerRequest ) |
|
2720 { |
|
2721 DEBUG1( "CWlmServer::CompleteExternalRequest() - index (%d)", aIndex ); |
|
2722 |
|
2723 // Take the entry out from queue |
|
2724 SRequestMapEntry requestEntry = iRequestMap[ aIndex ]; |
|
2725 |
|
2726 // Find out the request type |
|
2727 // in order to handle possible return parameters |
|
2728 switch( requestEntry.iFunction ) |
|
2729 { |
|
2730 case EGetScanResults: |
|
2731 { |
|
2732 ScanList* tmp( NULL ); |
|
2733 core_ssid_s* ssid = reinterpret_cast<core_ssid_s*>( requestEntry.iParam1 ); |
|
2734 TTime* completedScanTime = reinterpret_cast<TTime*>( requestEntry.iTime ); |
|
2735 ScanList* completedScanList = reinterpret_cast<ScanList*>( requestEntry.iParam0 ); |
|
2736 |
|
2737 if( aTriggerRequest == NULL ) |
|
2738 { |
|
2739 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request handled by core" ); |
|
2740 |
|
2741 tmp = reinterpret_cast<ScanList*>( requestEntry.iParam0); |
|
2742 } |
|
2743 else |
|
2744 { |
|
2745 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request not handled by core" ); |
|
2746 // Use the results of the triggering request to complete also this other request |
|
2747 // Check was the triggering request background scan or GetAvailableIaps or |
|
2748 // was it GetScanResults because the ScanList is stored to different parameter |
|
2749 if( aTriggerRequest->iRequestId >= KWlanExtCmdBase && aTriggerRequest->iFunction == EGetScanResults ) |
|
2750 { |
|
2751 tmp = reinterpret_cast<ScanList*>( aTriggerRequest->iParam0 ); |
|
2752 } |
|
2753 else |
|
2754 { |
|
2755 tmp = reinterpret_cast<ScanList*>( aTriggerRequest->iParam2 ); |
|
2756 } |
|
2757 } |
|
2758 |
|
2759 if( aStatus == core_error_ok ) |
|
2760 { |
|
2761 TDynamicScanList dynamicScanList; |
|
2762 dynamicScanList.count = tmp->Count(); |
|
2763 dynamicScanList.size = tmp->Size(); |
|
2764 |
|
2765 TPckgBuf<TDynamicScanList> pckgDynamicScanList( dynamicScanList ); |
|
2766 TPtr8 ptrScanList( |
|
2767 tmp->Data(), |
|
2768 tmp->Size(), |
|
2769 tmp->Size() ); |
|
2770 |
|
2771 DEBUG2( "CWlmServer::CompleteExternalRequest() - scan results count is %u, size is %u", |
|
2772 tmp->Count(), tmp->Size() ); |
|
2773 |
|
2774 if( requestEntry.iSessionId != 0 ) |
|
2775 { |
|
2776 requestEntry.iMessage.Write( 0, ptrScanList ); |
|
2777 requestEntry.iMessage.Write( 2, pckgDynamicScanList ); |
|
2778 } |
|
2779 |
|
2780 // Check whether to cache the results or not |
|
2781 if( ssid->length > 0 && aTriggerRequest == NULL ) |
|
2782 { |
|
2783 // direct scan results are not cached |
|
2784 DEBUG( "CWlmServer::CompleteExternalRequest() - direct scan; not caching scan results" ); |
|
2785 |
|
2786 delete tmp; |
|
2787 } |
|
2788 else if( aTriggerRequest == NULL ) |
|
2789 { |
|
2790 // not deleting scanList, because cache takes the ownership |
|
2791 DEBUG( "CWlmServer::CompleteExternalRequest() - caching scan results" ); |
|
2792 iCache->UpdateScanList( tmp ); |
|
2793 } |
|
2794 else |
|
2795 { |
|
2796 DEBUG( "CWlmServer::CompleteExternalRequest() - request not handled by core; not caching scan results" ); |
|
2797 |
|
2798 delete completedScanList; |
|
2799 } |
|
2800 } |
|
2801 else |
|
2802 { |
|
2803 // scan failed due to some reason: not caching anything |
|
2804 if( aTriggerRequest == NULL ) |
|
2805 { |
|
2806 delete tmp; |
|
2807 } |
|
2808 else |
|
2809 { |
|
2810 delete completedScanList; |
|
2811 } |
|
2812 } |
|
2813 |
|
2814 delete ssid; // ssid |
|
2815 delete completedScanTime; |
|
2816 break; |
|
2817 } |
|
2818 case EReset: |
|
2819 { |
|
2820 // no parameters to return |
|
2821 break; |
|
2822 } |
|
2823 case EGetAvailableIaps: |
|
2824 { |
|
2825 // Create pointers to parameters |
|
2826 core_type_list_c<core_ssid_entry_s>* iapSsidList; |
|
2827 ScanList* scanList; |
|
2828 core_type_list_c<u32_t>* coreIdList; |
|
2829 core_type_list_c<core_iap_data_s>* iapDataList; |
|
2830 |
|
2831 iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( requestEntry.iParam3 ); |
|
2832 iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( requestEntry.iParam0 ); |
|
2833 |
|
2834 TTime* completedScanTime = reinterpret_cast<TTime*>( requestEntry.iTime ); |
|
2835 ScanList* completedScanList = reinterpret_cast<ScanList*>( requestEntry.iParam2); |
|
2836 core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( requestEntry.iParam1 ); |
|
2837 |
|
2838 if( aTriggerRequest == NULL ) |
|
2839 { |
|
2840 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request handled by core" ); |
|
2841 |
|
2842 scanList = reinterpret_cast<ScanList*>( requestEntry.iParam2); |
|
2843 coreIdList = reinterpret_cast<core_type_list_c<u32_t>*>( requestEntry.iParam1 ); |
|
2844 } |
|
2845 else |
|
2846 { |
|
2847 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request not handled by core" ); |
|
2848 //Use the results of the triggering request to complete also this other request |
|
2849 scanList = reinterpret_cast<ScanList*>( aTriggerRequest->iParam2); |
|
2850 coreIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aTriggerRequest->iParam1 ); |
|
2851 } |
|
2852 |
|
2853 delete iapSsidList; |
|
2854 iapSsidList = NULL; |
|
2855 delete iapDataList; |
|
2856 iapDataList = NULL; |
|
2857 |
|
2858 if( aStatus == core_error_ok ) |
|
2859 { |
|
2860 RArray<TWlanAvailableNetwork> networkList; |
|
2861 GetNetworkList( *scanList, networkList ); |
|
2862 |
|
2863 // Update Cached results |
|
2864 TBool newIaps( EFalse ); |
|
2865 TBool lostIaps( EFalse ); |
|
2866 |
|
2867 if( aTriggerRequest == NULL ) |
|
2868 { |
|
2869 iCache->UpdateAvailableNetworksList( |
|
2870 *coreIdList, |
|
2871 networkList, |
|
2872 newIaps, |
|
2873 lostIaps ); |
|
2874 } |
|
2875 networkList.Close(); |
|
2876 |
|
2877 TWlmAvailableIaps tmp; |
|
2878 TUint32* pInt = coreIdList->first(); |
|
2879 TInt idx = 0; |
|
2880 while( pInt ) |
|
2881 { |
|
2882 DEBUG1( "CWlmServer::CompleteExternalRequest() - IAP %u is available", |
|
2883 *pInt ); |
|
2884 tmp.iaps[ idx ] = *pInt; |
|
2885 idx++; |
|
2886 pInt = coreIdList->next(); |
|
2887 } |
|
2888 |
|
2889 tmp.count = idx; |
|
2890 |
|
2891 if( requestEntry.iSessionId != 0 ) |
|
2892 { |
|
2893 TPckg<TWlmAvailableIaps> outPckg( tmp ); |
|
2894 requestEntry.iMessage.Write( 0, outPckg ); |
|
2895 } |
|
2896 if( aTriggerRequest == NULL ) |
|
2897 { |
|
2898 DEBUG1("CWlmServer::CompleteExternalRequest() - delete iapIdList (%d)", coreIdList); |
|
2899 |
|
2900 delete coreIdList; |
|
2901 } |
|
2902 else |
|
2903 { |
|
2904 // If this completed request was not the triggering request then there is no need |
|
2905 // to cache anything. The triggering request results will be cached. |
|
2906 delete completedIdList; |
|
2907 delete completedScanList; |
|
2908 } |
|
2909 |
|
2910 // handle scan list |
|
2911 if( aTriggerRequest == NULL ) |
|
2912 { |
|
2913 iCache->UpdateScanList( scanList ); |
|
2914 // not deleting scanList, because cache takes the ownership |
|
2915 |
|
2916 UpdateAvailabilityInfo( |
|
2917 newIaps, |
|
2918 lostIaps, |
|
2919 scanList->Count() != 0 ); |
|
2920 } |
|
2921 } |
|
2922 else |
|
2923 { |
|
2924 // scan failed due to some reason: not caching anything |
|
2925 if( aTriggerRequest == NULL ) |
|
2926 { |
|
2927 delete coreIdList; |
|
2928 delete scanList; |
|
2929 } |
|
2930 else |
|
2931 { |
|
2932 // Delete only the lists of the completed request. Triggering request lists are |
|
2933 // deleted later on when that request is actually handled. |
|
2934 delete completedIdList; |
|
2935 delete completedScanList; |
|
2936 } |
|
2937 } |
|
2938 delete completedScanTime; |
|
2939 break; |
|
2940 } |
|
2941 case EGetCurrentRSSI: |
|
2942 { |
|
2943 TUint32 tmp |
|
2944 = *( reinterpret_cast<TUint32*> |
|
2945 ( requestEntry.iParam0 ) ); |
|
2946 if( requestEntry.iSessionId != 0 ) |
|
2947 { |
|
2948 TPckg<TUint32> outPckg( tmp ); |
|
2949 requestEntry.iMessage.Write( 0, outPckg ); |
|
2950 } |
|
2951 iPrevRcpiValue = tmp; |
|
2952 delete reinterpret_cast<TUint32*>( requestEntry.iParam0 ); |
|
2953 break; |
|
2954 } |
|
2955 case EGetSystemMode: |
|
2956 { |
|
2957 // not asynch request; never comes here |
|
2958 break; |
|
2959 } |
|
2960 case EConfigureMulticastGroup: |
|
2961 { |
|
2962 // no parameters to return |
|
2963 delete reinterpret_cast<TUint32*>( requestEntry.iParam0 ); |
|
2964 break; |
|
2965 } |
|
2966 case EGetPacketStatistics: |
|
2967 { |
|
2968 core_packet_statistics_s* coreStatistics = |
|
2969 reinterpret_cast<core_packet_statistics_s*>( requestEntry.iParam0 ); |
|
2970 if( requestEntry.iSessionId != 0 ) |
|
2971 { |
|
2972 TPckgBuf<TWlanPacketStatistics> statisticPckg; |
|
2973 TWlanConversionUtil::ConvertPacketStatistics( |
|
2974 statisticPckg(), |
|
2975 *coreStatistics ); |
|
2976 requestEntry.iMessage.Write( 0, statisticPckg ); |
|
2977 } |
|
2978 delete coreStatistics; |
|
2979 break; |
|
2980 } |
|
2981 case ECreateTrafficStream: |
|
2982 { |
|
2983 u32_t* coreStreamId = |
|
2984 reinterpret_cast<u32_t*>( requestEntry.iParam0 ); |
|
2985 core_traffic_stream_status_e* coreStreamStatus = |
|
2986 reinterpret_cast<core_traffic_stream_status_e*>( requestEntry.iParam1 ); |
|
2987 if( requestEntry.iSessionId != 0 && |
|
2988 aStatus == core_error_ok ) |
|
2989 { |
|
2990 TPckgBuf<TUint> streamIdPckg( |
|
2991 *coreStreamId ); |
|
2992 TPckgBuf<TWlanTrafficStreamStatus> streamStatusPckg( |
|
2993 TWlanConversionUtil::ConvertTrafficStreamStatus( *coreStreamStatus ) ); |
|
2994 requestEntry.iMessage.Write( 2, streamIdPckg ); |
|
2995 requestEntry.iMessage.Write( 3, streamStatusPckg ); |
|
2996 } |
|
2997 delete coreStreamId; |
|
2998 delete coreStreamStatus; |
|
2999 break; |
|
3000 } |
|
3001 case EDeleteTrafficStream: |
|
3002 { |
|
3003 // no parameters to return |
|
3004 break; |
|
3005 } |
|
3006 case EDirectedRoam: |
|
3007 { |
|
3008 // no parameters to return |
|
3009 break; |
|
3010 } |
|
3011 default: |
|
3012 { |
|
3013 DEBUG1( "CWlmServer::CompleteExternalRequest() - ERROR: unknown request type (%d)!", |
|
3014 requestEntry.iFunction ); |
|
3015 break; |
|
3016 } |
|
3017 } |
|
3018 } |
|
3019 |
|
3020 // --------------------------------------------------------- |
|
3021 // CWlmServer::IsAvailableNetworkEqual |
|
3022 // --------------------------------------------------------- |
|
3023 // |
|
3024 TBool CWlmServer::IsAvailableNetworkEqual( |
|
3025 const TWlanAvailableNetwork& aFirst, |
|
3026 const TWlanAvailableNetwork& aSecond ) |
|
3027 { |
|
3028 if( aFirst.ssid != aSecond.ssid ) |
|
3029 { |
|
3030 return EFalse; |
|
3031 } |
|
3032 |
|
3033 if( aFirst.networkType != aSecond.networkType ) |
|
3034 { |
|
3035 return EFalse; |
|
3036 } |
|
3037 |
|
3038 if( aFirst.securityMode != aSecond.securityMode ) |
|
3039 { |
|
3040 return EFalse; |
|
3041 } |
|
3042 |
|
3043 return ETrue; |
|
3044 } |
|
3045 |
|
3046 // --------------------------------------------------------- |
|
3047 // CWlmServer::GetNetworkList |
|
3048 // --------------------------------------------------------- |
|
3049 // |
|
3050 TInt CWlmServer::GetNetworkList( |
|
3051 const ScanList& aScanList, |
|
3052 RArray<TWlanAvailableNetwork>& aNetworkList ) |
|
3053 { |
|
3054 DEBUG( "CWlmServer::GetNetworkList()" ); |
|
3055 |
|
3056 ScanInfo info( aScanList ); |
|
3057 TIdentityRelation<TWlanAvailableNetwork> isEqual( IsAvailableNetworkEqual ); |
|
3058 for( info.First(); !info.IsDone(); info.Next() ) |
|
3059 { |
|
3060 TUint8 ieLength( 0 ); |
|
3061 const TUint8* ieData = NULL; |
|
3062 |
|
3063 if ( info.InformationElement( E802Dot11SsidIE, ieLength, &ieData ) == WlanScanError_Ok && |
|
3064 ieLength <= KMaxSSIDLength ) |
|
3065 { |
|
3066 TWlanAvailableNetwork network; |
|
3067 network.ssid.Copy( ieData, ieLength ); |
|
3068 network.securityMode = info.SecurityMode(); |
|
3069 if( info.OperatingMode() == WlanOperatingModeInfra ) |
|
3070 { |
|
3071 network.networkType = Infrastructure; |
|
3072 } |
|
3073 else |
|
3074 { |
|
3075 network.networkType = Adhoc; |
|
3076 } |
|
3077 |
|
3078 if ( aNetworkList.Find( network, isEqual ) == KErrNotFound ) |
|
3079 { |
|
3080 DEBUG1S( "CWlmServer::GetNetworkList() - appending SSID ", |
|
3081 ieLength, ieData ); |
|
3082 aNetworkList.Append( network ); |
|
3083 } |
|
3084 } |
|
3085 } |
|
3086 |
|
3087 return KErrNone; |
|
3088 } |
|
3089 |
|
3090 // --------------------------------------------------------- |
|
3091 // CWlmServer::UpdateAvailabilityInfo |
|
3092 // --------------------------------------------------------- |
|
3093 // |
|
3094 void CWlmServer::UpdateAvailabilityInfo( |
|
3095 TBool aNewNetworksDetected, |
|
3096 TBool aOldNetworksLost, |
|
3097 TBool aAnyNetworksDetected ) |
|
3098 { |
|
3099 DEBUG1( "CWlmServer::UpdateAvailabilityInfo() - aNewNetworksDetected: %u", |
|
3100 aNewNetworksDetected ); |
|
3101 DEBUG1( "CWlmServer::UpdateAvailabilityInfo() - aOldNetworksLost: %u", |
|
3102 aOldNetworksLost ); |
|
3103 DEBUG1( "CWlmServer::UpdateAvailabilityInfo() - aAnyNetworksDetected: %u", |
|
3104 aAnyNetworksDetected ); |
|
3105 |
|
3106 /** |
|
3107 * Make sure background scan is on before giving any indications. |
|
3108 */ |
|
3109 if( !iBgScanProvider->IsBgScanEnabled() ) |
|
3110 { |
|
3111 DEBUG( "CWlmServer::UpdateAvailabilityInfo() - background scan is not enabled, not sending any indications" ); |
|
3112 return; |
|
3113 } |
|
3114 |
|
3115 /** |
|
3116 * Notify clients about new networks/IAPs if necessary. |
|
3117 */ |
|
3118 if( aNewNetworksDetected ) |
|
3119 { |
|
3120 TBuf8<1> tmp; |
|
3121 for( TInt i = 0; i < iNotificationArray.Count(); i++ ) |
|
3122 { |
|
3123 iNotificationArray[i]->AddNotification( EWlmNotifyNewNetworksDetected, tmp ); |
|
3124 } |
|
3125 } |
|
3126 |
|
3127 /** |
|
3128 * Notify clients about lost networks/IAPs if necessary. |
|
3129 */ |
|
3130 if( aOldNetworksLost ) |
|
3131 { |
|
3132 TBuf8<1> tmp; |
|
3133 for( TInt i = 0; i < iNotificationArray.Count(); i++ ) |
|
3134 { |
|
3135 iNotificationArray[i]->AddNotification( EWlmNotifyOldNetworksLost, tmp ); |
|
3136 } |
|
3137 } |
|
3138 |
|
3139 /** |
|
3140 * Set icon state if not connected. |
|
3141 */ |
|
3142 if( iConnectionState == EWlanStateNotConnected ) |
|
3143 { |
|
3144 if( aAnyNetworksDetected ) |
|
3145 { |
|
3146 SetIconState( EWlmIconStatusAvailable ); |
|
3147 } |
|
3148 else |
|
3149 { |
|
3150 SetIconState( EWlmIconStatusNotAvailable ); |
|
3151 } |
|
3152 } |
|
3153 } |
|
3154 |
|
3155 // --------------------------------------------------------- |
|
3156 // CWlmServer::CancelExternalRequest |
|
3157 // --------------------------------------------------------- |
|
3158 // |
|
3159 void CWlmServer::CancelExternalRequest( |
|
3160 TUint aSessionId, |
|
3161 TWLMCommands aCommand ) |
|
3162 { |
|
3163 DEBUG( "CWlmServer::CancelExternalRequest()" ); |
|
3164 DEBUG1( "CWlmServer::CancelExternalRequest() - aSessionId: %u", |
|
3165 aSessionId ); |
|
3166 DEBUG1( "CWlmServer::CancelExternalRequest() - aCommand: %u", |
|
3167 aCommand ); |
|
3168 |
|
3169 #ifdef _DEBUG |
|
3170 DEBUG( "CWlmServer::CancelExternalRequest()" ); |
|
3171 DEBUG( "CWlmServer::CancelExternalRequest() - iRequestMap:" ); |
|
3172 |
|
3173 for ( TInt idx( 0 ); idx < iRequestMap.Count(); ++idx ) |
|
3174 { |
|
3175 DEBUG1( "CWlmServer::CancelExternalRequest() - iRequestId %u", |
|
3176 iRequestMap[idx].iRequestId ); |
|
3177 DEBUG1( "CWlmServer::CancelExternalRequest() - iSessionId %u", |
|
3178 iRequestMap[idx].iSessionId ); |
|
3179 DEBUG1( "CWlmServer::CancelExternalRequest() - iFunction: %d", |
|
3180 iRequestMap[idx].iFunction ); |
|
3181 } |
|
3182 #endif // _DEBUG |
|
3183 |
|
3184 for( TInt i( 0 ); i < iRequestMap.Count(); i++ ) |
|
3185 { |
|
3186 if( iRequestMap[i].iSessionId == aSessionId && |
|
3187 iRequestMap[i].iFunction == aCommand ) |
|
3188 { |
|
3189 DEBUG( "CWlmServer::CancelExternalRequest() - corresponding request found, cancelling" ); |
|
3190 |
|
3191 if( iRequestMap[i].iRequestId == iRequestTriggeringScanning && |
|
3192 iCoreHandlingScanRequest ) |
|
3193 { |
|
3194 // Core is already handling this scan request |
|
3195 // request Core to cancel the handling |
|
3196 DEBUG( "CWlmServer::CancelExternalRequest() - Core is already handling this request, send cancel request" ); |
|
3197 |
|
3198 iCoreServer->cancel_request( |
|
3199 iRequestMap[i].iRequestId ); |
|
3200 } |
|
3201 else if( iRequestMap[i].iRequestId == iRequestTriggeringScanning ) |
|
3202 { |
|
3203 // Core is not handling currently this scan request |
|
3204 // Complete the cancelled request and timer is set again |
|
3205 DEBUG( "CWlmServer::CancelExternalRequest() - Core is not handling currently this request" ); |
|
3206 DEBUG( "CWlmServer::CancelExternalRequest() - Cancel timer, complete cancelled request and set timer" ); |
|
3207 |
|
3208 iScanSchedulingTimer->Cancel(); |
|
3209 request_complete( iRequestMap[i].iRequestId, core_error_cancel ); |
|
3210 } |
|
3211 else |
|
3212 { |
|
3213 if( iRequestMap[i].iFunction == EGetScanResults || |
|
3214 iRequestMap[i].iFunction == EGetAvailableIaps ) |
|
3215 { |
|
3216 // Core is not handling currently this scan request |
|
3217 // Remove the cancelled request |
|
3218 DEBUG( "CWlmServer::CancelExternalRequest() - Core is not handling currently this scan request" ); |
|
3219 DEBUG( "CWlmServer::CancelExternalRequest() - this request is not the scan scheduling triggering request" ); |
|
3220 DEBUG( "CWlmServer::CancelExternalRequest() - remove the cancelled request" ); |
|
3221 |
|
3222 CompleteExternalRequest( i, core_error_cancel ); |
|
3223 if( IsSessionActive( iRequestMap[i] ) ) |
|
3224 { |
|
3225 iRequestMap[i].iMessage.Complete( |
|
3226 TWlanConversionUtil::ConvertErrorCode( core_error_cancel ) ); |
|
3227 } |
|
3228 |
|
3229 iRequestMap.Remove( i ); |
|
3230 } |
|
3231 else |
|
3232 { |
|
3233 // Cancelled request is not a scan scheduling related request |
|
3234 // make normal cancel handling and request Core to cancel the handling |
|
3235 DEBUG( "CWlmServer::CancelExternalRequest() - Cancelled request is not a scan scheduling related request" ); |
|
3236 |
|
3237 iCoreServer->cancel_request( |
|
3238 iRequestMap[i].iRequestId ); |
|
3239 } |
|
3240 } |
|
3241 return; |
|
3242 } |
|
3243 } |
|
3244 |
|
3245 DEBUG( "CWlmServer::CancelExternalRequest() - no pending request found, ignoring" ); |
|
3246 } |
|
3247 |
|
3248 // --------------------------------------------------------- |
|
3249 // CWlmServer::CheckScanSchedulingParameters |
|
3250 // --------------------------------------------------------- |
|
3251 // |
|
3252 void CWlmServer::CheckScanSchedulingParameters( |
|
3253 TInt& aCacheLifetime, |
|
3254 TUint& aMaxDelay ) |
|
3255 { |
|
3256 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - aCacheLifetime: %d", aCacheLifetime ); |
|
3257 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - aMaxDelay: %u", aMaxDelay); |
|
3258 |
|
3259 if( aMaxDelay == KWlmInfiniteScanDelay ) |
|
3260 { |
|
3261 DEBUG( "CWlmServer::CheckScanSchedulingParameters() - infinite aMaxDelay" ); |
|
3262 } |
|
3263 else if( aMaxDelay > KWlmMaxScanDelay ) |
|
3264 { |
|
3265 aMaxDelay = KWlmMaxScanDelay; |
|
3266 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - new aMaxDelay: %u", aMaxDelay ); |
|
3267 } |
|
3268 else |
|
3269 { |
|
3270 DEBUG( "CWlmServer::CheckScanSchedulingParameters() - no changes to aMaxDelay" ); |
|
3271 } |
|
3272 |
|
3273 // cacheLifetime parameter has meaning only when maxDelay is zero |
|
3274 if( aMaxDelay != 0 ) |
|
3275 { |
|
3276 aCacheLifetime = 0; |
|
3277 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - aMaxDelay non-zero -> new aCacheLifetime: %d", aCacheLifetime ); |
|
3278 } |
|
3279 else |
|
3280 { |
|
3281 if( aCacheLifetime > KWlmMaxScanCacheLifetime ) |
|
3282 { |
|
3283 aCacheLifetime = KWlmMaxScanCacheLifetime; |
|
3284 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - new aCacheLifetime: %d", aCacheLifetime ); |
|
3285 } |
|
3286 else if( aCacheLifetime == KWlmDefaultScanCacheLifetime ) |
|
3287 { |
|
3288 aCacheLifetime = iConfiguredCacheLifetime; |
|
3289 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - new aCacheLifetime: %d", aCacheLifetime ); |
|
3290 } |
|
3291 else if( aCacheLifetime < KWlmMinScanCacheLifetime ) |
|
3292 { |
|
3293 aCacheLifetime = KWlmMinScanCacheLifetime; |
|
3294 DEBUG1( "CWlmServer::CheckScanSchedulingParameters() - new aCacheLifetime: %d", aCacheLifetime ); |
|
3295 } |
|
3296 else |
|
3297 { |
|
3298 DEBUG( "CWlmServer::CheckScanSchedulingParameters() - no changes to aCacheLifetime" ); |
|
3299 } |
|
3300 } |
|
3301 } |
|
3302 |
|
3303 // --------------------------------------------------------- |
|
3304 // CWlmServer::cancel_request |
|
3305 // --------------------------------------------------------- |
|
3306 // |
|
3307 void CWlmServer::cancel_request( |
|
3308 u32_t /* request_id */ ) |
|
3309 { |
|
3310 DEBUG( "CWlmServer::cancel_request" ); |
|
3311 } |
|
3312 |
|
3313 // --------------------------------------------------------- |
|
3314 // CWlmServer::load_eapol |
|
3315 // --------------------------------------------------------- |
|
3316 // |
|
3317 u32_t CWlmServer::load_eapol( |
|
3318 core_eapol_operating_mode_e mode, |
|
3319 abs_wlan_eapol_callback_c* const partner ) |
|
3320 { |
|
3321 DEBUG( "CWlmServer::load_eapol" ); |
|
3322 |
|
3323 if ( iEapolClient ) |
|
3324 { |
|
3325 DEBUG( "CWlmServer::load_eapol - CWlanEapolClient already instantiated." ); |
|
3326 return wlan_eapol_if_error_ok; |
|
3327 } |
|
3328 |
|
3329 TInt implementationUid( KCWlanEapolClientUid ); |
|
3330 if( mode == core_eapol_operating_mode_wapi ) |
|
3331 { |
|
3332 implementationUid = KCWlanWapiClientUid; |
|
3333 } |
|
3334 |
|
3335 TRAPD( ret, iEapolClient = CWlanEapolClient::NewL( |
|
3336 implementationUid, this ) ); // "this" is instance providing SendData() |
|
3337 if( ret != KErrNone ) |
|
3338 { |
|
3339 DEBUG1( "ERROR: CWlanEapolClient::NewL leaved with %d.", ret ); |
|
3340 return wlan_eapol_if_error_allocation_error; |
|
3341 } |
|
3342 iEapolHandler = partner; |
|
3343 return wlan_eapol_if_error_ok; |
|
3344 } |
|
3345 |
|
3346 // --------------------------------------------------------- |
|
3347 // CWlmServer::shutdown |
|
3348 // --------------------------------------------------------- |
|
3349 // |
|
3350 u32_t CWlmServer::shutdown() |
|
3351 { |
|
3352 DEBUG( "CWlmServer::shutdown" ); |
|
3353 ASSERT( iEapolClient ); |
|
3354 |
|
3355 iEapolClient->Shutdown(); |
|
3356 delete iEapolClient; |
|
3357 iEapolClient = NULL; |
|
3358 |
|
3359 return wlan_eapol_if_error_ok; |
|
3360 } |
|
3361 |
|
3362 // --------------------------------------------------------- |
|
3363 // CWlmServer::configure |
|
3364 // --------------------------------------------------------- |
|
3365 // |
|
3366 u32_t CWlmServer::configure( |
|
3367 const u32_t header_offset, |
|
3368 const u32_t MTU, |
|
3369 const u32_t trailer_length ) |
|
3370 { |
|
3371 DEBUG( "CWlmServer::configure" ); |
|
3372 ASSERT( iEapolClient ); |
|
3373 return iEapolClient->Configure( header_offset, MTU, trailer_length ); |
|
3374 } |
|
3375 |
|
3376 |
|
3377 // --------------------------------------------------------- |
|
3378 // CWlmServer::process_data |
|
3379 // --------------------------------------------------------- |
|
3380 // |
|
3381 u32_t CWlmServer::process_data( |
|
3382 const void * const data, |
|
3383 const u32_t length ) |
|
3384 { |
|
3385 DEBUG( "CWlmServer::process_data" ); |
|
3386 ASSERT( iEapolClient ); |
|
3387 return iEapolClient->ProcessData( data, length ); |
|
3388 } |
|
3389 |
|
3390 |
|
3391 // --------------------------------------------------------- |
|
3392 // CWlmServer::HandleCoreAsynchCb |
|
3393 // --------------------------------------------------------- |
|
3394 // |
|
3395 TInt CWlmServer::HandleCoreAsynchCb( TAny* aThisPtr ) |
|
3396 { |
|
3397 CWlmServer* self = static_cast<CWlmServer*>( aThisPtr ); |
|
3398 |
|
3399 /** |
|
3400 * This could be a problem if the core immediately sets |
|
3401 * another pending callback request. |
|
3402 */ |
|
3403 |
|
3404 self->iCoreServer->request_complete( |
|
3405 self->iCoreAsynchCbId, |
|
3406 self->iCoreAsynchCbStatus ); |
|
3407 |
|
3408 self->iCoreAsynchCbId = 0; |
|
3409 self->iCoreAsynchCbStatus = core_error_ok; |
|
3410 |
|
3411 return KErrNone; |
|
3412 } |
|
3413 |
|
3414 // --------------------------------------------------------- |
|
3415 // CWlmServer::BackgroundScanRequest |
|
3416 // --------------------------------------------------------- |
|
3417 // |
|
3418 TInt CWlmServer::BackgroundScanRequest( |
|
3419 TUint aScanStartInterval ) |
|
3420 { |
|
3421 DEBUG1( "CWlmServer::BackgroundScanRequest() - aScanStartInterval %u", aScanStartInterval ); |
|
3422 |
|
3423 // Create list for WLAN IAP data |
|
3424 core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>; |
|
3425 if( iapDataList == NULL ) |
|
3426 { |
|
3427 // Do nothing and hope that on next expiry there is enough memory |
|
3428 DEBUG( "CWlmServer::BackgroundScanRequest() - Out of memory" ); |
|
3429 return KErrNoMemory; |
|
3430 } |
|
3431 |
|
3432 // Create list for secondary SSID data |
|
3433 core_type_list_c<core_ssid_entry_s>* iapSsidList = new core_type_list_c<core_ssid_entry_s>; |
|
3434 if ( !iapSsidList ) |
|
3435 { |
|
3436 DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instance core_ssid_entry_s list" ); |
|
3437 |
|
3438 delete iapDataList; |
|
3439 |
|
3440 return KErrNoMemory; |
|
3441 } |
|
3442 |
|
3443 // Read IAP data from CommDb |
|
3444 RArray<TWlanLimitedIapData> iapList; |
|
3445 TInt ret = iCache->GetIapDataList( iapList ); |
|
3446 if( ret ) |
|
3447 { |
|
3448 DEBUG1( "CWlmServer::BackgroundScanRequest() - GetIapDataList failed (%d)", ret ); |
|
3449 |
|
3450 delete iapDataList; |
|
3451 delete iapSsidList; |
|
3452 iapList.Close(); |
|
3453 |
|
3454 return ret; |
|
3455 } |
|
3456 |
|
3457 // Convert IAP data |
|
3458 ret = GetIapDataList( |
|
3459 *iapDataList, |
|
3460 *iapSsidList, |
|
3461 iapList ); |
|
3462 if ( ret != KErrNone ) |
|
3463 { |
|
3464 DEBUG1( "CWlmServer::BackgroundScanRequest() - unable to convert IAP data (%d)", ret ); |
|
3465 |
|
3466 delete iapDataList; |
|
3467 delete iapSsidList; |
|
3468 iapList.Close(); |
|
3469 |
|
3470 return ret; |
|
3471 } |
|
3472 |
|
3473 iapList.Close(); |
|
3474 |
|
3475 // Create output list |
|
3476 core_type_list_c<u32_t>* iapIdList = new core_type_list_c<u32_t>; |
|
3477 if( iapIdList == NULL ) |
|
3478 { |
|
3479 DEBUG( "ERROR: Out of memory" ); |
|
3480 delete iapDataList; |
|
3481 delete iapSsidList; |
|
3482 return KErrNoMemory; |
|
3483 } |
|
3484 |
|
3485 // Create ScanList |
|
3486 ScanList* scanList = new ScanList( KWlmScanListMaxSize ); |
|
3487 if( scanList == NULL ) |
|
3488 { |
|
3489 DEBUG( "CWlmServer::BackgroundScanRequest() - Out of memory when instantiating ScanList" ); |
|
3490 delete iapDataList; |
|
3491 delete iapSsidList; |
|
3492 delete iapIdList; |
|
3493 return KErrNoMemory; |
|
3494 } |
|
3495 |
|
3496 TTime* scanTime = new TTime( |
|
3497 CalculateScanStartTime( aScanStartInterval ).Int64() ); |
|
3498 if( !scanTime ) |
|
3499 { |
|
3500 DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TTime" ); |
|
3501 |
|
3502 delete iapDataList; |
|
3503 delete iapSsidList; |
|
3504 delete iapIdList; |
|
3505 delete scanList; |
|
3506 return KErrNoMemory; |
|
3507 } |
|
3508 |
|
3509 // create mapping |
|
3510 SRequestMapEntry mapEntry; |
|
3511 mapEntry.iRequestId = KWlanIntCmdBackgroundScan; |
|
3512 mapEntry.iParam0 = iapDataList; |
|
3513 mapEntry.iParam1 = iapIdList; |
|
3514 mapEntry.iParam2 = scanList; |
|
3515 mapEntry.iParam3 = iapSsidList; |
|
3516 mapEntry.iTime = scanTime; |
|
3517 iRequestMap.Append( mapEntry ); |
|
3518 |
|
3519 if( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration ) |
|
3520 { |
|
3521 // Scan scheduling timer needs to be set again because this request needs the results earlier |
|
3522 UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId ); |
|
3523 } |
|
3524 |
|
3525 return KErrNone; |
|
3526 } |
|
3527 |
|
3528 // --------------------------------------------------------- |
|
3529 // CWlmServer::ScanSchedulingTimerExpired |
|
3530 // --------------------------------------------------------- |
|
3531 // |
|
3532 TInt CWlmServer::ScanSchedulingTimerExpired( TAny* aThisPtr ) |
|
3533 { |
|
3534 DEBUG( "CWlmServer::ScanSchedulingTimerExpired()" ); |
|
3535 |
|
3536 CWlmServer* self = static_cast<CWlmServer*>( aThisPtr ); |
|
3537 |
|
3538 TInt index = self->FindRequestIndex( self->iRequestTriggeringScanning ); |
|
3539 |
|
3540 if( index >= self->iRequestMap.Count() && self->iBgScanProvider->IsBgScanEnabled() ) |
|
3541 { |
|
3542 /** |
|
3543 * This is most probably caused by the periodic background scan. It can happen if background |
|
3544 * scan is enabled but something fails when background scan request is tried to be added to |
|
3545 * scan scheduling queue. |
|
3546 * |
|
3547 * Add background scan request to scan scheduling queue and it should be handled immediately. |
|
3548 * Check that there are no background scans pending in the queue. |
|
3549 */ |
|
3550 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - request is not in iRequestMap, but background scan enabled" ); |
|
3551 |
|
3552 self->BackgroundScanRequest( 0 ); |
|
3553 } |
|
3554 else if( index >= self->iRequestMap.Count() ) |
|
3555 { |
|
3556 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - request is not in the iRequestMap, do nothing" ); |
|
3557 return KErrNone; |
|
3558 } |
|
3559 |
|
3560 DEBUG1( "CWlmServer::ScanSchedulingTimerExpired() - iRequestId %u", self->iRequestMap[index].iRequestId ); |
|
3561 |
|
3562 TUint indexNextScan( 0 ); |
|
3563 // If roaming is ongoing, scanning is not started for GetScanResults. |
|
3564 if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && |
|
3565 self->iRequestMap[index].iFunction == EGetScanResults && |
|
3566 self->IsRoaming() ) |
|
3567 { |
|
3568 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, roam in progress, returning empty scan results" ); |
|
3569 |
|
3570 ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 ); |
|
3571 core_ssid_s* completedSsid = reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 ); |
|
3572 TTime* completedScanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime ); |
|
3573 |
|
3574 // Only the triggering request is completed and then scan scheduling timer is set again |
|
3575 TPckgBuf<TUint32> pckgCount( 0 ); |
|
3576 TPckgBuf<TUint32> pckgSize( 0 ); |
|
3577 |
|
3578 TPckgBuf<TDynamicScanList> pckgDynamicScanList; |
|
3579 pckgDynamicScanList().count = 0; |
|
3580 pckgDynamicScanList().size = 0; |
|
3581 |
|
3582 if( self->IsSessionActive( self->iRequestMap[index] ) ) |
|
3583 { |
|
3584 self->iRequestMap[index].iMessage.Write( 2, pckgDynamicScanList ); |
|
3585 self->iRequestMap[index].iMessage.Complete( KErrNone ); |
|
3586 } |
|
3587 |
|
3588 delete completedScanList; |
|
3589 completedScanList = NULL; |
|
3590 delete completedSsid; |
|
3591 completedSsid = NULL; |
|
3592 delete completedScanTime; |
|
3593 completedScanTime = NULL; |
|
3594 |
|
3595 self->iRequestMap.Remove( index ); |
|
3596 |
|
3597 if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) ) |
|
3598 { |
|
3599 TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime ); |
|
3600 self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId ); |
|
3601 } |
|
3602 |
|
3603 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty scan results" ); |
|
3604 return KErrNone; |
|
3605 } |
|
3606 |
|
3607 // If roaming is ongoing, scanning is not started for GetAvailableIaps. |
|
3608 if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && |
|
3609 self->iRequestMap[index].iFunction == EGetAvailableIaps && |
|
3610 self->IsRoaming() ) |
|
3611 { |
|
3612 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps, roam in progress, returning empty iap list" ); |
|
3613 |
|
3614 core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 ); |
|
3615 core_type_list_c<u32_t>* iapIdList = reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 ); |
|
3616 ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 ); |
|
3617 core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 ); |
|
3618 TTime* scanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime ); |
|
3619 |
|
3620 // Only the triggering request is completed and then scan scheduling timer is set again |
|
3621 if( self->IsSessionActive( self->iRequestMap[index] ) ) |
|
3622 { |
|
3623 TWlmAvailableIaps tmp = { 0 }; |
|
3624 TPckg<TWlmAvailableIaps> outPckg( tmp ); |
|
3625 self->iRequestMap[index].iMessage.Write( 0, outPckg ); |
|
3626 self->iRequestMap[index].iMessage.Complete( KErrNone ); |
|
3627 } |
|
3628 |
|
3629 delete iapDataList; |
|
3630 iapDataList = NULL; |
|
3631 delete iapIdList; |
|
3632 iapIdList = NULL; |
|
3633 delete scanList; |
|
3634 scanList = NULL; |
|
3635 delete iapSsidList; |
|
3636 iapSsidList = NULL; |
|
3637 delete scanTime; |
|
3638 scanTime = NULL; |
|
3639 |
|
3640 self->iRequestMap.Remove( index ); |
|
3641 |
|
3642 if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) ) |
|
3643 { |
|
3644 TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime ); |
|
3645 self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId ); |
|
3646 } |
|
3647 |
|
3648 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty iap list" ); |
|
3649 return KErrNone; |
|
3650 } |
|
3651 |
|
3652 // If triggering request is background scan and WLAN connection exist, background scan is skipped |
|
3653 if( self->iRequestMap[index].iRequestId == KWlanIntCmdBackgroundScan && |
|
3654 self->iConnectionState != EWlanStateNotConnected ) |
|
3655 { |
|
3656 DEBUG("CWlmServer::ScanSchedulingTimerExpired() - active connection exists: skipping background scan"); |
|
3657 |
|
3658 // notify bg scan provider so it will issue a new CWlmServer::Scan() call, |
|
3659 // where the existing request map entry will be updated |
|
3660 self->iBgScanProvider->ScanComplete(); |
|
3661 |
|
3662 return KErrNone; |
|
3663 } |
|
3664 |
|
3665 // Scan mode is either passive or active |
|
3666 core_scan_mode_e mode = core_scan_mode_active; |
|
3667 TBool isActiveScanAllowed( ETrue ); |
|
3668 if( self->iPlatform->GetScanType() == EWLMScanForcedPassive ) |
|
3669 { |
|
3670 mode = core_scan_mode_passive; |
|
3671 isActiveScanAllowed = EFalse; |
|
3672 } |
|
3673 |
|
3674 if( self->iRequestMap[index].iRequestId == KWlanIntCmdBackgroundScan ) |
|
3675 { |
|
3676 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting background scan, cancel timer" ); |
|
3677 // pass request to core |
|
3678 core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 ); |
|
3679 core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 ); |
|
3680 core_type_list_c<u32_t>* iapIdList = reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 ); |
|
3681 ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 ); |
|
3682 |
|
3683 self->iCoreServer->get_available_iaps( |
|
3684 self->iRequestMap[index].iRequestId, |
|
3685 isActiveScanAllowed, |
|
3686 *iapDataList, |
|
3687 *iapIdList, |
|
3688 iapSsidList, |
|
3689 *scanList ); |
|
3690 |
|
3691 self->iScanSchedulingTimer->Cancel(); |
|
3692 } |
|
3693 else if( self->iRequestMap[index].iFunction == EGetScanResults ) |
|
3694 { |
|
3695 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting GetScanResults, cancel timer" ); |
|
3696 |
|
3697 // pass request to core |
|
3698 ScanList* tmp = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0); |
|
3699 core_ssid_s* ssid2 = reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 ); |
|
3700 |
|
3701 self->iCoreServer->get_scan_result( |
|
3702 self->iRequestMap[index].iRequestId, |
|
3703 mode, |
|
3704 *ssid2, |
|
3705 SCAN_CHANNELS_2DOT4GHZ_ETSI, |
|
3706 0, |
|
3707 *tmp, |
|
3708 false_t ); |
|
3709 |
|
3710 self->iScanSchedulingTimer->Cancel(); |
|
3711 } |
|
3712 else if( self->iRequestMap[index].iFunction == EGetAvailableIaps ) |
|
3713 { |
|
3714 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting GetAvailableIaps, cancel timer" ); |
|
3715 |
|
3716 // pass request to core |
|
3717 core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 ); |
|
3718 core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 ); |
|
3719 core_type_list_c<u32_t>* iapIdList = reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 ); |
|
3720 ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 ); |
|
3721 |
|
3722 self->iCoreServer->get_available_iaps( |
|
3723 self->iRequestMap[index].iRequestId, |
|
3724 isActiveScanAllowed, |
|
3725 *iapDataList, |
|
3726 *iapIdList, |
|
3727 iapSsidList, |
|
3728 *scanList ); |
|
3729 |
|
3730 self->iScanSchedulingTimer->Cancel(); |
|
3731 } |
|
3732 self->iCoreHandlingScanRequest = ETrue; |
|
3733 return KErrNone; |
|
3734 } |
|
3735 |
|
3736 // --------------------------------------------------------- |
|
3737 // CWlmServer::GetIapDataList() |
|
3738 // --------------------------------------------------------- |
|
3739 // |
|
3740 TInt CWlmServer::GetIapDataList( |
|
3741 core_type_list_c<core_iap_data_s>& aCoreIapDataList, |
|
3742 core_type_list_c<core_ssid_entry_s>& aCoreIapSsidList, |
|
3743 const RArray<TWlanLimitedIapData>& aAmIapDataList ) |
|
3744 { |
|
3745 DEBUG( "CWlmServer::GetIapDataList()" ); |
|
3746 DEBUG1( "CWlmServer::GetIapDataList() - converting %u entries", |
|
3747 aAmIapDataList.Count() ); |
|
3748 |
|
3749 /** |
|
3750 * Create a commsdat session for retrieving possible secondary SSIDs. |
|
3751 */ |
|
3752 CWLanSettings wlanSettings; |
|
3753 TInt ret = wlanSettings.Connect(); |
|
3754 if ( ret != KErrNone ) |
|
3755 { |
|
3756 DEBUG1( "CWlmServer::GetIapDataList() - CWLanSettings::Connect() failed (%d)", |
|
3757 ret ); |
|
3758 |
|
3759 return ret; |
|
3760 } |
|
3761 |
|
3762 // Loop given list of IAPs and create respective list of iap data |
|
3763 for( TInt idx( 0 ); idx < aAmIapDataList.Count(); idx++ ) |
|
3764 { |
|
3765 if( aAmIapDataList[idx].ssid.Length() ) // filter out EasyWlan IAP |
|
3766 { |
|
3767 DEBUG1( "CWlmServer::GetIapDataList() - converting IAP %u", |
|
3768 aAmIapDataList[idx].iapId ); |
|
3769 |
|
3770 core_iap_data_s* coreData = new core_iap_data_s; |
|
3771 if( !coreData ) |
|
3772 { |
|
3773 DEBUG( "CWlmServer::GetIapDataList() - unable to instantiate core_iap_data_s" ); |
|
3774 wlanSettings.Disconnect(); |
|
3775 |
|
3776 return KErrNoMemory; |
|
3777 } |
|
3778 |
|
3779 TWlanConversionUtil::ConvertIapSettings( |
|
3780 *coreData, |
|
3781 aAmIapDataList[idx] ); |
|
3782 |
|
3783 ret = aCoreIapDataList.append( coreData ); |
|
3784 if( ret ) |
|
3785 { |
|
3786 DEBUG1( "CWlmServer::GetIapDataList() - unable to append core_iap_data_s entry (%u)", |
|
3787 ret ); |
|
3788 wlanSettings.Disconnect(); |
|
3789 delete coreData; |
|
3790 |
|
3791 return ret; |
|
3792 } |
|
3793 |
|
3794 // Read possible secondary ssids |
|
3795 RArray<TWlanSecondarySsid> secondarySsidList; |
|
3796 wlanSettings.GetSecondarySsidsForService( |
|
3797 aAmIapDataList[idx].serviceId, |
|
3798 secondarySsidList ); |
|
3799 |
|
3800 // Create secondary SSID list if needed |
|
3801 if( aAmIapDataList[idx].usedSsid.Length() || secondarySsidList.Count() ) |
|
3802 { |
|
3803 DEBUG1( "CWlmServer::GetIapDataList() - IAP %u has secondary SSIDs defined", |
|
3804 coreData->id ); |
|
3805 |
|
3806 core_ssid_entry_s* entry = new core_ssid_entry_s; |
|
3807 if ( !entry ) |
|
3808 { |
|
3809 DEBUG( "CWlmServer::GetIapDataList() - unable to instantiate core_ssid_entry_s" ); |
|
3810 |
|
3811 secondarySsidList.Close(); |
|
3812 wlanSettings.Disconnect(); |
|
3813 |
|
3814 return KErrNoMemory; |
|
3815 } |
|
3816 |
|
3817 entry->id = coreData->id; |
|
3818 entry->ssid = coreData->ssid; |
|
3819 if( aAmIapDataList[idx].usedSsid.Length() ) |
|
3820 { |
|
3821 TWlanConversionUtil::ConvertSSID( entry->used_ssid, aAmIapDataList[idx].usedSsid ); |
|
3822 } |
|
3823 else |
|
3824 { |
|
3825 entry->used_ssid = entry->ssid; |
|
3826 } |
|
3827 aCoreIapSsidList.append( entry ); |
|
3828 |
|
3829 for( TInt idx( 0 ); idx < secondarySsidList.Count(); ++idx ) |
|
3830 { |
|
3831 entry = new core_ssid_entry_s; |
|
3832 if ( !entry ) |
|
3833 { |
|
3834 DEBUG( "CWlmServer::GetIapDataList() - unable to instantiate core_ssid_entry_s" ); |
|
3835 |
|
3836 secondarySsidList.Close(); |
|
3837 wlanSettings.Disconnect(); |
|
3838 |
|
3839 return KErrNoMemory; |
|
3840 } |
|
3841 |
|
3842 entry->id = coreData->id; |
|
3843 TWlanConversionUtil::ConvertSSID( |
|
3844 entry->ssid, secondarySsidList[idx].ssid ); |
|
3845 if ( secondarySsidList[idx].usedSsid.Length() ) |
|
3846 { |
|
3847 TWlanConversionUtil::ConvertSSID( |
|
3848 entry->used_ssid, secondarySsidList[idx].usedSsid ); |
|
3849 } |
|
3850 else |
|
3851 { |
|
3852 entry->used_ssid = coreData->ssid; |
|
3853 } |
|
3854 aCoreIapSsidList.append( entry ); |
|
3855 } |
|
3856 } |
|
3857 |
|
3858 secondarySsidList.Close(); |
|
3859 } |
|
3860 } // for loop |
|
3861 |
|
3862 wlanSettings.Disconnect(); |
|
3863 |
|
3864 return KErrNone; |
|
3865 } |
|
3866 |
|
3867 // --------------------------------------------------------- |
|
3868 // CWlmServer::GetLanSettings() |
|
3869 // --------------------------------------------------------- |
|
3870 // |
|
3871 TInt CWlmServer::GetLanSettings( |
|
3872 TUint32 aLanServiceId, |
|
3873 SLanSettings& aLanSettings ) |
|
3874 { |
|
3875 DEBUG("CWlmServer::GetLanSettings()"); |
|
3876 |
|
3877 TInt ret = KErrNone; |
|
3878 CLanSettings* lanSettings = new CLanSettings; |
|
3879 if( lanSettings == NULL ) |
|
3880 { |
|
3881 DEBUG( "ERROR creating CLanSettings" ); |
|
3882 return KErrNoMemory; |
|
3883 } |
|
3884 |
|
3885 ret = lanSettings->Connect(); |
|
3886 if( ret != KErrNone ) |
|
3887 { |
|
3888 DEBUG1( "ERROR - Connect() failed with %d", ret ); |
|
3889 lanSettings->Disconnect(); |
|
3890 delete lanSettings; |
|
3891 return ret; |
|
3892 } |
|
3893 |
|
3894 ret = lanSettings->GetLanSettings( aLanServiceId, aLanSettings ); |
|
3895 if( ret != KErrNone ) |
|
3896 { |
|
3897 DEBUG1( "ERROR - GetLanSettings() failed with %d", ret ); |
|
3898 } |
|
3899 lanSettings->Disconnect(); |
|
3900 delete lanSettings; |
|
3901 return ret; |
|
3902 } |
|
3903 |
|
3904 // --------------------------------------------------------- |
|
3905 // CWlmServer::BtConnectionEstablished |
|
3906 // --------------------------------------------------------- |
|
3907 // |
|
3908 void CWlmServer::BtConnectionEstablished() |
|
3909 { |
|
3910 iDriverIf->Notify( core_am_indication_bt_connection_established ); |
|
3911 } |
|
3912 |
|
3913 // --------------------------------------------------------- |
|
3914 // CWlmServer::BtConnectionDisabled |
|
3915 // --------------------------------------------------------- |
|
3916 // |
|
3917 void CWlmServer::BtConnectionDisabled() |
|
3918 { |
|
3919 iDriverIf->Notify( core_am_indication_bt_connection_disconnected ); |
|
3920 } |
|
3921 |
|
3922 // --------------------------------------------------------- |
|
3923 // CWlmServer::SystemTimeChanged |
|
3924 // --------------------------------------------------------- |
|
3925 // |
|
3926 void CWlmServer::SystemTimeChanged() |
|
3927 { |
|
3928 DEBUG("CWlmServer::SystemTimeChanged()"); |
|
3929 |
|
3930 if ( iIsStartupComplete ) |
|
3931 { |
|
3932 // If the changed time is less than cached region timestamp, |
|
3933 // then cache is cleared. |
|
3934 TTime newTime; |
|
3935 newTime.UniversalTime(); |
|
3936 |
|
3937 if ( newTime.Int64() < iTimeofDomainQuery.Int64() ) |
|
3938 { |
|
3939 // Region cache expires when user has changed the time |
|
3940 TTime timestampClear(1); |
|
3941 iTimeofDomainQuery = timestampClear; |
|
3942 |
|
3943 TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, KWlmRegionUnknown )); |
|
3944 if ( ret == KErrNone ) |
|
3945 { |
|
3946 TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, iTimeofDomainQuery.Int64() )); |
|
3947 if ( ret != KErrNone ) |
|
3948 { |
|
3949 DEBUG1( "CWlmServer::SystemTimeChanged() - attempt to store region timestamp leaved with code %d,", ret ); |
|
3950 } |
|
3951 } |
|
3952 else |
|
3953 { |
|
3954 DEBUG1( "CWlmServer::SystemTimeChanged() - attempt to store region leaved with code %d,", ret ); |
|
3955 } |
|
3956 } |
|
3957 |
|
3958 DEBUG("CWlmServer::SystemTimeChanged() - inform timer services about system time change"); |
|
3959 iTimerServices->HandleTimeout(); |
|
3960 DEBUG("CWlmServer::SystemTimeChanged() - refreshing settings to BgScan provider"); |
|
3961 iBgScanProvider->NotifyChangedSettings( iBgScanProviderSettings ); |
|
3962 |
|
3963 // Pending scan requests should be handled because after the system time change all the |
|
3964 // timestamps are invalid. Change the scan start times to start immediately |
|
3965 |
|
3966 DEBUG("CWlmServer::SystemTimeChanged() - set all pending requests to expire immediately"); |
|
3967 |
|
3968 TInt i( 0 ); |
|
3969 for( i = 0; i < iRequestMap.Count(); i++ ) |
|
3970 { |
|
3971 if( IsPendingTimedScanRequest(i) ) |
|
3972 { |
|
3973 DEBUG1( "CWlmServer::SystemTimeChanged() - setting iTime to current time for request %i", |
|
3974 iRequestMap[i].iRequestId ); |
|
3975 |
|
3976 TTime* requestedScanTime = reinterpret_cast<TTime*>( iRequestMap[i].iTime ); |
|
3977 requestedScanTime->UniversalTime(); |
|
3978 } |
|
3979 } |
|
3980 if( !iCoreHandlingScanRequest ) |
|
3981 { |
|
3982 // Core is not handling any scan request so update the timer |
|
3983 DEBUG("CWlmServer::SystemTimeChanged() - Core is not currently handling any scan requests"); |
|
3984 DEBUG("CWlmServer::SystemTimeChanged() - Cancel timer and set it again to new value"); |
|
3985 |
|
3986 iScanSchedulingTimer->Cancel(); |
|
3987 TUint indexNextScan; |
|
3988 if( FindNextTimedScanSchedulingRequest( indexNextScan ) ) |
|
3989 { |
|
3990 TTime* nextScanTime = reinterpret_cast<TTime*>( iRequestMap[indexNextScan].iTime ); |
|
3991 UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId ); |
|
3992 } |
|
3993 } |
|
3994 } |
|
3995 } |
|
3996 |
|
3997 // --------------------------------------------------------- |
|
3998 // CWlmServer::ClearRegionCache |
|
3999 // --------------------------------------------------------- |
|
4000 // |
|
4001 void CWlmServer::ClearRegionCache() |
|
4002 { |
|
4003 DEBUG("CWlmServer::ClearRegionCache()"); |
|
4004 |
|
4005 // Region cache expires when user has changed the time |
|
4006 TTime timestampClear(1); |
|
4007 iTimeofDomainQuery = timestampClear; |
|
4008 |
|
4009 TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, KWlmRegionUnknown )); |
|
4010 if ( ret != KErrNone ) |
|
4011 { |
|
4012 DEBUG1( "CWlmServer::ClearRegionCache() - StoreWlanCenRepKeyValueL() leaved with code %d,", ret ); |
|
4013 } |
|
4014 TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, iTimeofDomainQuery.Int64() )); |
|
4015 if ( ret != KErrNone ) |
|
4016 { |
|
4017 DEBUG1( "CWlmServer::ClearRegionCache() - StoreWlanCenRepKeyValueL() leaved with code %d,", ret ); |
|
4018 } |
|
4019 } |
|
4020 |
|
4021 // --------------------------------------------------------- |
|
4022 // CWlmServer::SendData |
|
4023 // --------------------------------------------------------- |
|
4024 // |
|
4025 TInt CWlmServer::SendData( |
|
4026 const void * const aData, |
|
4027 const TInt aLength ) |
|
4028 { |
|
4029 DEBUG2( "CWlmServer::SendData(data=0x%08X, length=%i)", aData, aLength ); |
|
4030 ASSERT( iEapolHandler ); |
|
4031 return iEapolHandler->send_data( aData, aLength ); |
|
4032 } |
|
4033 |
|
4034 // --------------------------------------------------------- |
|
4035 // CWlmServer::Scan |
|
4036 // --------------------------------------------------------- |
|
4037 // |
|
4038 void CWlmServer::Scan( |
|
4039 const TUint& aMaxDelay ) |
|
4040 { |
|
4041 DEBUG1( "CWlmServer::Scan() - aMaxDelay %u", aMaxDelay ); |
|
4042 |
|
4043 // - by design, this method is called only if background scan is enabled |
|
4044 ASSERT( iBgScanProvider->IsBgScanEnabled() ); |
|
4045 // - by design, this method is only called if iIsStartupComplete is true |
|
4046 ASSERT( iIsStartupComplete ); |
|
4047 // - by design, a background scan request can already be in the queue |
|
4048 // -> instead of creating a new request to the request map, modify the existing one |
|
4049 // - by design, background scan request might be issued even if we're connected |
|
4050 // - update scan scheduling timer if needed |
|
4051 |
|
4052 TInt index = FindRequestIndex( KWlanIntCmdBackgroundScan ); |
|
4053 |
|
4054 if( index >= iRequestMap.Count() ) |
|
4055 { |
|
4056 // there are no pending background scan requests |
|
4057 DEBUG( "CWlmServer::Scan() - there are NO pending background scan requests" ); |
|
4058 |
|
4059 BackgroundScanRequest( aMaxDelay ); |
|
4060 } |
|
4061 else |
|
4062 { |
|
4063 DEBUG1( "CWlmServer::Scan() - there is a pending background scan request, index (%d)", index); |
|
4064 |
|
4065 ASSERT( iRequestMap[index].iTime ); |
|
4066 |
|
4067 DEBUG( "CWlmServer::Scan() - cancel scan scheduling timer (might already be cancelled but it doesn't matter)" ); |
|
4068 iScanSchedulingTimer->Cancel(); |
|
4069 |
|
4070 if( !iCoreHandlingScanRequest ) |
|
4071 { |
|
4072 DEBUG( "CWlmServer::Scan() - core is not handling background scan request" ); |
|
4073 |
|
4074 DEBUG( "CWlmServer::Scan() - set new scan start time for existing background scan request" ); |
|
4075 *iRequestMap[index].iTime = CalculateScanStartTime( aMaxDelay ); |
|
4076 |
|
4077 DEBUG( "CWlmServer::Scan() - find the scan scheduling request which expires next" ); |
|
4078 TUint indexNextScan; |
|
4079 if( FindNextTimedScanSchedulingRequest( indexNextScan ) ) |
|
4080 { |
|
4081 UpdateScanSchedulingTimer( *iRequestMap[indexNextScan].iTime, |
|
4082 iRequestMap[indexNextScan].iRequestId ); |
|
4083 } |
|
4084 #ifdef _DEBUG |
|
4085 else |
|
4086 { |
|
4087 DEBUG( "CWlmServer::Scan() - no scan scheduling request found!!" ); |
|
4088 ASSERT( 0 ); |
|
4089 } |
|
4090 #endif |
|
4091 } |
|
4092 else |
|
4093 { |
|
4094 DEBUG( "CWlmServer::Scan() - core is currently handling some scan request" ); |
|
4095 |
|
4096 if( iRequestTriggeringScanning == iRequestMap[index].iRequestId ) |
|
4097 { |
|
4098 DEBUG( "CWlmServer::Scan() - core is handling background scanning currently" ); |
|
4099 DEBUG( "CWlmServer::Scan() - no need to update the existing background scan request" ); |
|
4100 } |
|
4101 else |
|
4102 { |
|
4103 DEBUG( "CWlmServer::Scan() - core is NOT handling background scanning currently" ); |
|
4104 DEBUG( "CWlmServer::Scan() - just update the time to the background scan request" ); |
|
4105 *iRequestMap[index].iTime = CalculateScanStartTime( aMaxDelay ); |
|
4106 } |
|
4107 } |
|
4108 } |
|
4109 |
|
4110 DEBUG( "CWlmServer::Scan() - returning" ); |
|
4111 } |
|
4112 |
|
4113 // --------------------------------------------------------- |
|
4114 // CWlmServer::CancelScan |
|
4115 // --------------------------------------------------------- |
|
4116 // |
|
4117 void CWlmServer::CancelScan() |
|
4118 { |
|
4119 DEBUG( "CWlmServer::CancelScan()" ); |
|
4120 |
|
4121 if( iConnectionState == EWlanStateNotConnected ) |
|
4122 { |
|
4123 SetIconState( EWlmIconStatusNotAvailable ); |
|
4124 } |
|
4125 |
|
4126 // look for the background scan request |
|
4127 TUint index = FindRequestIndex( KWlanIntCmdBackgroundScan ); |
|
4128 |
|
4129 if( index < iRequestMap.Count() ) |
|
4130 { |
|
4131 // pending background scan request found |
|
4132 if( !iCoreHandlingScanRequest ) |
|
4133 { |
|
4134 DEBUG( "CWlmServer::CancelScan() - core is not yet handling the next scan request" ); |
|
4135 |
|
4136 DEBUG( "CWlmServer::CancelScan() - cancel timer" ); |
|
4137 iScanSchedulingTimer->Cancel(); |
|
4138 |
|
4139 DEBUG( "CWlmServer::CancelScan() - remove entry from request map" ); |
|
4140 iRequestMap.Remove( index ); |
|
4141 |
|
4142 DEBUG( "CWlmServer::CancelScan() - find next possible timed scan scheduling request" ); |
|
4143 TUint indexNextScan; |
|
4144 if( FindNextTimedScanSchedulingRequest( indexNextScan ) ) |
|
4145 { |
|
4146 UpdateScanSchedulingTimer( *iRequestMap[indexNextScan].iTime, iRequestMap[indexNextScan].iRequestId ); |
|
4147 } |
|
4148 #ifdef _DEBUG |
|
4149 else |
|
4150 { |
|
4151 DEBUG( "CWlmServer::CancelScan() - no next timed scan scheduling request found" ); |
|
4152 } |
|
4153 #endif |
|
4154 } |
|
4155 else |
|
4156 { |
|
4157 // Core is currently handling scanning |
|
4158 DEBUG( "CWlmServer::CancelScan() - core is currently handling scanning" ); |
|
4159 |
|
4160 if( iRequestTriggeringScanning == iRequestMap[index].iRequestId ) |
|
4161 { |
|
4162 DEBUG( "CWlmServer::CancelScan() - core is handling background scanning currently" ); |
|
4163 DEBUG( "CWlmServer::CancelScan() - no need to remove background scan request" ); |
|
4164 } |
|
4165 else |
|
4166 { |
|
4167 DEBUG( "CWlmServer::CancelScan() - core is NOT handling background scanning currently" ); |
|
4168 DEBUG( "CWlmServer::CancelScan() - just remove the entry from the request map" ); |
|
4169 |
|
4170 DEBUG( "CWlmServer::CancelScan() - remove entry from request map" ); |
|
4171 iRequestMap.Remove( index ); |
|
4172 } |
|
4173 } |
|
4174 } |
|
4175 DEBUG( "CWlmServer::CancelScan() - returning" ); |
|
4176 } |
|
4177 |
|
4178 // --------------------------------------------------------- |
|
4179 // CWlmServer::GetPacketStatistics |
|
4180 // --------------------------------------------------------- |
|
4181 // |
|
4182 void CWlmServer::GetPacketStatistics( |
|
4183 TUint aSessionId, |
|
4184 const RMessage2& aMessage ) |
|
4185 { |
|
4186 DEBUG( "CWlmServer::GetPacketStatistics()" ); |
|
4187 |
|
4188 // create mapping |
|
4189 SRequestMapEntry mapEntry; |
|
4190 mapEntry.iMessage = aMessage; |
|
4191 mapEntry.iFunction = EGetPacketStatistics; |
|
4192 mapEntry.iRequestId = iRequestIdCounter++; |
|
4193 mapEntry.iSessionId = aSessionId; |
|
4194 core_packet_statistics_s* tmp = new core_packet_statistics_s; |
|
4195 if( tmp == NULL ) |
|
4196 { |
|
4197 aMessage.Complete( KErrNoMemory ); |
|
4198 return; |
|
4199 } |
|
4200 mapEntry.iParam0 = tmp; |
|
4201 iRequestMap.Append( mapEntry ); |
|
4202 |
|
4203 // pass request to core |
|
4204 iCoreServer->get_packet_statistics( |
|
4205 mapEntry.iRequestId, |
|
4206 *tmp ); |
|
4207 } |
|
4208 |
|
4209 // --------------------------------------------------------- |
|
4210 // CWlmServer::ClearPacketStatistics |
|
4211 // --------------------------------------------------------- |
|
4212 // |
|
4213 void CWlmServer::ClearPacketStatistics( |
|
4214 TUint /* aSessionId */, |
|
4215 const RMessage2& aMessage ) |
|
4216 { |
|
4217 DEBUG( "CWlmServer::ClearPacketStatistics()" ); |
|
4218 |
|
4219 core_error_e ret = iCoreServer->clear_packet_statistics(); |
|
4220 if ( ret != core_error_ok ) |
|
4221 { |
|
4222 DEBUG1( "CWlmServer::ClearPacketStatistics() - clear_packet_statistics() failed with %u", |
|
4223 ret ); |
|
4224 } |
|
4225 |
|
4226 aMessage.Complete( |
|
4227 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4228 } |
|
4229 |
|
4230 // --------------------------------------------------------- |
|
4231 // CWlmServer::GetUapsdSettings |
|
4232 // --------------------------------------------------------- |
|
4233 // |
|
4234 void CWlmServer::GetUapsdSettings( |
|
4235 TUint /* aSessionId */, |
|
4236 const RMessage2& aMessage ) |
|
4237 { |
|
4238 DEBUG( "CWlmServer::GetUapsdSettings()" ); |
|
4239 |
|
4240 core_uapsd_settings_s coreSettings; |
|
4241 core_error_e ret = iCoreServer->get_uapsd_settings( coreSettings ); |
|
4242 if ( ret != core_error_ok ) |
|
4243 { |
|
4244 DEBUG1( "CWlmServer::GetUapsdSettings() - get_uapsd_settings() failed with %u", |
|
4245 ret ); |
|
4246 } |
|
4247 |
|
4248 TWlanUapsdSettings settings; |
|
4249 TWlanConversionUtil::ConvertUapsdSettings( |
|
4250 settings, |
|
4251 coreSettings ); |
|
4252 TPckg<TWlanUapsdSettings> outPckg( settings ); |
|
4253 aMessage.Write( 0, outPckg ); |
|
4254 aMessage.Complete( |
|
4255 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4256 } |
|
4257 |
|
4258 // --------------------------------------------------------- |
|
4259 // CWlmServer::SetUapsdSettings |
|
4260 // --------------------------------------------------------- |
|
4261 // |
|
4262 void CWlmServer::SetUapsdSettings( |
|
4263 TUint /* aSessionId */, |
|
4264 const RMessage2& aMessage ) |
|
4265 { |
|
4266 DEBUG( "CWlmServer::SetUapsdSettings()" ); |
|
4267 |
|
4268 TWlanUapsdSettings settings = |
|
4269 { EWlanMaxServicePeriodLengthAll, ETrue, ETrue, ETrue, ETrue }; |
|
4270 TPckg<TWlanUapsdSettings> inPckg( settings ); |
|
4271 TInt err( aMessage.Read( 0, inPckg ) ); |
|
4272 if( err != KErrNone ) |
|
4273 { |
|
4274 aMessage.Complete( err ); |
|
4275 return; |
|
4276 } |
|
4277 |
|
4278 core_uapsd_settings_s coreSettings; |
|
4279 TWlanConversionUtil::ConvertUapsdSettings( |
|
4280 coreSettings, |
|
4281 settings ); |
|
4282 |
|
4283 core_error_e ret = iCoreServer->set_uapsd_settings( coreSettings ); |
|
4284 if ( ret != core_error_ok ) |
|
4285 { |
|
4286 DEBUG1( "CWlmServer::SetUapsdSettings() - set_uapsd_settings() failed with %u", |
|
4287 ret ); |
|
4288 } |
|
4289 |
|
4290 aMessage.Complete( |
|
4291 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4292 } |
|
4293 |
|
4294 // --------------------------------------------------------- |
|
4295 // CWlmServer::GetPowerSaveSettings |
|
4296 // --------------------------------------------------------- |
|
4297 // |
|
4298 void CWlmServer::GetPowerSaveSettings( |
|
4299 TUint /* aSessionId */, |
|
4300 const RMessage2& aMessage ) |
|
4301 { |
|
4302 DEBUG( "CWlmServer::GetPowerSaveSettings()" ); |
|
4303 |
|
4304 core_power_save_settings_s coreSettings; |
|
4305 core_error_e ret = iCoreServer->get_power_save_settings( coreSettings ); |
|
4306 if ( ret != core_error_ok ) |
|
4307 { |
|
4308 DEBUG1( "CWlmServer::GetPowerSaveSettings() - get_power_save_settings() failed with %u", |
|
4309 ret ); |
|
4310 } |
|
4311 |
|
4312 TWlanPowerSaveSettings settings; |
|
4313 TWlanConversionUtil::ConvertPowerSaveSettings( |
|
4314 settings, |
|
4315 coreSettings ); |
|
4316 TPckg<TWlanPowerSaveSettings> outPckg( settings ); |
|
4317 aMessage.Write( 0, outPckg ); |
|
4318 aMessage.Complete( |
|
4319 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4320 } |
|
4321 |
|
4322 // --------------------------------------------------------- |
|
4323 // CWlmServer::SetPowerSaveSettings |
|
4324 // --------------------------------------------------------- |
|
4325 // |
|
4326 void CWlmServer::SetPowerSaveSettings( |
|
4327 TUint /* aSessionId */, |
|
4328 const RMessage2& aMessage ) |
|
4329 { |
|
4330 DEBUG( "CWlmServer::SetPowerSaveSettings()" ); |
|
4331 |
|
4332 TWlanPowerSaveSettings settings = |
|
4333 { ETrue, EFalse, EFalse, EFalse, EFalse, EFalse, EFalse, EFalse }; |
|
4334 TPckg<TWlanPowerSaveSettings> inPckg( settings ); |
|
4335 TInt err( aMessage.Read( 0, inPckg ) ); |
|
4336 if( err != KErrNone ) |
|
4337 { |
|
4338 aMessage.Complete( err ); |
|
4339 return; |
|
4340 } |
|
4341 |
|
4342 core_power_save_settings_s coreSettings; |
|
4343 TWlanConversionUtil::ConvertPowerSaveSettings( |
|
4344 coreSettings, |
|
4345 settings ); |
|
4346 |
|
4347 core_error_e ret = iCoreServer->set_power_save_settings( coreSettings ); |
|
4348 if ( ret != core_error_ok ) |
|
4349 { |
|
4350 DEBUG1( "CWlmServer::SetPowerSaveSettings() - set_power_save_settings() failed with %u", |
|
4351 ret ); |
|
4352 } |
|
4353 |
|
4354 aMessage.Complete( |
|
4355 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4356 } |
|
4357 |
|
4358 // --------------------------------------------------------- |
|
4359 // CWlmServer::RunProtectedSetup |
|
4360 // --------------------------------------------------------- |
|
4361 // |
|
4362 void CWlmServer::RunProtectedSetup( |
|
4363 TUint aSessionId, |
|
4364 const RMessage2& aMessage ) |
|
4365 { |
|
4366 DEBUG( "CWlmServer::RunProtectedSetup()" ); |
|
4367 |
|
4368 // Get WlanSettings and secondarySSID list |
|
4369 // (lanServiceId specifies the table row in wlansettings) |
|
4370 SWLANSettings iapData; |
|
4371 RArray<TWlanSecondarySsid> secondarySsidList; |
|
4372 TInt lanServiceId = aMessage.Int0(); |
|
4373 TRAPD( err, GetIapSettingsL( lanServiceId, iapData, secondarySsidList ) ) ; |
|
4374 if( err != KErrNone ) |
|
4375 { |
|
4376 DEBUG1( "CWlmServer::RunProtectedSetup() - GetIapSettingsL leaved with %d", |
|
4377 err ); |
|
4378 secondarySsidList.Close(); |
|
4379 aMessage.Complete( err ); |
|
4380 return; |
|
4381 } |
|
4382 secondarySsidList.Close(); |
|
4383 |
|
4384 // Type conversion |
|
4385 core_iap_data_s* coreIapData = new core_iap_data_s; |
|
4386 if( !coreIapData ) |
|
4387 { |
|
4388 aMessage.Complete( KErrNoMemory ); |
|
4389 return; |
|
4390 } |
|
4391 |
|
4392 TWLMOverrideSettings override = { 0 }; |
|
4393 TWlanConversionUtil::ConvertIapSettings( |
|
4394 *coreIapData, |
|
4395 iapData, |
|
4396 ETrue, // dhcp usage is not important here |
|
4397 override ); |
|
4398 |
|
4399 |
|
4400 // Create a list for the results. |
|
4401 core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>; |
|
4402 if( iapDataList == NULL ) |
|
4403 { |
|
4404 DEBUG( "CWlmServer::RunProtectedSetup() - unable to create iapDataList" ); |
|
4405 delete coreIapData; |
|
4406 |
|
4407 aMessage.Complete( KErrNoMemory ); |
|
4408 return; |
|
4409 } |
|
4410 |
|
4411 // Protected Setup status |
|
4412 core_protected_setup_status_e* protectedSetupStatus = new core_protected_setup_status_e; |
|
4413 if( !protectedSetupStatus ) |
|
4414 { |
|
4415 delete coreIapData; |
|
4416 delete iapDataList; |
|
4417 |
|
4418 aMessage.Complete( KErrNoMemory ); |
|
4419 return; |
|
4420 } |
|
4421 *protectedSetupStatus = core_protected_setup_status_undefined; |
|
4422 |
|
4423 // create mapping |
|
4424 SRequestMapEntry mapEntry; |
|
4425 mapEntry.iMessage = aMessage; |
|
4426 mapEntry.iFunction = ERunProtectedSetup; |
|
4427 mapEntry.iRequestId = iRequestIdCounter++; |
|
4428 mapEntry.iSessionId = aSessionId; |
|
4429 mapEntry.iParam0 = coreIapData; |
|
4430 mapEntry.iParam1 = iapDataList; |
|
4431 mapEntry.iParam2 = protectedSetupStatus; |
|
4432 iRequestMap.Append( mapEntry ); |
|
4433 |
|
4434 // pass request to core |
|
4435 iCoreServer->run_protected_setup( |
|
4436 mapEntry.iRequestId, *coreIapData, *iapDataList, *protectedSetupStatus ); |
|
4437 } |
|
4438 |
|
4439 // --------------------------------------------------------- |
|
4440 // CWlmServer::CancelProtectedSetup |
|
4441 // --------------------------------------------------------- |
|
4442 // |
|
4443 void CWlmServer::CancelProtectedSetup( |
|
4444 TUint aSessionId, |
|
4445 const RMessage2& aMessage ) |
|
4446 { |
|
4447 DEBUG( "CWlmServer::CancelProtectedSetup()" ); |
|
4448 |
|
4449 CancelExternalRequest( |
|
4450 aSessionId, |
|
4451 ERunProtectedSetup ); |
|
4452 |
|
4453 aMessage.Complete( KErrNone ); |
|
4454 } |
|
4455 |
|
4456 // --------------------------------------------------------- |
|
4457 // CWlmServer::CreateTrafficStream |
|
4458 // --------------------------------------------------------- |
|
4459 // |
|
4460 void CWlmServer::CreateTrafficStream( |
|
4461 TUint aSessionId, |
|
4462 const RMessage2& aMessage ) |
|
4463 { |
|
4464 DEBUG( "CWlmServer::CreateTrafficStream()" ); |
|
4465 |
|
4466 TPckgBuf<TWlanTrafficStreamParameters> paramsPckg( 0 ); |
|
4467 TInt ret( aMessage.Read( 0, paramsPckg ) ); |
|
4468 if( ret != KErrNone ) |
|
4469 { |
|
4470 aMessage.Complete( ret ); |
|
4471 return; |
|
4472 } |
|
4473 if( paramsPckg().iUserPriority > MAX_USER_PRIORITY ) |
|
4474 { |
|
4475 aMessage.Complete( KErrArgument ); |
|
4476 return; |
|
4477 } |
|
4478 |
|
4479 TBool isAutomatic = aMessage.Int1(); |
|
4480 |
|
4481 u32_t* coreStreamId = new u32_t; |
|
4482 core_traffic_stream_status_e* coreStreamStatus = new core_traffic_stream_status_e; |
|
4483 if( !coreStreamId || |
|
4484 !coreStreamStatus ) |
|
4485 { |
|
4486 delete coreStreamId; |
|
4487 delete coreStreamStatus; |
|
4488 |
|
4489 aMessage.Complete( KErrNoMemory ); |
|
4490 return; |
|
4491 } |
|
4492 |
|
4493 u8_t coreTid( TRAFFIC_STREAM_TID_NONE ); |
|
4494 u8_t coreUserPriority( 0 ); |
|
4495 core_traffic_stream_params_s coreParams = { 0 }; |
|
4496 TWlanConversionUtil::ConvertTrafficStreamParameters( |
|
4497 coreTid, |
|
4498 coreUserPriority, |
|
4499 coreParams, |
|
4500 paramsPckg() ); |
|
4501 |
|
4502 // create mapping |
|
4503 SRequestMapEntry mapEntry; |
|
4504 mapEntry.iMessage = aMessage; |
|
4505 mapEntry.iFunction = ECreateTrafficStream; |
|
4506 mapEntry.iRequestId = iRequestIdCounter++; |
|
4507 mapEntry.iSessionId = aSessionId; |
|
4508 mapEntry.iParam0 = coreStreamId; |
|
4509 mapEntry.iParam1 = coreStreamStatus; |
|
4510 iRequestMap.Append( mapEntry ); |
|
4511 |
|
4512 // pass request to core |
|
4513 iCoreServer->create_traffic_stream( |
|
4514 mapEntry.iRequestId, |
|
4515 coreTid, |
|
4516 coreUserPriority, |
|
4517 isAutomatic, |
|
4518 coreParams, |
|
4519 *coreStreamId, |
|
4520 *coreStreamStatus ); |
|
4521 } |
|
4522 |
|
4523 // --------------------------------------------------------- |
|
4524 // CWlmServer::CancelCreateTrafficStream |
|
4525 // --------------------------------------------------------- |
|
4526 // |
|
4527 void CWlmServer::CancelCreateTrafficStream( |
|
4528 TUint aSessionId, |
|
4529 const RMessage2& aMessage ) |
|
4530 { |
|
4531 CancelExternalRequest( |
|
4532 aSessionId, |
|
4533 ECreateTrafficStream ); |
|
4534 |
|
4535 aMessage.Complete( KErrNone ); |
|
4536 } |
|
4537 |
|
4538 // --------------------------------------------------------- |
|
4539 // CWlmServer::DeleteTrafficStream |
|
4540 // --------------------------------------------------------- |
|
4541 // |
|
4542 void CWlmServer::DeleteTrafficStream( |
|
4543 TUint aSessionId, |
|
4544 const RMessage2& aMessage ) |
|
4545 { |
|
4546 DEBUG( "CWlmServer::DeleteTrafficStream()" ); |
|
4547 |
|
4548 u32_t streamId = aMessage.Int0(); |
|
4549 |
|
4550 // create mapping |
|
4551 SRequestMapEntry mapEntry; |
|
4552 mapEntry.iMessage = aMessage; |
|
4553 mapEntry.iFunction = EDeleteTrafficStream; |
|
4554 mapEntry.iRequestId = iRequestIdCounter++; |
|
4555 mapEntry.iSessionId = aSessionId; |
|
4556 iRequestMap.Append( mapEntry ); |
|
4557 |
|
4558 // pass request to core |
|
4559 iCoreServer->delete_traffic_stream( |
|
4560 mapEntry.iRequestId, |
|
4561 streamId ); |
|
4562 } |
|
4563 |
|
4564 // --------------------------------------------------------- |
|
4565 // CWlmServer::CancelDeleteTrafficStream |
|
4566 // --------------------------------------------------------- |
|
4567 // |
|
4568 void CWlmServer::CancelDeleteTrafficStream( |
|
4569 TUint aSessionId, |
|
4570 const RMessage2& aMessage ) |
|
4571 { |
|
4572 CancelExternalRequest( |
|
4573 aSessionId, |
|
4574 EDeleteTrafficStream ); |
|
4575 |
|
4576 aMessage.Complete( KErrNone ); |
|
4577 } |
|
4578 |
|
4579 // --------------------------------------------------------- |
|
4580 // CWlmServer::GetAccessPointInfo |
|
4581 // --------------------------------------------------------- |
|
4582 // |
|
4583 void CWlmServer::GetAccessPointInfo( |
|
4584 TUint /* aSessionId */, |
|
4585 const RMessage2& aMessage ) |
|
4586 { |
|
4587 DEBUG( "CWlmServer::GetAccessPointInfo()" ); |
|
4588 |
|
4589 core_ap_information_s coreInfo; |
|
4590 core_error_e ret = iCoreServer->get_current_ap_info( coreInfo ); |
|
4591 if ( ret != core_error_ok ) |
|
4592 { |
|
4593 DEBUG1( "CWlmServer::GetAccessPointInfo() - get_current_ap_info() failed with %u", |
|
4594 ret ); |
|
4595 } |
|
4596 |
|
4597 TWlanAccessPointInfo info; |
|
4598 TWlanConversionUtil::ConvertApInformation( |
|
4599 info, |
|
4600 coreInfo ); |
|
4601 TPckg<TWlanAccessPointInfo> outPckg( info ); |
|
4602 aMessage.Write( 0, outPckg ); |
|
4603 aMessage.Complete( |
|
4604 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4605 } |
|
4606 |
|
4607 // --------------------------------------------------------- |
|
4608 // CWlmServer::GetRoamMetrics |
|
4609 // --------------------------------------------------------- |
|
4610 // |
|
4611 void CWlmServer::GetRoamMetrics( |
|
4612 TUint /* aSessionId */, |
|
4613 const RMessage2& aMessage ) |
|
4614 { |
|
4615 DEBUG( "CWlmServer::GetRoamMetrics()" ); |
|
4616 |
|
4617 core_roam_metrics_s coreRoamMetrics; |
|
4618 iCoreServer->get_roam_metrics( coreRoamMetrics ); |
|
4619 |
|
4620 TWlanRoamMetrics roamMetrics; |
|
4621 TWlanConversionUtil::ConvertRoamMetrics( |
|
4622 roamMetrics, |
|
4623 coreRoamMetrics ); |
|
4624 |
|
4625 TPckg<TWlanRoamMetrics> outPckg( roamMetrics ); |
|
4626 aMessage.Write( 0, outPckg ); |
|
4627 aMessage.Complete( |
|
4628 TWlanConversionUtil::ConvertErrorCode( core_error_ok ) ); |
|
4629 } |
|
4630 |
|
4631 // --------------------------------------------------------- |
|
4632 // CWlmServer::GetRogueList |
|
4633 // --------------------------------------------------------- |
|
4634 // |
|
4635 void CWlmServer::GetRogueList( |
|
4636 TUint /* aSessionId */, |
|
4637 const RMessage2& aMessage ) |
|
4638 { |
|
4639 DEBUG( "CWlmServer::GetRogueList()" ); |
|
4640 |
|
4641 core_type_list_c<core_mac_address_s> coreRogueList; |
|
4642 core_error_e ret = iCoreServer->get_rogue_list( coreRogueList ); |
|
4643 if ( ret != core_error_ok ) |
|
4644 { |
|
4645 DEBUG1( "CWlmServer::GetRogueList() - get_rogue_list() failed with %u", |
|
4646 ret ); |
|
4647 } |
|
4648 |
|
4649 TWlmRogueList rogueList; |
|
4650 TWlanConversionUtil::ConvertRogueList( |
|
4651 rogueList, |
|
4652 coreRogueList ); |
|
4653 |
|
4654 TPckg<TWlmRogueList> outPckg( rogueList ); |
|
4655 aMessage.Write( 0, outPckg ); |
|
4656 aMessage.Complete( |
|
4657 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4658 } |
|
4659 |
|
4660 // --------------------------------------------------------- |
|
4661 // CWlmServer::GetRegulatoryDomain |
|
4662 // --------------------------------------------------------- |
|
4663 // |
|
4664 void CWlmServer::GetRegulatoryDomain( |
|
4665 TUint /* aSessionId */, |
|
4666 const RMessage2& aMessage ) |
|
4667 { |
|
4668 DEBUG( "CWlmServer::GetRegulatoryDomain()" ); |
|
4669 |
|
4670 TPckg<TWlanRegion> outPckg( iRegion ); |
|
4671 aMessage.Write( 0, outPckg ); |
|
4672 aMessage.Complete( |
|
4673 TWlanConversionUtil::ConvertErrorCode( core_error_ok ) ); |
|
4674 } |
|
4675 |
|
4676 // --------------------------------------------------------- |
|
4677 // CWlmServer::GetPowerSaveMode |
|
4678 // --------------------------------------------------------- |
|
4679 // |
|
4680 void CWlmServer::GetPowerSaveMode( |
|
4681 TUint /* aSessionId */, |
|
4682 const RMessage2& aMessage ) |
|
4683 { |
|
4684 DEBUG( "CWlmServer::GetPowerSaveMode()" ); |
|
4685 |
|
4686 TWlanPowerSave powerSaveMode( iPowerSaveMode ); |
|
4687 if ( !iPowerSaveEnabled ) |
|
4688 { |
|
4689 powerSaveMode = EWlanPowerSaveNone; |
|
4690 } |
|
4691 |
|
4692 TPckg<TWlanPowerSave> outPckg( powerSaveMode ); |
|
4693 aMessage.Write( 0, outPckg ); |
|
4694 aMessage.Complete( |
|
4695 TWlanConversionUtil::ConvertErrorCode( core_error_ok ) ); |
|
4696 } |
|
4697 |
|
4698 // --------------------------------------------------------- |
|
4699 // CWlmServer::AddIapSsidListL |
|
4700 // --------------------------------------------------------- |
|
4701 // |
|
4702 void CWlmServer::AddIapSsidListL( |
|
4703 TUint /* aSessionId */, |
|
4704 const RMessage2& aMessage ) |
|
4705 { |
|
4706 DEBUG( "CWlmServer::AddIapSsidListL()" ); |
|
4707 |
|
4708 TUint iapId( |
|
4709 aMessage.Int0() ); |
|
4710 TUint ssidCount( |
|
4711 aMessage.Int1() ); |
|
4712 TInt ssidListSize( 0 ); |
|
4713 if( aMessage.Ptr2() ) |
|
4714 { |
|
4715 ssidListSize = aMessage.GetDesLengthL( 2 ); |
|
4716 } |
|
4717 |
|
4718 DEBUG3( "CWlmServer::AddIapSsidListL() - IAP ID: %u, SSID list count: %u, SSID list size: %u", |
|
4719 iapId, ssidCount, ssidListSize ); |
|
4720 |
|
4721 if( ssidCount && |
|
4722 ssidListSize ) |
|
4723 { |
|
4724 /** |
|
4725 * Make sure the IAP ID actually exists. |
|
4726 */ |
|
4727 RArray<TWlanLimitedIapData> iapList; |
|
4728 iCache->GetIapDataList( iapList ); |
|
4729 TBool isMatch( EFalse ); |
|
4730 for( TInt idx( 0 ); idx < iapList.Count() && !isMatch; ++idx ) |
|
4731 { |
|
4732 if( iapList[idx].iapId == iapId ) |
|
4733 { |
|
4734 isMatch = ETrue; |
|
4735 } |
|
4736 } |
|
4737 iapList.Close(); |
|
4738 if( !isMatch ) |
|
4739 { |
|
4740 DEBUG1( "CWlmServer::AddIapSsidListL() - IAP ID %u not found", iapId ); |
|
4741 |
|
4742 User::Leave( KErrNotFound ); |
|
4743 } |
|
4744 |
|
4745 /** |
|
4746 * Read the SSID list from the client side to a temporary buffer. |
|
4747 */ |
|
4748 HBufC8* buffer = HBufC8::NewL( ssidListSize ); |
|
4749 CleanupStack::PushL( buffer ); |
|
4750 |
|
4751 TPtr8 bufferPtr( |
|
4752 buffer->Des() ); |
|
4753 aMessage.ReadL( 2, bufferPtr ); |
|
4754 |
|
4755 /** |
|
4756 * Copy the contents of the buffer to an CArrayFixFlat instance |
|
4757 * so that they can be iterated. |
|
4758 */ |
|
4759 CArrayFixFlat<TWlanSsid>* ssidBuffer = |
|
4760 new CArrayFixFlat<TWlanSsid>( ssidCount ); |
|
4761 if( !ssidBuffer ) |
|
4762 { |
|
4763 DEBUG( "CWlmServer::AddIapSsidListL() - unable to instantiate CArrayFixFlat" ); |
|
4764 |
|
4765 User::Leave( KErrNoMemory ); |
|
4766 } |
|
4767 CleanupStack::PushL( ssidBuffer ); |
|
4768 ssidBuffer->AppendL( |
|
4769 reinterpret_cast<const TWlanSsid*>( buffer->Ptr() ), ssidCount ); |
|
4770 |
|
4771 CleanupStack::Pop( ssidBuffer ); |
|
4772 CleanupStack::PopAndDestroy( buffer ); |
|
4773 CleanupStack::PushL( ssidBuffer ); |
|
4774 |
|
4775 /** |
|
4776 * Initialize an SSID list and store SSIDs into it. |
|
4777 */ |
|
4778 CWlanSsidList* ssidList = CWlanSsidList::NewL( ssidCount ); |
|
4779 CleanupStack::PushL( ssidList ); |
|
4780 |
|
4781 for( TInt idx( 0 ); idx < ssidBuffer->Count(); ++idx ) |
|
4782 { |
|
4783 if( ssidBuffer->At( idx ).Length() <= KWlanMaxSsidLength ) |
|
4784 { |
|
4785 TInt ret = ssidList->AddSsid( ssidBuffer->At( idx ) ); |
|
4786 if( ret != KErrNone ) |
|
4787 { |
|
4788 DEBUG1( "CWlmServer::AddIapSsidListL() - AddSsid failed with %d", |
|
4789 ret ); |
|
4790 } |
|
4791 |
|
4792 User::LeaveIfError( ret ); |
|
4793 } |
|
4794 } |
|
4795 |
|
4796 DEBUG2( "CWlmServer::AddIapSsidListL() - attaching a list of %u SSID(s) to IAP ID %u", |
|
4797 ssidList->Count(), iapId ); |
|
4798 |
|
4799 iSsidListDb->WriteListL( |
|
4800 iapId, |
|
4801 *ssidList ); |
|
4802 |
|
4803 CleanupStack::PopAndDestroy( ssidList ); |
|
4804 CleanupStack::PopAndDestroy( ssidBuffer ); |
|
4805 |
|
4806 DEBUG( "CWlmServer::AddIapSsidListL() - SSID list succesfully attached" ); |
|
4807 } |
|
4808 else |
|
4809 { |
|
4810 iSsidListDb->DeleteListL( |
|
4811 iapId ); |
|
4812 |
|
4813 DEBUG( "CWlmServer::AddIapSsidListL() - SSID list succesfully deleted" ); |
|
4814 } |
|
4815 |
|
4816 /** |
|
4817 * Invalidate cached IAP availability results since they might |
|
4818 * not be valid anymore. |
|
4819 */ |
|
4820 iCache->InvalidateAvailabilityCache(); |
|
4821 |
|
4822 aMessage.Complete( KErrNone ); |
|
4823 } |
|
4824 |
|
4825 // --------------------------------------------------------- |
|
4826 // CWlmServer::RemoveIapSsidListL |
|
4827 // --------------------------------------------------------- |
|
4828 // |
|
4829 void CWlmServer::RemoveIapSsidListL( |
|
4830 TUint /* aSessionId */, |
|
4831 const RMessage2& aMessage ) |
|
4832 { |
|
4833 DEBUG( "CWlmServer::RemoveIapSsidListL()" ); |
|
4834 |
|
4835 TUint iapId = aMessage.Int0(); |
|
4836 |
|
4837 DEBUG1( "CWlmServer::RemoveIapSsidListL() - removing SSID list from IAP ID %u", |
|
4838 iapId ); |
|
4839 |
|
4840 iSsidListDb->DeleteListL( |
|
4841 iapId ); |
|
4842 |
|
4843 DEBUG( "CWlmServer::RemoveIapSsidListL() - SSID list succesfully removed" ); |
|
4844 |
|
4845 /** |
|
4846 * Invalidate cached IAP availability results since they might |
|
4847 * not be valid anymore. |
|
4848 */ |
|
4849 iCache->InvalidateAvailabilityCache(); |
|
4850 |
|
4851 aMessage.Complete( KErrNone ); |
|
4852 } |
|
4853 |
|
4854 // --------------------------------------------------------- |
|
4855 // CWlmServer::SetPowerSaveMode |
|
4856 // --------------------------------------------------------- |
|
4857 // |
|
4858 void CWlmServer::SetPowerSaveMode( |
|
4859 TUint /* aSessionId */, |
|
4860 const RMessage2& aMessage ) |
|
4861 { |
|
4862 DEBUG( "CWlmServer::SetPowerSaveMode()" ); |
|
4863 |
|
4864 TWlanPowerSaveMode mode = static_cast<TWlanPowerSaveMode>( |
|
4865 aMessage.Int0() ); |
|
4866 |
|
4867 DEBUG1( "CWlmServer::SetPowerSaveMode() - mode %u", |
|
4868 mode ); |
|
4869 |
|
4870 core_power_save_mode_s coreMode; |
|
4871 TWlanConversionUtil::ConvertPowerSaveMode( |
|
4872 coreMode, |
|
4873 mode ); |
|
4874 |
|
4875 iCoreServer->set_power_save_mode( coreMode ); |
|
4876 |
|
4877 aMessage.Complete( KErrNone ); |
|
4878 } |
|
4879 |
|
4880 // --------------------------------------------------------- |
|
4881 // CWlmServer::GetAcTrafficStatus |
|
4882 // --------------------------------------------------------- |
|
4883 // |
|
4884 void CWlmServer::GetAcTrafficStatus( |
|
4885 TUint /* aSessionId */, |
|
4886 const RMessage2& aMessage ) |
|
4887 { |
|
4888 DEBUG( "CWlmServer::GetAcTrafficStatus()" ); |
|
4889 |
|
4890 core_ac_traffic_information_s coreInfo; |
|
4891 core_error_e ret = iCoreServer->get_current_ac_traffic_info( coreInfo ); |
|
4892 if( ret != core_error_ok ) |
|
4893 { |
|
4894 DEBUG1( "CWlmServer::GetAcTrafficStatus() - get_current_ac_traffic_info() failed with %u", |
|
4895 ret ); |
|
4896 |
|
4897 aMessage.Complete( |
|
4898 TWlanConversionUtil::ConvertErrorCode( ret ) ); |
|
4899 } |
|
4900 |
|
4901 TWlmAcTrafficStatusArray info; |
|
4902 TPckg<TWlmAcTrafficStatusArray> outPckg( info ); |
|
4903 info[EWlmAccessClassBestEffort] = TWlanConversionUtil::ConvertTrafficStatus( |
|
4904 coreInfo.status_for_best_effort ); |
|
4905 info[EWlmAccessClassBackground] = TWlanConversionUtil::ConvertTrafficStatus( |
|
4906 coreInfo.status_for_background ); |
|
4907 info[EWlmAccessClassVideo] = TWlanConversionUtil::ConvertTrafficStatus( |
|
4908 coreInfo.status_for_video ); |
|
4909 info[EWlmAccessClassVoice] = TWlanConversionUtil::ConvertTrafficStatus( |
|
4910 coreInfo.status_for_voice ); |
|
4911 |
|
4912 aMessage.Write( 0, outPckg ); |
|
4913 aMessage.Complete( KErrNone ); |
|
4914 } |
|
4915 |
|
4916 // --------------------------------------------------------- |
|
4917 // CWlmServer::DirectedRoam |
|
4918 // --------------------------------------------------------- |
|
4919 // |
|
4920 void CWlmServer::DirectedRoam( |
|
4921 TUint aSessionId, |
|
4922 const RMessage2& aMessage ) |
|
4923 { |
|
4924 DEBUG( "CWlmServer::DirectedRoam()" ); |
|
4925 |
|
4926 TPckgBuf<TMacAddress> bssidPckg; |
|
4927 TInt ret( aMessage.Read( 0, bssidPckg ) ); |
|
4928 if( ret != KErrNone ) |
|
4929 { |
|
4930 aMessage.Complete( ret ); |
|
4931 return; |
|
4932 } |
|
4933 |
|
4934 core_mac_address_s coreBssid( ZERO_MAC_ADDR ); |
|
4935 TWlanConversionUtil::ConvertMacAddress( |
|
4936 coreBssid, |
|
4937 bssidPckg() ); |
|
4938 |
|
4939 // create mapping |
|
4940 SRequestMapEntry mapEntry; |
|
4941 mapEntry.iMessage = aMessage; |
|
4942 mapEntry.iFunction = EDirectedRoam; |
|
4943 mapEntry.iRequestId = iRequestIdCounter++; |
|
4944 mapEntry.iSessionId = aSessionId; |
|
4945 iRequestMap.Append( mapEntry ); |
|
4946 |
|
4947 // pass request to core |
|
4948 iCoreServer->directed_roam( |
|
4949 mapEntry.iRequestId, |
|
4950 coreBssid ); |
|
4951 } |
|
4952 |
|
4953 // --------------------------------------------------------- |
|
4954 // CWlmServer::CancelDirectedRoam |
|
4955 // --------------------------------------------------------- |
|
4956 // |
|
4957 void CWlmServer::CancelDirectedRoam( |
|
4958 TUint aSessionId, |
|
4959 const RMessage2& aMessage ) |
|
4960 { |
|
4961 DEBUG( "CWlmServer::CancelDirectedRoam()" ); |
|
4962 |
|
4963 CancelExternalRequest( |
|
4964 aSessionId, |
|
4965 EDirectedRoam ); |
|
4966 |
|
4967 aMessage.Complete( KErrNone ); |
|
4968 } |
|
4969 |
|
4970 // --------------------------------------------------------- |
|
4971 // CWlmServer::StartupComplete |
|
4972 // --------------------------------------------------------- |
|
4973 // |
|
4974 void CWlmServer::StartupComplete() |
|
4975 { |
|
4976 iIsStartupComplete = ETrue; |
|
4977 |
|
4978 SetIconState( EWlmIconStatusNotAvailable ); |
|
4979 |
|
4980 iCoreServer->enable_wlan( KWlanIntCmdEnableWlan ); |
|
4981 |
|
4982 /** |
|
4983 * Read the CommsDat data again so that we can be sure |
|
4984 * that it is up to date after reboot. It can happen that |
|
4985 * when WLAN engine boots up commsdat is not up to date yet. |
|
4986 */ |
|
4987 UpdateWlanSettings(); |
|
4988 |
|
4989 iPlatform->InitializeSystemTimeHandler(); |
|
4990 } |
|
4991 |
|
4992 |
|
4993 // --------------------------------------------------------- |
|
4994 // CWlmServer::EmergencyCallComplete |
|
4995 // --------------------------------------------------------- |
|
4996 // |
|
4997 void CWlmServer::EmergencyCallComplete( TBool aStartupCompleted ) |
|
4998 { |
|
4999 if ( !aStartupCompleted ) |
|
5000 { |
|
5001 iCoreServer->disable_wlan( KWlanIntCmdDisableWlan ); |
|
5002 } |
|
5003 else |
|
5004 { |
|
5005 if ( iIsStartupComplete == EFalse ) |
|
5006 { |
|
5007 iIsStartupComplete = ETrue; |
|
5008 |
|
5009 UpdateWlanSettings(); |
|
5010 |
|
5011 iPlatform->InitializeSystemTimeHandler(); |
|
5012 } |
|
5013 } |
|
5014 } |
|
5015 |
|
5016 // --------------------------------------------------------- |
|
5017 // CWlmServer::HandleSsidListAvailabilityL |
|
5018 // --------------------------------------------------------- |
|
5019 // |
|
5020 void CWlmServer::HandleSsidListAvailabilityL( |
|
5021 const SRequestMapEntry& aMapEntry ) |
|
5022 { |
|
5023 DEBUG( "CWlmServer::HandleSsidListAvailabilityL()" ); |
|
5024 |
|
5025 ScanList* scanList = |
|
5026 reinterpret_cast<ScanList*>( aMapEntry.iParam2 ); |
|
5027 core_type_list_c<u32_t>* iapIdList = |
|
5028 reinterpret_cast<core_type_list_c<u32_t>*>( aMapEntry.iParam1 ); |
|
5029 |
|
5030 /** |
|
5031 * Go through the IAP list and find IAPs that haven't been found |
|
5032 * during GetAvailableIaps and have an SSID list attached. |
|
5033 */ |
|
5034 RArray<TWlanLimitedIapData> attachedIapList; |
|
5035 CleanupClosePushL( attachedIapList ); |
|
5036 const RArray<TWlanLimitedIapData>& cachedIapList( |
|
5037 iCache->CachedIapDataList() ); |
|
5038 core_type_list_iterator_c<u32_t> iter( *iapIdList ); |
|
5039 for( TInt idx( 0 ); idx < cachedIapList.Count(); ++idx ) |
|
5040 { |
|
5041 TBool isFound( EFalse ); |
|
5042 for( u32_t* item = iter.first(); !isFound && item; item = iter.next() ) |
|
5043 { |
|
5044 if( *item == cachedIapList[idx].iapId ) |
|
5045 { |
|
5046 isFound = ETrue; |
|
5047 } |
|
5048 } |
|
5049 if( !isFound ) |
|
5050 { |
|
5051 DEBUG1( "CWlmServer::HandleSsidListAvailabilityL() - IAP ID %u isn't available", |
|
5052 cachedIapList[idx].iapId ); |
|
5053 if( iSsidListDb->IsListAttached( |
|
5054 cachedIapList[idx].iapId ) ) |
|
5055 { |
|
5056 DEBUG1( "CWlmServer::HandleSsidListAvailabilityL() - IAP %u has an SSID list attached", |
|
5057 cachedIapList[idx].iapId ); |
|
5058 attachedIapList.Append( cachedIapList[idx] ); |
|
5059 } |
|
5060 } |
|
5061 } |
|
5062 |
|
5063 if( !attachedIapList.Count() ) |
|
5064 { |
|
5065 DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - no IAPs with an list attached, nothing to do" ); |
|
5066 |
|
5067 CleanupStack::PopAndDestroy( &attachedIapList ); |
|
5068 |
|
5069 return; |
|
5070 } |
|
5071 |
|
5072 /** |
|
5073 * Generate a list of SSIDs detected during the scan and go through |
|
5074 * the IAPs with lists attached again. |
|
5075 */ |
|
5076 RArray<TWlanAvailableNetwork> networkList; |
|
5077 CleanupClosePushL( networkList ); |
|
5078 GetNetworkList( *scanList, networkList ); |
|
5079 |
|
5080 for( TInt idx( 0 ); idx < attachedIapList.Count(); ++idx ) |
|
5081 { |
|
5082 DEBUG1( "CWlmServer::HandleSsidListAvailabilityL() - requesting SSID list for IAP %u", |
|
5083 attachedIapList[idx].iapId ); |
|
5084 |
|
5085 CWlanSsidList* ssidList = CWlanSsidList::NewL( KWlanSsidListGranularity ); |
|
5086 CleanupStack::PushL( ssidList ); |
|
5087 iSsidListDb->ReadListL( |
|
5088 attachedIapList[idx].iapId, |
|
5089 *ssidList ); |
|
5090 TBool isMatch( EFalse ); |
|
5091 for( TInt iidx( 0 ); !isMatch && iidx < networkList.Count(); ++iidx ) |
|
5092 { |
|
5093 if( attachedIapList[idx].networkType == networkList[iidx].networkType && |
|
5094 ssidList->IsInList( networkList[iidx].ssid ) ) |
|
5095 { |
|
5096 isMatch = ETrue; |
|
5097 } |
|
5098 } |
|
5099 |
|
5100 if( isMatch ) |
|
5101 { |
|
5102 DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - matching SSID found" ); |
|
5103 |
|
5104 /** |
|
5105 * A match has been found, mark the IAP as available. |
|
5106 */ |
|
5107 u32_t* iapId = new (ELeave) u32_t( |
|
5108 attachedIapList[idx].iapId ); |
|
5109 iapIdList->append( |
|
5110 iapId ); |
|
5111 } |
|
5112 else |
|
5113 { |
|
5114 DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - no matching SSIDs found for IAP" ); |
|
5115 } |
|
5116 |
|
5117 CleanupStack::PopAndDestroy( ssidList ); |
|
5118 } |
|
5119 |
|
5120 CleanupStack::PopAndDestroy( &networkList ); |
|
5121 CleanupStack::PopAndDestroy( &attachedIapList ); |
|
5122 |
|
5123 DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - all done" ); |
|
5124 } |
|
5125 |
|
5126 // --------------------------------------------------------- |
|
5127 // CWlmServer::GetCurrentIapId |
|
5128 // --------------------------------------------------------- |
|
5129 // |
|
5130 TInt CWlmServer::GetCurrentIapId( |
|
5131 const TUint aLanServiceId, |
|
5132 core_iap_data_s& aCoreIapData ) |
|
5133 { |
|
5134 DEBUG( "CWlmServer::GetCurrentIapId()" ); |
|
5135 /** |
|
5136 * Read all WLAN IAPs from commsdat. |
|
5137 */ |
|
5138 CWLanSettings wlanSettings; |
|
5139 TInt ret = wlanSettings.Connect(); |
|
5140 if ( ret != KErrNone ) |
|
5141 { |
|
5142 DEBUG1( "CWlmServer::GetCurrentIapId - CWLanSettings::Connect() failed (%d)", |
|
5143 ret ); |
|
5144 |
|
5145 return ret; |
|
5146 } |
|
5147 |
|
5148 RArray<SWlanIAPId> wlanIapIds; |
|
5149 TRAP( ret, wlanSettings.GetIAPWlanServicesL( wlanIapIds ) ); |
|
5150 if( ret != KErrNone ) |
|
5151 { |
|
5152 DEBUG1( "CWlmServer::GetCurrentIapId - CWLanSettings::GetIAPWlanServicesL() failed (%d)", |
|
5153 ret ); |
|
5154 wlanIapIds.Close(); |
|
5155 wlanSettings.Disconnect(); |
|
5156 |
|
5157 return ret; |
|
5158 } |
|
5159 TInt IapsCount = wlanIapIds.Count(); |
|
5160 /** |
|
5161 * Get the matching IAP id. |
|
5162 */ |
|
5163 for ( TInt i = 0; i < IapsCount; i++ ) |
|
5164 { |
|
5165 if ( wlanIapIds[i].iWLANRecordId == aLanServiceId ) |
|
5166 { |
|
5167 aCoreIapData.iap_id = wlanIapIds[i].iIAPId; |
|
5168 i = IapsCount; |
|
5169 } |
|
5170 } |
|
5171 |
|
5172 wlanSettings.Disconnect(); |
|
5173 |
|
5174 DEBUG( "CWlmServer::GetCurrentIapId() - all done" ); |
|
5175 |
|
5176 return KErrNone; |
|
5177 } |