-rw-r--r-- | libopie2/opienet/onetwork.cpp | 55 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 2 |
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 | |||
@@ -39,52 +39,54 @@ | |||
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* UNIX */ | 43 | /* UNIX */ |
44 | 44 | ||
45 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
46 | #include <cerrno> | 46 | #include <cerrno> |
47 | #include <cstring> | 47 | #include <cstring> |
48 | #include <cstdlib> | 48 | #include <cstdlib> |
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 54 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | ||
55 | #include <stdarg.h> | 56 | #include <stdarg.h> |
56 | 57 | ||
57 | using namespace std; | 58 | using namespace std; |
58 | 59 | ||
59 | /*====================================================================================== | 60 | /*====================================================================================== |
60 | * ONetwork | 61 | * ONetwork |
61 | *======================================================================================*/ | 62 | *======================================================================================*/ |
62 | 63 | ||
63 | ONetwork* ONetwork::_instance = 0; | 64 | ONetwork* ONetwork::_instance = 0; |
64 | 65 | ||
65 | ONetwork::ONetwork() | 66 | ONetwork::ONetwork() |
66 | { | 67 | { |
67 | qDebug( "ONetwork::ONetwork()" ); | 68 | qDebug( "ONetwork::ONetwork()" ); |
68 | synchronize(); | 69 | synchronize(); |
69 | } | 70 | } |
70 | 71 | ||
71 | void ONetwork::synchronize() | 72 | void ONetwork::synchronize() |
72 | { | 73 | { |
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 | ||
76 | _interfaces.clear(); | 78 | _interfaces.clear(); |
77 | QString str; | 79 | QString str; |
78 | QFile f( "/proc/net/dev" ); | 80 | QFile f( "/proc/net/dev" ); |
79 | bool hasFile = f.open( IO_ReadOnly ); | 81 | bool hasFile = f.open( IO_ReadOnly ); |
80 | if ( !hasFile ) | 82 | if ( !hasFile ) |
81 | { | 83 | { |
82 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
83 | return; | 85 | return; |
84 | } | 86 | } |
85 | QTextStream s( &f ); | 87 | QTextStream s( &f ); |
86 | s.readLine(); | 88 | s.readLine(); |
87 | s.readLine(); | 89 | s.readLine(); |
88 | while ( !s.atEnd() ) | 90 | while ( !s.atEnd() ) |
89 | { | 91 | { |
90 | s >> str; | 92 | s >> str; |
@@ -119,37 +121,33 @@ ONetwork* ONetwork::instance() | |||
119 | } | 121 | } |
120 | 122 | ||
121 | 123 | ||
122 | ONetwork::InterfaceIterator ONetwork::iterator() const | 124 | ONetwork::InterfaceIterator ONetwork::iterator() const |
123 | { | 125 | { |
124 | return ONetwork::InterfaceIterator( _interfaces ); | 126 | return ONetwork::InterfaceIterator( _interfaces ); |
125 | } | 127 | } |
126 | 128 | ||
127 | 129 | ||
128 | bool ONetwork::isWirelessInterface( const char* name ) const | 130 | bool ONetwork::isWirelessInterface( const char* name ) const |
129 | { | 131 | { |
130 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
131 | struct iwreq iwr; | 133 | struct iwreq iwr; |
132 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 134 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
133 | strcpy( (char*) &iwr.ifr_name, name ); | 135 | strcpy( (char*) &iwr.ifr_name, name ); |
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 | } |
141 | 139 | ||
142 | /*====================================================================================== | 140 | /*====================================================================================== |
143 | * ONetworkInterface | 141 | * ONetworkInterface |
144 | *======================================================================================*/ | 142 | *======================================================================================*/ |
145 | 143 | ||
146 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
147 | :QObject( parent, name ), | 145 | :QObject( parent, name ), |
148 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
149 | { | 147 | { |
150 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
151 | init(); | 149 | init(); |
152 | } | 150 | } |
153 | 151 | ||
154 | 152 | ||
155 | struct ifreq& ONetworkInterface::ifr() const | 153 | struct ifreq& ONetworkInterface::ifr() const |
@@ -226,32 +224,45 @@ QString ONetworkInterface::ipV4Address() const | |||
226 | } | 224 | } |
227 | 225 | ||
228 | 226 | ||
229 | OMacAddress ONetworkInterface::macAddress() const | 227 | OMacAddress ONetworkInterface::macAddress() const |
230 | { | 228 | { |
231 | if ( ioctl( SIOCGIFHWADDR ) ) | 229 | if ( ioctl( SIOCGIFHWADDR ) ) |
232 | { | 230 | { |
233 | return OMacAddress( _ifr ); | 231 | return OMacAddress( _ifr ); |
234 | } | 232 | } |
235 | else | 233 | else |
236 | { | 234 | { |
237 | return OMacAddress::unknown; | 235 | return OMacAddress::unknown; |
238 | } | 236 | } |
239 | } | 237 | } |
240 | 238 | ||
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 ) |
243 | { | 254 | { |
244 | _mon = m; | 255 | _mon = m; |
245 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 256 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
246 | } | 257 | } |
247 | 258 | ||
248 | 259 | ||
249 | OMonitoringInterface* ONetworkInterface::monitoring() const | 260 | OMonitoringInterface* ONetworkInterface::monitoring() const |
250 | { | 261 | { |
251 | return _mon; | 262 | return _mon; |
252 | } | 263 | } |
253 | 264 | ||
254 | 265 | ||
255 | ONetworkInterface::~ONetworkInterface() | 266 | ONetworkInterface::~ONetworkInterface() |
256 | { | 267 | { |
257 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 268 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
@@ -572,33 +583,34 @@ int OWirelessNetworkInterface::channelHopping() const | |||
572 | { | 583 | { |
573 | return _hopper->interval(); | 584 | return _hopper->interval(); |
574 | } | 585 | } |
575 | 586 | ||
576 | 587 | ||
577 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 588 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
578 | { | 589 | { |
579 | if ( _mon ) | 590 | if ( _mon ) |
580 | _mon->setEnabled( b ); | 591 | _mon->setEnabled( b ); |
581 | else | 592 | else |
582 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 593 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
583 | } | 594 | } |
584 | 595 | ||
585 | 596 | ||
586 | bool OWirelessNetworkInterface::monitorMode() const | 597 | bool OWirelessNetworkInterface::monitorMode() const |
587 | { | 598 | { |
588 | return _mon ? _mon->enabled() : false; | 599 | qDebug( "dataLinkType = %d", dataLinkType() ); |
600 | return dataLinkType() == ARPHRD_IEEE80211; | ||
589 | } | 601 | } |
590 | 602 | ||
591 | 603 | ||
592 | QString OWirelessNetworkInterface::nickName() const | 604 | QString OWirelessNetworkInterface::nickName() const |
593 | { | 605 | { |
594 | char str[IW_ESSID_MAX_SIZE]; | 606 | char str[IW_ESSID_MAX_SIZE]; |
595 | _iwr.u.data.pointer = &str[0]; | 607 | _iwr.u.data.pointer = &str[0]; |
596 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 608 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
597 | if ( !wioctl( SIOCGIWNICKN ) ) | 609 | if ( !wioctl( SIOCGIWNICKN ) ) |
598 | { | 610 | { |
599 | return "<unknown>"; | 611 | return "<unknown>"; |
600 | } | 612 | } |
601 | else | 613 | else |
602 | { | 614 | { |
603 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 615 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
604 | return str; | 616 | return str; |
@@ -672,107 +684,92 @@ bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | |||
672 | return ( result != -1 ); | 684 | return ( result != -1 ); |
673 | } | 685 | } |
674 | 686 | ||
675 | 687 | ||
676 | bool OWirelessNetworkInterface::wioctl( int call ) const | 688 | bool OWirelessNetworkInterface::wioctl( int call ) const |
677 | { | 689 | { |
678 | strcpy( _iwr.ifr_name, name() ); | 690 | strcpy( _iwr.ifr_name, name() ); |
679 | return wioctl( call, _iwr ); | 691 | return wioctl( call, _iwr ); |
680 | } | 692 | } |
681 | 693 | ||
682 | 694 | ||
683 | /*====================================================================================== | 695 | /*====================================================================================== |
684 | * OMonitoringInterface | 696 | * OMonitoringInterface |
685 | *======================================================================================*/ | 697 | *======================================================================================*/ |
686 | 698 | ||
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 | { |
690 | } | 702 | } |
691 | 703 | ||
692 | 704 | ||
693 | OMonitoringInterface::~OMonitoringInterface() | 705 | OMonitoringInterface::~OMonitoringInterface() |
694 | { | 706 | { |
695 | } | 707 | } |
696 | 708 | ||
697 | 709 | ||
698 | void OMonitoringInterface::setChannel( int c ) | 710 | void OMonitoringInterface::setChannel( int c ) |
699 | { | 711 | { |
700 | // use standard WE channel switching protocol | 712 | // use standard WE channel switching protocol |
701 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 713 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
702 | _if->_iwr.u.freq.m = c; | 714 | _if->_iwr.u.freq.m = c; |
703 | _if->_iwr.u.freq.e = 0; | 715 | _if->_iwr.u.freq.e = 0; |
704 | _if->wioctl( SIOCSIWFREQ ); | 716 | _if->wioctl( SIOCSIWFREQ ); |
705 | } | 717 | } |
706 | 718 | ||
707 | 719 | ||
708 | bool OMonitoringInterface::enabled() const | 720 | bool OMonitoringInterface::enabled() const |
709 | { | 721 | { |
710 | return _enabled; | 722 | return _if->monitorMode(); |
711 | } | 723 | } |
712 | 724 | ||
725 | |||
713 | void OMonitoringInterface::setEnabled( bool b ) | 726 | void OMonitoringInterface::setEnabled( bool b ) |
714 | { | 727 | { |
715 | // open a packet capturer here or leave this to | ||
716 | // the client code? | ||
717 | |||
718 | /* | ||
719 | |||
720 | if ( b ) | ||
721 | { | ||
722 | OPacketCapturer* opcap = new OPacketCapturer(); | ||
723 | opcap->open( _if->name() ); | ||
724 | } | ||
725 | */ | ||
726 | |||
727 | _enabled = b; | ||
728 | |||
729 | } | 728 | } |
730 | 729 | ||
730 | |||
731 | /*====================================================================================== | 731 | /*====================================================================================== |
732 | * OCiscoMonitoringInterface | 732 | * OCiscoMonitoringInterface |
733 | *======================================================================================*/ | 733 | *======================================================================================*/ |
734 | 734 | ||
735 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) | 735 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) |
736 | :OMonitoringInterface( iface ) | 736 | :OMonitoringInterface( iface ) |
737 | { | 737 | { |
738 | iface->setMonitoring( this ); | 738 | iface->setMonitoring( this ); |
739 | } | 739 | } |
740 | 740 | ||
741 | 741 | ||
742 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 742 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
743 | { | 743 | { |
744 | } | 744 | } |
745 | 745 | ||
746 | 746 | ||
747 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 747 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
748 | { | 748 | { |
749 | QString fname; | 749 | QString fname; |
750 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 750 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
751 | QFile f( fname ); | 751 | QFile f( fname ); |
752 | if ( !f.exists() ) return; | 752 | if ( !f.exists() ) return; |
753 | 753 | ||
754 | if ( f.open( IO_WriteOnly ) ) | 754 | if ( f.open( IO_WriteOnly ) ) |
755 | { | 755 | { |
756 | QTextStream s( &f ); | 756 | QTextStream s( &f ); |
757 | s << "Mode: r"; | 757 | s << "Mode: r"; |
758 | s << "Mode: y"; | 758 | s << "Mode: y"; |
759 | s << "XmitPower: 1"; | 759 | s << "XmitPower: 1"; |
760 | |||
761 | OMonitoringInterface::setEnabled( b ); | ||
762 | |||
763 | } | 760 | } |
764 | 761 | ||
765 | // flushing and closing will be done automatically when f goes out of scope | 762 | // flushing and closing will be done automatically when f goes out of scope |
766 | } | 763 | } |
767 | 764 | ||
768 | 765 | ||
769 | QString OCiscoMonitoringInterface::name() const | 766 | QString OCiscoMonitoringInterface::name() const |
770 | { | 767 | { |
771 | return "cisco"; | 768 | return "cisco"; |
772 | } | 769 | } |
773 | 770 | ||
774 | 771 | ||
775 | void OCiscoMonitoringInterface::setChannel( int ) | 772 | void OCiscoMonitoringInterface::setChannel( int ) |
776 | { | 773 | { |
777 | // cisco devices automatically switch channels when in monitor mode | 774 | // cisco devices automatically switch channels when in monitor mode |
778 | } | 775 | } |
@@ -790,34 +787,32 @@ OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface | |||
790 | } | 787 | } |
791 | 788 | ||
792 | 789 | ||
793 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 790 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
794 | { | 791 | { |
795 | } | 792 | } |
796 | 793 | ||
797 | 794 | ||
798 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 795 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
799 | { | 796 | { |
800 | //FIXME: do nothing if its already in the same mode | 797 | //FIXME: do nothing if its already in the same mode |
801 | 798 | ||
802 | QString enable = b ? "true" : "false"; | 799 | QString enable = b ? "true" : "false"; |
803 | QString cmd; | 800 | QString cmd; |
804 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); | 801 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); |
805 | system( cmd ); | 802 | system( cmd ); |
806 | |||
807 | OMonitoringInterface::setEnabled( b ); | ||
808 | } | 803 | } |
809 | 804 | ||
810 | 805 | ||
811 | QString OWlanNGMonitoringInterface::name() const | 806 | QString OWlanNGMonitoringInterface::name() const |
812 | { | 807 | { |
813 | return "wlan-ng"; | 808 | return "wlan-ng"; |
814 | } | 809 | } |
815 | 810 | ||
816 | 811 | ||
817 | void OWlanNGMonitoringInterface::setChannel( int ) | 812 | void OWlanNGMonitoringInterface::setChannel( int ) |
818 | { | 813 | { |
819 | // wlan-ng devices automatically switch channels when in monitor mode | 814 | // wlan-ng devices automatically switch channels when in monitor mode |
820 | } | 815 | } |
821 | 816 | ||
822 | 817 | ||
823 | /*====================================================================================== | 818 | /*====================================================================================== |
@@ -850,34 +845,32 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
850 | args[1] = 0; | 845 | args[1] = 0; |
851 | _if->wioctl( SIOCDEVPRIVATE ); | 846 | _if->wioctl( SIOCDEVPRIVATE ); |
852 | #endif | 847 | #endif |
853 | } | 848 | } |
854 | else | 849 | else |
855 | { | 850 | { |
856 | #if WIRELESS_EXT > 14 | 851 | #if WIRELESS_EXT > 14 |
857 | _if->_iwr.u.mode = IW_MODE_INFRA; | 852 | _if->_iwr.u.mode = IW_MODE_INFRA; |
858 | _if->wioctl( SIOCSIWMODE ); | 853 | _if->wioctl( SIOCSIWMODE ); |
859 | #else | 854 | #else |
860 | int* args = (int*) &_if->_iwr.u.name; | 855 | int* args = (int*) &_if->_iwr.u.name; |
861 | args[0] = 0; | 856 | args[0] = 0; |
862 | args[1] = 0; | 857 | args[1] = 0; |
863 | _if->wioctl( SIOCDEVPRIVATE ); | 858 | _if->wioctl( SIOCDEVPRIVATE ); |
864 | #endif | 859 | #endif |
865 | } | 860 | } |
866 | |||
867 | OMonitoringInterface::setEnabled( b ); | ||
868 | } | 861 | } |
869 | 862 | ||
870 | 863 | ||
871 | QString OHostAPMonitoringInterface::name() const | 864 | QString OHostAPMonitoringInterface::name() const |
872 | { | 865 | { |
873 | return "hostap"; | 866 | return "hostap"; |
874 | } | 867 | } |
875 | 868 | ||
876 | 869 | ||
877 | /*====================================================================================== | 870 | /*====================================================================================== |
878 | * OOrinocoNetworkInterface | 871 | * OOrinocoNetworkInterface |
879 | *======================================================================================*/ | 872 | *======================================================================================*/ |
880 | 873 | ||
881 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) | 874 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) |
882 | :OMonitoringInterface( iface ) | 875 | :OMonitoringInterface( iface ) |
883 | { | 876 | { |
@@ -901,25 +894,23 @@ void OOrinocoMonitoringInterface::setChannel( int c ) | |||
901 | 894 | ||
902 | 895 | ||
903 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 896 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
904 | { | 897 | { |
905 | if ( b ) | 898 | if ( b ) |
906 | { | 899 | { |
907 | setChannel( 1 ); | 900 | setChannel( 1 ); |
908 | } | 901 | } |
909 | else | 902 | else |
910 | { | 903 | { |
911 | // call iwpriv <device> monitor 0 0 | 904 | // call iwpriv <device> monitor 0 0 |
912 | int* args = (int*) &_if->_iwr.u.name; | 905 | int* args = (int*) &_if->_iwr.u.name; |
913 | args[0] = 0; | 906 | args[0] = 0; |
914 | args[1] = 0; | 907 | args[1] = 0; |
915 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); | 908 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); |
916 | } | 909 | } |
917 | |||
918 | OMonitoringInterface::setEnabled( b ); | ||
919 | } | 910 | } |
920 | 911 | ||
921 | 912 | ||
922 | QString OOrinocoMonitoringInterface::name() const | 913 | QString OOrinocoMonitoringInterface::name() const |
923 | { | 914 | { |
924 | return "orinoco"; | 915 | return "orinoco"; |
925 | } | 916 | } |
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 | |||
@@ -113,32 +113,33 @@ class ONetworkInterface : public QObject | |||
113 | friend class OOrinocoMonitoringInterface; | 113 | friend class OOrinocoMonitoringInterface; |
114 | 114 | ||
115 | public: | 115 | public: |
116 | ONetworkInterface( QObject* parent, const char* name ); | 116 | ONetworkInterface( QObject* parent, const char* name ); |
117 | virtual ~ONetworkInterface(); | 117 | virtual ~ONetworkInterface(); |
118 | 118 | ||
119 | void setMonitoring( OMonitoringInterface* ); | 119 | void setMonitoring( OMonitoringInterface* ); |
120 | OMonitoringInterface* monitoring() const; | 120 | OMonitoringInterface* monitoring() const; |
121 | bool setPromiscuousMode( bool ); | 121 | bool setPromiscuousMode( bool ); |
122 | bool promiscuousMode() const; | 122 | bool promiscuousMode() const; |
123 | bool setUp( bool ); | 123 | bool setUp( bool ); |
124 | bool isUp() const; | 124 | bool isUp() const; |
125 | bool isLoopback() const; | 125 | bool isLoopback() const; |
126 | bool isWireless() const; | 126 | bool isWireless() const; |
127 | QString ipV4Address() const; | 127 | QString ipV4Address() const; |
128 | OMacAddress macAddress() const; | 128 | OMacAddress macAddress() const; |
129 | int dataLinkType() const; | ||
129 | 130 | ||
130 | protected: | 131 | protected: |
131 | const int _sfd; | 132 | const int _sfd; |
132 | mutable ifreq _ifr; | 133 | mutable ifreq _ifr; |
133 | OMonitoringInterface* _mon; | 134 | OMonitoringInterface* _mon; |
134 | 135 | ||
135 | protected: | 136 | protected: |
136 | struct ifreq& ifr() const; | 137 | struct ifreq& ifr() const; |
137 | virtual void init(); | 138 | virtual void init(); |
138 | bool ioctl( int call ) const; | 139 | bool ioctl( int call ) const; |
139 | bool ioctl( int call, struct ifreq& ) const; | 140 | bool ioctl( int call, struct ifreq& ) const; |
140 | }; | 141 | }; |
141 | 142 | ||
142 | /*====================================================================================== | 143 | /*====================================================================================== |
143 | * OChannelHopper | 144 | * OChannelHopper |
144 | *======================================================================================*/ | 145 | *======================================================================================*/ |
@@ -235,33 +236,32 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
235 | 236 | ||
236 | class OMonitoringInterface | 237 | class OMonitoringInterface |
237 | { | 238 | { |
238 | public: | 239 | public: |
239 | OMonitoringInterface(); | 240 | OMonitoringInterface(); |
240 | OMonitoringInterface( ONetworkInterface* ); | 241 | OMonitoringInterface( ONetworkInterface* ); |
241 | virtual ~OMonitoringInterface(); | 242 | virtual ~OMonitoringInterface(); |
242 | 243 | ||
243 | public: | 244 | public: |
244 | virtual void setEnabled( bool ); | 245 | virtual void setEnabled( bool ); |
245 | virtual bool enabled() const; | 246 | virtual bool enabled() const; |
246 | virtual void setChannel( int ); | 247 | virtual void setChannel( int ); |
247 | 248 | ||
248 | virtual QString name() const = 0; | 249 | virtual QString name() const = 0; |
249 | 250 | ||
250 | protected: | 251 | protected: |
251 | bool _enabled; | ||
252 | const OWirelessNetworkInterface* _if; | 252 | const OWirelessNetworkInterface* _if; |
253 | 253 | ||
254 | }; | 254 | }; |
255 | 255 | ||
256 | 256 | ||
257 | /*====================================================================================== | 257 | /*====================================================================================== |
258 | * OCiscoMonitoring | 258 | * OCiscoMonitoring |
259 | *======================================================================================*/ | 259 | *======================================================================================*/ |
260 | 260 | ||
261 | 261 | ||
262 | class OCiscoMonitoringInterface : public OMonitoringInterface | 262 | class OCiscoMonitoringInterface : public OMonitoringInterface |
263 | { | 263 | { |
264 | public: | 264 | public: |
265 | OCiscoMonitoringInterface( ONetworkInterface* ); | 265 | OCiscoMonitoringInterface( ONetworkInterface* ); |
266 | virtual ~OCiscoMonitoringInterface(); | 266 | virtual ~OCiscoMonitoringInterface(); |
267 | 267 | ||