-rw-r--r-- | libopie2/opienet/onetwork.cpp | 98 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 16 |
2 files changed, 65 insertions, 49 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 50c6679..c329e9a 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -673,40 +673,82 @@ OChannelHopper* OWirelessNetworkInterface::channelHopper() const } -void OWirelessNetworkInterface::setMode( const QString& mode ) +void OWirelessNetworkInterface::commit() const { - _iwr.u.mode = stringToMode( mode ); - wioctl( SIOCSIWMODE ); + wioctl( SIOCSIWCOMMIT ); } -QString OWirelessNetworkInterface::mode() const +void OWirelessNetworkInterface::setMode( const QString& newMode ) { - if ( !wioctl( SIOCGIWMODE ) ) + #ifdef FINALIZE + QString currentMode = mode(); + if ( currentMode == newMode ) return; + #endif + + qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); + + _iwr.u.mode = stringToMode( newMode ); + + if ( _iwr.u.mode != IW_MODE_MONITOR ) { - return "<unknown>"; - } - return modeToString( _iwr.u.mode ); -} + // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! + _iwr.u.mode = stringToMode( newMode ); + wioctl( SIOCSIWMODE ); + // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) -void OWirelessNetworkInterface::setMonitorMode( bool b ) + if ( mode() == "monitor" ) { + qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); if ( _mon ) - _mon->setEnabled( b ); + _mon->setEnabled( false ); else qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); } + } + else // special iwpriv fallback for monitor mode + { + if ( wioctl( SIOCSIWMODE ) ) + { + qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); + } + else + { + qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); + + if ( _mon ) + _mon->setEnabled( true ); + else + qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); + } + } +} + -bool OWirelessNetworkInterface::monitorMode() const +QString OWirelessNetworkInterface::mode() const { - qDebug( "dataLinkType = %d", dataLinkType() ); - return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); - //FIXME: 802 is the header type for PRISM - Linux support for this is pending... - //FIXME: What is 119, by the way? + memset( &_iwr, 0, sizeof( struct iwreq ) ); + + if ( !wioctl( SIOCGIWMODE ) ) + { + return "<unknown>"; } + qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); + + // legacy compatible monitor mode check + + if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) + { + return "monitor"; + } + else + { + return modeToString( _iwr.u.mode ); + } +} void OWirelessNetworkInterface::setNickName( const QString& nickname ) { @@ -969,12 +1011,6 @@ void OMonitoringInterface::setChannel( int c ) } -bool OMonitoringInterface::enabled() const -{ - return _if->monitorMode(); -} - - void OMonitoringInterface::setEnabled( bool b ) { } @@ -1092,15 +1128,6 @@ OHostAPMonitoringInterface::~OHostAPMonitoringInterface() void OHostAPMonitoringInterface::setEnabled( bool b ) { - // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 - // Wireless Extensions < Version 15 need iwpriv commandos for monitoring - - #if WIRELESS_EXT > 14 - if ( b ) - _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header - else - _if->setMode( "managed" ); - #else int monitorCode = _prismHeader ? 1 : 2; if ( b ) { @@ -1110,7 +1137,6 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) { _if->setPrivate( "monitor", 1, 0 ); } - #endif } @@ -1149,13 +1175,6 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) // Wireless Extensions < Version 15 need iwpriv commandos for monitoring // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported - #if 0 - //#if WIRELESS_EXT > 14 - if ( b ) - _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header - else - _if->setMode( "managed" ); - #else if ( b ) { setChannel( 1 ); @@ -1164,7 +1183,6 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) { _if->setPrivate( "monitor", 2, 0, 0 ); } - #endif } diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 0eb4542..eb6c86e 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -349,9 +349,8 @@ class OWirelessNetworkInterface : public ONetworkInterface /** * @returns the current IEEE 802.11 operation mode. * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown - */ - virtual QString mode() const; - /** + * + * @note: Important note concerning the 'monitor' mode: * Setting the monitor mode on a wireless network interface enables * listening to IEEE 802.11 data and management frames which normally * are handled by the device firmware. This can be used to detect @@ -362,11 +361,7 @@ class OWirelessNetworkInterface : public ONetworkInterface * the proper @ref OMonitoringInterface to be associated with the interface. * @see OMonitoringInterface */ - virtual void setMonitorMode( bool ); //FIXME: ==> setMode( "monitor" ); Use IW_MONITOR first, if this doesn't work, then use iwpriv! - /** - * @returns true if the device is listening in IEEE 802.11 monitor mode - */ - virtual bool monitorMode() const; //FIXME: ==> mode() + virtual QString mode() const; /** * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. * @see OChannelHopper @@ -422,6 +417,10 @@ class OWirelessNetworkInterface : public ONetworkInterface * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! */ virtual OStationList* scanNetwork(); + /** @internal commit pending changes to the driver + * + */ + void commit() const; protected: void buildInformation(); @@ -456,7 +455,6 @@ class OMonitoringInterface public: virtual void setEnabled( bool ); - virtual bool enabled() const; virtual void setChannel( int ); virtual QString name() const = 0; |