summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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
@@ -53,4 +53,5 @@
#include <unistd.h>
#include <linux/sockios.h>
+#include <net/if_arp.h>
#include <stdarg.h>
@@ -72,5 +73,6 @@ 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
_interfaces.clear();
@@ -133,9 +135,5 @@ bool ONetwork::isWirelessInterface( const char* name ) const
strcpy( (char*) &iwr.ifr_name, name );
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;
}
@@ -240,4 +238,17 @@ 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 )
{
@@ -586,5 +597,6 @@ void OWirelessNetworkInterface::setMonitorMode( bool b )
bool OWirelessNetworkInterface::monitorMode() const
{
- return _mon ? _mon->enabled() : false;
+ qDebug( "dataLinkType = %d", dataLinkType() );
+ return dataLinkType() == ARPHRD_IEEE80211;
}
@@ -686,5 +698,5 @@ bool OWirelessNetworkInterface::wioctl( int call ) const
OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface )
- :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) )
+ :_if( static_cast<OWirelessNetworkInterface*>( iface ) )
{
}
@@ -708,25 +720,13 @@ void OMonitoringInterface::setChannel( int c )
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;
-
}
+
/*======================================================================================
* OCiscoMonitoringInterface
@@ -758,7 +758,4 @@ void OCiscoMonitoringInterface::setEnabled( bool b )
s << "Mode: y";
s << "XmitPower: 1";
-
- OMonitoringInterface::setEnabled( b );
-
}
@@ -804,6 +801,4 @@ void OWlanNGMonitoringInterface::setEnabled( bool b )
cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable );
system( cmd );
-
- OMonitoringInterface::setEnabled( b );
}
@@ -864,6 +859,4 @@ void OHostAPMonitoringInterface::setEnabled( bool b )
#endif
}
-
- OMonitoringInterface::setEnabled( b );
}
@@ -915,6 +908,4 @@ void OOrinocoMonitoringInterface::setEnabled( bool b )
_if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
}
-
- 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
@@ -127,4 +127,5 @@ class ONetworkInterface : public QObject
QString ipV4Address() const;
OMacAddress macAddress() const;
+ int dataLinkType() const;
protected:
@@ -249,5 +250,4 @@ class OMonitoringInterface
protected:
- bool _enabled;
const OWirelessNetworkInterface* _if;