wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacDot11Idle.h
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of 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:   Declaration of the WlanDot11Idle class
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 26 %
       
    20 */
       
    21 
       
    22 #ifndef WLANDOT11IDLE_H
       
    23 #define WLANDOT11IDLE_H
       
    24 
       
    25 #include "UmacDot11State.h"
       
    26 
       
    27 /**
       
    28 *  Logical start state of the dot11 protocol statemachine
       
    29 *
       
    30 *  @lib wlanumac.lib
       
    31 *  @since S60 v3.1
       
    32 */
       
    33 class WlanDot11Idle : public WlanDot11State
       
    34     {
       
    35     // Types for the FSM
       
    36     
       
    37     // events for the FSM
       
    38     enum TEvent
       
    39         {
       
    40         ESTATEENTRY,    // state entry action to be executed                        
       
    41         ETXCOMPLETE,    // underlying sw layer tx delivery complete event   
       
    42         ESCAN,          // scan event
       
    43         ECONNECT,       // connect to BSS event
       
    44         ECONNECTIBSS,   // connect to IBSS event
       
    45         EDISCONNECT,    // disconnect event
       
    46         ERELEASE,       // release event
       
    47         EABORT,         // abort execution event
       
    48         EEVENTMAX       // defined as an upper bound
       
    49         };
       
    50 
       
    51     // states of the FSM
       
    52     enum TState
       
    53         {
       
    54         EINIT,          // start state of the state machine
       
    55         EWRITEMIB,      // write mib
       
    56         EFINIT,         // end state
       
    57         ESTATEMAX       // defined as an upper bound        
       
    58         }; 
       
    59        
       
    60 public:
       
    61    
       
    62     /**
       
    63     * C++ default constructor.
       
    64     */
       
    65     WlanDot11Idle() : 
       
    66             iState( EINIT ),
       
    67             iCompletionCode( KErrNone ), 
       
    68             iEventMask( 0 ) {};
       
    69 
       
    70     /**
       
    71     * Destructor.
       
    72     */
       
    73     virtual ~WlanDot11Idle() {};
       
    74 
       
    75     void Set( TInt aCompletionCode );
       
    76 
       
    77     /**
       
    78     * Requests this state to indicate scan completion to management client
       
    79     * upon state entry.
       
    80     *
       
    81     * @since S60 3.2
       
    82     */
       
    83     void CompleteScanUponEntry();
       
    84     
       
    85 private:
       
    86 
       
    87     virtual void Entry( WlanContextImpl& aCtxImpl );
       
    88     virtual void Exit( WlanContextImpl& aCtxImpl );
       
    89 
       
    90     /**
       
    91     * Connect (authenticate and associate) to a WLAN network
       
    92     *
       
    93     * @since S60 3.1
       
    94     * @param aCtxImpl statemachine context
       
    95     * @param aSSID Name of the network
       
    96     * @param aBSSID BSSID of the access point
       
    97     * @param aAuthAlgorithmNbr Authentication algorithm number to be used
       
    98     * @param aEncryptionStatus Used encryption level
       
    99     * @param aIsInfra ETrue when connecting to infrastructure network
       
   100     * @param aScanResponseFrameBodyLength length of the scan response frame body
       
   101     * @param aScanResponseFrameBody scan response frame body
       
   102     * @param aIeData The IE(s) to be included into the (re-)association request.
       
   103     *              NULL, if none to be included
       
   104     * @param aIeDataLength Length of the IE(s) to be included into the 
       
   105     *                    (re-)association request
       
   106     * @return ETrue if a state transition occurred
       
   107     *         EFalse otherwise
       
   108     */
       
   109     virtual TBool Connect(
       
   110         WlanContextImpl& aCtxImpl,
       
   111         const TSSID& aSSID,                 
       
   112         const TMacAddress& aBSSID,          
       
   113         TUint16 aAuthAlgorithmNbr,      
       
   114         TEncryptionStatus aEncryptionStatus,
       
   115         TBool aIsInfra,
       
   116         TUint16 aScanResponseFrameBodyLength,
       
   117         const TUint8* aScanResponseFrameBody,
       
   118         const TUint8* aIeData,
       
   119         TUint16 aIeDataLength );
       
   120 
       
   121     virtual TBool StartIBSS(
       
   122         WlanContextImpl& aCtxImpl,
       
   123         const TSSID& aSSID,                 
       
   124         TUint32 aBeaconInterval,            
       
   125         TUint32 aAtim,                      
       
   126         TUint32 aChannel,                   
       
   127         TEncryptionStatus aEncryptionStatus); 
       
   128     
       
   129     virtual TBool Disconnect( WlanContextImpl& aCtxImpl );
       
   130 
       
   131     /**
       
   132     * Scan all available networks. 
       
   133     * This SW module decides is background scan or foreground scan used
       
   134     * @param aCtxImpl statemachine context
       
   135     * @param aMode passive or active scan see #TScanMode
       
   136     * @param aSSID Network that APs are scanned. Can be broadcast SSID.
       
   137     * @param aScanRate Rate that is used in active scanning 
       
   138     * @param aMinChannelTime min. time to listen beacons/probe responses on 
       
   139     *                        a channel
       
   140     * @param aMaxChannelTime max. time to listen beacons/probe responses on 
       
   141     *                        a channel
       
   142     * @param aSplitScan if ETrue, use split scan
       
   143     * @return KErrNone = command completed successfully, 
       
   144     * any other = failure
       
   145     */
       
   146     virtual TBool RealScan(
       
   147         WlanContextImpl& aCtxImpl,
       
   148         TScanMode aMode,                    
       
   149         const TSSID& aSSID,                 
       
   150         TUint32 aScanRate,                    
       
   151         SChannels& aChannels,
       
   152         TUint32 aMinChannelTime,            
       
   153         TUint32 aMaxChannelTime,
       
   154         TBool aSplitScan );               
       
   155                          
       
   156     /**
       
   157      * From MWlanUserEvent
       
   158      * Make system ready for unloading
       
   159      *
       
   160      * @since S60 3.1
       
   161      */
       
   162     virtual void FinitSystem( WlanContextImpl& aCtxImpl );
       
   163 
       
   164     /**
       
   165      * From MWlanUserEvent
       
   166      * Add/set (or replace) a broadcast WEP key also sets it as a PTK
       
   167      *
       
   168      * @since S60 3.1
       
   169      * @param aCtxImpl statemachine context
       
   170      * @param aKeyIndex Index of the key in the default key table 
       
   171      * @param aKeyLength Length of the key in BYTES
       
   172      * @param aKey The WEP key
       
   173      * @param aMac MAC address associated with the key
       
   174      * @return ETrue if state transition occurred, EFalse otherwise
       
   175      */
       
   176     virtual TBool AddBroadcastWepKey(
       
   177         WlanContextImpl& aCtxImpl,
       
   178         TUint32 aKeyIndex,             
       
   179         TBool aUseAsDefaulKey,                
       
   180         TUint32 aKeyLength,                      
       
   181         const TUint8 aKey[KMaxWEPKeyLength],
       
   182         const TMacAddress& aMac );   
       
   183 
       
   184     virtual TBool AddUnicastWepKey(
       
   185         WlanContextImpl& aCtxImpl,
       
   186         const TMacAddress& aMacAddr,
       
   187         TUint32 aKeyLength,                      
       
   188         const TUint8 aKey[KMaxWEPKeyLength]);
       
   189 
       
   190     /**
       
   191     * Returns the states name
       
   192     * @param aLength (OUT) length of the name of the state
       
   193     * @return name of the state
       
   194     */
       
   195 #ifndef NDEBUG 
       
   196     virtual const TInt8* GetStateName( TUint8& aLength ) const;
       
   197 #endif // !NDEBUG 
       
   198 
       
   199     /**
       
   200     * ?member_description.
       
   201     * @since S60 3.1
       
   202     * @param aCtxImpl global statemachine context
       
   203     */
       
   204     void ChangeInternalState( 
       
   205         WlanContextImpl& aCtxImpl, 
       
   206         TState aNewState );
       
   207 
       
   208     /**
       
   209     * ?member_description.
       
   210     * @since S60 3.1
       
   211     * @param aCtxImpl global statemachine context
       
   212     */
       
   213     void Fsm( 
       
   214         WlanContextImpl& aCtxImpl, 
       
   215         TEvent aEvent ); 
       
   216 
       
   217     /**
       
   218     * ?member_description.
       
   219     * @since S60 3.1
       
   220     * @param aCtxImpl global statemachine context
       
   221     */
       
   222     void OnStateEntryEvent( WlanContextImpl& aCtxImpl );
       
   223 
       
   224     /**
       
   225     * ?member_description.
       
   226     * @since S60 3.1
       
   227     * @param aCtxImpl global statemachine context
       
   228     */
       
   229     void OnTxCompleteEvent( WlanContextImpl& aCtxImpl );
       
   230 
       
   231     /**
       
   232     * ?member_description.
       
   233     * @since S60 3.1
       
   234     * @param aCtxImpl global statemachine context
       
   235     */
       
   236     void OnAbortEvent( WlanContextImpl& aCtxImpl );
       
   237 
       
   238     /**
       
   239     * ?member_description.
       
   240     * @since S60 3.1
       
   241     * @param aCtxImpl global statemachine context
       
   242     */
       
   243     void OnScanEvent( WlanContextImpl& aCtxImpl );
       
   244 
       
   245     /**
       
   246     * ?member_description.
       
   247     * @since S60 3.1
       
   248     * @param aCtxImpl global statemachine context
       
   249     */
       
   250     void OnConnectEvent( WlanContextImpl& aCtxImpl );
       
   251 
       
   252     /**
       
   253     * ?member_description.
       
   254     * @since S60 3.1
       
   255     * @param aCtxImpl global statemachine context
       
   256     */
       
   257     void OnConnectIbssEvent( WlanContextImpl& aCtxImpl );
       
   258 
       
   259     /**
       
   260     * ?member_description.
       
   261     * @since S60 3.1
       
   262     * @param aCtxImpl global statemachine context
       
   263     */
       
   264     void OnDisconnectEvent( WlanContextImpl& aCtxImpl );
       
   265 
       
   266     /**
       
   267      * ?description
       
   268      *
       
   269      * @since S60 3.1
       
   270      * @param aCtxImpl global statemachine context
       
   271      */
       
   272     void OnReleaseEvent( WlanContextImpl& aCtxImpl );
       
   273 
       
   274     /**
       
   275     * ?member_description.
       
   276     * @since S60 3.1
       
   277     * @param aCtxImpl global statemachine context
       
   278     */
       
   279     void WriteSleepModeMib( WlanContextImpl& aCtxImpl );
       
   280 
       
   281     void GenerateRandomBssIDForIbss( WlanContextImpl& aCtxImpl ) const;
       
   282 
       
   283     void CompleteOid( WlanContextImpl& aCtxImpl );
       
   284 
       
   285     /**
       
   286      * Indicates scan completion to management client if necessary
       
   287      *
       
   288      * @since S60 3.2
       
   289      * @param aCtxImpl global statemachine context
       
   290      */
       
   291     void IndicateScanCompletion( WlanContextImpl& aCtxImpl );
       
   292 
       
   293     // Prohibit copy constructor 
       
   294     WlanDot11Idle( const WlanDot11Idle& );
       
   295     // Prohibit assigment operator 
       
   296     WlanDot11Idle& operator= ( const WlanDot11Idle& );
       
   297 
       
   298 private:   // Data
       
   299 
       
   300     TState              iState;
       
   301 
       
   302 #ifndef NDEBUG
       
   303     /** max length of state name for tracing */
       
   304     enum { KMaxStateStringLength = 50 };
       
   305     /** max length of event name for tracing */
       
   306     enum { KMaxEventStringLength = KMaxStateStringLength };
       
   307 
       
   308     /** state names for tracing */
       
   309     static const TUint8 iStateName[ESTATEMAX][KMaxStateStringLength];
       
   310     /** event names for tracing */
       
   311     static const TUint8 iEventName[EEVENTMAX][KMaxEventStringLength];
       
   312     /** state name */
       
   313     static const TInt8  iName[];
       
   314 #endif 
       
   315 
       
   316     /** completion code for user request */
       
   317     TInt                iCompletionCode;
       
   318     
       
   319     static const TUint  KCompleteUponEntry               = (1 << 0);
       
   320     /** indicate scan completion to management client upon state entry */
       
   321     static const TUint  KIndicateScanCompletionUponEntry = (1 << 1);
       
   322 
       
   323     TUint               iEventMask;
       
   324     };
       
   325 
       
   326 #endif      // WLANDOT11IDLE_H