summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authormickeyl <mickeyl>2003-10-28 16:38:55 (UTC)
committer mickeyl <mickeyl>2003-10-28 16:38:55 (UTC)
commit877bc5c756d94db71a745596dd7e48104a2ec9a1 (patch) (side-by-side diff)
treedf4de5f085b55e812488b0db2be1d66f63b67945 /libopie2/opienet
parent1fed961e25a6afd4070d8873b431aba8342406c3 (diff)
downloadopie-877bc5c756d94db71a745596dd7e48104a2ec9a1.zip
opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.tar.gz
opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.tar.bz2
- remove deprecated setMonitorMode() API. Use setMode( "monitor" ) now.
- monitor mode now tries to use the standard IW_MODE_MONITOR first. If that doesn't work, it falls back to using proprietary iwpriv commands
Diffstat (limited to 'libopie2/opienet') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp98
-rw-r--r--libopie2/opienet/onetwork.h16
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
@@ -675,6 +675,5 @@ OChannelHopper* OWirelessNetworkInterface::channelHopper() const
-void OWirelessNetworkInterface::setMode( const QString& mode )
+void OWirelessNetworkInterface::commit() const
{
- _iwr.u.mode = stringToMode( mode );
- wioctl( SIOCSIWMODE );
+ wioctl( SIOCSIWCOMMIT );
}
@@ -682,16 +681,26 @@ void OWirelessNetworkInterface::setMode( const QString& mode )
-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
@@ -700,11 +709,44 @@ void OWirelessNetworkInterface::setMonitorMode( bool b )
+ }
+ 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 );
+ }
+}
@@ -971,8 +1013,2 @@ void OMonitoringInterface::setChannel( int c )
-bool OMonitoringInterface::enabled() const
-{
- return _if->monitorMode();
-}
-
-
void OMonitoringInterface::setEnabled( bool b )
@@ -1094,11 +1130,2 @@ 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;
@@ -1112,3 +1139,2 @@ void OHostAPMonitoringInterface::setEnabled( bool b )
}
- #endif
}
@@ -1151,9 +1177,2 @@ void OOrinocoMonitoringInterface::setEnabled( bool b )
- #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 )
@@ -1166,3 +1185,2 @@ void OOrinocoMonitoringInterface::setEnabled( bool b )
}
- #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
@@ -351,5 +351,4 @@ class OWirelessNetworkInterface : public ONetworkInterface
* 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
@@ -364,7 +363,3 @@ class OWirelessNetworkInterface : public ONetworkInterface
*/
- 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;
/**
@@ -424,2 +419,6 @@ class OWirelessNetworkInterface : public ONetworkInterface
virtual OStationList* scanNetwork();
+ /** @internal commit pending changes to the driver
+ *
+ */
+ void commit() const;
@@ -458,3 +457,2 @@ class OMonitoringInterface
virtual void setEnabled( bool );
- virtual bool enabled() const;
virtual void setChannel( int );