wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepalive.cpp
changeset 46 2fbd1d709fe7
parent 38 2dc6da6fb431
child 61 e1d68407ed06
equal deleted inserted replaced
45:d9ec2b8c6bad 46:2fbd1d709fe7
    20 #include <rconnmon.h>
    20 #include <rconnmon.h>
    21 
    21 
    22 // User include files
    22 // User include files
    23 
    23 
    24 #include "wsfkeepalivetimer.h"
    24 #include "wsfkeepalivetimer.h"
       
    25 #include "wsfkeepalivecmm.h"
    25 #include "wsfkeepaliveconnmon.h"
    26 #include "wsfkeepaliveconnmon.h"
    26 #include "wsfkeepaliveconnmondisc.h"
    27 #include "wsfkeepaliveconnmondisc.h"
    27 #include "wsfkeepaliveesock.h"
    28 #include "wsfkeepaliveesock.h"
    28 #include "wsfkeepalive.h"
    29 #include "wsfkeepalive.h"
    29 #include "OstTraceDefinitions.h"
    30 #include "OstTraceDefinitions.h"
    42 static const int KKeepaliveInactivityInterval = 300;
    43 static const int KKeepaliveInactivityInterval = 300;
    43 
    44 
    44 // UID of Wlan sniffer application
    45 // UID of Wlan sniffer application
    45 static const TUid KWlanSnifferUid = { 0x10281CAA };
    46 static const TUid KWlanSnifferUid = { 0x10281CAA };
    46 
    47 
       
    48 // UID of Wlan login application
       
    49 static const TUid KWlanloginUid = { 0x2002E6D0 };
       
    50 
    47 // List of UIDs of clients not considered as "real"
    51 // List of UIDs of clients not considered as "real"
    48 static const TUid KDiscardedClientUids[] = 
    52 static const TUid KDiscardedClientUids[] = 
    49     {
    53     {
    50         { 0x2002FF5F }, // Sniffer keepalive process, that is, us
    54         { 0x2002FF5F }, // Sniffer keepalive process, that is, us
    51         KWlanSnifferUid, // Sniffer application (wlansniffer.exe)
    55         KWlanSnifferUid, // Sniffer application (wlansniffer.exe)
       
    56         KWlanloginUid, //   Wlan Login application (wlanlogin.exe)
    52         { 0x101fD9C5 }  // DHCP server (dhcpserv.exe)
    57         { 0x101fD9C5 }  // DHCP server (dhcpserv.exe)
    53     };
    58     };
    54 
    59 
    55 // ======== LOCAL FUNCTIONS ========
    60 // ======== LOCAL FUNCTIONS ========
    56 
    61 
    73     {
    78     {
    74     OstTraceFunctionEntry0( DUP1_CWSFKEEPALIVE_CWSFKEEPALIVE_ENTRY );
    79     OstTraceFunctionEntry0( DUP1_CWSFKEEPALIVE_CWSFKEEPALIVE_ENTRY );
    75 
    80 
    76     delete iEsock;
    81     delete iEsock;
    77     delete iConnMonDisc;
    82     delete iConnMonDisc;
       
    83     delete iCmMgr;
    78     delete iConnMon;
    84     delete iConnMon;
    79     delete iTimer;
    85     delete iTimer;
    80     
    86     
    81     OstTraceFunctionExit0( DUP1_CWSFKEEPALIVE_CWSFKEEPALIVE_EXIT );
    87     OstTraceFunctionExit0( DUP1_CWSFKEEPALIVE_CWSFKEEPALIVE_EXIT );
    82     }
    88     }
   161     if ( OpenedByWlanSniffer( aConnectionId ) )
   167     if ( OpenedByWlanSniffer( aConnectionId ) )
   162         {
   168         {
   163         // Start to monitor this connection, and add us as a user to the
   169         // Start to monitor this connection, and add us as a user to the
   164         // connection
   170         // connection
   165         iConnectionId = aConnectionId;
   171         iConnectionId = aConnectionId;
       
   172         iIapId = aIapId;
   166         iEsock->ConnectL( aIapId );
   173         iEsock->ConnectL( aIapId );
   167 
   174 
   168         // Assume there are no real clients yet. Setup timer for polling
   175         // Assume there are no real clients yet. Setup timer for polling
   169         // when real clients might be added to the connection
   176         // when real clients might be added to the connection
   170         SetState( EActiveNoClients );
   177         SetState( EActiveNoClients );
   190     SetState( EInactive );
   197     SetState( EInactive );
   191     iConnectionId = KInvalidConnectionId;
   198     iConnectionId = KInvalidConnectionId;
   192     // Stop also the polling timer
   199     // Stop also the polling timer
   193     iTimer->Stop();
   200     iTimer->Stop();
   194     
   201     
       
   202     OstTrace1(
       
   203         TRACE_NORMAL,
       
   204         CWSFKEEPALIVE_WLANCONNECTIONCLOSED_IAPID,
       
   205         "CWsfKeepalive::WlanConnectionClosed iapId=%d",
       
   206         iIapId );
       
   207     
       
   208     // If connected to hotspot IAP, the IAP must be deleted
       
   209     if ( iCmMgr->GetHotspotInfoL( iIapId ) )
       
   210         {
       
   211         OstTrace0(
       
   212             TRACE_NORMAL,
       
   213             CWSFKEEPALIVE_WLANCONNECTIONCLOSED_HOTSPOTDETECTED,
       
   214             "CWsfKeepalive::WlanConnectionClosed Hotspot IAP detected" );
       
   215 
       
   216         if ( !iCmMgr->DeleteHotspotIapL( iIapId ) )
       
   217             {
       
   218             OstTrace0(
       
   219                 TRACE_NORMAL,
       
   220                 CWSFKEEPALIVE_WLANCONNECTIONCLOSED_HOTSPOTDELETEFAILED,
       
   221                 "CWsfKeepalive::WlanConnectionClosed Hotspot delete failed" );
       
   222             }
       
   223         iIapId = 0;
       
   224         }
       
   225     
   195     OstTraceFunctionExit0( CWSFKEEPALIVE_WLANCONNECTIONCLOSED_EXIT );
   226     OstTraceFunctionExit0( CWSFKEEPALIVE_WLANCONNECTIONCLOSED_EXIT );
   196     }
   227     }
   197 
   228 
   198 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   199 // Default constructor
   230 // Default constructor
   200 // ---------------------------------------------------------------------------
   231 // ---------------------------------------------------------------------------
   201 //
   232 //
   202 CWsfKeepalive::CWsfKeepalive() :
   233 CWsfKeepalive::CWsfKeepalive() :
   203     iConnectionId( KInvalidConnectionId ),
   234     iConnectionId( KInvalidConnectionId ),
   204     iState( EInactive )
   235     iState( EInactive ),
       
   236     iIapId( 0 )
   205     {
   237     {
   206     OstTraceFunctionEntry0( CWSFKEEPALIVE_CWSFKEEPALIVE_ENTRY );
   238     OstTraceFunctionEntry0( CWSFKEEPALIVE_CWSFKEEPALIVE_ENTRY );
   207     OstTraceFunctionExit0( CWSFKEEPALIVE_CWSFKEEPALIVE_EXIT );
   239     OstTraceFunctionExit0( CWSFKEEPALIVE_CWSFKEEPALIVE_EXIT );
   208     }
   240     }
   209 
   241 
   217     
   249     
   218     iTimer = CWsfKeepaliveTimer::NewL( *this );
   250     iTimer = CWsfKeepaliveTimer::NewL( *this );
   219     iConnMon = CWsfKeepaliveConnMon::NewL( *this );
   251     iConnMon = CWsfKeepaliveConnMon::NewL( *this );
   220     iConnMonDisc = CWsfKeepaliveConnMonDisc::NewL();
   252     iConnMonDisc = CWsfKeepaliveConnMonDisc::NewL();
   221     iEsock = CWsfKeepaliveEsock::NewL();
   253     iEsock = CWsfKeepaliveEsock::NewL();
       
   254     iCmMgr = CWsfKeepaliveCmm::NewL();
   222     
   255     
   223     OstTraceFunctionExit0( CWSFKEEPALIVE_CONSTRUCTL_EXIT );
   256     OstTraceFunctionExit0( CWSFKEEPALIVE_CONSTRUCTL_EXIT );
   224     }
   257     }
   225  
   258  
   226 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------