summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp55
-rw-r--r--libopie2/opienet/onetwork.h2
2 files changed, 24 insertions, 33 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 789e8ca..6a363d7 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -54,2 +54,3 @@
#include <linux/sockios.h>
+#include <net/if_arp.h>
#include <stdarg.h>
@@ -73,3 +74,4 @@ void ONetwork::synchronize()
// gather available interfaces by inspecting /proc/net/dev
- // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
+ //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
@@ -134,7 +136,3 @@ bool ONetwork::isWirelessInterface( const char* name ) const
int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
- if ( result == -1 )
- qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) );
- else
- qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." );
- return ( result != -1 );
+ return result != -1;
}
@@ -241,2 +239,15 @@ OMacAddress ONetworkInterface::macAddress() const
+int ONetworkInterface::dataLinkType() const
+{
+ if ( ioctl( SIOCGIFHWADDR ) )
+ {
+ return _ifr.ifr_hwaddr.sa_family;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+
void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
@@ -587,3 +598,4 @@ bool OWirelessNetworkInterface::monitorMode() const
{
- return _mon ? _mon->enabled() : false;
+ qDebug( "dataLinkType = %d", dataLinkType() );
+ return dataLinkType() == ARPHRD_IEEE80211;
}
@@ -687,3 +699,3 @@ bool OWirelessNetworkInterface::wioctl( int call ) const
OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface )
- :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) )
+ :_if( static_cast<OWirelessNetworkInterface*>( iface ) )
{
@@ -709,23 +721,11 @@ bool OMonitoringInterface::enabled() const
{
- return _enabled;
+ return _if->monitorMode();
}
+
void OMonitoringInterface::setEnabled( bool b )
{
- // open a packet capturer here or leave this to
- // the client code?
-
- /*
-
- if ( b )
- {
- OPacketCapturer* opcap = new OPacketCapturer();
- opcap->open( _if->name() );
- }
- */
-
- _enabled = b;
-
}
+
/*======================================================================================
@@ -759,5 +759,2 @@ void OCiscoMonitoringInterface::setEnabled( bool b )
s << "XmitPower: 1";
-
- OMonitoringInterface::setEnabled( b );
-
}
@@ -805,4 +802,2 @@ void OWlanNGMonitoringInterface::setEnabled( bool b )
system( cmd );
-
- OMonitoringInterface::setEnabled( b );
}
@@ -865,4 +860,2 @@ void OHostAPMonitoringInterface::setEnabled( bool b )
}
-
- OMonitoringInterface::setEnabled( b );
}
@@ -916,4 +909,2 @@ void OOrinocoMonitoringInterface::setEnabled( bool b )
}
-
- OMonitoringInterface::setEnabled( b );
}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 509c3db..4cadbeb 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -128,2 +128,3 @@ class ONetworkInterface : public QObject
OMacAddress macAddress() const;
+ int dataLinkType() const;
@@ -250,3 +251,2 @@ class OMonitoringInterface
protected:
- bool _enabled;
const OWirelessNetworkInterface* _if;