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