-rw-r--r-- | libopie2/opienet/onetwork.cpp | 28 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 8 |
2 files changed, 29 insertions, 7 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 6cef5cf..751d841 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -62,16 +62,17 @@ using namespace std; * ONetwork *======================================================================================*/ ONetwork* ONetwork::_instance = 0; ONetwork::ONetwork() { qDebug( "ONetwork::ONetwork()" ); + qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); synchronize(); } void ONetwork::synchronize() { // gather available interfaces by inspecting /proc/net/dev //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices @@ -104,16 +105,22 @@ void ONetwork::synchronize() iface = new ONetworkInterface( this, (const char*) str ); } _interfaces.insert( str, iface ); s.readLine(); } } +short ONetwork::wirelessExtensionVersion() +{ + return WIRELESS_EXT; +} + + int ONetwork::count() const { return _interfaces.count(); } ONetworkInterface* ONetwork::interface( const QString& iface ) const { @@ -944,29 +951,32 @@ 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 - //TODO: check wireless extensions version on runtime and use - //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 - + #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 ) { _if->setPrivate( "monitor", 1, monitorCode ); } else { _if->setPrivate( "monitor", 1, 0 ); } + #endif } QString OHostAPMonitoringInterface::name() const { return "hostap"; } @@ -991,23 +1001,33 @@ void OOrinocoMonitoringInterface::setChannel( int c ) { int monitorCode = _prismHeader ? 1 : 2; _if->setPrivate( "monitor", 2, monitorCode, c ); } void OOrinocoMonitoringInterface::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 if ( b ) { setChannel( 1 ); } else { _if->setPrivate( "monitor", 2, 0, 0 ); } + #endif } QString OOrinocoMonitoringInterface::name() const { return "orinoco"; } diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index cfb999d..2553a61 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -99,30 +99,32 @@ class ONetwork : public QObject static ONetwork* instance(); /** * @returns an iterator usable for iterating through all network interfaces. */ InterfaceIterator iterator() const; /** * @returns true, if the @a interface supports the wireless extension protocol. */ - // FIXME QString? -zecke bool isWirelessInterface( const char* interface ) const; /** - * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found + * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. * @see ONetworkInterface */ - // FIXME: const QString& is prefered over QString!!! -zecke ONetworkInterface* interface( const QString& interface ) const; /** * @internal Rebuild the internal interface database * @note Sometimes it might be useful to call this from client code, * e.g. after issuing a cardctl insert */ void synchronize(); + /** + * @returns the wireless extension version used at compile time. + **/ + static short wirelessExtensionVersion(); protected: ONetwork(); private: static ONetwork* _instance; InterfaceMap _interfaces; }; |