wlanutilities/wlansniffer/engine/server/inc/wsfwlanscanner.h
branchRCL_3
changeset 25 f28ada11abbf
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class header for CWsfWlanScanner
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_WSFWLANSCANNER_H
       
    21 #define C_WSFWLANSCANNER_H
       
    22 
       
    23 //  EXTERNAL INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <wlanmgmtcommon.h>
       
    26 #include <commsdattypesv1_1.h>
       
    27 #include <cmmanagerext.h>
       
    28 
       
    29 
       
    30 
       
    31 //  INTERNAL INCLUDES
       
    32 #include "wsfwlanscannerobserver.h"
       
    33 #include "wsfwlanmonitorobserver.h"
       
    34 #include "wsfwlanscanintervalchangeobserver.h"
       
    35 #include "wsfwlaninfo.h"
       
    36 
       
    37 
       
    38 const TUint8 TX_RATE_BASIC_MASK = 0x80;
       
    39 
       
    40 
       
    41 /**
       
    42  * Defines the possible TX rate values.
       
    43  */
       
    44 typedef enum _core_tx_rate_e
       
    45     {
       
    46     core_tx_rate_none       = 0x00000000,
       
    47     core_tx_rate_1mbit      = 0x00000001,
       
    48     core_tx_rate_2mbit      = 0x00000002,
       
    49     core_tx_rate_5p5mbit    = 0x00000004,
       
    50     core_tx_rate_6mbit      = 0x00000008,
       
    51     core_tx_rate_9mbit      = 0x00000010,
       
    52     core_tx_rate_11mbit     = 0x00000020,
       
    53     core_tx_rate_12mbit     = 0x00000040,
       
    54     core_tx_rate_18mbit     = 0x00000080,
       
    55     core_tx_rate_22mbit     = 0x00000100,
       
    56     core_tx_rate_24mbit     = 0x00000200,
       
    57     core_tx_rate_33mbit     = 0x00000400,
       
    58     core_tx_rate_36mbit     = 0x00000800,
       
    59     core_tx_rate_48mbit     = 0x00001000,
       
    60     core_tx_rate_54mbit     = 0x00002000
       
    61     } core_tx_rate_e;
       
    62 
       
    63 const TUint32 CORE_TX_RATES_802P11B =
       
    64     core_tx_rate_1mbit |
       
    65     core_tx_rate_2mbit |
       
    66     core_tx_rate_5p5mbit |
       
    67     core_tx_rate_11mbit;
       
    68 
       
    69 const TUint32 CORE_TX_RATES_802P11G =
       
    70     core_tx_rate_6mbit |
       
    71     core_tx_rate_9mbit |
       
    72     core_tx_rate_12mbit |
       
    73     core_tx_rate_18mbit |
       
    74     core_tx_rate_22mbit |
       
    75     core_tx_rate_24mbit |
       
    76     core_tx_rate_33mbit |
       
    77     core_tx_rate_36mbit |
       
    78     core_tx_rate_48mbit |
       
    79     core_tx_rate_54mbit;
       
    80 
       
    81 /**
       
    82  * Define the possible TX rate value as units of 500kbit/s.
       
    83  */
       
    84 typedef enum _core_tx_rate_value_e
       
    85     {
       
    86     core_tx_rate_value_none    = 0,
       
    87     core_tx_rate_value_1mbit   = 2,
       
    88     core_tx_rate_value_2mbit   = 4,
       
    89     core_tx_rate_value_5p5mbit = 11,
       
    90     core_tx_rate_value_6mbit   = 12,
       
    91     core_tx_rate_value_9mbit   = 18,
       
    92     core_tx_rate_value_11mbit  = 22,
       
    93     core_tx_rate_value_12mbit  = 24,
       
    94     core_tx_rate_value_18mbit  = 36,
       
    95     core_tx_rate_value_22mbit  = 44,
       
    96     core_tx_rate_value_24mbit  = 48,
       
    97     core_tx_rate_value_33mbit  = 66,
       
    98     core_tx_rate_value_36mbit  = 72,
       
    99     core_tx_rate_value_48mbit  = 96,
       
   100     core_tx_rate_value_54mbit  = 108,
       
   101     } _core_tx_rate_value_e;
       
   102 
       
   103 
       
   104 //  FORWARD DECLARATIONS
       
   105 class CWlanMgmtClient;
       
   106 class CWlanScanInfo;
       
   107 class CWsfWlanSettingsAccessor;
       
   108 class CWsfWlanInfoArray;
       
   109 class TWsfWlanInfo;
       
   110 class MWsfWlanConnectionDetailsProvider;
       
   111 class MWsfKnownIapRecognizer;
       
   112 
       
   113 
       
   114 //  CLASS DEFINITION
       
   115 /**
       
   116  * Class to schedule WLAN scanning and process the resultant data
       
   117  *
       
   118  * @since S60 5.0
       
   119  * @lib wsfserver.exe
       
   120  */
       
   121 NONSHARABLE_CLASS( CWsfWlanScanner ): public CActive, 
       
   122                                       public MWlanMgmtNotifications, 
       
   123                                       public MWsfWlanMonitorObserver,
       
   124                                       public MWsfWlanScanIntervalChangeObserver
       
   125     {
       
   126     private:     // Type definitions
       
   127     
       
   128         /**
       
   129         * States of the scanning process
       
   130         */
       
   131         enum TWsfScanState 
       
   132             {
       
   133             /**
       
   134             * Not scanning but scheduled
       
   135             */
       
   136             EIdle,
       
   137             
       
   138             /**
       
   139             * Do broadcast scan
       
   140             */
       
   141             EBroadcastScan,
       
   142             
       
   143             /**
       
   144             * Processing broadcast scan results
       
   145             */
       
   146             EProcessBroadcastScan,
       
   147             
       
   148             /**
       
   149             * Processing direct scan results
       
   150             */
       
   151             EDirectScan,
       
   152             
       
   153             /**
       
   154             * Scanning finished, cleanup and notification
       
   155             */
       
   156             EFinished
       
   157             };
       
   158             
       
   159     public:     // Constructors and destructor
       
   160 
       
   161         /**
       
   162         * Factory function.
       
   163         * @since S60 5.0
       
   164         * @param aDbSession Reference to the database session to use
       
   165         * @return Class instance
       
   166         */
       
   167         static CWsfWlanScanner* NewL( CommsDat::CMDBSession& aDbSession );
       
   168 
       
   169         /**
       
   170         * Factory function.
       
   171         * @since S60 5.0
       
   172         * @param aDbSession Reference to the database session to use
       
   173         * @return Class instance
       
   174         */
       
   175         static CWsfWlanScanner* NewLC( CommsDat::CMDBSession& aDbSession );
       
   176 
       
   177         /**
       
   178         * Destructor.
       
   179         */
       
   180         ~CWsfWlanScanner();
       
   181 
       
   182 
       
   183     private:    // Constructors
       
   184     
       
   185         /**
       
   186         * Constructor
       
   187         * @since S60 5.0
       
   188         * @param aDbSession Reference to the database session to use
       
   189         */
       
   190         CWsfWlanScanner( CommsDat::CMDBSession& aSession );
       
   191 
       
   192         /**
       
   193         * Second-phase constructor.
       
   194         * @since S60 5.0
       
   195         */
       
   196         void ConstructL();
       
   197 
       
   198 
       
   199     public:     // New methods
       
   200         /**
       
   201         * Sets the observer of this class
       
   202         * @since S60 5.0
       
   203         * @param aObserver The observer to be notified of scanning events
       
   204         */
       
   205         void SetObserver( MWsfWlanScannerObserver& aObserver );
       
   206 
       
   207         /**
       
   208         * Enables scanning for wlans
       
   209         * @since S60 5.0
       
   210         */
       
   211         void StartScanningL();
       
   212 
       
   213         /**
       
   214         * Stops the activation timer and cancels the mgmt client to 
       
   215         * give notifications
       
   216         * @since S60 5.0
       
   217         */
       
   218         void StopScanning();      
       
   219         
       
   220         /**
       
   221         * Initiates a new scanning if it was already enabled but was idle.
       
   222         * @since S60 5.0
       
   223         * @return ETrue if scanning was in fact restarted
       
   224         */
       
   225         TBool RestartScanning();
       
   226 
       
   227         /**
       
   228         * Aborts the scanning process if it was active. However, it does not 
       
   229         * disable scanning
       
   230         * @since S60 5.0
       
   231         */
       
   232         void AbortScanning();
       
   233         
       
   234         /**
       
   235         * Returns the serialized contents of scan results 
       
   236         * @since S60 5.0
       
   237         * @return A serialized array of wlaninfo items
       
   238         */       
       
   239         HBufC8* ScanResults();
       
   240         
       
   241         /**
       
   242         * Sets ConnectionDetails provider handle to get data about 
       
   243         * connected wlans
       
   244         * @since S60 5.0
       
   245         * @param aProvider The object to be asked for connection details
       
   246         */ 
       
   247         void SetConnectionDetailProvider( 
       
   248                                MWsfWlanConnectionDetailsProvider& aProvider );
       
   249 
       
   250 
       
   251     public:     // From MWlanMgmtNotifications
       
   252         /**
       
   253         * Connection status has changed.
       
   254         * @since S60 5.0
       
   255         * @param aNewState The new connection state
       
   256         */
       
   257         void ConnectionStateChanged( TWlanConnectionMode aNewState );
       
   258     
       
   259         /**
       
   260         * BSSID has changed (i.e. AP handover).
       
   261         * @since S60 5.0
       
   262         * @param aNewBssid The new BSSID
       
   263         */
       
   264         void BssidChanged( TWlanBssid& aNewBssid );
       
   265 
       
   266         /**
       
   267         * Connection has been lost.
       
   268         * @since S60 5.0
       
   269         */
       
   270         void BssLost();
       
   271 
       
   272         /**
       
   273         * Connection has been regained.
       
   274         * @since S60 5.0
       
   275         */
       
   276         void BssRegained();
       
   277 
       
   278         /**
       
   279         * New networks have been detected during scan.
       
   280         * @since S60 5.0
       
   281         */
       
   282         void NewNetworksDetected();
       
   283 
       
   284         /**
       
   285         * One or more networks have been lost since the last scan.
       
   286         * @since S60 5.0
       
   287         */
       
   288         void OldNetworksLost();
       
   289 
       
   290         /**
       
   291         * The used transmit power has been changed.
       
   292         * @since S60 5.0
       
   293         * @param aPower The transmit power in mW.
       
   294         */
       
   295         void TransmitPowerChanged( TUint aPower );
       
   296         
       
   297         /**
       
   298         * Received signal strength level has been changed.
       
   299         * @since S60 5.0
       
   300         * @param aRssClass specifies the current class of the received signal
       
   301         * @param aRss RSS level in absolute dBm values.
       
   302         */
       
   303         void RssChanged( TWlanRssClass aRssClass, TUint aRss );
       
   304         
       
   305 
       
   306     private:    // New methods
       
   307         /** 
       
   308         * Processes the results of the broadcast scan
       
   309         * @since S60 5.0
       
   310         */
       
   311         void DoScanForNetworksL();
       
   312            
       
   313         /**
       
   314         * Compares two SSIDs
       
   315         * @since S60 5.0
       
   316         * @param aSsid1 First SSID
       
   317         * @param aSsid2 Second SSID
       
   318         * @return ETrue if the SSIDs are the same, EFalse otherwise
       
   319         */
       
   320         static TBool SsidIdentity( const TWlanSsid& aSsid1, 
       
   321                                    const TWlanSsid& aSsid2 );
       
   322 
       
   323 #ifdef _DEBUG
       
   324         /**
       
   325         * Dumps the scan results to the log
       
   326         * @since S60 5.0
       
   327         * @param aArray Array of wlaninfo items added during scanning
       
   328         */
       
   329         static void DumpScanResultsL( CWsfWlanInfoArray* aArray );
       
   330 #endif
       
   331 
       
   332         /**
       
   333         * Check if the given SSID implies a hidden WLAN
       
   334         * @since S60 5.0
       
   335         * @param aSsidLength Length of the SSID passed
       
   336         * @param aSsid SSID as array of bytes
       
   337         * @return ETrue if the network in question is hidden, EFalse otherwise
       
   338         */
       
   339         TBool IsHiddenSsid( TUint aSsidLength, const TUint8* aSsid );
       
   340 
       
   341         /**
       
   342         * Parses the scan results for the network name
       
   343         * @since S60 5.0
       
   344         * @param aWlanInfo The wlaninfo to put the results in
       
   345         * @return ETrue if the network is a hidden one
       
   346         */
       
   347         TBool RefreshNetworkNameL( TWsfWlanInfo& aWlanInfo );
       
   348 
       
   349         /**
       
   350         * Parses the scan results for the wlan signal stregth 
       
   351         * @since S60 5.0
       
   352         * @param aWlanInfo The wlaninfo to put the results in
       
   353         */
       
   354         void RefreshSignalStrength( TWsfWlanInfo& aWlanInfo );
       
   355 
       
   356         /**
       
   357         * Parses the scan results for the network mode
       
   358         * @since S60 5.0
       
   359         * @param aWlanInfo The wlaninfo to put the results in
       
   360         */
       
   361         void RefreshNetworkMode( TWsfWlanInfo& aWlanInfo );
       
   362 
       
   363         /**
       
   364         * Parses the scan results for the security mode
       
   365         * @since S60 5.0
       
   366         * @param aWlanInfo The wlaninfo to put the results in
       
   367         */
       
   368         void RefreshSecurityMode( TWsfWlanInfo& aWlanInfo );
       
   369 
       
   370         /**
       
   371         * Convert the given rate value (500kbit/s per unit) 
       
   372         * to a corresponding enum.
       
   373         * @since S60 5.2
       
   374         * @param aRate Rate value to be converted.
       
   375         * @return Corresponding rate enum.
       
   376         */
       
   377         core_tx_rate_e ConvertTxRateToTxRateEnum( TUint8 aRate );
       
   378 
       
   379         /**
       
   380         * Parses the scan results for the technology information
       
   381         * @since S60 5.2
       
   382         * @param aWlanInfo The wlaninfo to put the results in
       
   383         */
       
   384         void RefreshTechnology( TWsfWlanInfo& aWlanInfo );
       
   385 
       
   386         /**
       
   387         * Prepares for direct scanning
       
   388         * @since S60 5.0
       
   389         */
       
   390         void PrepareDirectScan();
       
   391 
       
   392         /**
       
   393         * Processes the result of the last direct scan
       
   394         * @since S60 5.0
       
   395         */
       
   396         void ProcessDirectScanResultL();
       
   397         
       
   398         /**
       
   399         * Checks iScanArray and replaces SSIDs of known networks
       
   400         * with their IAP names. 
       
   401         * @param aWlanInfo The wlaninfo to put the results in
       
   402         * @since S60 5.0
       
   403         */
       
   404         void ReplaceSsidsWithIapName(TWsfWlanInfo& aWlanInfo);
       
   405         
       
   406         /**
       
   407         * Updates IAPs priority
       
   408         * @since S60 5.0
       
   409         * @param aWlanInfo The wlaninfo to put the results in
       
   410         */
       
   411         void UpdatePriorityL( TWsfWlanInfo& aWlanInfo );
       
   412         
       
   413         /**
       
   414          * Finds the security mode, network mode from WLAN table
       
   415          * with their IAP names. 
       
   416          * @param aWlanInfo The wlaninfo to put the results in
       
   417          * @since S60 5.0
       
   418          */
       
   419         void GetWlanInfoFromIapL( TWsfWlanInfo& aWlanInfo );
       
   420         
       
   421         /**
       
   422          * Add connected wlan info to scan results
       
   423          * @since S60 5.0
       
   424          */
       
   425         void AddConnectedWLANInfoL();
       
   426         
       
   427      private:    // From CActive
       
   428         /**
       
   429         * Implements cancellation of an outstanding request.
       
   430         * @since S60 5.0
       
   431         */
       
   432         void DoCancel();
       
   433 
       
   434         /**
       
   435         * Handles an active object's request completion event.
       
   436         * @since S60 5.0
       
   437         */
       
   438         void RunL();
       
   439 
       
   440         /**
       
   441         * Handles a leave occurring in RunL().
       
   442         * @since S60 5.0
       
   443         * @param aError Leave code
       
   444         * @return aError
       
   445         */
       
   446         TInt RunError( TInt aError );
       
   447         
       
   448 
       
   449     public: // from MWsfWlanMonitorObserver
       
   450 
       
   451         /**
       
   452         * Called when a wlan connection is established
       
   453         * @since S60 5.0
       
   454         * @param aConnectionName WLAN connection name (SSID)
       
   455         */
       
   456         void ConnectionEstablishedL( const TDesC& aConnectionName );
       
   457 
       
   458         /**
       
   459         * Called when wlan connection has been lost
       
   460         * @since S60 5.0
       
   461         */
       
   462         void ConnectionLostL();
       
   463         
       
   464         /**
       
   465         * Called when the connection process failed for some reason
       
   466         * @since S60 5.0
       
   467         * @param aError System wide error code
       
   468         */
       
   469         void ConnectingFailedL( TInt aError );
       
   470         
       
   471         /**
       
   472         * Called when the connection no longer needs the IAP it was using
       
   473         * @since S60 5.0
       
   474         */
       
   475         void ConnectedIapReleasedL();
       
   476         
       
   477         
       
   478     public: // from MWsfWlanScanIntervalChangeObserver
       
   479         /**
       
   480         * Called when the value of the background scan interval or the
       
   481         * show availability flag has been changed
       
   482         * @since S60 5.0
       
   483         * @param aNewScanInterval The new value for the scan interval
       
   484         * @param aShowAvailability The new value for the 
       
   485         *                          Show WLAN availability flag
       
   486         */
       
   487         void WlanScanIntervalChangedL( TUint aNewScanInterval,
       
   488                                        TBool aShowAvailability );
       
   489 
       
   490     private:    // Data
       
   491         /**
       
   492         * Reference to the observer of this class (not owned)
       
   493         */
       
   494         MWsfWlanScannerObserver* iObserver; 
       
   495         
       
   496         /**
       
   497         * Reference to the database session to use (not owned)
       
   498         */
       
   499         CommsDat::CMDBSession* iDbSession; 
       
   500         
       
   501         /**
       
   502         * Reference to the connection details providing object (not owned)
       
   503         */
       
   504         MWsfWlanConnectionDetailsProvider* iConnectionDetailsProvider;
       
   505         
       
   506         /**
       
   507         * Handle to the WLAN management client (owned)
       
   508         */
       
   509         CWlanMgmtClient* iWlanMgmtClient;
       
   510         
       
   511         /**
       
   512         * Scan info object (owned)
       
   513         */
       
   514         CWlanScanInfo* iScanInfo;
       
   515         
       
   516         /**
       
   517         * WLAN settings monitoring object (owned)
       
   518         */        
       
   519         CWsfWlanSettingsAccessor* iWlanSettingsAccessor;
       
   520         
       
   521         /**
       
   522         * The array containing the wlaninfo items found during scanning 
       
   523         * (owned)
       
   524         */
       
   525         CWsfWlanInfoArray* iScanArray;
       
   526         
       
   527         /**
       
   528         * Name of the active connection (owned)
       
   529         */
       
   530         HBufC* iActiveConnectionName;
       
   531         
       
   532         /**
       
   533         * Timer for scheduling WLAN scans
       
   534         */
       
   535         RTimer iTimer;
       
   536         
       
   537         /**
       
   538         * Handle to the CmManager
       
   539         */
       
   540         RCmManagerExt iCmManagerExt;
       
   541         
       
   542         /**
       
   543         * Buffer to store the serialized array of wlaninfo items (owned)
       
   544         */
       
   545         HBufC8* iScanResults;
       
   546         
       
   547         /**
       
   548         * The background scan interval in microseconds
       
   549         */
       
   550         TUint iScanningInterval;
       
   551 
       
   552         /**
       
   553         * Value of Show WLAN availability flag
       
   554         */
       
   555         TBool iShowAvailability;
       
   556         
       
   557         /**
       
   558         * Array of SSIDs that are in CommsDat but have not been found 
       
   559         * by broadcast scan
       
   560         */
       
   561         RArray<TWlanSsid> iDirectScanSsids;
       
   562         
       
   563         /**
       
   564         * Array of IapIDs that are in CommsDat but have not been found 
       
   565         * by broadcast scan
       
   566         */
       
   567         RArray<TUint> iDirectScanIapIDs;
       
   568         
       
   569         /**
       
   570         * Indicates the scanning state
       
   571         */
       
   572         TWsfScanState iScanState;
       
   573              
       
   574         /**
       
   575         * Connected SSID or IAP name
       
   576         */
       
   577         TBuf8<KWlanMaxAccessPointNameLength> iConnectedSsidOrIap;
       
   578         
       
   579 		/**
       
   580         * Array containing the available IAP IDs and Signal Strengths
       
   581         */
       
   582         RArray<TWlanIapAvailabilityData> iAvailableIaps;
       
   583         
       
   584         /**
       
   585         * Cache lifetime.
       
   586         * Parameter needed for issuing "get available WLAN IAPs"
       
   587         * request.
       
   588         */
       
   589         TInt iCacheLifetime;
       
   590         
       
   591         /**
       
   592         * Max Delay.
       
   593         * Parameter needed for issuing "get available WLAN IAPs"
       
   594         * request.
       
   595         */
       
   596         TUint iMaxDelay; 
       
   597 
       
   598         
       
   599     };
       
   600 
       
   601 
       
   602 #endif      //  C_WSFWLANSCANNER_H
       
   603 
       
   604 // End of file