-rw-r--r-- | libopie2/opienet/onetwork.cpp | 53 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 2 |
2 files changed, 23 insertions, 32 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 @@ | |||
54 | #include <linux/sockios.h> | 54 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | ||
55 | #include <stdarg.h> | 56 | #include <stdarg.h> |
@@ -73,3 +74,4 @@ void ONetwork::synchronize() | |||
73 | // gather available interfaces by inspecting /proc/net/dev | 74 | // gather available interfaces by inspecting /proc/net/dev |
74 | // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | ||
75 | 77 | ||
@@ -134,7 +136,3 @@ bool ONetwork::isWirelessInterface( const char* name ) const | |||
134 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
135 | if ( result == -1 ) | 137 | return result != -1; |
136 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); | ||
137 | else | ||
138 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); | ||
139 | return ( result != -1 ); | ||
140 | } | 138 | } |
@@ -241,2 +239,15 @@ OMacAddress ONetworkInterface::macAddress() const | |||
241 | 239 | ||
240 | int ONetworkInterface::dataLinkType() const | ||
241 | { | ||
242 | if ( ioctl( SIOCGIFHWADDR ) ) | ||
243 | { | ||
244 | return _ifr.ifr_hwaddr.sa_family; | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | return -1; | ||
249 | } | ||
250 | } | ||
251 | |||
252 | |||
242 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 253 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
@@ -587,3 +598,4 @@ bool OWirelessNetworkInterface::monitorMode() const | |||
587 | { | 598 | { |
588 | return _mon ? _mon->enabled() : false; | 599 | qDebug( "dataLinkType = %d", dataLinkType() ); |
600 | return dataLinkType() == ARPHRD_IEEE80211; | ||
589 | } | 601 | } |
@@ -687,3 +699,3 @@ bool OWirelessNetworkInterface::wioctl( int call ) const | |||
687 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) | 699 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) |
688 | :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) ) | 700 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ) |
689 | { | 701 | { |
@@ -709,22 +721,10 @@ bool OMonitoringInterface::enabled() const | |||
709 | { | 721 | { |
710 | return _enabled; | 722 | return _if->monitorMode(); |
711 | } | 723 | } |
712 | 724 | ||
713 | void OMonitoringInterface::setEnabled( bool b ) | ||
714 | { | ||
715 | // open a packet capturer here or leave this to | ||
716 | // the client code? | ||
717 | |||
718 | /* | ||
719 | 725 | ||
720 | if ( b ) | 726 | void OMonitoringInterface::setEnabled( bool b ) |
721 | { | 727 | { |
722 | OPacketCapturer* opcap = new OPacketCapturer(); | ||
723 | opcap->open( _if->name() ); | ||
724 | } | 728 | } |
725 | */ | ||
726 | 729 | ||
727 | _enabled = b; | ||
728 | |||
729 | } | ||
730 | 730 | ||
@@ -759,5 +759,2 @@ void OCiscoMonitoringInterface::setEnabled( bool b ) | |||
759 | s << "XmitPower: 1"; | 759 | s << "XmitPower: 1"; |
760 | |||
761 | OMonitoringInterface::setEnabled( b ); | ||
762 | |||
763 | } | 760 | } |
@@ -805,4 +802,2 @@ void OWlanNGMonitoringInterface::setEnabled( bool b ) | |||
805 | system( cmd ); | 802 | system( cmd ); |
806 | |||
807 | OMonitoringInterface::setEnabled( b ); | ||
808 | } | 803 | } |
@@ -865,4 +860,2 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
865 | } | 860 | } |
866 | |||
867 | OMonitoringInterface::setEnabled( b ); | ||
868 | } | 861 | } |
@@ -916,4 +909,2 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) | |||
916 | } | 909 | } |
917 | |||
918 | OMonitoringInterface::setEnabled( b ); | ||
919 | } | 910 | } |
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 | |||
128 | OMacAddress macAddress() const; | 128 | OMacAddress macAddress() const; |
129 | int dataLinkType() const; | ||
129 | 130 | ||
@@ -250,3 +251,2 @@ class OMonitoringInterface | |||
250 | protected: | 251 | protected: |
251 | bool _enabled; | ||
252 | const OWirelessNetworkInterface* _if; | 252 | const OWirelessNetworkInterface* _if; |