summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp18
-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
5 files changed, 73 insertions, 34 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
index b010ac5..020fc23 100644
--- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
+++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
@@ -1,43 +1,61 @@
1#include <opie2/onetwork.h> 1#include <opie2/onetwork.h>
2 2
3int main( int argc, char** argv ) 3int main( int argc, char** argv )
4{ 4{
5 qDebug( "OPIE Network Demo" ); 5 qDebug( "OPIE Network Demo" );
6 6
7 ONetwork* net = ONetwork::instance(); 7 ONetwork* net = ONetwork::instance();
8 8
9 ONetwork::InterfaceIterator it = net->iterator(); 9 ONetwork::InterfaceIterator it = net->iterator();
10 10
11 while ( it.current() ) 11 while ( it.current() )
12 { 12 {
13 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); 13 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
14 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); 14 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
15 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); 15 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
16 if ( it.current()->isWireless() ) 16 if ( it.current()->isWireless() )
17 { 17 {
18 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); 18 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
19 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); 19 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
20 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); 20 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
21 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); 21 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
22 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); 22 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
23 23
24 //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) 24 //if ( iface->mode() == OWirelessNetworkInterface::adhoc )
25 //{ 25 //{
26 qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); 26 qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() );
27 //} 27 //}
28 28
29 // try to set monitor mode 29 // try to set monitor mode
30 30
31 /*
32
31 // first some wrong calls to check if this is working 33 // first some wrong calls to check if this is working
32 iface->setPrivate( "seppel", 10 ); 34 iface->setPrivate( "seppel", 10 );
33 iface->setPrivate( "monitor", 0 ); 35 iface->setPrivate( "monitor", 0 );
34 36
35 // now the real deal 37 // now the real deal
36 iface->setPrivate( "monitor", 2, 2, 3 ); 38 iface->setPrivate( "monitor", 2, 2, 3 );
39
40 */
41
42 // trying to set hw address to 12:34:56:AB:CD:EF
43
44 /*
45
46 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" );
47 iface->setUp( false );
48 iface->setMacAddress( addr );
49 iface->setUp( true );
50 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() );
51
52 */
53
54
37 } 55 }
38 ++it; 56 ++it;
39 } 57 }
40 58
41 return 0; 59 return 0;
42 60
43} 61}
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
@@ -17,117 +17,143 @@
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/onetutils.h> 32#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34 34
35#include <net/if.h> 35#include <net/if.h>
36 36
37#include <cstdio> 37#include <cstdio>
38using namespace std; 38using namespace std;
39 39
40#define IW_PRIV_TYPE_MASK 0x7000 40#define IW_PRIV_TYPE_MASK 0x7000
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 *======================================================================================*/
110 136
111OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 137OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
112 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 138 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
113{ 139{
114} 140}
115 141
116 142
117OPrivateIOCTL::~OPrivateIOCTL() 143OPrivateIOCTL::~OPrivateIOCTL()
118{ 144{
119} 145}
120 146
121 147
122#ifdef QT_NO_DEBUG 148#ifdef QT_NO_DEBUG
123inline 149inline
124#endif 150#endif
125int OPrivateIOCTL::numberGetArgs() const 151int OPrivateIOCTL::numberGetArgs() const
126{ 152{
127 return _getargs & IW_PRIV_SIZE_MASK; 153 return _getargs & IW_PRIV_SIZE_MASK;
128} 154}
129 155
130 156
131#ifdef QT_NO_DEBUG 157#ifdef QT_NO_DEBUG
132inline 158inline
133#endif 159#endif
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
@@ -11,96 +11,99 @@
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef ONETUTILS_H 32#ifndef ONETUTILS_H
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> 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();
83}; 86};
84 87
85 88
86/*====================================================================================== 89/*======================================================================================
87 * OPrivateIOCTL 90 * OPrivateIOCTL
88 *======================================================================================*/ 91 *======================================================================================*/
89 92
90class OPrivateIOCTL : public QObject 93class OPrivateIOCTL : public QObject
91{ 94{
92 public: 95 public:
93 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 96 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
94 ~OPrivateIOCTL(); 97 ~OPrivateIOCTL();
95 98
96 int numberGetArgs() const; 99 int numberGetArgs() const;
97 int typeGetArgs() const; 100 int typeGetArgs() const;
98 int numberSetArgs() const; 101 int numberSetArgs() const;
99 int typeSetArgs() const; 102 int typeSetArgs() const;
100 103
101 void invoke() const; 104 void invoke() const;
102 void setParameter( int, u_int32_t ); 105 void setParameter( int, u_int32_t );
103 106
104 private: 107 private:
105 u_int32_t _ioctl; 108 u_int32_t _ioctl;
106 u_int16_t _getargs; 109 u_int16_t _getargs;
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
@@ -179,96 +179,104 @@ bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
179 qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); 179 qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call );
180 return ( result != -1 ); 180 return ( result != -1 );
181} 181}
182 182
183 183
184bool ONetworkInterface::ioctl( int call ) const 184bool ONetworkInterface::ioctl( int call ) const
185{ 185{
186 strcpy( _ifr.ifr_name, name() ); 186 strcpy( _ifr.ifr_name, name() );
187 return ioctl( call, _ifr ); 187 return ioctl( call, _ifr );
188} 188}
189 189
190 190
191bool ONetworkInterface::isLoopback() const 191bool ONetworkInterface::isLoopback() const
192{ 192{
193 ioctl( SIOCGIFFLAGS ); 193 ioctl( SIOCGIFFLAGS );
194 return _ifr.ifr_flags & IFF_LOOPBACK; 194 return _ifr.ifr_flags & IFF_LOOPBACK;
195} 195}
196 196
197 197
198bool ONetworkInterface::setUp( bool b ) 198bool ONetworkInterface::setUp( bool b )
199{ 199{
200 ioctl( SIOCGIFFLAGS ); 200 ioctl( SIOCGIFFLAGS );
201 if ( b ) _ifr.ifr_flags |= IFF_UP; 201 if ( b ) _ifr.ifr_flags |= IFF_UP;
202 else _ifr.ifr_flags &= (~IFF_UP); 202 else _ifr.ifr_flags &= (~IFF_UP);
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}
251 259
252 260
253void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 261void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
254{ 262{
255 _mon = m; 263 _mon = m;
256 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); 264 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() );
257} 265}
258 266
259 267
260OMonitoringInterface* ONetworkInterface::monitoring() const 268OMonitoringInterface* ONetworkInterface::monitoring() const
261{ 269{
262 return _mon; 270 return _mon;
263} 271}
264 272
265 273
266ONetworkInterface::~ONetworkInterface() 274ONetworkInterface::~ONetworkInterface()
267{ 275{
268 qDebug( "ONetworkInterface::~ONetworkInterface()" ); 276 qDebug( "ONetworkInterface::~ONetworkInterface()" );
269 if ( _sfd != -1 ) ::close( _sfd ); 277 if ( _sfd != -1 ) ::close( _sfd );
270} 278}
271 279
272 280
273bool ONetworkInterface::setPromiscuousMode( bool b ) 281bool ONetworkInterface::setPromiscuousMode( bool b )
274{ 282{
@@ -602,96 +610,103 @@ bool OWirelessNetworkInterface::monitorMode() const
602 610
603 611
604QString OWirelessNetworkInterface::nickName() const 612QString OWirelessNetworkInterface::nickName() const
605{ 613{
606 char str[IW_ESSID_MAX_SIZE]; 614 char str[IW_ESSID_MAX_SIZE];
607 _iwr.u.data.pointer = &str[0]; 615 _iwr.u.data.pointer = &str[0];
608 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 616 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
609 if ( !wioctl( SIOCGIWNICKN ) ) 617 if ( !wioctl( SIOCGIWNICKN ) )
610 { 618 {
611 return "<unknown>"; 619 return "<unknown>";
612 } 620 }
613 else 621 else
614 { 622 {
615 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 623 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
616 return str; 624 return str;
617 } 625 }
618} 626}
619 627
620 628
621void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 629void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
622{ 630{
623 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 631 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
624 if ( !priv ) 632 if ( !priv )
625 { 633 {
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 );
674} 689}
675 690
676 691
677bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 692bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
678{ 693{
679 int result = ::ioctl( _sfd, call, &iwreq ); 694 int result = ::ioctl( _sfd, call, &iwreq );
680 if ( result == -1 ) 695 if ( result == -1 )
681 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); 696 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) );
682 else 697 else
683 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); 698 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call );
684 return ( result != -1 ); 699 return ( result != -1 );
685} 700}
686 701
687 702
688bool OWirelessNetworkInterface::wioctl( int call ) const 703bool OWirelessNetworkInterface::wioctl( int call ) const
689{ 704{
690 strcpy( _iwr.ifr_name, name() ); 705 strcpy( _iwr.ifr_name, name() );
691 return wioctl( call, _iwr ); 706 return wioctl( call, _iwr );
692} 707}
693 708
694 709
695/*====================================================================================== 710/*======================================================================================
696 * OMonitoringInterface 711 * OMonitoringInterface
697 *======================================================================================*/ 712 *======================================================================================*/
@@ -789,128 +804,107 @@ OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface
789 804
790OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 805OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
791{ 806{
792} 807}
793 808
794 809
795void OWlanNGMonitoringInterface::setEnabled( bool b ) 810void OWlanNGMonitoringInterface::setEnabled( bool b )
796{ 811{
797 //FIXME: do nothing if its already in the same mode 812 //FIXME: do nothing if its already in the same mode
798 813
799 QString enable = b ? "true" : "false"; 814 QString enable = b ? "true" : "false";
800 QString cmd; 815 QString cmd;
801 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); 816 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable );
802 system( cmd ); 817 system( cmd );
803} 818}
804 819
805 820
806QString OWlanNGMonitoringInterface::name() const 821QString OWlanNGMonitoringInterface::name() const
807{ 822{
808 return "wlan-ng"; 823 return "wlan-ng";
809} 824}
810 825
811 826
812void OWlanNGMonitoringInterface::setChannel( int ) 827void 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
@@ -18,283 +18,281 @@
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ONETWORK_H 34#ifndef ONETWORK_H
35#define ONETWORK_H 35#define ONETWORK_H
36 36
37/* QT */ 37/* QT */
38 38
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qdict.h> 40#include <qdict.h>
41#include <qmap.h> 41#include <qmap.h>
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:
94 ONetwork(); 90 ONetwork();
95 void synchronize(); 91 void synchronize();
96 92
97 private: 93 private:
98 static ONetwork* _instance; 94 static ONetwork* _instance;
99 InterfaceMap _interfaces; 95 InterfaceMap _interfaces;
100}; 96};
101 97
102 98
103/*====================================================================================== 99/*======================================================================================
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();
152 bool isActive() const; 149 bool isActive() const;
153 int channel() const; 150 int channel() const;
154 virtual void timerEvent( QTimerEvent* ); 151 virtual void timerEvent( QTimerEvent* );
155 void setInterval( int ); 152 void setInterval( int );
156 int interval() const; 153 int interval() const;
157 154
158 private: 155 private:
159 OWirelessNetworkInterface* _iface; 156 OWirelessNetworkInterface* _iface;
160 int _interval; 157 int _interval;
161 int _tid; 158 int _tid;
162 QValueList<int> _channels; 159 QValueList<int> _channels;
163 QValueList<int>::Iterator _channel; 160 QValueList<int>::Iterator _channel;
164 161
165}; 162};
166 163
167 164
168/*====================================================================================== 165/*======================================================================================
169 * OWirelessNetworkInterface 166 * OWirelessNetworkInterface
170 *======================================================================================*/ 167 *======================================================================================*/
171 168
172class OWirelessNetworkInterface : public ONetworkInterface 169class OWirelessNetworkInterface : public ONetworkInterface
173{ 170{
174 friend class OMonitoringInterface; 171 friend class OMonitoringInterface;
175 friend class OCiscoMonitoringInterface; 172 friend class OCiscoMonitoringInterface;
176 friend class OWlanNGMonitoringInterface; 173 friend class OWlanNGMonitoringInterface;
177 friend class OHostAPMonitoringInterface; 174 friend class OHostAPMonitoringInterface;
178 friend class OOrinocoMonitoringInterface; 175 friend class OOrinocoMonitoringInterface;
179 176
180 friend class OPrivateIOCTL; 177 friend class OPrivateIOCTL;
181 178
182 public: 179 public:
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 *======================================================================================*/
277 275
278class OWlanNGMonitoringInterface : public OMonitoringInterface 276class OWlanNGMonitoringInterface : public OMonitoringInterface
279{ 277{
280 public: 278 public:
281 OWlanNGMonitoringInterface( ONetworkInterface* ); 279 OWlanNGMonitoringInterface( ONetworkInterface* );
282 virtual ~OWlanNGMonitoringInterface(); 280 virtual ~OWlanNGMonitoringInterface();
283 281
284 public: 282 public:
285 virtual void setEnabled( bool ); 283 virtual void setEnabled( bool );
286 virtual QString name() const; 284 virtual QString name() const;
287 virtual void setChannel( int ); 285 virtual void setChannel( int );
288 286
289}; 287};
290 288
291/*====================================================================================== 289/*======================================================================================
292 * OHostAPMonitoringInterface 290 * OHostAPMonitoringInterface
293 *======================================================================================*/ 291 *======================================================================================*/
294 292
295class OHostAPMonitoringInterface : public OMonitoringInterface 293class OHostAPMonitoringInterface : public OMonitoringInterface
296{ 294{
297 public: 295 public:
298 OHostAPMonitoringInterface( ONetworkInterface* ); 296 OHostAPMonitoringInterface( ONetworkInterface* );
299 virtual ~OHostAPMonitoringInterface(); 297 virtual ~OHostAPMonitoringInterface();
300 298