wlan_bearer/wlanldd/wlan_common/umac_common/src/umacdot11infrastructurescanningmode.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-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 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:   Implementation of the WlanDot11InfrastructureScanningMode 
       
    15 *                class.
       
    16 *
       
    17 */
       
    18 
       
    19 /*
       
    20 * %version: 21 %
       
    21 */
       
    22 
       
    23 #include "config.h"
       
    24 #include "umacdot11infrastructurescanningmode.h"
       
    25 #include "umacscanfsmcntx.h"
       
    26 #include "UmacContextImpl.h"
       
    27 #include "UmacWsaWriteMib.h"
       
    28 #include "UmacWsaScan.h"
       
    29 #include "umacwhastopscan.h"
       
    30 #include "umacwhatodot11typeconverter.h"
       
    31 
       
    32 
       
    33 #ifndef NDEBUG
       
    34 const TInt8 WlanDot11InfrastructureScanningMode::iName[] 
       
    35     = "dot11-infrastructurescanningmode";
       
    36 
       
    37 const TUint8 WlanDot11InfrastructureScanningMode::iStateName
       
    38     [ESTATEMAX][KMaxStateStringLength] = 
       
    39     {
       
    40         {"EINIT"}, 
       
    41         {"EEXECUTESCANFSM"},
       
    42         {"ECONTINUEDOT11TRAVERSE"}
       
    43     };
       
    44 
       
    45 const TUint8 WlanDot11InfrastructureScanningMode::iEventName
       
    46     [EEVENTMAX][KMaxEventStringLength] = 
       
    47     {
       
    48         {"ESTATEENTRY"}, 
       
    49         {"ETXCOMPLETE"},
       
    50         {"ESTARTSCANNINGMODE"},
       
    51         {"ESCANMODERUNNING"},
       
    52         {"ESTOPSCANNINGMODE"},
       
    53         {"ESCANNINGMODEEXIT"},
       
    54         {"EABORT"}
       
    55     };
       
    56 #endif
       
    57 
       
    58 // ======== MEMBER FUNCTIONS ========
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // 
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 WlanDot11InfrastructureScanningMode::~WlanDot11InfrastructureScanningMode() 
       
    65     {
       
    66     iCtxImpl = NULL;
       
    67     iSSID = NULL;
       
    68     iChannels = NULL;
       
    69     iPimpl = NULL;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // 
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void WlanDot11InfrastructureScanningMode::Set( 
       
    77     WlanContextImpl& aCtxImpl )
       
    78     {
       
    79     iCtxImpl = &aCtxImpl;
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // 
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void WlanDot11InfrastructureScanningMode::Set( 
       
    87     TScanMode aMode,                    
       
    88     const TSSID& aSSID,                 
       
    89     TUint32 aScanRate,                    
       
    90     SChannels& aChannels,
       
    91     TUint32 aMinChannelTime,            
       
    92     TUint32 aMaxChannelTime,
       
    93     TBool aSplitScan,
       
    94     WHA::TScanType aScanType )    
       
    95     {
       
    96     // we can store pointers as oid parameters are guaranteed to be valid 
       
    97     // to the point the corresponding completion method is called
       
    98     iMode = aMode;
       
    99     iSSID = &aSSID;
       
   100     iScanRate = aScanRate;
       
   101     iChannels = &aChannels;
       
   102     iMinChannelTime = aMinChannelTime;           
       
   103     iMaxChannelTime = aMaxChannelTime;
       
   104     iSplitScan = aSplitScan;
       
   105     iScanType = aScanType;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // The internal state transition method.
       
   110 // It is guaranteed by the FSM framework that no WHA command is pending
       
   111 // when this method is entered
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 void WlanDot11InfrastructureScanningMode::ChangeInternalState( 
       
   115     WlanContextImpl& aCtxImpl, 
       
   116     TState aNewState )
       
   117     {
       
   118     iState = aNewState;
       
   119     Fsm( aCtxImpl, ESTATEENTRY );
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // The event dispatcher method.
       
   124 // It is guaranteed by the FSM framework that no WHA command is pending
       
   125 // when this method is entered
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void WlanDot11InfrastructureScanningMode::Fsm( 
       
   129     WlanContextImpl& aCtxImpl, 
       
   130     TEvent aEvent )
       
   131     {
       
   132     OsTracePrint( KScan, 
       
   133         (TUint8*)("UMAC * dot11-infrastructurescanningmode * FSM EVENT") );
       
   134 #ifndef NDEBUG
       
   135     OsTracePrint( KScan, (TUint8*)("event:"));
       
   136     OsTracePrint( KScan, iEventName[aEvent] );
       
   137     OsTracePrint( KScan, (TUint8*)("state:"));
       
   138     OsTracePrint( KScan, iStateName[iState] );
       
   139 #endif
       
   140 
       
   141     switch ( aEvent )
       
   142         {
       
   143         case ESTATEENTRY:
       
   144             OnStateEntryEvent( aCtxImpl );
       
   145             break;
       
   146         case ETXCOMPLETE:
       
   147             OnTxCompleteEvent( aCtxImpl );
       
   148             break;
       
   149         case ESTARTSCANNINGMODE:
       
   150             OnStartScanningModeEvent( aCtxImpl );
       
   151             break;
       
   152         case ESCANMODERUNNING:
       
   153             OnScanModeRunningEvent( aCtxImpl );
       
   154             break;
       
   155         case ESTOPSCANNINGMODE:
       
   156             OnStopScanningModeEvent( aCtxImpl );
       
   157             break;
       
   158         case ESCANNINGMODEEXIT:
       
   159             OnScanningModeExitEvent( aCtxImpl );
       
   160             break;
       
   161         case EABORT:
       
   162             OnAbortEvent( aCtxImpl );
       
   163             break;
       
   164         default:
       
   165             // catch internal FSM programming error
       
   166 #ifndef NDEBUG
       
   167             OsTracePrint( KErrorLevel, (TUint8*)("event:"));
       
   168             OsTracePrint( KErrorLevel, iEventName[aEvent] );                
       
   169 #endif
       
   170             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   171                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   172             break;
       
   173         }
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // Handler for the event.
       
   178 // It is guaranteed by the FSM framework that no WHA command is pending
       
   179 // when this method is entered
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void WlanDot11InfrastructureScanningMode::OnStateEntryEvent( 
       
   183     WlanContextImpl& aCtxImpl )
       
   184     {
       
   185     switch ( iState )
       
   186         {
       
   187         case EINIT:
       
   188             iPimpl = static_cast<WlanScanFsmCntx*>
       
   189                 (os_alloc( sizeof(WlanScanFsmCntx) ));
       
   190             if ( iPimpl )
       
   191                 {
       
   192                 // allocation success
       
   193                 new (iPimpl) WlanScanFsmCntx( *this );
       
   194                 // start fsm traversal
       
   195                 ChangeInternalState( aCtxImpl, EEXECUTESCANFSM );                
       
   196                 }
       
   197             else
       
   198                 {
       
   199                 // allocation failure
       
   200                 Fsm( aCtxImpl, EABORT );
       
   201                 }
       
   202 
       
   203             break;
       
   204         case EEXECUTESCANFSM:
       
   205             ExecuteScanFsm( aCtxImpl );
       
   206             break;
       
   207         case ECONTINUEDOT11TRAVERSE:
       
   208             ContinueDot11StateTraversal( aCtxImpl );
       
   209             break;
       
   210         default:
       
   211             // catch internal FSM programming error
       
   212 #ifndef NDEBUG
       
   213             OsTracePrint( KErrorLevel, (TUint8*)("state:"));
       
   214             OsTracePrint( KErrorLevel, iStateName[iState] );
       
   215 #endif 
       
   216             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   217                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   218             break;
       
   219         }
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // Handler for the event.
       
   224 // It is guaranteed by the FSM framework that no WHA command is pending
       
   225 // when this method is entered
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void WlanDot11InfrastructureScanningMode::OnTxCompleteEvent( 
       
   229     WlanContextImpl& /*aCtxImpl*/ ) const
       
   230     {
       
   231     switch ( iState )
       
   232         {
       
   233         case EEXECUTESCANFSM:
       
   234             // we are running the scan fsm 
       
   235             // and we have nothing to do here
       
   236             break;
       
   237         default:
       
   238             // catch internal FSM programming error
       
   239 #ifndef NDEBUG
       
   240             OsTracePrint( KErrorLevel, (TUint8*)("state:"));
       
   241             OsTracePrint( KErrorLevel, iStateName[iState] );
       
   242 #endif
       
   243             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   244                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   245             break;
       
   246         }
       
   247     }
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // Handler for the event.
       
   251 // It is guaranteed by the FSM framework that no WHA command is pending
       
   252 // when this method is entered
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 void WlanDot11InfrastructureScanningMode::OnStartScanningModeEvent( 
       
   256     WlanContextImpl& aCtxImpl )
       
   257     {
       
   258     // start the scanning mode
       
   259 
       
   260     // convert scan parameters to WHA types
       
   261     // Note that we need to deallocate the memory from whaChannels
       
   262     // - which is allocated in ConvertToWhaTypes() - when we are done
       
   263 
       
   264     WHA::SSSID* wha_ssid = 
       
   265         static_cast<WHA::SSSID*>(os_alloc( sizeof(WHA::SSSID) )); 
       
   266     if ( !wha_ssid )
       
   267         {
       
   268         // memory allocation failue; that's fatal
       
   269         Fsm( aCtxImpl, EABORT );
       
   270         return;
       
   271         }
       
   272 
       
   273     WHA::SChannels* wha_channels( NULL );
       
   274     TUint8 wha_channelcount( 0 );
       
   275 
       
   276     if ( !(WlanWhaToDot11TypeConverter::ConvertToWhaTypes(       
       
   277         aCtxImpl, 
       
   278         iSSID, 
       
   279         *wha_ssid, 
       
   280         iChannels, 
       
   281         iMinChannelTime,
       
   282         iMaxChannelTime,
       
   283         wha_channels, 
       
   284         wha_channelcount )) )
       
   285         {
       
   286         // memory allocation failue; that's fatal
       
   287         os_free( wha_ssid );
       
   288         Fsm( aCtxImpl, EABORT );
       
   289         }
       
   290     else
       
   291         {
       
   292         // start the scanning process
       
   293 
       
   294         const TUint8 KNbrOfProbeReqsPerCh = 2;
       
   295         const TUint8 KNoProbeReqs = 0;        
       
   296         const TUint8 KNbrOfSsids = 1;
       
   297         const TUint8 KNoSsids = 0;
       
   298         
       
   299         // in the most common case we use forced background
       
   300         // scan, so that we wouldn't lose data frames while scanning.
       
   301         if ( aCtxImpl.DisassociatedByAp() )
       
   302             {
       
   303             if ( aCtxImpl.CurrentDot11PwrMgmtMode() == WHA::KPsDisable )
       
   304                 {
       
   305                 // we have been disassociated by the AP and we are
       
   306                 // currently in Active mode => use foreground scan, so that we 
       
   307                 // won't send the AP any more class 3 frames (to inform it 
       
   308                 // about us moving to PS mode)
       
   309                 iScanType = WHA::EFgScan;
       
   310                 }
       
   311             }
       
   312         
       
   313         // set the context
       
   314         aCtxImpl.WsaScan().Set( 
       
   315             aCtxImpl,
       
   316             iScanRate,
       
   317             iChannels->iBand,
       
   318             wha_channelcount,
       
   319             wha_channels,
       
   320             iScanType,
       
   321             (iMode == EActiveScan) ? KNbrOfProbeReqsPerCh : KNoProbeReqs,
       
   322             // in the normal case, do a split scan
       
   323             iSplitScan,
       
   324             wha_ssid->iSSIDLength ? KNbrOfSsids : KNoSsids,
       
   325             wha_ssid );
       
   326         
       
   327         // change global state: entry procedure triggers action
       
   328         ChangeState( aCtxImpl, 
       
   329             *this,              // prev state
       
   330             aCtxImpl.WsaScan()  // next state
       
   331             );
       
   332             
       
   333         // as the parameters have been supplied we can now deallocate
       
   334         os_free( wha_ssid );
       
   335         os_free( wha_channels );                                    
       
   336         }
       
   337     }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // Handler for the event.
       
   341 // It is guaranteed by the FSM framework that no WHA command is pending
       
   342 // when this method is entered
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 void WlanDot11InfrastructureScanningMode::OnScanModeRunningEvent( 
       
   346     WlanContextImpl& aCtxImpl ) const
       
   347     {
       
   348     // complete the scan request
       
   349     
       
   350     OsTracePrint( KScan, (TUint8*)
       
   351         ("UMAC: WlanDot11InfrastructureScanningMode::OnScanModeRunningEvent: Complete scan request") );
       
   352     OnOidComplete( aCtxImpl );            
       
   353     }
       
   354 
       
   355 // -----------------------------------------------------------------------------
       
   356 // Handler for the event.
       
   357 // It is guaranteed by the FSM framework that no WHA command is pending
       
   358 // when this method is entered
       
   359 // -----------------------------------------------------------------------------
       
   360 //
       
   361 void WlanDot11InfrastructureScanningMode::OnStopScanningModeEvent( 
       
   362     WlanContextImpl& aCtxImpl )
       
   363     {
       
   364     // change global state: entry procedure triggers action
       
   365     ChangeState( aCtxImpl, 
       
   366         *this,                  // prev state
       
   367         aCtxImpl.WhaStopScan()  // next state
       
   368         );
       
   369     }
       
   370 
       
   371 // -----------------------------------------------------------------------------
       
   372 // Handler for the event.
       
   373 // It is guaranteed by the FSM framework that no WHA command is pending
       
   374 // when this method is entered
       
   375 // -----------------------------------------------------------------------------
       
   376 //
       
   377 void WlanDot11InfrastructureScanningMode::OnScanningModeExitEvent( 
       
   378     WlanContextImpl& aCtxImpl )
       
   379     {
       
   380     // scanning mode has stopped and so can we
       
   381     
       
   382     // inform the mgmt client about scan completion
       
   383 
       
   384     OsTracePrint( KScan, (TUint8*)
       
   385         ("UMAC: WlanDot11InfrastructureScanningMode::OnScanningModeExitEvent: Send scan complete indication"));
       
   386     
       
   387     OnInDicationEvent( aCtxImpl, EScanCompleted );
       
   388     
       
   389     // continue with the dot11 state traversal
       
   390     ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------
       
   394 // simulate macnotresponding error
       
   395 // ---------------------------------------------------------
       
   396 //
       
   397 void WlanDot11InfrastructureScanningMode::OnAbortEvent( 
       
   398     WlanContextImpl& aCtxImpl )
       
   399     {
       
   400     OsTracePrint( KWarningLevel, 
       
   401         (TUint8*)("UMAC * dot11-idlescanningmode * abort") );
       
   402 
       
   403     DoErrorIndication( aCtxImpl, WHA::KErrorMacNotResponding );
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // 
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 void WlanDot11InfrastructureScanningMode::ExecuteScanFsm( 
       
   411     WlanContextImpl& /*aCtxImpl*/ )
       
   412     {
       
   413     // start scan fsm
       
   414     iPimpl->Current().StartScanningMode( *iPimpl );
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // 
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 void WlanDot11InfrastructureScanningMode::ContinueDot11StateTraversal( 
       
   422     WlanContextImpl& aCtxImpl )
       
   423     {
       
   424     if ( iFlags & KDot11StateBackTrack )
       
   425         {
       
   426         // recall previous dot11 state
       
   427         ChangeState( aCtxImpl, 
       
   428             *this,              // prev state
       
   429             Dot11History()      // next state
       
   430             );
       
   431         }
       
   432     else
       
   433         {
       
   434         // we go somewhere else
       
   435 
       
   436         if ( !(iFlags & KDot11PwrMgmtModeDifference) )
       
   437             {
       
   438             // no dot11 power management mode difference 
       
   439             // between pre and post scanning mode detected
       
   440             ChangeState( aCtxImpl, 
       
   441                 *this,                                      // prev state
       
   442                 aCtxImpl.iStates.iInfrastructureNormalMode  // next state
       
   443                 );
       
   444             }
       
   445         else
       
   446             {
       
   447             // dot11 power management mode difference 
       
   448             // between pre and post scanning mode detected
       
   449             
       
   450             // initialize the counter which we use to determine if we should 
       
   451             // indicate BSS lost if we continuously are unsuccessful in changing the
       
   452             // power mgmt mode
       
   453             aCtxImpl.InitializeSetPsModeCount();
       
   454             
       
   455             ChangeState( aCtxImpl, 
       
   456                 *this,                                      // prev state
       
   457                 aCtxImpl.iStates.iPwrMgmtTransitionMode     // next state
       
   458                 );
       
   459             }
       
   460         }
       
   461     }
       
   462 
       
   463 // -----------------------------------------------------------------------------
       
   464 // Handler for WHA command response event.
       
   465 // It is guaranteed by the global protocol fsm framework that no WHA command is 
       
   466 // pending when this method is entered
       
   467 // -----------------------------------------------------------------------------
       
   468 //
       
   469 void WlanDot11InfrastructureScanningMode::OnWhaCommandResponse( 
       
   470     WlanContextImpl& aCtxImpl, 
       
   471     WHA::TCommandId aCommandId, 
       
   472     WHA::TStatus aStatus,
       
   473     const WHA::UCommandResponseParams& aCommandResponseParams,
       
   474     TUint32 aAct )
       
   475     {
       
   476     if ( aCommandId == WHA::EScanCommandResponse )
       
   477         {
       
   478         OsTracePrint( KScan, (TUint8*)("UMAC * OnScanningModeStarted"));
       
   479 
       
   480         // morph event to the scan fsm
       
   481         iPimpl->Current().OnScanningModeStarted( *iPimpl );
       
   482         }
       
   483     else if ( aCommandId == WHA::EStopScanResponse )
       
   484         {
       
   485         // complete the stop scan request
       
   486 
       
   487         OsTracePrint( KScan, (TUint8*)
       
   488             ("UMAC: WlanDot11InfrastructureScanningMode::OnWhaCommandResponse: complete stop scan request"));
       
   489 
       
   490         OnOidComplete( aCtxImpl );
       
   491         }
       
   492     else
       
   493         {
       
   494         // this is a response to a command that was not generated 
       
   495         // by this dot11 state object
       
   496         // so let's forward it to the default handler 
       
   497         WlanDot11State::OnWhaCommandResponse(
       
   498             aCtxImpl, 
       
   499             aCommandId, 
       
   500             aStatus,
       
   501             aCommandResponseParams,
       
   502             aAct );
       
   503         }
       
   504     }
       
   505 
       
   506 // -----------------------------------------------------------------------------
       
   507 // Handler for WHA command completion event.
       
   508 // It is guaranteed by the global protocol fsm framework that no WHA command is 
       
   509 // pending when this method is entered
       
   510 // -----------------------------------------------------------------------------
       
   511 //
       
   512 TBool WlanDot11InfrastructureScanningMode::CommandComplete( 
       
   513     WlanContextImpl& aCtxImpl, 
       
   514     WHA::TCompleteCommandId aCompleteCommandId, 
       
   515     WHA::TStatus /*aStatus*/,
       
   516     const WHA::UCommandCompletionParams& aCommandCompletionParams )
       
   517     {
       
   518     if ( aCompleteCommandId != WHA::EScanComplete )
       
   519         {
       
   520         // implementation error as this can be the only one
       
   521         OsAssert( (TUint8*)("UMAC * panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   522         }
       
   523     
       
   524     const WHA::TPsMode current_ps_mode( 
       
   525         aCommandCompletionParams.iScanComplete.iDot11PowerManagementMode );
       
   526     aCtxImpl.CurrentDot11PwrMgmtMode( current_ps_mode );
       
   527 
       
   528     OsTracePrint( KPwrStateTransition | KScan, 
       
   529         (TUint8*)("current dot11 power managememnt mode after scanning mode: %d"), 
       
   530         current_ps_mode );
       
   531 
       
   532     if ( current_ps_mode != aCtxImpl.DesiredDot11PwrMgmtMode() 
       
   533         && !(iFlags & KDot11StateBackTrack) )
       
   534         {
       
   535         // difference in dot11 power management 
       
   536         // mode between actual and desired mode exists 
       
   537         // and we not in dot11 state backtrack mode
       
   538         OsTracePrint( KWarningLevel, 
       
   539             (TUint8*)("UMAC * dot11-infrastructurescanningmode") );
       
   540         OsTracePrint( KWarningLevel, 
       
   541             (TUint8*)("difference in dot11 power management mode between") );
       
   542         OsTracePrint( KWarningLevel, 
       
   543             (TUint8*)("actual and desired mode detected") );
       
   544         OsTracePrint( KWarningLevel, (TUint8*)("post scanning mode state: %d"),
       
   545             current_ps_mode );
       
   546 
       
   547         iFlags |= KDot11PwrMgmtModeDifference;
       
   548         }
       
   549 
       
   550     OsTracePrint( KScan, (TUint8*)("UMAC * OnScanningModeStopped"));
       
   551 
       
   552     // morph event to scan fsm
       
   553     iPimpl->Current().OnScanningModeStopped( *iPimpl );
       
   554 
       
   555     // as scanning mode has ended we will change dot11 state.
       
   556     // Signal it to caller
       
   557     return ETrue;
       
   558     }
       
   559 
       
   560 // -----------------------------------------------------------------------------
       
   561 // 
       
   562 // -----------------------------------------------------------------------------
       
   563 //
       
   564 TAny* WlanDot11InfrastructureScanningMode::RequestForBuffer( 
       
   565     WlanContextImpl& aCtxImpl, 
       
   566     TUint16 aLength )
       
   567     {
       
   568     return aCtxImpl.GetRxBuffer( aLength );
       
   569     }
       
   570 
       
   571 // -----------------------------------------------------------------------------
       
   572 // 
       
   573 // -----------------------------------------------------------------------------
       
   574 //
       
   575 void WlanDot11InfrastructureScanningMode::OnBeaconFrameRx( 
       
   576     WlanContextImpl& aCtxImpl,
       
   577     const TAny* aFrame,
       
   578     const TUint32 aLength,
       
   579     WHA::TRcpi aRcpi,
       
   580     TUint8* aBuffer )
       
   581     {
       
   582     // as we have a beacon frame
       
   583     // we will pass it to the client of the mgmt interface
       
   584     XferDot11FrameToMgmtClient( aCtxImpl, aFrame, aLength, aRcpi, aBuffer );
       
   585     }
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // 
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 void WlanDot11InfrastructureScanningMode::OnProbeResponseFrameRx( 
       
   592     WlanContextImpl& aCtxImpl,
       
   593     const TAny* aFrame,
       
   594     const TUint32 aLength,
       
   595     WHA::TRcpi aRcpi,
       
   596     TUint8* aBuffer )
       
   597     {
       
   598     // as we have a probe response frame
       
   599     // we will pass it to the client of the mgmt interface
       
   600     XferDot11FrameToMgmtClient( aCtxImpl, aFrame, aLength, aRcpi, aBuffer );
       
   601     }
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // 
       
   605 // -----------------------------------------------------------------------------
       
   606 //
       
   607 void WlanDot11InfrastructureScanningMode::Entry( 
       
   608     WlanContextImpl& aCtxImpl )
       
   609     {
       
   610     if ( aCtxImpl.WsaCmdActive() )
       
   611         {
       
   612         // sanity checking code
       
   613         OsAssert( (TUint8*)("UMAC * panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   614         }
       
   615 
       
   616     // we don't want to do full event dispatching here as we want
       
   617     // to run this dot11 state in non pre-emptive mode.
       
   618     // However, we do want to handle the scan complete event in case it has
       
   619     // been registered
       
   620     if ( aCtxImpl.CommandCompletionEventRegistered( WHA::EScanComplete ) )
       
   621         {
       
   622         OsTracePrint( KScan, (TUint8*)
       
   623             ("UMAC: WlanDot11InfrastructureScanningMode::Entry: Scan complete event registered") );
       
   624         
       
   625         aCtxImpl.DispatchCommandCompletionEvent();
       
   626         // in this case we have actually already changed to another state
       
   627         // so there's nothing more for us to do here
       
   628         }
       
   629     else
       
   630         {
       
   631         // scan complete event not registered. Continue in the normal fashion
       
   632 
       
   633         if ( iState != EINIT )
       
   634             {
       
   635             // this is NOT the start of the the FSM actions
       
   636             // note that we send the ETXCOMPLETE event as the states
       
   637             // that wait for it are the only ones that can be interrupted
       
   638             // as they are asynchronous operations by nature
       
   639             // and wait for corresponding WHA completion method
       
   640             Fsm( aCtxImpl, ETXCOMPLETE );
       
   641             }
       
   642         else
       
   643             {
       
   644             // this is the start of the FSM actions
       
   645             Fsm( aCtxImpl, ESTATEENTRY );
       
   646             }
       
   647         }
       
   648     }
       
   649 
       
   650 // -----------------------------------------------------------------------------
       
   651 // 
       
   652 // -----------------------------------------------------------------------------
       
   653 //
       
   654 void WlanDot11InfrastructureScanningMode::Exit( 
       
   655     WlanContextImpl& /*aCtxImpl*/ )
       
   656     {
       
   657     // reset fsm
       
   658     iFlags = 0;
       
   659     iState = EINIT;
       
   660 
       
   661     // get rid of scan fsm implementation
       
   662     iPimpl->~WlanScanFsmCntx();
       
   663     os_free( iPimpl );
       
   664     iPimpl = NULL;
       
   665     }
       
   666 
       
   667 // -----------------------------------------------------------------------------
       
   668 // 
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 TBool WlanDot11InfrastructureScanningMode::StopScan( 
       
   672     WlanContextImpl& /*aCtxImpl*/ )
       
   673     {
       
   674     // inform scan fsm that scanning mode stop is desired
       
   675     iPimpl->Current().StopScanningMode( *iPimpl );
       
   676     // indicate that a state change has occurred
       
   677     return ETrue;
       
   678     }
       
   679 
       
   680 #ifndef NDEBUG                                    
       
   681 // -----------------------------------------------------------------------------
       
   682 // 
       
   683 // -----------------------------------------------------------------------------
       
   684 //
       
   685 const TInt8* WlanDot11InfrastructureScanningMode::GetStateName( 
       
   686     TUint8& aLength ) const
       
   687     {
       
   688     aLength = sizeof( iName );
       
   689     return iName;
       
   690     }
       
   691 #endif
       
   692 
       
   693 // -----------------------------------------------------------------------------
       
   694 // Handler for scan fsm event.
       
   695 // It is guaranteed by the FSM framework that no WHA command is pending
       
   696 // when this method is entered
       
   697 // -----------------------------------------------------------------------------
       
   698 //
       
   699 void WlanDot11InfrastructureScanningMode::OnScanFsmEvent( 
       
   700     MWlanScanFsmCb::TEvent aEvent )
       
   701     {
       
   702     OsTracePrint( KScan, (TUint8*)
       
   703         ("UMAC * dot11-infrastructurescanningmode * SCAN FSM EVENT: %d"), aEvent );
       
   704 
       
   705     // do what the scan fsm desires
       
   706     switch( aEvent )
       
   707         {
       
   708         case EFSMSTARTSCANNINGMODE:
       
   709             // scanning mode start desired
       
   710             Fsm( *iCtxImpl, ESTARTSCANNINGMODE );
       
   711             break;
       
   712         case EFSMSCANMODERUNNING:
       
   713             // scanning mode is running
       
   714             Fsm( *iCtxImpl, ESCANMODERUNNING );            
       
   715             break;
       
   716         case EFSMSTOPSCANNINGMODE:
       
   717             // scanning mode stop desired
       
   718             Fsm( *iCtxImpl, ESTOPSCANNINGMODE );
       
   719             break;
       
   720         case EFSMSCANMODESTOPPED:
       
   721             // scanning mode has stopped
       
   722             Fsm( *iCtxImpl, ESCANNINGMODEEXIT );
       
   723             break;
       
   724         default:
       
   725             // catch scan FSM programming error
       
   726             OsTracePrint( KErrorLevel, 
       
   727                 (TUint8*)("UMAC* scan fsm event: :%d"), aEvent);
       
   728             OsAssert( (TUint8*)("* UMAC * panic"), 
       
   729                 (TUint8*)(WLAN_FILE), __LINE__ );
       
   730             break;
       
   731         }
       
   732     }