wlanutilities/wlansniffer/engine/server/src/wsfwlanscanner.cpp
branchRCL_3
changeset 12 981afc7d3841
parent 10 dff6ebfd236f
child 18 aaabc7526ded
equal deleted inserted replaced
11:8b0eae1b1d71 12:981afc7d3841
   640 TBool CWsfWlanScanner::RestartScanning()
   640 TBool CWsfWlanScanner::RestartScanning()
   641     {
   641     {
   642     LOG_ENTERFN( "CWsfWlanScanner::RestartScanning" );
   642     LOG_ENTERFN( "CWsfWlanScanner::RestartScanning" );
   643 
   643 
   644     TBool restarted( EFalse );
   644     TBool restarted( EFalse );
       
   645     LOG_WRITEF( "iScanState = %d isActive = %d iShowAvailability = %d",
       
   646                iScanState, IsActive(), iShowAvailability );
   645     
   647     
   646     if ( iScanState == EIdle && ( IsActive() || iShowAvailability ) )
   648     if ( iScanState == EIdle && ( IsActive() || iShowAvailability ) )
   647         {
   649         {
   648         // we have been waiting for the timer to complete
   650         // we have been waiting for the timer to complete
   649         // cancel it manually
   651         // cancel it manually
   654         TRequestStatus* status = &iStatus;
   656         TRequestStatus* status = &iStatus;
   655         User::RequestComplete( status, KErrNone );
   657         User::RequestComplete( status, KErrNone );
   656         restarted = ETrue;
   658         restarted = ETrue;
   657         }
   659         }
   658     
   660     
       
   661     LOG_WRITEF( "restarted = %d", restarted );
   659     return restarted;
   662     return restarted;
   660     }
   663     }
   661 
   664 
   662 
   665 
   663 // ---------------------------------------------------------------------------
   666 // ---------------------------------------------------------------------------
   860             	{
   863             	{
   861             	//if already found increase coverage
   864             	//if already found increase coverage
   862                 TWsfWlanInfo* temp = matchArray[i];
   865                 TWsfWlanInfo* temp = matchArray[i];
   863                 ++temp->iCoverage;
   866                 ++temp->iCoverage;
   864                 RefreshSignalStrength( *temp );
   867                 RefreshSignalStrength( *temp );
   865                 RefreshMaxRate( *temp );
   868                 RefreshTechnology( *temp );
   866              	}
   869              	}
   867             }
   870             }
   868         // Close() for matchArray
   871         // Close() for matchArray
   869         CleanupStack::PopAndDestroy( &matchArray );  
   872         CleanupStack::PopAndDestroy( &matchArray );  
   870         } // for iScanInfo              
   873         } // for iScanInfo              
  1033         if( !isHidden )
  1036         if( !isHidden )
  1034             {
  1037             {
  1035             // not hidden
  1038             // not hidden
  1036             RefreshNetworkMode( *wlanInfo );
  1039             RefreshNetworkMode( *wlanInfo );
  1037             RefreshSecurityMode( *wlanInfo );
  1040             RefreshSecurityMode( *wlanInfo );
  1038             RefreshMaxRate( *wlanInfo );
  1041             RefreshTechnology( *wlanInfo );
  1039 
  1042 
  1040             // check if we already have an entry/entries corresponding to a scan result
  1043             // check if we already have an entry/entries corresponding to a scan result
  1041             // (multiple entries for one scan result possible if GetAvailableIaps()
  1044             // (multiple entries for one scan result possible if GetAvailableIaps()
  1042             // found several iaps configured for same wlan)
  1045             // found several iaps configured for same wlan)
  1043             RPointerArray<TWsfWlanInfo> matchArray;
  1046             RPointerArray<TWsfWlanInfo> matchArray;
  1050             // if not found
  1053             // if not found
  1051             if( matchcount == 0 )
  1054             if( matchcount == 0 )
  1052                 {
  1055                 {
  1053                 wlanInfo->iCoverage = 1;
  1056                 wlanInfo->iCoverage = 1;
  1054                 RefreshSignalStrength( *wlanInfo );
  1057                 RefreshSignalStrength( *wlanInfo );
  1055                 RefreshMaxRate( *wlanInfo );
  1058                 RefreshTechnology( *wlanInfo );
  1056                 ++nElem; // new entry, inc index in array
  1059                 ++nElem; // new entry, inc index in array
  1057                 }
  1060                 }
  1058             else // if found inc coverage and refresh signal strength and rate
  1061             else // if found inc coverage and refresh signal strength and rate
  1059                 {
  1062                 {
  1060                 for( TInt i(0); i < matchcount; i++ )
  1063                 for( TInt i(0); i < matchcount; i++ )
  1061                     {
  1064                     {
  1062                     TWsfWlanInfo* temp = matchArray[i];
  1065                     TWsfWlanInfo* temp = matchArray[i];
  1063                     ++temp->iCoverage;
  1066                     ++temp->iCoverage;
  1064                     RefreshSignalStrength( *temp );
  1067                     RefreshSignalStrength( *temp );
  1065                     RefreshMaxRate( *temp );
  1068                     RefreshTechnology( *temp );
  1066 
  1069 
  1067                     if ( temp->iIapId )
  1070                     if ( temp->iIapId )
  1068                         {
  1071                         {
  1069                         TInt index( KErrNone );
  1072                         TInt index( KErrNone );
  1070                         do {
  1073                         do {
  1574                 (TInt)aWlanInfo.iSecurityMode,
  1577                 (TInt)aWlanInfo.iSecurityMode,
  1575                 (TInt)aWlanInfo.UsesPreSharedKey() );
  1578                 (TInt)aWlanInfo.UsesPreSharedKey() );
  1576     }
  1579     }
  1577 
  1580 
  1578 
  1581 
  1579 // ---------------------------------------------------------------------------
  1582 // -----------------------------------------------------------------------------
  1580 // CWsfWlanScanner::RefreshMaxRate
  1583 // CWsfWlanScanner::ConvertTxRateToTxRateEnum
  1581 // ---------------------------------------------------------------------------
  1584 // -----------------------------------------------------------------------------
  1582 //
  1585 //
  1583 void CWsfWlanScanner::RefreshMaxRate( TWsfWlanInfo& aWlanInfo )
  1586 core_tx_rate_e CWsfWlanScanner::ConvertTxRateToTxRateEnum( TUint8 aRate )
  1584     {
  1587     {
  1585     LOG_ENTERFN( "CWsfWlanScanner::RefreshMaxRate" );
  1588     LOG_ENTERFN( "CWsfWlanScanner::ConvertTxRateToTxRateEnum" );
  1586 
  1589 
  1587     TUint8 ieLen( 0 );
  1590     switch ( aRate )
       
  1591         {
       
  1592         case core_tx_rate_value_1mbit:
       
  1593             return core_tx_rate_1mbit;
       
  1594         case core_tx_rate_value_2mbit:
       
  1595             return core_tx_rate_2mbit;
       
  1596         case core_tx_rate_value_5p5mbit:
       
  1597             return core_tx_rate_5p5mbit;
       
  1598         case core_tx_rate_value_6mbit:
       
  1599             return core_tx_rate_6mbit;
       
  1600         case core_tx_rate_value_9mbit:
       
  1601             return core_tx_rate_9mbit;
       
  1602         case core_tx_rate_value_11mbit:
       
  1603             return core_tx_rate_11mbit;
       
  1604         case core_tx_rate_value_12mbit:
       
  1605             return core_tx_rate_12mbit;
       
  1606         case core_tx_rate_value_18mbit:
       
  1607             return core_tx_rate_18mbit;
       
  1608         case core_tx_rate_value_22mbit:
       
  1609             return core_tx_rate_22mbit;
       
  1610         case core_tx_rate_value_24mbit:
       
  1611             return core_tx_rate_24mbit;
       
  1612         case core_tx_rate_value_33mbit:
       
  1613             return core_tx_rate_33mbit;
       
  1614         case core_tx_rate_value_36mbit:
       
  1615             return core_tx_rate_36mbit;
       
  1616         case core_tx_rate_value_48mbit:
       
  1617             return core_tx_rate_48mbit;
       
  1618         case core_tx_rate_value_54mbit:
       
  1619             return core_tx_rate_54mbit;
       
  1620         default:
       
  1621             return core_tx_rate_none;
       
  1622         }
       
  1623     }
       
  1624 
       
  1625 
       
  1626 // ---------------------------------------------------------------------------
       
  1627 // CWsfWlanScanner::RefreshTechnology
       
  1628 // ---------------------------------------------------------------------------
       
  1629 //
       
  1630 void CWsfWlanScanner::RefreshTechnology( TWsfWlanInfo& aWlanInfo )
       
  1631     {
       
  1632     LOG_ENTERFN( "CWsfWlanScanner::RefreshTechnology" );
       
  1633 
       
  1634     TUint8 ieLen(0);
  1588     const TUint8* ieData;
  1635     const TUint8* ieData;
  1589     TUint8 dataRates[KMaxNumberOfRates];
  1636     TUint8 dataRates[KMaxNumberOfRates];
  1590     TUint8 maxDataRate( aWlanInfo.iTransferRate * 2 );
  1637 
  1591 
  1638     if ( iScanInfo->InformationElement( E802Dot11HtCapabilitiesIE, ieLen,
  1592     Mem::FillZ( &dataRates[0], sizeof( dataRates ) );
  1639             &ieData ) == 0 )
  1593 
  1640         {
  1594     // Supported Rates
  1641         // 802.11n supported
  1595     iScanInfo->InformationElement( E802Dot11SupportedRatesIE, ieLen, &ieData );
  1642         aWlanInfo.iTransferRate = 0x8;
  1596 
  1643         }
  1597     Mem::Copy( dataRates, ieData, ieLen );
  1644     else
  1598 
  1645         {
  1599     for ( TInt a = 0; a < ieLen; a++ )
  1646         Mem::FillZ( &dataRates[0], sizeof( dataRates ) );
  1600         {
  1647         core_tx_rate_e rate( core_tx_rate_none );
  1601         // ignore the highest bit
  1648         TUint32 basic_rates( 0 );
  1602         dataRates[a] &= 0x7f;
  1649         TUint32 supported_rates( 0 );
  1603         if ( maxDataRate < dataRates[a] )
  1650 
  1604             {
  1651         // Supported Rates
  1605             maxDataRate = dataRates[a];
  1652         iScanInfo->InformationElement( E802Dot11SupportedRatesIE, ieLen,
  1606             }
  1653                 &ieData );
  1607         }
  1654 
  1608 
  1655         Mem::Copy( dataRates, ieData, ieLen );
  1609     // Extended Supported Rates
  1656 
  1610     Mem::FillZ( &dataRates[0], sizeof( dataRates ) );
  1657         TUint32 temp_basic_rates( 0 );
  1611 
  1658         TUint32 temp_supported_rates( 0 );
  1612     iScanInfo->InformationElement( E802Dot11ExtendedRatesIE, ieLen, &ieData );
  1659 
  1613 
       
  1614     Mem::Copy( dataRates, ieData, ieLen );
       
  1615 
       
  1616     if ( ieData )
       
  1617         {
       
  1618         for ( TInt a = 0; a < ieLen; a++ )
  1660         for ( TInt a = 0; a < ieLen; a++ )
  1619             {
  1661             {
  1620             dataRates[a] &= 0x7f;
  1662             rate = ConvertTxRateToTxRateEnum( dataRates[a]
  1621             if ( maxDataRate < dataRates[a] )
  1663                     & ~TX_RATE_BASIC_MASK );
       
  1664 
       
  1665             temp_supported_rates |= rate;
       
  1666 
       
  1667             if ( dataRates[a] & TX_RATE_BASIC_MASK )
  1622                 {
  1668                 {
  1623                 maxDataRate = dataRates[a];
  1669                 /**
       
  1670                  * The highest bit is enabled, the rate is both a basic rate
       
  1671                  * and a supported rate.
       
  1672                  */
       
  1673                 temp_basic_rates |= rate;
  1624                 }
  1674                 }
  1625             }
  1675             }
  1626         }
  1676 
  1627     aWlanInfo.iTransferRate = maxDataRate / 2;
  1677         basic_rates |= temp_basic_rates;
  1628     LOG_WRITEF( "maxRate = %d", aWlanInfo.iTransferRate );
  1678         supported_rates |= temp_supported_rates;
       
  1679 
       
  1680         // Extended Supported Rates
       
  1681         Mem::FillZ( &dataRates[0], sizeof( dataRates ) );
       
  1682 
       
  1683         iScanInfo->InformationElement( E802Dot11ExtendedRatesIE, ieLen,
       
  1684                 &ieData );
       
  1685 
       
  1686         Mem::Copy( dataRates, ieData, ieLen );
       
  1687 
       
  1688         if ( ieData )
       
  1689             {
       
  1690             temp_basic_rates = 0;
       
  1691             temp_supported_rates = 0;
       
  1692 
       
  1693             for ( TInt a = 0; a < ieLen; a++ )
       
  1694                 {
       
  1695                 rate = ConvertTxRateToTxRateEnum( dataRates[a]
       
  1696                         & ~TX_RATE_BASIC_MASK );
       
  1697 
       
  1698                 temp_supported_rates |= rate;
       
  1699 
       
  1700                 if ( dataRates[a] & TX_RATE_BASIC_MASK )
       
  1701                     {
       
  1702                     /**
       
  1703                      * The highest bit is enabled, the rate is both a basic rate
       
  1704                      * and a supported rate.
       
  1705                      */
       
  1706                     temp_basic_rates |= rate;
       
  1707                     }
       
  1708                 }
       
  1709 
       
  1710             basic_rates |= temp_basic_rates;
       
  1711             supported_rates |= temp_supported_rates;
       
  1712             }
       
  1713 
       
  1714         aWlanInfo.iTransferRate = 0x4; // 802.11bg
       
  1715 
       
  1716         // AP is 802.11b only if only 802.11b rates 
       
  1717         // are advertised as supported rates.
       
  1718         if ( !( supported_rates & ~CORE_TX_RATES_802P11B ) )
       
  1719             {
       
  1720             aWlanInfo.iTransferRate = 0x1; // 802.11b
       
  1721             }
       
  1722         // AP is 802.11g only if any of the 802.11g rates is a basic rate.
       
  1723         else if ( basic_rates & CORE_TX_RATES_802P11G )
       
  1724             {
       
  1725             aWlanInfo.iTransferRate = 0x2; // 802.11g
       
  1726             }
       
  1727         }
       
  1728 
       
  1729     LOG_WRITEF( "technology = %d", aWlanInfo.iTransferRate );
  1629     }
  1730     }
  1630 
  1731 
  1631 
  1732 
  1632 // ---------------------------------------------------------------------------
  1733 // ---------------------------------------------------------------------------
  1633 // CWsfWlanScanner::ConnectionEstablishedL
  1734 // CWsfWlanScanner::ConnectionEstablishedL