summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-03 14:17:03 (UTC)
committer mickeyl <mickeyl>2003-04-03 14:17:03 (UTC)
commitf62005c53c93148eaa13eac50ea6814a41afb216 (patch) (unidiff)
tree93e7e626205fd9d06b5ac7c29e78be52ce749e5d
parente9eeb493c75bfe6078f40952e85e859fb71fe970 (diff)
downloadopie-f62005c53c93148eaa13eac50ea6814a41afb216.zip
opie-f62005c53c93148eaa13eac50ea6814a41afb216.tar.gz
opie-f62005c53c93148eaa13eac50ea6814a41afb216.tar.bz2
- ONetworkInterfaces are now QObjects
- add support for private IOCTLS - make buildChannelList() more safe in case of faulty drivers
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp59
-rw-r--r--libopie2/opienet/onetutils.h25
-rw-r--r--libopie2/opienet/onetwork.cpp127
-rw-r--r--libopie2/opienet/onetwork.h21
4 files changed, 178 insertions, 54 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 8006f41..3e11b53 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -33,12 +33,22 @@
33 33
34#include <net/if.h> 34#include <net/if.h>
35 35
36#include <cstdio> 36#include <cstdio>
37using namespace std; 37using namespace std;
38 38
39#define IW_PRIV_TYPE_MASK 0x7000
40#define IW_PRIV_TYPE_NONE 0x0000
41#define IW_PRIV_TYPE_BYTE 0x1000
42#define IW_PRIV_TYPE_CHAR 0x2000
43#define IW_PRIV_TYPE_INT 0x4000
44#define IW_PRIV_TYPE_FLOAT 0x5000
45#define IW_PRIV_TYPE_ADDR 0x6000
46#define IW_PRIV_SIZE_FIXED 0x0800
47#define IW_PRIV_SIZE_MASK 0x07FF
48
39/*====================================================================================== 49/*======================================================================================
40 * OMacAddress 50 * OMacAddress
41 *======================================================================================*/ 51 *======================================================================================*/
42 52
43// static initializer for broadcast and unknown MAC Adresses 53// static initializer for broadcast and unknown MAC Adresses
44const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 54const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -84,12 +94,61 @@ QString OMacAddress::toString() const
84 94
85bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 95bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
86{ 96{
87 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 97 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
88} 98}
89 99
100
101/*======================================================================================
102 * OHostAddress
103 *======================================================================================*/
104
105
106/*======================================================================================
107 * OPrivateIOCTL
108 *======================================================================================*/
109
110OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
111 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
112{
113}
114
115
116OPrivateIOCTL::~OPrivateIOCTL()
117{
118}
119
120
121inline int OPrivateIOCTL::numberGetArgs() const
122{
123 return _getargs & IW_PRIV_SIZE_MASK;
124}
125
126
127inline int OPrivateIOCTL::typeGetArgs() const
128{
129 return _getargs & IW_PRIV_TYPE_MASK >> 12;
130}
131
132
133inline int OPrivateIOCTL::numberSetArgs() const
134{
135 return _setargs & IW_PRIV_SIZE_MASK;
136}
137
138
139inline int OPrivateIOCTL::typeSetArgs() const
140{
141 return _setargs & IW_PRIV_TYPE_MASK >> 12;
142}
143
144
145/*======================================================================================
146 * assorted functions
147 *======================================================================================*/
148
90void dumpBytes( const unsigned char* data, int num ) 149void dumpBytes( const unsigned char* data, int num )
91{ 150{
92 printf( "Dumping %d bytes @ %0x", num, data ); 151 printf( "Dumping %d bytes @ %0x", num, data );
93 printf( "-------------------------------------------\n" ); 152 printf( "-------------------------------------------\n" );
94 153
95 for ( int i = 0; i < num; ++i ) 154 for ( int i = 0; i < num; ++i )
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index 0dabe8d..6640515 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -33,14 +33,18 @@
33#define ONETUTILS_H 33#define ONETUTILS_H
34 34
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>
40
41#include <sys/types.h>
39 42
40struct ifreq; 43struct ifreq;
44class OWirelessNetworkInterface;
41 45
42/*====================================================================================== 46/*======================================================================================
43 * OMacAddress 47 * OMacAddress
44 *======================================================================================*/ 48 *======================================================================================*/
45 49
46class OMacAddress 50class OMacAddress
@@ -77,12 +81,33 @@ class OHostAddress : public QHostAddress
77 OHostAddress(); 81 OHostAddress();
78 ~OHostAddress(); 82 ~OHostAddress();
79}; 83};
80 84
81 85
82/*====================================================================================== 86/*======================================================================================
87 * OPrivateIOCTL
88 *======================================================================================*/
89
90class OPrivateIOCTL : public QObject
91{
92 public:
93 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
94 ~OPrivateIOCTL();
95
96 int numberGetArgs() const;
97 int typeGetArgs() const;
98 int numberSetArgs() const;
99 int typeSetArgs() const;
100
101 private:
102 u_int32_t _ioctl;
103 u_int16_t _getargs;
104 u_int16_t _setargs;
105};
106
107 /*======================================================================================
83 * Miscellaneous 108 * Miscellaneous
84 *======================================================================================*/ 109 *======================================================================================*/
85 110
86/* dump bytes */ 111/* dump bytes */
87 112
88void dumpBytes( const unsigned char* data, int num ); 113void dumpBytes( const unsigned char* data, int num );
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index ac2857a..2548a04 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -89,18 +89,18 @@ void ONetwork::synchronize()
89 s >> str; 89 s >> str;
90 str.truncate( str.find( ':' ) ); 90 str.truncate( str.find( ':' ) );
91 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 91 qDebug( "ONetwork: found interface '%s'", (const char*) str );
92 ONetworkInterface* iface; 92 ONetworkInterface* iface;
93 if ( isWirelessInterface( str ) ) 93 if ( isWirelessInterface( str ) )
94 { 94 {
95 iface = new OWirelessNetworkInterface( str ); 95 iface = new OWirelessNetworkInterface( this, str );
96 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 96 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
97 } 97 }
98 else 98 else
99 { 99 {
100 iface = new ONetworkInterface( str ); 100 iface = new ONetworkInterface( this, str );
101 } 101 }
102 _interfaces.insert( str, iface ); 102 _interfaces.insert( str, iface );
103 s.readLine(); 103 s.readLine();
104 } 104 }
105} 105}
106 106
@@ -123,13 +123,13 @@ ONetwork::InterfaceIterator ONetwork::iterator() const
123 return ONetwork::InterfaceIterator( _interfaces ); 123 return ONetwork::InterfaceIterator( _interfaces );
124} 124}
125 125
126 126
127bool ONetwork::isWirelessInterface( const char* name ) const 127bool ONetwork::isWirelessInterface( const char* name ) const
128{ 128{
129 int sfd = socket( AF_INET, SOCK_DGRAM, 0 ); 129 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
130 iwreqstruct iwr; 130 iwreqstruct iwr;
131 memset( &iwr, 0, sizeof( iwreqstruct ) ); 131 memset( &iwr, 0, sizeof( iwreqstruct ) );
132 strcpy( (char*) &iwr.ifr_name, name ); 132 strcpy( (char*) &iwr.ifr_name, name );
133 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 133 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
134 if ( result == -1 ) 134 if ( result == -1 )
135 qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); 135 qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) );
@@ -139,14 +139,15 @@ bool ONetwork::isWirelessInterface( const char* name ) const
139} 139}
140 140
141/*====================================================================================== 141/*======================================================================================
142 * ONetworkInterface 142 * ONetworkInterface
143 *======================================================================================*/ 143 *======================================================================================*/
144 144
145ONetworkInterface::ONetworkInterface( const QString& name ) 145ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
146 :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 146 :QObject( parent, name ),
147 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
147{ 148{
148 qDebug( "ONetworkInterface::ONetworkInterface()" ); 149 qDebug( "ONetworkInterface::ONetworkInterface()" );
149 init(); 150 init();
150} 151}
151 152
152 153
@@ -161,13 +162,13 @@ void ONetworkInterface::init()
161 qDebug( "ONetworkInterface::init()" ); 162 qDebug( "ONetworkInterface::init()" );
162 163
163 memset( &_ifr, 0, sizeof( struct ifreq ) ); 164 memset( &_ifr, 0, sizeof( struct ifreq ) );
164 165
165 if ( _sfd == -1 ) 166 if ( _sfd == -1 )
166 { 167 {
167 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", (const char*) _name ); 168 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() );
168 return; 169 return;
169 } 170 }
170} 171}
171 172
172 173
173bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const 174bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const
@@ -180,13 +181,13 @@ bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const
180 return ( result != -1 ); 181 return ( result != -1 );
181} 182}
182 183
183 184
184bool ONetworkInterface::ioctl( int call ) const 185bool ONetworkInterface::ioctl( int call ) const
185{ 186{
186 strcpy( _ifr.ifr_name, (const char*) _name ); 187 strcpy( _ifr.ifr_name, name() );
187 return ioctl( call, _ifr ); 188 return ioctl( call, _ifr );
188} 189}
189 190
190 191
191bool ONetworkInterface::isLoopback() const 192bool ONetworkInterface::isLoopback() const
192{ 193{
@@ -237,28 +238,22 @@ OMacAddress ONetworkInterface::macAddress() const
237} 238}
238 239
239 240
240void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 241void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
241{ 242{
242 _mon = m; 243 _mon = m;
243 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), (const char*) _name ); 244 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() );
244} 245}
245 246
246 247
247OMonitoringInterface* ONetworkInterface::monitoring() const 248OMonitoringInterface* ONetworkInterface::monitoring() const
248{ 249{
249 return _mon; 250 return _mon;
250} 251}
251 252
252 253
253const QString& ONetworkInterface::name() const
254{
255 return _name;
256}
257
258
259ONetworkInterface::~ONetworkInterface() 254ONetworkInterface::~ONetworkInterface()
260{ 255{
261 qDebug( "ONetworkInterface::~ONetworkInterface()" ); 256 qDebug( "ONetworkInterface::~ONetworkInterface()" );
262 if ( _sfd != -1 ) ::close( _sfd ); 257 if ( _sfd != -1 ) ::close( _sfd );
263} 258}
264 259
@@ -365,14 +360,14 @@ int OChannelHopper::interval() const
365 360
366 361
367/*====================================================================================== 362/*======================================================================================
368 * OWirelessNetworkInterface 363 * OWirelessNetworkInterface
369 *======================================================================================*/ 364 *======================================================================================*/
370 365
371OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) 366OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
372 :ONetworkInterface( name ), _hopper( 0 ) 367 :ONetworkInterface( parent, name ), _hopper( 0 )
373{ 368{
374 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 369 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
375 init(); 370 init();
376} 371}
377 372
378 373
@@ -387,41 +382,15 @@ iwreqstruct& OWirelessNetworkInterface::iwr() const
387} 382}
388 383
389 384
390void OWirelessNetworkInterface::init() 385void OWirelessNetworkInterface::init()
391{ 386{
392 qDebug( "OWirelessNetworkInterface::init()" ); 387 qDebug( "OWirelessNetworkInterface::init()" );
393
394 memset( &_iwr, 0, sizeof( struct iwreq ) ); 388 memset( &_iwr, 0, sizeof( struct iwreq ) );
395 389 buildChannelList();
396 // IEEE802.11(b) radio frequency channels 390 buildPrivateList();
397
398 iwrangestruct range;
399 //ML: work around an ugly HostAP bug, which needs
400 //ML: extra space or will complain with "invalid argument length"... :-(
401 //ML: But don't allocate too much or prism2_usb will segfault *sigh*
402 char __extraBufferForBuggyDrivers[20];
403
404 qDebug( "sizeof(iwrangestruct)=%d, sizeof range=%d, sizeof range*2=%d", sizeof(iwrangestruct), sizeof range, (sizeof range)*2 );
405
406 _iwr.u.data.pointer = (char*) &range;
407 _iwr.u.data.length = sizeof(iwrangestruct)+20;
408 _iwr.u.data.flags = 0;
409 if ( !wioctl( SIOCGIWRANGE ) )
410 {
411 qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) );
412 return;
413 }
414
415 qDebug( "OWirelessNetworkInterface::init(): Interface %s reported to have %d channels.", (const char*) _name, range.num_frequency );
416
417 for ( int i = 0; i < range.num_frequency; ++i )
418 {
419 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
420 _channels.insert( freq, i+1 );
421 }
422} 391}
423 392
424 393
425QString OWirelessNetworkInterface::associatedAP() const 394QString OWirelessNetworkInterface::associatedAP() const
426{ 395{
427 //FIXME: use OMacAddress 396 //FIXME: use OMacAddress
@@ -442,12 +411,79 @@ QString OWirelessNetworkInterface::associatedAP() const
442 mac = "<Unknown>"; 411 mac = "<Unknown>";
443 } 412 }
444 return mac; 413 return mac;
445} 414}
446 415
447 416
417void OWirelessNetworkInterface::buildChannelList()
418{
419 // IEEE802.11(b) radio frequency channels
420 struct iw_range range;
421
422 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck
423 //ML: The HostAP drivers need more than sizeof struct_iw range to complete
424 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length".
425 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate
426 //ML: _too much_ space. This is damn shitty crap *sigh*
427
428 _iwr.u.data.pointer = (char*) &range;
429 _iwr.u.data.length = IW_MAX_FREQUENCIES; //sizeof range;
430 _iwr.u.data.flags = 0;
431
432 if ( !wioctl( SIOCGIWRANGE ) )
433 {
434 qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) );
435 _channels.insert( 2412, 1 ); // 2.412 GHz
436 _channels.insert( 2417, 2 ); // 2.417 GHz
437 _channels.insert( 2422, 3 ); // 2.422 GHz
438 _channels.insert( 2427, 4 ); // 2.427 GHz
439 _channels.insert( 2432, 5 ); // 2.432 GHz
440 _channels.insert( 2437, 6 ); // 2.437 GHz
441 _channels.insert( 2442, 7 ); // 2.442 GHz
442 _channels.insert( 2447, 8 ); // 2.447 GHz
443 _channels.insert( 2452, 9 ); // 2.452 GHz
444 _channels.insert( 2457, 10 ); // 2.457 GHz
445 _channels.insert( 2462, 11 ); // 2.462 GHz
446 }
447 else
448 {
449 qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency );
450 for ( int i = 0; i < range.num_frequency; ++i )
451 {
452 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
453 _channels.insert( freq, i+1 );
454 }
455 }
456 qDebug( "OWirelessNetworkInterface::buildChannelList(): Channel list constructed." );
457}
458
459
460void OWirelessNetworkInterface::buildPrivateList()
461{
462 qDebug( "OWirelessNetworkInterface::buildPrivateList()" );
463
464 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
465
466 _iwr.u.data.pointer = (char*) &priv;
467 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
468 _iwr.u.data.flags = 0;
469
470 if ( !wioctl( SIOCGIWPRIV ) )
471 {
472 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) );
473 return;
474 }
475
476 for ( int i = 0; i < _iwr.u.data.length; ++i )
477 {
478 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
479 }
480 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." );
481}
482
483
448int OWirelessNetworkInterface::channel() const 484int OWirelessNetworkInterface::channel() const
449{ 485{
450 //FIXME: When monitoring enabled, then use it 486 //FIXME: When monitoring enabled, then use it
451 //FIXME: to gather the current RF channel 487 //FIXME: to gather the current RF channel
452 //FIXME: Until then, get active channel from hopper. 488 //FIXME: Until then, get active channel from hopper.
453 if ( _hopper && _hopper->isActive() ) 489 if ( _hopper && _hopper->isActive() )
@@ -501,12 +537,13 @@ int OWirelessNetworkInterface::channels() const
501 537
502void OWirelessNetworkInterface::setChannelHopping( int interval ) 538void OWirelessNetworkInterface::setChannelHopping( int interval )
503{ 539{
504 if ( !_hopper ) _hopper = new OChannelHopper( this ); 540 if ( !_hopper ) _hopper = new OChannelHopper( this );
505 _hopper->setInterval( interval ); 541 _hopper->setInterval( interval );
506 //FIXME: When and by whom will the channel hopper be deleted? 542 //FIXME: When and by whom will the channel hopper be deleted?
543 //TODO: rely on QObject hierarchy
507} 544}
508 545
509 546
510int OWirelessNetworkInterface::channelHopping() const 547int OWirelessNetworkInterface::channelHopping() const
511{ 548{
512 return _hopper->interval(); 549 return _hopper->interval();
@@ -579,13 +616,13 @@ bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const
579 return ( result != -1 ); 616 return ( result != -1 );
580} 617}
581 618
582 619
583bool OWirelessNetworkInterface::wioctl( int call ) const 620bool OWirelessNetworkInterface::wioctl( int call ) const
584{ 621{
585 strcpy( _iwr.ifr_name, (const char*) _name ); 622 strcpy( _iwr.ifr_name, name() );
586 return wioctl( call, _iwr ); 623 return wioctl( call, _iwr );
587} 624}
588 625
589 626
590/*====================================================================================== 627/*======================================================================================
591 * OMonitoringInterface 628 * OMonitoringInterface
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index b57ac3f..acf2f69 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -46,12 +46,15 @@
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
53#define IW_MAX_PRIV_DEF 128
54#endif
52 55
53// 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
54// 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>
55// ML: which conflicts with the user header <net/if.h> 58// ML: which conflicts with the user header <net/if.h>
56// 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>
57// ML: I will drop Jean an mail on that subject 60// ML: I will drop Jean an mail on that subject
@@ -105,38 +108,36 @@ class ONetwork : public QObject
105 108
106 109
107/*====================================================================================== 110/*======================================================================================
108 * ONetworkInterface 111 * ONetworkInterface
109 *======================================================================================*/ 112 *======================================================================================*/
110 113
111class ONetworkInterface 114class ONetworkInterface : public QObject
112{ 115{
113 friend class OMonitoringInterface; 116 friend class OMonitoringInterface;
114 friend class OCiscoMonitoringInterface; 117 friend class OCiscoMonitoringInterface;
115 friend class OWlanNGMonitoringInterface; 118 friend class OWlanNGMonitoringInterface;
116 friend class OHostAPMonitoringInterface; 119 friend class OHostAPMonitoringInterface;
117 friend class OOrinocoMonitoringInterface; 120 friend class OOrinocoMonitoringInterface;
118 121
119 public: 122 public:
120 ONetworkInterface( const QString& name ); 123 ONetworkInterface( QObject* parent, const char* name );
121 virtual ~ONetworkInterface(); 124 virtual ~ONetworkInterface();
122 125
123 const QString& name() const;
124 void setMonitoring( OMonitoringInterface* ); 126 void setMonitoring( OMonitoringInterface* );
125 OMonitoringInterface* monitoring() const; 127 OMonitoringInterface* monitoring() const;
126 bool setPromiscuousMode( bool ); 128 bool setPromiscuousMode( bool );
127 bool promiscuousMode() const; 129 bool promiscuousMode() const;
128 bool setUp( bool ); 130 bool setUp( bool );
129 bool isUp() const; 131 bool isUp() const;
130 bool isLoopback() const; 132 bool isLoopback() const;
131 bool isWireless() const; 133 bool isWireless() const;
132 QString ipV4Address() const; 134 QString ipV4Address() const;
133 OMacAddress macAddress() const; 135 OMacAddress macAddress() const;
134 136
135 protected: 137 protected:
136 const QString _name;
137 const int _sfd; 138 const int _sfd;
138 mutable ifreqstruct _ifr; 139 mutable ifreqstruct _ifr;
139 OMonitoringInterface* _mon; 140 OMonitoringInterface* _mon;
140 141
141 protected: 142 protected:
142 ifreqstruct& ifr() const; 143 ifreqstruct& ifr() const;
@@ -182,13 +183,13 @@ class OWirelessNetworkInterface : public ONetworkInterface
182 friend class OHostAPMonitoringInterface; 183 friend class OHostAPMonitoringInterface;
183 friend class OOrinocoMonitoringInterface; 184 friend class OOrinocoMonitoringInterface;
184 185
185 public: 186 public:
186 enum Mode { AdHoc, Managed, Monitor }; 187 enum Mode { AdHoc, Managed, Monitor };
187 188
188 OWirelessNetworkInterface( const QString& name ); 189 OWirelessNetworkInterface( QObject* parent, const char* name );
189 virtual ~OWirelessNetworkInterface(); 190 virtual ~OWirelessNetworkInterface();
190 191
191 virtual void setChannel( int ) const; 192 virtual void setChannel( int ) const;
192 virtual int channel() const; 193 virtual int channel() const;
193 virtual double frequency() const; 194 virtual double frequency() const;
194 virtual int channels() const; 195 virtual int channels() const;
@@ -210,21 +211,23 @@ class OWirelessNetworkInterface : public ONetworkInterface
210 virtual QString associatedAP() const; 211 virtual QString associatedAP() const;
211 212
212 virtual void setSSID( const QString& ); 213 virtual void setSSID( const QString& );
213 virtual QString SSID() const; 214 virtual QString SSID() const;
214 215
215 protected: 216 protected:
216 mutable iwreqstruct _iwr; 217 void buildChannelList();
217 QMap<int,int> _channels; 218 void buildPrivateList();
218
219 protected:
220 virtual void init(); 219 virtual void init();
221 iwreqstruct& iwr() const; 220 iwreqstruct& iwr() const;
222 bool wioctl( int call ) const; 221 bool wioctl( int call ) const;
223 bool wioctl( int call, iwreqstruct& ) const; 222 bool wioctl( int call, iwreqstruct& ) const;
224 223
224 protected:
225 mutable iwreqstruct _iwr;
226 QMap<int,int> _channels;
227
225 private: 228 private:
226 OChannelHopper* _hopper; 229 OChannelHopper* _hopper;
227}; 230};
228 231
229 232
230/*====================================================================================== 233/*======================================================================================