wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
branchRCL_3
changeset 10 0abc8c98be24
parent 8 e0f767079796
child 20 a9473894c0f1
equal deleted inserted replaced
8:e0f767079796 10:0abc8c98be24
    14 * Description:  Server class of wlan engine
    14 * Description:  Server class of wlan engine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 102 %
    19 * %version: 105 %
    20 */
    20 */
    21 
    21 
    22 #include <e32def.h>
    22 #include <e32def.h>
    23 #include <e32std.h>
    23 #include <e32std.h>
    24 #include <featmgr.h>
    24 #include <featmgr.h>
    84 /** Granularity for WLAN SSID lists. */
    84 /** Granularity for WLAN SSID lists. */
    85 const TUint KWlanSsidListGranularity = 100;
    85 const TUint KWlanSsidListGranularity = 100;
    86 
    86 
    87 /** Bitmask of WLAN features enabled at compile-time. */
    87 /** Bitmask of WLAN features enabled at compile-time. */
    88 const TUint KWlanStaticFeatures =
    88 const TUint KWlanStaticFeatures =
    89     CWlmServer::EWlanFeaturePowerSaveTest |
    89     CWlmServer::EWlanStaticFeature802dot11k |
    90     CWlmServer::EWlanFeature802dot11k;
    90     CWlmServer::EWlanStaticFeature802dot11n;
    91 
    91 
    92 /** Multiplier for converting seconds into microseconds */
    92 /** Multiplier for converting seconds into microseconds */
    93 const TUint KWlanSecsToMicrosecsMultiplier( 1000000 );
    93 const TUint KWlanSecsToMicrosecsMultiplier( 1000000 );
    94 
    94 
    95 /** Minimum value for aggressive background scan interval, in seconds */
    95 /** Minimum value for aggressive background scan interval, in seconds */
   173         User::Leave( KErrNotSupported );
   173         User::Leave( KErrNotSupported );
   174         }
   174         }
   175 
   175 
   176     if( FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi ) )
   176     if( FeatureManager::FeatureSupported( KFeatureIdFfWlanWapi ) )
   177         {
   177         {
   178         iSupportedFeatures |= EWlanFeatureWapi;
   178         iSupportedFeatures |= EWlanStaticFeatureWapi;
   179         }
   179         }
   180 
   180 
   181     DEBUG1( "CWlmServer::ConstructL() - supported WLAN features: 0x%08X",
   181     DEBUG1( "CWlmServer::ConstructL() - supported WLAN features: 0x%08X",
   182         iSupportedFeatures );
   182         iSupportedFeatures );
   183     FeatureManager::UnInitializeLib();
   183     FeatureManager::UnInitializeLib();
   204     CWlanDeviceSettings::SWlanDeviceSettings deviceSettings;
   204     CWlanDeviceSettings::SWlanDeviceSettings deviceSettings;
   205     GetWlanSettingsL( deviceSettings );
   205     GetWlanSettingsL( deviceSettings );
   206     SetCachedRegion(deviceSettings.region, deviceSettings.regionTimestamp);    
   206     SetCachedRegion(deviceSettings.region, deviceSettings.regionTimestamp);    
   207     core_device_settings_s coreSettings; // core needs the settings here
   207     core_device_settings_s coreSettings; // core needs the settings here
   208     TWlanConversionUtil::ConvertDeviceSettings( coreSettings, deviceSettings );
   208     TWlanConversionUtil::ConvertDeviceSettings( coreSettings, deviceSettings );
   209         
   209 
   210     // Create core server    
   210     // Create core server    
   211     User::LeaveIfNull( iCoreServer = core_server_factory_c::instance(
   211     User::LeaveIfNull( iCoreServer = core_server_factory_c::instance(
   212         *this,
   212         *this,
   213         *iDriverIf,
   213         *iDriverIf,
   214         coreSettings,
   214         coreSettings,
   215         core_mac,
   215         core_mac,
   216         TWlanConversionUtil::ConvertFeatureFlags( iSupportedFeatures ) ) );
   216         TWlanConversionUtil::ConvertFeatureFlags(
       
   217             iSupportedFeatures,
       
   218             deviceSettings.enabledFeatures ) ) );
   217     iCoreServer->disable_wlan( KWlanIntCmdDisableWlan );
   219     iCoreServer->disable_wlan( KWlanIntCmdDisableWlan );
   218 
   220 
   219     // Create scan timer
   221     // Create scan timer
   220     DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
   222     DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
   221     iScanSchedulingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   223     iScanSchedulingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   276     while( (session = static_cast<CWlmSession*>(iSessionIter++)) != NULL )
   278     while( (session = static_cast<CWlmSession*>(iSessionIter++)) != NULL )
   277         {
   279         {
   278         delete session;
   280         delete session;
   279         }
   281         }
   280 
   282 
       
   283     // Stop all plugins
   281     iGenericWlanPlugin.StopPlugins();
   284     iGenericWlanPlugin.StopPlugins();
   282     
   285 
   283     delete iCoreServer;
   286     delete iCoreServer;
   284     delete iDriverIf;
   287     delete iDriverIf;
   285     iNotificationArray.Close();
   288     iNotificationArray.Close();
   286     delete iCache;
   289     delete iCache;
   287     delete iPlatform;
   290     delete iPlatform;
   288     iRequestMap.Close();
   291     iRequestMap.Close();
   289     delete iCoreAsynchCb;
   292     delete iCoreAsynchCb;
   290     delete iScanSchedulingTimer;
   293     delete iScanSchedulingTimer;
   291     delete iSsidListDb;
   294     delete iSsidListDb;
   292     if ( iEapolClient )
   295     delete iBgScanProvider;
   293         {
   296     delete iTimerServices;
   294         delete iEapolClient;
   297     delete iEapolClient;
   295         iEapolClient = NULL;
       
   296         }
       
   297     iEapolHandler = NULL;
   298     iEapolHandler = NULL;
       
   299     REComSession::FinalClose();    
   298     }
   300     }
   299 
   301 
   300 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   301 // CWlmServer::StartServerThread
   303 // CWlmServer::StartServerThread
   302 // -----------------------------------------------------------------------------
   304 // -----------------------------------------------------------------------------
   482         iapData.SecurityMode, iapData.WPAKeyLength, iapData.WPAPreSharedKey.Length(),
   484         iapData.SecurityMode, iapData.WPAKeyLength, iapData.WPAPreSharedKey.Length(),
   483         iapData.EnableWpaPsk, iapData.PresharedKeyFormat );
   485         iapData.EnableWpaPsk, iapData.PresharedKeyFormat );
   484 
   486 
   485     // Check whether WAPI is supported
   487     // Check whether WAPI is supported
   486     if( iapData.SecurityMode == Wapi &&
   488     if( iapData.SecurityMode == Wapi &&
   487         !( iSupportedFeatures & EWlanFeatureWapi ) )
   489         !( iSupportedFeatures & EWlanStaticFeatureWapi ) )
   488         {
   490         {
   489         DEBUG( "CWlmServer::Connect() - WAPI is not supported" );
   491         DEBUG( "CWlmServer::Connect() - WAPI is not supported" );
   490 
   492 
   491         secondarySsidList.Close();        
   493         secondarySsidList.Close();        
   492         aMessage.Complete( KErrNotSupported );
   494         aMessage.Complete( KErrNotSupported );
  1515         DEBUG1( "CWlmServer::UpdateWlanSettings() - update_device_settings() failed with %u",
  1517         DEBUG1( "CWlmServer::UpdateWlanSettings() - update_device_settings() failed with %u",
  1516             ret );
  1518             ret );
  1517 
  1519 
  1518         return TWlanConversionUtil::ConvertErrorCode( ret );
  1520         return TWlanConversionUtil::ConvertErrorCode( ret );
  1519         }
  1521         }
       
  1522     
       
  1523     u32_t coreFeatures = TWlanConversionUtil::ConvertFeatureFlags(
       
  1524         iSupportedFeatures,
       
  1525         settings.enabledFeatures );
       
  1526     ret = iCoreServer->set_enabled_features( coreFeatures );
       
  1527     if( ret != core_error_ok )
       
  1528         {
       
  1529         DEBUG1( "CWlmServer::UpdateWlanSettings() - set_enabled_features() failed with %u",
       
  1530             ret );
       
  1531 
       
  1532         return TWlanConversionUtil::ConvertErrorCode( ret );
       
  1533         }
       
  1534 
  1520     DEBUG( "CWlmServer::UpdateWlanSettings() - returning" );
  1535     DEBUG( "CWlmServer::UpdateWlanSettings() - returning" );
  1521 
  1536 
  1522     return KErrNone;
  1537     return KErrNone;
  1523     }
  1538     }
  1524 
  1539 
  2567 void CWlmServer::CompleteInternalRequest(
  2582 void CWlmServer::CompleteInternalRequest(
  2568     const SRequestMapEntry& aRequest, 
  2583     const SRequestMapEntry& aRequest, 
  2569     core_error_e aStatus,
  2584     core_error_e aStatus,
  2570     TBool aCompletedWasTriggering )
  2585     TBool aCompletedWasTriggering )
  2571     {
  2586     {
  2572 
       
  2573     TInt idx = FindRequestIndex( aRequest.iRequestId );
  2587     TInt idx = FindRequestIndex( aRequest.iRequestId );
  2574     
  2588     
  2575     if( idx >= iRequestMap.Count() )
  2589     if( idx >= iRequestMap.Count() )
  2576         {
  2590         {
  2577         DEBUG1("CWlmServer::CompleteInternalRequest() - request (ID %u) not in request map", idx );
  2591         DEBUG1("CWlmServer::CompleteInternalRequest() - request (ID %u) not in request map", idx );
  2578         return;
  2592         return;
  2579         }
  2593         }
  2580     
  2594     
  2581     DEBUG1( "CWlmServer::CompleteInternalRequest() - index (%d)", idx );
  2595     DEBUG1( "CWlmServer::CompleteInternalRequest() - index (%d)", idx );
  2582     
       
  2583     iRequestMap.Remove( idx );
       
  2584 
  2596 
  2585     switch( aRequest.iRequestId )
  2597     switch( aRequest.iRequestId )
  2586         {
  2598         {
  2587         case KWlanIntCmdBackgroundScan:
  2599         case KWlanIntCmdBackgroundScan:
  2588             {
  2600             {
  2628                         
  2640                         
  2629             break;
  2641             break;
  2630             }
  2642             }
  2631         case KWlanIntCmdNull: // Fall through on purpose
  2643         case KWlanIntCmdNull: // Fall through on purpose
  2632         default:
  2644         default:
       
  2645             DEBUG1( "CWlmServer::CompleteInternalRequest() - request ID %u not handled", aRequest.iRequestId );
  2633             break;
  2646             break;
  2634             // not interested in rest of the internal request completions
  2647             // not interested in rest of the internal request completions
  2635         }
  2648         }
       
  2649 
       
  2650     iRequestMap.Remove( idx );
  2636     }
  2651     }
  2637 
  2652 
  2638 // ---------------------------------------------------------
  2653 // ---------------------------------------------------------
  2639 // CWlmServer::CompleteExternalRequest
  2654 // CWlmServer::CompleteExternalRequest
  2640 // ---------------------------------------------------------
  2655 // ---------------------------------------------------------
  3434         return KErrNoMemory;
  3449         return KErrNoMemory;
  3435         }
  3450         }
  3436     
  3451     
  3437     // create mapping
  3452     // create mapping
  3438     SRequestMapEntry mapEntry;
  3453     SRequestMapEntry mapEntry;
       
  3454     mapEntry.iFunction = EGetAvailableIaps;
  3439     mapEntry.iRequestId = KWlanIntCmdBackgroundScan;
  3455     mapEntry.iRequestId = KWlanIntCmdBackgroundScan;
       
  3456     mapEntry.iSessionId = 0;
  3440     mapEntry.iParam0 = iapDataList;
  3457     mapEntry.iParam0 = iapDataList;
  3441     mapEntry.iParam1 = iapIdList;
  3458     mapEntry.iParam1 = iapIdList;
  3442     mapEntry.iParam2 = scanList;
  3459     mapEntry.iParam2 = scanList;
  3443     mapEntry.iParam3 = iapSsidList;
  3460     mapEntry.iParam3 = iapSsidList;
  3444     mapEntry.iTime = scanTime;
  3461     mapEntry.iTime = scanTime;
  4048             {
  4065             {
  4049             DEBUG( "CWlmServer::CancelScan() - core is not yet handling the next scan request" );
  4066             DEBUG( "CWlmServer::CancelScan() - core is not yet handling the next scan request" );
  4050             
  4067             
  4051             DEBUG( "CWlmServer::CancelScan() - cancel timer" );
  4068             DEBUG( "CWlmServer::CancelScan() - cancel timer" );
  4052             iScanSchedulingTimer->Cancel();
  4069             iScanSchedulingTimer->Cancel();
  4053             
  4070 
  4054             DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
  4071             DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
       
  4072             SRequestMapEntry entry = iRequestMap[index];
       
  4073             delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
       
  4074             delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
       
  4075             delete reinterpret_cast<ScanList*>( entry.iParam2);
       
  4076             delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
       
  4077             delete reinterpret_cast<TTime*>( entry.iTime );
  4055             iRequestMap.Remove( index );
  4078             iRequestMap.Remove( index );
  4056 
  4079 
  4057             DEBUG( "CWlmServer::CancelScan() - find next possible timed scan scheduling request" );
  4080             DEBUG( "CWlmServer::CancelScan() - find next possible timed scan scheduling request" );
  4058             TUint indexNextScan;
  4081             TUint indexNextScan;
  4059             if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
  4082             if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
  4081                 {
  4104                 {
  4082                 DEBUG( "CWlmServer::CancelScan() - core is NOT handling background scanning currently" );
  4105                 DEBUG( "CWlmServer::CancelScan() - core is NOT handling background scanning currently" );
  4083                 DEBUG( "CWlmServer::CancelScan() - just remove the entry from the request map" );
  4106                 DEBUG( "CWlmServer::CancelScan() - just remove the entry from the request map" );
  4084                 
  4107                 
  4085                 DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
  4108                 DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
       
  4109                 SRequestMapEntry entry = iRequestMap[index];
       
  4110                 delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
       
  4111                 delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
       
  4112                 delete reinterpret_cast<ScanList*>( entry.iParam2);
       
  4113                 delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
       
  4114                 delete reinterpret_cast<TTime*>( entry.iTime );                
  4086                 iRequestMap.Remove( index );
  4115                 iRequestMap.Remove( index );
  4087                 }
  4116                 }
  4088             }
  4117             }
  4089         }
  4118         }
  4090     DEBUG( "CWlmServer::CancelScan() - returning" );
  4119     DEBUG( "CWlmServer::CancelScan() - returning" );