summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp28
-rw-r--r--libopie2/opienet/onetutils.h3
-rw-r--r--libopie2/opienet/onetwork.cpp50
-rw-r--r--libopie2/opienet/onetwork.h8
4 files changed, 55 insertions, 34 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index b317810..0fb21ff 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -41,69 +41,95 @@ using namespace std;
41#define IW_PRIV_TYPE_NONE 0x0000 41#define IW_PRIV_TYPE_NONE 0x0000
42#define IW_PRIV_TYPE_BYTE 0x1000 42#define IW_PRIV_TYPE_BYTE 0x1000
43#define IW_PRIV_TYPE_CHAR 0x2000 43#define IW_PRIV_TYPE_CHAR 0x2000
44#define IW_PRIV_TYPE_INT 0x4000 44#define IW_PRIV_TYPE_INT 0x4000
45#define IW_PRIV_TYPE_FLOAT 0x5000 45#define IW_PRIV_TYPE_FLOAT 0x5000
46#define IW_PRIV_TYPE_ADDR 0x6000 46#define IW_PRIV_TYPE_ADDR 0x6000
47#define IW_PRIV_SIZE_FIXED 0x0800 47#define IW_PRIV_SIZE_FIXED 0x0800
48#define IW_PRIV_SIZE_MASK 0x07FF 48#define IW_PRIV_SIZE_MASK 0x07FF
49 49
50/*====================================================================================== 50/*======================================================================================
51 * OMacAddress 51 * OMacAddress
52 *======================================================================================*/ 52 *======================================================================================*/
53 53
54// static initializer for broadcast and unknown MAC Adresses 54// static initializer for broadcast and unknown MAC Adresses
55const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 55const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
56const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 56const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
57const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 57const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
58const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 58const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
59 59
60 60
61//TODO: Incorporate Ethernet Manufacturer database here! 61//TODO: Incorporate Ethernet Manufacturer database here!
62 62
63OMacAddress::OMacAddress( unsigned char* p ) 63OMacAddress::OMacAddress( unsigned char* p )
64{ 64{
65 memcpy( _bytes, p, 6 ); // D'OH! memcpy in my sources... eeek... 65 memcpy( _bytes, p, 6 );
66} 66}
67 67
68 68
69OMacAddress::OMacAddress( const unsigned char* p ) 69OMacAddress::OMacAddress( const unsigned char* p )
70{ 70{
71 memcpy( _bytes, p, 6 ); 71 memcpy( _bytes, p, 6 );
72} 72}
73 73
74 74
75OMacAddress::OMacAddress( struct ifreq& ifr ) 75OMacAddress::OMacAddress( struct ifreq& ifr )
76{ 76{
77 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 77 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
78} 78}
79 79
80 80
81OMacAddress::~OMacAddress() 81OMacAddress::~OMacAddress()
82{ 82{
83} 83}
84 84
85 85
86#ifdef QT_NO_DEBUG
87inline
88#endif
89const unsigned char* OMacAddress::native() const
90{
91 return (const unsigned char*) &_bytes;
92}
93
94
95OMacAddress OMacAddress::fromString( const QString& str )
96{
97 QString addr( str );
98 unsigned char buf[6];
99 bool ok = true;
100 int index = 14;
101 for ( int i = 5; i >= 0; --i )
102 {
103 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
104 if ( !ok ) return OMacAddress::unknown;
105 addr.truncate( index );
106 index -= 3;
107 }
108 return (const unsigned char*) &buf;
109}
110
111
86QString OMacAddress::toString() const 112QString OMacAddress::toString() const
87{ 113{
88 QString s; 114 QString s;
89 s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 115 s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
90 _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff, 116 _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff,
91 _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 117 _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
92 return s; 118 return s;
93} 119}
94 120
95 121
96bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 122bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
97{ 123{
98 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 124 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
99} 125}
100 126
101 127
102/*====================================================================================== 128/*======================================================================================
103 * OHostAddress 129 * OHostAddress
104 *======================================================================================*/ 130 *======================================================================================*/
105 131
106 132
107/*====================================================================================== 133/*======================================================================================
108 * OPrivateIOCTL 134 * OPrivateIOCTL
109 *======================================================================================*/ 135 *======================================================================================*/
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index 8be042b..73d52cc 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -35,48 +35,51 @@
35#include <qdict.h> 35#include <qdict.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43struct ifreq; 43struct ifreq;
44class OWirelessNetworkInterface; 44class OWirelessNetworkInterface;
45 45
46/*====================================================================================== 46/*======================================================================================
47 * OMacAddress 47 * OMacAddress
48 *======================================================================================*/ 48 *======================================================================================*/
49 49
50class OMacAddress 50class OMacAddress
51{ 51{
52 public: 52 public:
53 OMacAddress( unsigned char* ); 53 OMacAddress( unsigned char* );
54 OMacAddress( const unsigned char* ); 54 OMacAddress( const unsigned char* );
55 OMacAddress( struct ifreq& ); 55 OMacAddress( struct ifreq& );
56 ~OMacAddress(); 56 ~OMacAddress();
57 57
58 QString toString() const; 58 QString toString() const;
59 const unsigned char* native() const;
60
61 static OMacAddress fromString( const QString& );
59 62
60 public: 63 public:
61 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 64 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
62 static const OMacAddress& unknown; // 44:44:44:44:44:44 65 static const OMacAddress& unknown; // 44:44:44:44:44:44
63 66
64 private: 67 private:
65 unsigned char _bytes[6]; 68 unsigned char _bytes[6];
66 69
67 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 70 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
68 71
69}; 72};
70 73
71bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 74bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
72 75
73 76
74/*====================================================================================== 77/*======================================================================================
75 * OHostAddress 78 * OHostAddress
76 *======================================================================================*/ 79 *======================================================================================*/
77 80
78class OHostAddress : public QHostAddress 81class OHostAddress : public QHostAddress
79{ 82{
80 public: 83 public:
81 OHostAddress(); 84 OHostAddress();
82 ~OHostAddress(); 85 ~OHostAddress();
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index f52279a..e916c44 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -203,48 +203,56 @@ bool ONetworkInterface::setUp( bool b )
203 return ioctl( SIOCSIFFLAGS ); 203 return ioctl( SIOCSIFFLAGS );
204} 204}
205 205
206 206
207bool ONetworkInterface::isUp() const 207bool ONetworkInterface::isUp() const
208{ 208{
209 ioctl( SIOCGIFFLAGS ); 209 ioctl( SIOCGIFFLAGS );
210 return _ifr.ifr_flags & IFF_UP; 210 return _ifr.ifr_flags & IFF_UP;
211} 211}
212 212
213 213
214QString ONetworkInterface::ipV4Address() const 214QString ONetworkInterface::ipV4Address() const
215{ 215{
216 if ( ioctl( SIOCGIFADDR ) ) 216 if ( ioctl( SIOCGIFADDR ) )
217 { 217 {
218 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 218 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
219 //FIXME: Use QHostAddress here 219 //FIXME: Use QHostAddress here
220 return QString( inet_ntoa( sa->sin_addr ) ); 220 return QString( inet_ntoa( sa->sin_addr ) );
221 } 221 }
222 else 222 else
223 return "<unknown>"; 223 return "<unknown>";
224} 224}
225 225
226 226
227void ONetworkInterface::setMacAddress( const OMacAddress& addr )
228{
229 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
230 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
231 ioctl( SIOCSIFHWADDR );
232}
233
234
227OMacAddress ONetworkInterface::macAddress() const 235OMacAddress ONetworkInterface::macAddress() const
228{ 236{
229 if ( ioctl( SIOCGIFHWADDR ) ) 237 if ( ioctl( SIOCGIFHWADDR ) )
230 { 238 {
231 return OMacAddress( _ifr ); 239 return OMacAddress( _ifr );
232 } 240 }
233 else 241 else
234 { 242 {
235 return OMacAddress::unknown; 243 return OMacAddress::unknown;
236 } 244 }
237} 245}
238 246
239 247
240int ONetworkInterface::dataLinkType() const 248int ONetworkInterface::dataLinkType() const
241{ 249{
242 if ( ioctl( SIOCGIFHWADDR ) ) 250 if ( ioctl( SIOCGIFHWADDR ) )
243 { 251 {
244 return _ifr.ifr_hwaddr.sa_family; 252 return _ifr.ifr_hwaddr.sa_family;
245 } 253 }
246 else 254 else
247 { 255 {
248 return -1; 256 return -1;
249 } 257 }
250} 258}
@@ -626,48 +634,55 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
626 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); 634 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call );
627 return; 635 return;
628 } 636 }
629 if ( priv->numberSetArgs() != numargs ) 637 if ( priv->numberSetArgs() != numargs )
630 { 638 {
631 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); 639 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs );
632 return; 640 return;
633 } 641 }
634 642
635 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); 643 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
636 memset( &_iwr, 0, sizeof _iwr ); 644 memset( &_iwr, 0, sizeof _iwr );
637 va_list argp; 645 va_list argp;
638 va_start( argp, numargs ); 646 va_start( argp, numargs );
639 for ( int i = 0; i < numargs; ++i ) 647 for ( int i = 0; i < numargs; ++i )
640 { 648 {
641 priv->setParameter( i, va_arg( argp, int ) ); 649 priv->setParameter( i, va_arg( argp, int ) );
642 } 650 }
643 va_end( argp ); 651 va_end( argp );
644 priv->invoke(); 652 priv->invoke();
645} 653}
646 654
647 655
648void OWirelessNetworkInterface::getPrivate( const QString& call ) 656void OWirelessNetworkInterface::getPrivate( const QString& call )
649{ 657{
658 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
659}
660
661
662bool OWirelessNetworkInterface::hasPrivate( const QString& call )
663{
664 return child( (const char*) call );
650} 665}
651 666
652 667
653QString OWirelessNetworkInterface::SSID() const 668QString OWirelessNetworkInterface::SSID() const
654{ 669{
655 char str[IW_ESSID_MAX_SIZE]; 670 char str[IW_ESSID_MAX_SIZE];
656 _iwr.u.essid.pointer = &str[0]; 671 _iwr.u.essid.pointer = &str[0];
657 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 672 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
658 if ( !wioctl( SIOCGIWESSID ) ) 673 if ( !wioctl( SIOCGIWESSID ) )
659 { 674 {
660 return "<unknown>"; 675 return "<unknown>";
661 } 676 }
662 else 677 else
663 { 678 {
664 return str; 679 return str;
665 } 680 }
666} 681}
667 682
668 683
669void OWirelessNetworkInterface::setSSID( const QString& ssid ) 684void OWirelessNetworkInterface::setSSID( const QString& ssid )
670{ 685{
671 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 686 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
672 _iwr.u.essid.length = ssid.length(); 687 _iwr.u.essid.length = ssid.length();
673 wioctl( SIOCSIWESSID ); 688 wioctl( SIOCSIWESSID );
@@ -813,104 +828,83 @@ void OWlanNGMonitoringInterface::setChannel( int )
813{ 828{
814 // wlan-ng devices automatically switch channels when in monitor mode 829 // wlan-ng devices automatically switch channels when in monitor mode
815} 830}
816 831
817 832
818/*====================================================================================== 833/*======================================================================================
819 * OHostAPMonitoringInterface 834 * OHostAPMonitoringInterface
820 *======================================================================================*/ 835 *======================================================================================*/
821 836
822OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) 837OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface )
823 :OMonitoringInterface( iface ) 838 :OMonitoringInterface( iface )
824{ 839{
825 iface->setMonitoring( this ); 840 iface->setMonitoring( this );
826} 841}
827 842
828OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 843OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
829{ 844{
830} 845}
831 846
832void OHostAPMonitoringInterface::setEnabled( bool b ) 847void OHostAPMonitoringInterface::setEnabled( bool b )
833{ 848{
834 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 849 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
835 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 850 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
836 851
852 //TODO: check wireless extensions version on runtime and use
853 //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15
854
837 if ( b ) 855 if ( b )
838 { 856 {
839 #if WIRELESS_EXT > 14 857 _if->setPrivate( "monitor", 1, 2 );
840 _if->_iwr.u.mode = IW_MODE_MONITOR;
841 _if->wioctl( SIOCSIWMODE );
842 #else
843 int* args = (int*) &_if->_iwr.u.name;
844 args[0] = 2;
845 args[1] = 0;
846 _if->wioctl( SIOCDEVPRIVATE );
847 #endif
848 } 858 }
849 else 859 else
850 { 860 {
851 #if WIRELESS_EXT > 14 861 _if->setPrivate( "monitor", 1, 0 );
852 _if->_iwr.u.mode = IW_MODE_INFRA;
853 _if->wioctl( SIOCSIWMODE );
854 #else
855 int* args = (int*) &_if->_iwr.u.name;
856 args[0] = 0;
857 args[1] = 0;
858 _if->wioctl( SIOCDEVPRIVATE );
859 #endif
860 } 862 }
861} 863}
862 864
863 865
864QString OHostAPMonitoringInterface::name() const 866QString OHostAPMonitoringInterface::name() const
865{ 867{
866 return "hostap"; 868 return "hostap";
867} 869}
868 870
869 871
870/*====================================================================================== 872/*======================================================================================
871 * OOrinocoNetworkInterface 873 * OOrinocoNetworkInterface
872 *======================================================================================*/ 874 *======================================================================================*/
873 875
874OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) 876OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface )
875 :OMonitoringInterface( iface ) 877 :OMonitoringInterface( iface )
876{ 878{
877 iface->setMonitoring( this ); 879 iface->setMonitoring( this );
878} 880}
879 881
880 882
881OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 883OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
882{ 884{
883} 885}
884 886
885 887
886void OOrinocoMonitoringInterface::setChannel( int c ) 888void OOrinocoMonitoringInterface::setChannel( int c )
887{ 889{
888 // call iwpriv <device> monitor 2 <channel> 890 _if->setPrivate( "monitor", 2, 2, c );
889 int* args = (int*) &_if->_iwr.u.name;
890 args[0] = 2;
891 args[1] = c;
892 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
893} 891}
894 892
895 893
896void OOrinocoMonitoringInterface::setEnabled( bool b ) 894void OOrinocoMonitoringInterface::setEnabled( bool b )
897{ 895{
898 if ( b ) 896 if ( b )
899 { 897 {
900 setChannel( 1 ); 898 setChannel( 1 );
901 } 899 }
902 else 900 else
903 { 901 {
904 // call iwpriv <device> monitor 0 0 902 _if->setPrivate( "monitor", 2, 0, 0 );
905 int* args = (int*) &_if->_iwr.u.name;
906 args[0] = 0;
907 args[1] = 0;
908 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
909 } 903 }
910} 904}
911 905
912 906
913QString OOrinocoMonitoringInterface::name() const 907QString OOrinocoMonitoringInterface::name() const
914{ 908{
915 return "orinoco"; 909 return "orinoco";
916} 910}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 4cadbeb..e249aee 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -42,52 +42,48 @@
42#include <qobject.h> 42#include <qobject.h>
43#include <qhostaddress.h> 43#include <qhostaddress.h>
44 44
45/* OPIE */ 45/* OPIE */
46 46
47#include <opie2/onetutils.h> 47#include <opie2/onetutils.h>
48 48
49#ifndef IFNAMSIZ 49#ifndef IFNAMSIZ
50#define IFNAMSIZ 16 50#define IFNAMSIZ 16
51#endif 51#endif
52#ifndef IW_MAX_PRIV_DEF 52#ifndef IW_MAX_PRIV_DEF
53#define IW_MAX_PRIV_DEF 128 53#define IW_MAX_PRIV_DEF 128
54#endif 54#endif
55 55
56// ML: Yeah, I hate to include kernel headers, but it's necessary here 56// ML: Yeah, I hate to include kernel headers, but it's necessary here
57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> 57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h>
58// ML: which conflicts with the user header <net/if.h> 58// ML: which conflicts with the user header <net/if.h>
59// ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> 59// ML: We really a user header for the Wireless Extensions, something like <net/wireless.h>
60// ML: I will drop Jean an mail on that subject 60// ML: I will drop Jean an mail on that subject
61 61
62#include <net/if.h> 62#include <net/if.h>
63#define _LINUX_IF_H 63#define _LINUX_IF_H
64#include <linux/wireless.h> 64#include <linux/wireless.h>
65 65
66#ifndef SIOCIWFIRSTPRIV
67#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
68#endif
69
70class ONetworkInterface; 66class ONetworkInterface;
71class OWirelessNetworkInterface; 67class OWirelessNetworkInterface;
72class OChannelHopper; 68class OChannelHopper;
73class OMonitoringInterface; 69class OMonitoringInterface;
74 70
75/*====================================================================================== 71/*======================================================================================
76 * ONetwork 72 * ONetwork
77 *======================================================================================*/ 73 *======================================================================================*/
78 74
79class ONetwork : public QObject 75class ONetwork : public QObject
80{ 76{
81 Q_OBJECT 77 Q_OBJECT
82 78
83 public: 79 public:
84 typedef QDict<ONetworkInterface> InterfaceMap; 80 typedef QDict<ONetworkInterface> InterfaceMap;
85 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 81 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
86 82
87 public: 83 public:
88 static ONetwork* instance(); 84 static ONetwork* instance();
89 InterfaceIterator iterator() const; 85 InterfaceIterator iterator() const;
90 bool isWirelessInterface( const char* ) const; 86 bool isWirelessInterface( const char* ) const;
91 ONetworkInterface* interface( QString ) const; 87 ONetworkInterface* interface( QString ) const;
92 88
93 protected: 89 protected:
@@ -104,48 +100,49 @@ class ONetwork : public QObject
104 * ONetworkInterface 100 * ONetworkInterface
105 *======================================================================================*/ 101 *======================================================================================*/
106 102
107class ONetworkInterface : public QObject 103class ONetworkInterface : public QObject
108{ 104{
109 friend class OMonitoringInterface; 105 friend class OMonitoringInterface;
110 friend class OCiscoMonitoringInterface; 106 friend class OCiscoMonitoringInterface;
111 friend class OWlanNGMonitoringInterface; 107 friend class OWlanNGMonitoringInterface;
112 friend class OHostAPMonitoringInterface; 108 friend class OHostAPMonitoringInterface;
113 friend class OOrinocoMonitoringInterface; 109 friend class OOrinocoMonitoringInterface;
114 110
115 public: 111 public:
116 ONetworkInterface( QObject* parent, const char* name ); 112 ONetworkInterface( QObject* parent, const char* name );
117 virtual ~ONetworkInterface(); 113 virtual ~ONetworkInterface();
118 114
119 void setMonitoring( OMonitoringInterface* ); 115 void setMonitoring( OMonitoringInterface* );
120 OMonitoringInterface* monitoring() const; 116 OMonitoringInterface* monitoring() const;
121 bool setPromiscuousMode( bool ); 117 bool setPromiscuousMode( bool );
122 bool promiscuousMode() const; 118 bool promiscuousMode() const;
123 bool setUp( bool ); 119 bool setUp( bool );
124 bool isUp() const; 120 bool isUp() const;
125 bool isLoopback() const; 121 bool isLoopback() const;
126 bool isWireless() const; 122 bool isWireless() const;
127 QString ipV4Address() const; 123 QString ipV4Address() const;
124 void setMacAddress( const OMacAddress& );
128 OMacAddress macAddress() const; 125 OMacAddress macAddress() const;
129 int dataLinkType() const; 126 int dataLinkType() const;
130 127
131 protected: 128 protected:
132 const int _sfd; 129 const int _sfd;
133 mutable ifreq _ifr; 130 mutable ifreq _ifr;
134 OMonitoringInterface* _mon; 131 OMonitoringInterface* _mon;
135 132
136 protected: 133 protected:
137 struct ifreq& ifr() const; 134 struct ifreq& ifr() const;
138 virtual void init(); 135 virtual void init();
139 bool ioctl( int call ) const; 136 bool ioctl( int call ) const;
140 bool ioctl( int call, struct ifreq& ) const; 137 bool ioctl( int call, struct ifreq& ) const;
141}; 138};
142 139
143/*====================================================================================== 140/*======================================================================================
144 * OChannelHopper 141 * OChannelHopper
145 *======================================================================================*/ 142 *======================================================================================*/
146 143
147class OChannelHopper : public QObject 144class OChannelHopper : public QObject
148{ 145{
149 public: 146 public:
150 OChannelHopper( OWirelessNetworkInterface* ); 147 OChannelHopper( OWirelessNetworkInterface* );
151 virtual ~OChannelHopper(); 148 virtual ~OChannelHopper();
@@ -183,94 +180,95 @@ class OWirelessNetworkInterface : public ONetworkInterface
183 enum Mode { AdHoc, Managed, Monitor }; 180 enum Mode { AdHoc, Managed, Monitor };
184 181
185 OWirelessNetworkInterface( QObject* parent, const char* name ); 182 OWirelessNetworkInterface( QObject* parent, const char* name );
186 virtual ~OWirelessNetworkInterface(); 183 virtual ~OWirelessNetworkInterface();
187 184
188 virtual void setChannel( int ) const; 185 virtual void setChannel( int ) const;
189 virtual int channel() const; 186 virtual int channel() const;
190 virtual double frequency() const; 187 virtual double frequency() const;
191 virtual int channels() const; 188 virtual int channels() const;
192 //virtual double frequency(int) const; 189 //virtual double frequency(int) const;
193 190
194 virtual void setMode( Mode ) {}; 191 virtual void setMode( Mode ) {};
195 virtual bool mode() const {}; 192 virtual bool mode() const {};
196 193
197 virtual void setMonitorMode( bool ); 194 virtual void setMonitorMode( bool );
198 virtual bool monitorMode() const; 195 virtual bool monitorMode() const;
199 196
200 virtual void setChannelHopping( int interval = 0 ); 197 virtual void setChannelHopping( int interval = 0 );
201 virtual int channelHopping() const; 198 virtual int channelHopping() const;
202 199
203 virtual void setNickName( const QString& ) {}; 200 virtual void setNickName( const QString& ) {};
204 virtual QString nickName() const; 201 virtual QString nickName() const;
205 202
206 virtual void setPrivate( const QString&, int, ... ); 203 virtual void setPrivate( const QString&, int, ... );
204 virtual bool hasPrivate( const QString& );
207 virtual void getPrivate( const QString& ); 205 virtual void getPrivate( const QString& );
208 206
209 virtual bool isAssociated() const {}; 207 virtual bool isAssociated() const {};
210 virtual QString associatedAP() const; 208 virtual QString associatedAP() const;
211 209
212 virtual void setSSID( const QString& ); 210 virtual void setSSID( const QString& );
213 virtual QString SSID() const; 211 virtual QString SSID() const;
214 212
215 protected: 213 protected:
216 void buildChannelList(); 214 void buildChannelList();
217 void buildPrivateList(); 215 void buildPrivateList();
218 virtual void init(); 216 virtual void init();
219 struct iwreq& iwr() const; 217 struct iwreq& iwr() const;
220 bool wioctl( int call ) const; 218 bool wioctl( int call ) const;
221 bool wioctl( int call, struct iwreq& ) const; 219 bool wioctl( int call, struct iwreq& ) const;
222 220
223 protected: 221 protected:
224 mutable struct iwreq _iwr; 222 mutable struct iwreq _iwr;
225 QMap<int,int> _channels; 223 QMap<int,int> _channels;
226 224
227 private: 225 private:
228 OChannelHopper* _hopper; 226 OChannelHopper* _hopper;
229}; 227};
230 228
231 229
232/*====================================================================================== 230/*======================================================================================
233 * OMonitoringInterface 231 * OMonitoringInterface
234 *======================================================================================*/ 232 *======================================================================================*/
235 233
236 234
237class OMonitoringInterface 235class OMonitoringInterface
238{ 236{
239 public: 237 public:
240 OMonitoringInterface(); 238 OMonitoringInterface();
241 OMonitoringInterface( ONetworkInterface* ); 239 OMonitoringInterface( ONetworkInterface* );
242 virtual ~OMonitoringInterface(); 240 virtual ~OMonitoringInterface();
243 241
244 public: 242 public:
245 virtual void setEnabled( bool ); 243 virtual void setEnabled( bool );
246 virtual bool enabled() const; 244 virtual bool enabled() const;
247 virtual void setChannel( int ); 245 virtual void setChannel( int );
248 246
249 virtual QString name() const = 0; 247 virtual QString name() const = 0;
250 248
251 protected: 249 protected:
252 const OWirelessNetworkInterface* _if; 250 OWirelessNetworkInterface* _if;
253 251
254}; 252};
255 253
256 254
257/*====================================================================================== 255/*======================================================================================
258 * OCiscoMonitoring 256 * OCiscoMonitoring
259 *======================================================================================*/ 257 *======================================================================================*/
260 258
261 259
262class OCiscoMonitoringInterface : public OMonitoringInterface 260class OCiscoMonitoringInterface : public OMonitoringInterface
263{ 261{
264 public: 262 public:
265 OCiscoMonitoringInterface( ONetworkInterface* ); 263 OCiscoMonitoringInterface( ONetworkInterface* );
266 virtual ~OCiscoMonitoringInterface(); 264 virtual ~OCiscoMonitoringInterface();
267 265
268 virtual void setEnabled( bool ); 266 virtual void setEnabled( bool );
269 virtual QString name() const; 267 virtual QString name() const;
270 virtual void setChannel( int ); 268 virtual void setChannel( int );
271 269
272}; 270};
273 271
274/*====================================================================================== 272/*======================================================================================
275 * OWlanNGMonitoringInterface 273 * OWlanNGMonitoringInterface
276 *======================================================================================*/ 274 *======================================================================================*/