summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp19
-rw-r--r--libopie2/opienet/onetutils.h8
-rw-r--r--libopie2/opienet/onetwork.cpp43
-rw-r--r--libopie2/opienet/onetwork.h7
4 files changed, 39 insertions, 38 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index c8c494a..9c3e650 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,241 +1,254 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 =.
6 .=l. 4 .=l.
7           .>+-= 5           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
13     ._= =}       : 11     ._= =}       :
14    .%`+i>       _;_. 12    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 19++=   -.     .`     .: details.
22 :     =  ...= . :.=- 20 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
29 27
30*/ 28*/
31 29
32#include <opie2/onetutils.h> 30#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 31#include <opie2/onetwork.h>
34#include <opie2/omanufacturerdb.h> 32#include <opie2/omanufacturerdb.h>
35 33
36#include <net/if.h> 34#include <net/if.h>
37#include <assert.h> 35#include <assert.h>
38#include <stdio.h> 36#include <stdio.h>
39 37
40namespace Opie { 38namespace Opie {
41namespace Net { 39namespace Net {
42 40
43/*====================================================================================== 41/*======================================================================================
44 * OMacAddress 42 * OMacAddress
45 *======================================================================================*/ 43 *======================================================================================*/
46 44
47// static initializer for broadcast and unknown MAC Adresses 45// static initializer for broadcast and unknown MAC Adresses
48const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 46const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
49const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 47const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
50const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 48const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
51const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 49const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
52 50
53//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 51//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
54 52
55OMacAddress::OMacAddress() 53OMacAddress::OMacAddress()
56{ 54{
57 memcpy( _bytes, __unknown, 6 ); 55 memcpy( _bytes, __unknown, 6 );
58} 56}
59 57
60 58
61OMacAddress::OMacAddress( unsigned char* p ) 59OMacAddress::OMacAddress( unsigned char* p )
62{ 60{
63 memcpy( _bytes, p, 6 ); 61 memcpy( _bytes, p, 6 );
64} 62}
65 63
66 64
67OMacAddress::OMacAddress( const unsigned char* p ) 65OMacAddress::OMacAddress( const unsigned char* p )
68{ 66{
69 memcpy( _bytes, p, 6 ); 67 memcpy( _bytes, p, 6 );
70} 68}
71 69
72 70
73OMacAddress::OMacAddress( struct ifreq& ifr ) 71OMacAddress::OMacAddress( struct ifreq& ifr )
74{ 72{
75 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 73 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
76} 74}
77 75
78 76
79OMacAddress::~OMacAddress() 77OMacAddress::~OMacAddress()
80{ 78{
81} 79}
82 80
83 81
84//#ifdef QT_NO_DEBUG 82//#ifdef QT_NO_DEBUG
85//inline 83//inline
86//#endif 84//#endif
87const unsigned char* OMacAddress::native() const 85const unsigned char* OMacAddress::native() const
88{ 86{
89 return (const unsigned char*) &_bytes; 87 return (const unsigned char*) &_bytes;
90} 88}
91 89
92 90
93OMacAddress OMacAddress::fromString( const QString& str ) 91OMacAddress OMacAddress::fromString( const QString& str )
94{ 92{
95 QString addr( str ); 93 QString addr( str );
96 unsigned char buf[6]; 94 unsigned char buf[6];
97 bool ok = true; 95 bool ok = true;
98 int index = 14; 96 int index = 14;
99 for ( int i = 5; i >= 0; --i ) 97 for ( int i = 5; i >= 0; --i )
100 { 98 {
101 buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); 99 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
102 if ( !ok ) return OMacAddress::unknown; 100 if ( !ok ) return OMacAddress::unknown;
103 addr.truncate( index ); 101 addr.truncate( index );
104 index -= 3; 102 index -= 3;
105 } 103 }
106 return (const unsigned char*) &buf; 104 return (const unsigned char*) &buf;
107} 105}
108 106
109 107
110QString OMacAddress::toString( bool substitute ) const 108QString OMacAddress::toString( bool substitute ) const
111{ 109{
112 QString manu; 110 QString manu;
113 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); 111 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
114 QString serial; 112 QString serial;
115 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 113 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
116 if ( !substitute ) return manu+serial; 114 if ( !substitute ) return manu+serial;
117 // fallback - if no vendor is found, just use the number 115 // fallback - if no vendor is found, just use the number
118 QString textmanu = OManufacturerDB::instance()->lookup( manu ); 116 QString textmanu = OManufacturerDB::instance()->lookup( manu );
119 return textmanu.isNull() ? manu+serial : textmanu+serial; 117 return textmanu.isNull() ? manu+serial : textmanu+serial;
120} 118}
121 119
122 120
123QString OMacAddress::manufacturer() const 121QString OMacAddress::manufacturer() const
124{ 122{
125 return OManufacturerDB::instance()->lookupExt( toString() ); 123 return OManufacturerDB::instance()->lookupExt( toString() );
126} 124}
127 125
128 126
129bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 127bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
130{ 128{
131 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 129 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
132} 130}
133 131
134 132
135/*====================================================================================== 133/*======================================================================================
136 * OHostAddress 134 * OHostAddress
137 *======================================================================================*/ 135 *======================================================================================*/
138 136
137OHostAddress::OHostAddress()
138 :QHostAddress()
139{
140}
141
142
143OHostAddress::OHostAddress( Q_UINT32 ip4Addr )
144 :QHostAddress( ip4Addr )
145{
146}
147
148
149OHostAddress::~OHostAddress()
150{
151}
139 152
140/*====================================================================================== 153/*======================================================================================
141 * OPrivateIOCTL 154 * OPrivateIOCTL
142 *======================================================================================*/ 155 *======================================================================================*/
143 156
144OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 157OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
145 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 158 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
146{ 159{
147} 160}
148 161
149 162
150OPrivateIOCTL::~OPrivateIOCTL() 163OPrivateIOCTL::~OPrivateIOCTL()
151{ 164{
152} 165}
153 166
154 167
155int OPrivateIOCTL::numberGetArgs() const 168int OPrivateIOCTL::numberGetArgs() const
156{ 169{
157 return _getargs & IW_PRIV_SIZE_MASK; 170 return _getargs & IW_PRIV_SIZE_MASK;
158} 171}
159 172
160 173
161int OPrivateIOCTL::typeGetArgs() const 174int OPrivateIOCTL::typeGetArgs() const
162{ 175{
163 return _getargs & IW_PRIV_TYPE_MASK >> 12; 176 return _getargs & IW_PRIV_TYPE_MASK >> 12;
164} 177}
165 178
166 179
167int OPrivateIOCTL::numberSetArgs() const 180int OPrivateIOCTL::numberSetArgs() const
168{ 181{
169 return _setargs & IW_PRIV_SIZE_MASK; 182 return _setargs & IW_PRIV_SIZE_MASK;
170} 183}
171 184
172 185
173int OPrivateIOCTL::typeSetArgs() const 186int OPrivateIOCTL::typeSetArgs() const
174{ 187{
175 return _setargs & IW_PRIV_TYPE_MASK >> 12; 188 return _setargs & IW_PRIV_TYPE_MASK >> 12;
176} 189}
177 190
178 191
179void OPrivateIOCTL::invoke() const 192void OPrivateIOCTL::invoke() const
180{ 193{
181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 194 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
182} 195}
183 196
184 197
185void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 198void OPrivateIOCTL::setParameter( int num, u_int32_t value )
186{ 199{
187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 200 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
188 arglist[num] = value; 201 arglist[num] = value;
189} 202}
190 203
191 204
192 205
193namespace Internal { 206namespace Internal {
194/*====================================================================================== 207/*======================================================================================
195 * assorted functions 208 * assorted functions
196 *======================================================================================*/ 209 *======================================================================================*/
197 210
198void dumpBytes( const unsigned char* data, int num ) 211void dumpBytes( const unsigned char* data, int num )
199{ 212{
200 printf( "Dumping %d bytes @ 0x%p", num, data ); 213 printf( "Dumping %d bytes @ 0x%p", num, data );
201 printf( "-------------------------------------------\n" ); 214 printf( "-------------------------------------------\n" );
202 215
203 for ( int i = 0; i < num; ++i ) 216 for ( int i = 0; i < num; ++i )
204 { 217 {
205 printf( "%02x ", data[i] ); 218 printf( "%02x ", data[i] );
206 if ( !((i+1) % 32) ) printf( "\n" ); 219 if ( !((i+1) % 32) ) printf( "\n" );
207 } 220 }
208 printf( "\n\n" ); 221 printf( "\n\n" );
209} 222}
210 223
211 224
212int stringToMode( const QString& mode ) 225int stringToMode( const QString& mode )
213{ 226{
214 if ( mode == "auto" ) return IW_MODE_AUTO; 227 if ( mode == "auto" ) return IW_MODE_AUTO;
215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 228 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
216 else if ( mode == "managed" ) return IW_MODE_INFRA; 229 else if ( mode == "managed" ) return IW_MODE_INFRA;
217 else if ( mode == "master" ) return IW_MODE_MASTER; 230 else if ( mode == "master" ) return IW_MODE_MASTER;
218 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 231 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
219 else if ( mode == "secondary" ) return IW_MODE_SECOND; 232 else if ( mode == "secondary" ) return IW_MODE_SECOND;
220 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 233 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
221 else assert( 0 ); 234 else assert( 0 );
222} 235}
223 236
224 237
225QString modeToString( int mode ) 238QString modeToString( int mode )
226{ 239{
227 switch ( mode ) 240 switch ( mode )
228 { 241 {
229 case IW_MODE_AUTO: return "auto"; 242 case IW_MODE_AUTO: return "auto";
230 case IW_MODE_ADHOC: return "adhoc"; 243 case IW_MODE_ADHOC: return "adhoc";
231 case IW_MODE_INFRA: return "managed"; 244 case IW_MODE_INFRA: return "managed";
232 case IW_MODE_MASTER: return "master"; 245 case IW_MODE_MASTER: return "master";
233 case IW_MODE_REPEAT: return "repeater"; 246 case IW_MODE_REPEAT: return "repeater";
234 case IW_MODE_SECOND: return "second"; 247 case IW_MODE_SECOND: return "second";
235 case IW_MODE_MONITOR: return "monitor"; 248 case IW_MODE_MONITOR: return "monitor";
236 default: assert( 0 ); 249 default: assert( 0 );
237 } 250 }
238} 251}
239} 252}
240} 253}
241} 254}
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index 25c9238..f08738c 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -1,223 +1,223 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 11     ._= =}       :
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31#ifndef ONETUTILS_H 30#ifndef ONETUTILS_H
32#define ONETUTILS_H 31#define ONETUTILS_H
33 32
34#include <qdict.h> 33#include <qdict.h>
35#include <qmap.h> 34#include <qmap.h>
36#include <qstring.h> 35#include <qstring.h>
37#include <qhostaddress.h> 36#include <qhostaddress.h>
38#include <qobject.h> 37#include <qobject.h>
39 38
40#include <sys/types.h> 39#include <sys/types.h>
41 40
42struct ifreq; 41struct ifreq;
43 42
44namespace Opie { 43namespace Opie {
45namespace Net { 44namespace Net {
46 45
47class OWirelessNetworkInterface; 46class OWirelessNetworkInterface;
48 47
49/*====================================================================================== 48/*======================================================================================
50 * OMacAddress 49 * OMacAddress
51 *======================================================================================*/ 50 *======================================================================================*/
52 51
53class OMacAddress 52class OMacAddress
54{ 53{
55 public: 54 public:
56 // QString c'tor? -zecke 55 // QString c'tor? -zecke
57 OMacAddress(); 56 OMacAddress();
58 OMacAddress( unsigned char* ); 57 OMacAddress( unsigned char* );
59 OMacAddress( const unsigned char* ); 58 OMacAddress( const unsigned char* );
60 OMacAddress( struct ifreq& ); 59 OMacAddress( struct ifreq& );
61 ~OMacAddress(); 60 ~OMacAddress();
62 61
63 QString manufacturer() const; 62 QString manufacturer() const;
64 QString toString( bool substitute = false ) const; 63 QString toString( bool substitute = false ) const;
65 const unsigned char* native() const; 64 const unsigned char* native() const;
66 65
67 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? 66 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
68 static OMacAddress fromString( const QString& ); 67 static OMacAddress fromString( const QString& );
69 68
70 public: 69 public:
71 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 70 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
72 static const OMacAddress& unknown; // 44:44:44:44:44:44 71 static const OMacAddress& unknown; // 44:44:44:44:44:44
73 72
74 private: 73 private:
75 unsigned char _bytes[6]; 74 unsigned char _bytes[6];
76 75
77 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 76 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
78 class Private; 77 class Private;
79 Private *d; 78 Private *d;
80 79
81}; 80};
82 81
83bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 82bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
84 83
85 84
86/*====================================================================================== 85/*======================================================================================
87 * OHostAddress 86 * OHostAddress
88 *======================================================================================*/ 87 *======================================================================================*/
89 88
90class OHostAddress : public QHostAddress 89class OHostAddress : public QHostAddress
91{ 90{
92 /*public: 91 public:
93 OHostAddress(); 92 OHostAddress();
93 OHostAddress( Q_UINT32 ip4Addr );
94 ~OHostAddress(); 94 ~OHostAddress();
95 */ 95
96 private: 96 private:
97 class Private; 97 class Private;
98 Private *d; 98 Private *d;
99}; 99};
100 100
101 101
102/*====================================================================================== 102/*======================================================================================
103 * ONetworkInterfaceDriverInfo 103 * ONetworkInterfaceDriverInfo
104 *======================================================================================*/ 104 *======================================================================================*/
105 105
106class ONetworkInterfaceDriverInfo 106class ONetworkInterfaceDriverInfo
107{ 107{
108 public: 108 public:
109 ONetworkInterfaceDriverInfo( const QString& name = "<unknown>", 109 ONetworkInterfaceDriverInfo( const QString& name = "<unknown>",
110 const QString& version = "<unknown>", 110 const QString& version = "<unknown>",
111 const QString& firmware = "<unknown>", 111 const QString& firmware = "<unknown>",
112 const QString& bus = "<unknown>" ) : 112 const QString& bus = "<unknown>" ) :
113 _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { }; 113 _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { };
114 ~ONetworkInterfaceDriverInfo() { }; 114 ~ONetworkInterfaceDriverInfo() { };
115 115
116 QString name() const { return _name; }; 116 QString name() const { return _name; };
117 QString version() const { return _version; }; 117 QString version() const { return _version; };
118 QString firmware() const { return _firmware; }; 118 QString firmware() const { return _firmware; };
119 QString bus() const { return _bus; }; 119 QString bus() const { return _bus; };
120 120
121 private: 121 private:
122 const QString _name; 122 const QString _name;
123 const QString _version; 123 const QString _version;
124 const QString _firmware; 124 const QString _firmware;
125 const QString _bus; 125 const QString _bus;
126}; 126};
127 127
128/*====================================================================================== 128/*======================================================================================
129 * OPrivateIOCTL 129 * OPrivateIOCTL
130 *======================================================================================*/ 130 *======================================================================================*/
131 131
132class OPrivateIOCTL : public QObject 132class OPrivateIOCTL : public QObject
133{ 133{
134 public: 134 public:
135 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 135 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
136 ~OPrivateIOCTL(); 136 ~OPrivateIOCTL();
137 137
138 int numberGetArgs() const; 138 int numberGetArgs() const;
139 int typeGetArgs() const; 139 int typeGetArgs() const;
140 int numberSetArgs() const; 140 int numberSetArgs() const;
141 int typeSetArgs() const; 141 int typeSetArgs() const;
142 142
143 // FIXME return int? as ::ioctl does? -zecke 143 // FIXME return int? as ::ioctl does? -zecke
144 void invoke() const; 144 void invoke() const;
145 void setParameter( int, u_int32_t ); 145 void setParameter( int, u_int32_t );
146 146
147 private: 147 private:
148 u_int32_t _ioctl; 148 u_int32_t _ioctl;
149 u_int16_t _getargs; 149 u_int16_t _getargs;
150 u_int16_t _setargs; 150 u_int16_t _setargs;
151 151
152 class Private; 152 class Private;
153 Private *d; 153 Private *d;
154}; 154};
155 155
156 /*====================================================================================== 156 /*======================================================================================
157 * Miscellaneous 157 * Miscellaneous
158 *======================================================================================*/ 158 *======================================================================================*/
159 159
160namespace Internal { 160namespace Internal {
161void dumpBytes( const unsigned char* data, int num ); 161void dumpBytes( const unsigned char* data, int num );
162QString modeToString( int ); 162QString modeToString( int );
163int stringToMode( const QString& ); 163int stringToMode( const QString& );
164} 164}
165} 165}
166} 166}
167 167
168#define IW_PRIV_TYPE_MASK 0x7000 168#define IW_PRIV_TYPE_MASK 0x7000
169#define IW_PRIV_TYPE_NONE 0x0000 169#define IW_PRIV_TYPE_NONE 0x0000
170#define IW_PRIV_TYPE_BYTE 0x1000 170#define IW_PRIV_TYPE_BYTE 0x1000
171#define IW_PRIV_TYPE_CHAR 0x2000 171#define IW_PRIV_TYPE_CHAR 0x2000
172#define IW_PRIV_TYPE_INT 0x4000 172#define IW_PRIV_TYPE_INT 0x4000
173#define IW_PRIV_TYPE_FLOAT 0x5000 173#define IW_PRIV_TYPE_FLOAT 0x5000
174#define IW_PRIV_TYPE_ADDR 0x6000 174#define IW_PRIV_TYPE_ADDR 0x6000
175#define IW_PRIV_SIZE_FIXED 0x0800 175#define IW_PRIV_SIZE_FIXED 0x0800
176#define IW_PRIV_SIZE_MASK 0x07FF 176#define IW_PRIV_SIZE_MASK 0x07FF
177 177
178#define IW_HEADER_TYPE_NULL 0 /* Not available */ 178#define IW_HEADER_TYPE_NULL 0 /* Not available */
179#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */ 179#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */
180#define IW_HEADER_TYPE_UINT 4 /* __u32 */ 180#define IW_HEADER_TYPE_UINT 4 /* __u32 */
181#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */ 181#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */
182#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */ 182#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */
183#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */ 183#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */
184#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */ 184#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */
185#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */ 185#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */
186 186
187#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ 187#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
188 (char *) NULL) 188 (char *) NULL)
189 189
190#ifndef ARPHRD_IEEE80211 190#ifndef ARPHRD_IEEE80211
191#define ARPHRD_IEEE80211 801 191#define ARPHRD_IEEE80211 801
192#endif 192#endif
193#ifndef ARPHRD_IEEE80211_PRISM 193#ifndef ARPHRD_IEEE80211_PRISM
194#define ARPHRD_IEEE80211_PRISM 802 194#define ARPHRD_IEEE80211_PRISM 802
195#endif 195#endif
196 196
197/* Wireless Extension Scanning Stuff */ 197/* Wireless Extension Scanning Stuff */
198struct iw_stream_descr 198struct iw_stream_descr
199{ 199{
200 char * end; /* End of the stream */ 200 char * end; /* End of the stream */
201 char * current; /* Current event in stream of events */ 201 char * current; /* Current event in stream of events */
202 char * value; /* Current value in event */ 202 char * value; /* Current value in event */
203}; 203};
204 204
205 205
206/* Network to host order macros */ 206/* Network to host order macros */
207 207
208#ifdef LBL_ALIGN 208#ifdef LBL_ALIGN
209#define EXTRACT_16BITS(p) \ 209#define EXTRACT_16BITS(p) \
210 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ 210 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
211 (u_int16_t)*((const u_int8_t *)(p) + 1))) 211 (u_int16_t)*((const u_int8_t *)(p) + 1)))
212#define EXTRACT_32BITS(p) \ 212#define EXTRACT_32BITS(p) \
213 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ 213 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
214 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ 214 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
215 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ 215 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
216 (u_int32_t)*((const u_int8_t *)(p) + 3))) 216 (u_int32_t)*((const u_int8_t *)(p) + 3)))
217#else 217#else
218#define EXTRACT_16BITS(p) \ 218#define EXTRACT_16BITS(p) \
219 ((u_int16_t)ntohs(*(const u_int16_t *)(p))) 219 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
220#define EXTRACT_32BITS(p) \ 220#define EXTRACT_32BITS(p) \
221 ((u_int32_t)ntohl(*(const u_int32_t *)(p))) 221 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
222#endif 222#endif
223 223
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 1deb051..0649ca2 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,678 +1,667 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 11     ._= =}       :
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31/* OPIE */ 30/* OPIE */
32#include <opie2/onetwork.h> 31#include <opie2/onetwork.h>
33#include <opie2/ostation.h> 32#include <opie2/ostation.h>
34#include <opie2/odebug.h> 33#include <opie2/odebug.h>
35using namespace Opie::Core; 34using namespace Opie::Core;
36 35
37/* QT */ 36/* QT */
38#include <qfile.h> 37#include <qfile.h>
39#include <qtextstream.h> 38#include <qtextstream.h>
40#include <qapplication.h> 39#include <qapplication.h>
41 40
42/* STD */ 41/* STD */
43#include <assert.h> 42#include <assert.h>
44#include <arpa/inet.h> 43#include <arpa/inet.h>
45#include <errno.h> 44#include <errno.h>
46#include <stdarg.h> 45#include <stdarg.h>
47#include <string.h> 46#include <string.h>
48#include <stdlib.h> 47#include <stdlib.h>
49#include <math.h> 48#include <math.h>
50#include <unistd.h> 49#include <unistd.h>
51#include <net/if_arp.h> 50#include <net/if_arp.h>
52#include <net/ethernet.h> 51#include <net/ethernet.h>
53#include <sys/ioctl.h> 52#include <sys/ioctl.h>
54#include <sys/socket.h> 53#include <sys/socket.h>
55#include <sys/types.h> 54#include <sys/types.h>
56#include <linux/types.h> 55#include <linux/types.h>
57#include <linux/sockios.h> 56#include <linux/sockios.h>
58#define u64 __u64 57#define u64 __u64
59#define u32 __u32 58#define u32 __u32
60#define u16 __u16 59#define u16 __u16
61#define u8 __u8 60#define u8 __u8
62#include <linux/ethtool.h> 61#include <linux/ethtool.h>
63 62
64#ifndef NODEBUG 63#ifndef NODEBUG
65#include <opie2/odebugmapper.h> 64#include <opie2/odebugmapper.h>
66using namespace Opie::Net::Internal; 65using namespace Opie::Net::Internal;
67DebugMapper* debugmapper = new DebugMapper(); 66DebugMapper* debugmapper = new DebugMapper();
68#endif 67#endif
69 68
70/*====================================================================================== 69/*======================================================================================
71 * ONetwork 70 * ONetwork
72 *======================================================================================*/ 71 *======================================================================================*/
73 72
74namespace Opie { 73namespace Opie {
75namespace Net { 74namespace Net {
76ONetwork* ONetwork::_instance = 0; 75ONetwork* ONetwork::_instance = 0;
77 76
78ONetwork::ONetwork() 77ONetwork::ONetwork()
79{ 78{
80 odebug << "ONetwork::ONetwork()" << oendl; 79 odebug << "ONetwork::ONetwork()" << oendl;
81 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 80 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
82 synchronize(); 81 synchronize();
83} 82}
84 83
85void ONetwork::synchronize() 84void ONetwork::synchronize()
86{ 85{
87 // gather available interfaces by inspecting /proc/net/dev 86 // gather available interfaces by inspecting /proc/net/dev
88 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
89 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
90 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
91
92 _interfaces.clear(); 87 _interfaces.clear();
93 QString str; 88 QString str;
94 QFile f( "/proc/net/dev" ); 89 QFile f( "/proc/net/dev" );
95 bool hasFile = f.open( IO_ReadOnly ); 90 bool hasFile = f.open( IO_ReadOnly );
96 if ( !hasFile ) 91 if ( !hasFile )
97 { 92 {
98 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 93 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
99 return; 94 return;
100 } 95 }
101 QTextStream s( &f ); 96 QTextStream s( &f );
102 s.readLine(); 97 s.readLine();
103 s.readLine(); 98 s.readLine();
104 while ( !s.atEnd() ) 99 while ( !s.atEnd() )
105 { 100 {
106 s >> str; 101 s >> str;
107 str.truncate( str.find( ':' ) ); 102 str.truncate( str.find( ':' ) );
108 odebug << "ONetwork: found interface '" << str << "'" << oendl; 103 odebug << "ONetwork: found interface '" << str << "'" << oendl;
109 if ( str.startsWith( "wifi" ) ) 104 if ( str.startsWith( "wifi" ) )
110 { 105 {
111 odebug << "ONetwork: ignoring hostap control interface" << oendl; 106 odebug << "ONetwork: ignoring hostap control interface" << oendl;
112 s.readLine(); 107 s.readLine();
113 continue; 108 continue;
114 } 109 }
115 ONetworkInterface* iface = 0; 110 ONetworkInterface* iface = 0;
116 if ( isWirelessInterface( str ) ) 111 if ( isWirelessInterface( str ) )
117 { 112 {
118 iface = new OWirelessNetworkInterface( this, (const char*) str ); 113 iface = new OWirelessNetworkInterface( this, (const char*) str );
119 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 114 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
120 } 115 }
121 else 116 else
122 { 117 {
123 iface = new ONetworkInterface( this, (const char*) str ); 118 iface = new ONetworkInterface( this, (const char*) str );
124 } 119 }
125 _interfaces.insert( str, iface ); 120 _interfaces.insert( str, iface );
126 s.readLine(); 121 s.readLine();
127 } 122 }
128} 123}
129 124
130 125
131short ONetwork::wirelessExtensionCompileVersion() 126short ONetwork::wirelessExtensionCompileVersion()
132{ 127{
133 return WIRELESS_EXT; 128 return WIRELESS_EXT;
134} 129}
135 130
136 131
137int ONetwork::count() const 132int ONetwork::count() const
138{ 133{
139 return _interfaces.count(); 134 return _interfaces.count();
140} 135}
141 136
142 137
143ONetworkInterface* ONetwork::interface( const QString& iface ) const 138ONetworkInterface* ONetwork::interface( const QString& iface ) const
144{ 139{
145 return _interfaces[iface]; 140 return _interfaces[iface];
146} 141}
147 142
148 143
149ONetwork* ONetwork::instance() 144ONetwork* ONetwork::instance()
150{ 145{
151 if ( !_instance ) _instance = new ONetwork(); 146 if ( !_instance ) _instance = new ONetwork();
152 return _instance; 147 return _instance;
153} 148}
154 149
155 150
156ONetwork::InterfaceIterator ONetwork::iterator() const 151ONetwork::InterfaceIterator ONetwork::iterator() const
157{ 152{
158 return ONetwork::InterfaceIterator( _interfaces ); 153 return ONetwork::InterfaceIterator( _interfaces );
159} 154}
160 155
161 156
162bool ONetwork::isPresent( const char* name ) const 157bool ONetwork::isPresent( const char* name ) const
163{ 158{
164 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 159 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
165 struct ifreq ifr; 160 struct ifreq ifr;
166 memset( &ifr, 0, sizeof( struct ifreq ) ); 161 memset( &ifr, 0, sizeof( struct ifreq ) );
167 strcpy( (char*) &ifr.ifr_name, name ); 162 strcpy( (char*) &ifr.ifr_name, name );
168 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); 163 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
169 return result != -1; 164 return result != -1;
170} 165}
171 166
172 167
173bool ONetwork::isWirelessInterface( const char* name ) const 168bool ONetwork::isWirelessInterface( const char* name ) const
174{ 169{
175 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 170 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
176 struct iwreq iwr; 171 struct iwreq iwr;
177 memset( &iwr, 0, sizeof( struct iwreq ) ); 172 memset( &iwr, 0, sizeof( struct iwreq ) );
178 strcpy( (char*) &iwr.ifr_name, name ); 173 strcpy( (char*) &iwr.ifr_name, name );
179 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 174 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
180 return result != -1; 175 return result != -1;
181} 176}
182 177
183/*====================================================================================== 178/*======================================================================================
184 * ONetworkInterface 179 * ONetworkInterface
185 *======================================================================================*/ 180 *======================================================================================*/
186 181
187ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 182ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
188 :QObject( parent, name ), 183 :QObject( parent, name ),
189 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 184 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
190{ 185{
191 odebug << "ONetworkInterface::ONetworkInterface()" << oendl; 186 odebug << "ONetworkInterface::ONetworkInterface()" << oendl;
192 init(); 187 init();
193} 188}
194 189
195 190
196struct ifreq& ONetworkInterface::ifr() const 191struct ifreq& ONetworkInterface::ifr() const
197{ 192{
198 return _ifr; 193 return _ifr;
199} 194}
200 195
201 196
202void ONetworkInterface::init() 197void ONetworkInterface::init()
203{ 198{
204 odebug << "ONetworkInterface::init()" << oendl; 199 odebug << "ONetworkInterface::init()" << oendl;
205
206 memset( &_ifr, 0, sizeof( struct ifreq ) ); 200 memset( &_ifr, 0, sizeof( struct ifreq ) );
207 201
208 if ( _sfd == -1 ) 202 if ( _sfd == -1 )
209 { 203 {
210 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; 204 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl;
211 return; 205 return;
212 } 206 }
213} 207}
214 208
215 209
216bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const 210bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
217{ 211{
218 #ifndef NODEBUG 212 #ifndef NODEBUG
219 int result = ::ioctl( _sfd, call, &ifreq ); 213 int result = ::ioctl( _sfd, call, &ifreq );
220 if ( result == -1 ) 214 if ( result == -1 )
221 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) 215 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
222 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 216 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
223 else 217 else
224 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) 218 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
225 << "' - Status: Ok." << oendl; 219 << "' - Status: Ok." << oendl;
226 return ( result != -1 ); 220 return ( result != -1 );
227 #else 221 #else
228 return ::ioctl( _sfd, call, &ifreq ) != -1; 222 return ::ioctl( _sfd, call, &ifreq ) != -1;
229 #endif 223 #endif
230} 224}
231 225
232 226
233bool ONetworkInterface::ioctl( int call ) const 227bool ONetworkInterface::ioctl( int call ) const
234{ 228{
235 strcpy( _ifr.ifr_name, name() ); 229 strcpy( _ifr.ifr_name, name() );
236 return ioctl( call, _ifr ); 230 return ioctl( call, _ifr );
237} 231}
238 232
239 233
240bool ONetworkInterface::isLoopback() const 234bool ONetworkInterface::isLoopback() const
241{ 235{
242 ioctl( SIOCGIFFLAGS ); 236 ioctl( SIOCGIFFLAGS );
243 return _ifr.ifr_flags & IFF_LOOPBACK; 237 return _ifr.ifr_flags & IFF_LOOPBACK;
244} 238}
245 239
246 240
247bool ONetworkInterface::setUp( bool b ) 241bool ONetworkInterface::setUp( bool b )
248{ 242{
249 ioctl( SIOCGIFFLAGS ); 243 ioctl( SIOCGIFFLAGS );
250 if ( b ) _ifr.ifr_flags |= IFF_UP; 244 if ( b ) _ifr.ifr_flags |= IFF_UP;
251 else _ifr.ifr_flags &= (~IFF_UP); 245 else _ifr.ifr_flags &= (~IFF_UP);
252 return ioctl( SIOCSIFFLAGS ); 246 return ioctl( SIOCSIFFLAGS );
253} 247}
254 248
255 249
256bool ONetworkInterface::isUp() const 250bool ONetworkInterface::isUp() const
257{ 251{
258 ioctl( SIOCGIFFLAGS ); 252 ioctl( SIOCGIFFLAGS );
259 return _ifr.ifr_flags & IFF_UP; 253 return _ifr.ifr_flags & IFF_UP;
260} 254}
261 255
262 256
263void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) 257void ONetworkInterface::setIPV4Address( const QHostAddress& addr )
264{ 258{
265 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 259 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
266 sa->sin_family = AF_INET; 260 sa->sin_family = AF_INET;
267 sa->sin_port = 0; 261 sa->sin_port = 0;
268 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 262 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
269 ioctl( SIOCSIFADDR ); 263 ioctl( SIOCSIFADDR );
270} 264}
271 265
272 266
273QString ONetworkInterface::ipV4Address() const 267OHostAddress ONetworkInterface::ipV4Address() const
274{ 268{
275 if ( ioctl( SIOCGIFADDR ) ) 269 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
276 { 270 return ioctl( SIOCGIFADDR ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress();
277 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
278 //FIXME: Use QHostAddress here
279 return QString( inet_ntoa( sa->sin_addr ) );
280 }
281 else
282 return "<unknown>";
283
284} 271}
285 272
286 273
287void ONetworkInterface::setMacAddress( const OMacAddress& addr ) 274void ONetworkInterface::setMacAddress( const OMacAddress& addr )
288{ 275{
289 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; 276 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
290 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); 277 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
291 ioctl( SIOCSIFHWADDR ); 278 ioctl( SIOCSIFHWADDR );
292} 279}
293 280
294 281
295OMacAddress ONetworkInterface::macAddress() const 282OMacAddress ONetworkInterface::macAddress() const
296{ 283{
297 if ( ioctl( SIOCGIFHWADDR ) ) 284 if ( ioctl( SIOCGIFHWADDR ) )
298 { 285 {
299 return OMacAddress( _ifr ); 286 return OMacAddress( _ifr );
300 } 287 }
301 else 288 else
302 { 289 {
303 return OMacAddress::unknown; 290 return OMacAddress::unknown;
304 } 291 }
305} 292}
306 293
307 294
308void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) 295void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr )
309{ 296{
310 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 297 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
311 sa->sin_family = AF_INET; 298 sa->sin_family = AF_INET;
312 sa->sin_port = 0; 299 sa->sin_port = 0;
313 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 300 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
314 ioctl( SIOCSIFNETMASK ); 301 ioctl( SIOCSIFNETMASK );
315} 302}
316 303
317 304
318QString ONetworkInterface::ipV4Netmask() const 305OHostAddress ONetworkInterface::ipV4Netmask() const
319{ 306{
320 if ( ioctl( SIOCGIFNETMASK ) ) 307 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
321 { 308 return ioctl( SIOCGIFNETMASK ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress();
322 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
323 //FIXME: Use QHostAddress here
324 return QString( inet_ntoa( sa->sin_addr ) );
325 }
326 else
327 return "<unknown>";
328} 309}
329 310
330 311
331int ONetworkInterface::dataLinkType() const 312int ONetworkInterface::dataLinkType() const
332{ 313{
333 if ( ioctl( SIOCGIFHWADDR ) ) 314 if ( ioctl( SIOCGIFHWADDR ) )
334 { 315 {
335 return _ifr.ifr_hwaddr.sa_family; 316 return _ifr.ifr_hwaddr.sa_family;
336 } 317 }
337 else 318 else
338 { 319 {
339 return -1; 320 return -1;
340 } 321 }
341} 322}
342 323
343 324
344void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 325void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
345{ 326{
346 _mon = m; 327 _mon = m;
347 odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; 328 odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl;
348} 329}
349 330
350 331
351OMonitoringInterface* ONetworkInterface::monitoring() const 332OMonitoringInterface* ONetworkInterface::monitoring() const
352{ 333{
353 return _mon; 334 return _mon;
354} 335}
355 336
356 337
357ONetworkInterface::~ONetworkInterface() 338ONetworkInterface::~ONetworkInterface()
358{ 339{
359 odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; 340 odebug << "ONetworkInterface::~ONetworkInterface()" << oendl;
360 if ( _sfd != -1 ) ::close( _sfd ); 341 if ( _sfd != -1 ) ::close( _sfd );
361} 342}
362 343
363 344
364bool ONetworkInterface::setPromiscuousMode( bool b ) 345bool ONetworkInterface::setPromiscuousMode( bool b )
365{ 346{
366 ioctl( SIOCGIFFLAGS ); 347 ioctl( SIOCGIFFLAGS );
367 if ( b ) _ifr.ifr_flags |= IFF_PROMISC; 348 if ( b ) _ifr.ifr_flags |= IFF_PROMISC;
368 else _ifr.ifr_flags &= (~IFF_PROMISC); 349 else _ifr.ifr_flags &= (~IFF_PROMISC);
369 return ioctl( SIOCSIFFLAGS ); 350 return ioctl( SIOCSIFFLAGS );
370} 351}
371 352
372 353
373bool ONetworkInterface::promiscuousMode() const 354bool ONetworkInterface::promiscuousMode() const
374{ 355{
375 ioctl( SIOCGIFFLAGS ); 356 ioctl( SIOCGIFFLAGS );
376 return _ifr.ifr_flags & IFF_PROMISC; 357 return _ifr.ifr_flags & IFF_PROMISC;
377} 358}
378 359
379 360
380bool ONetworkInterface::isWireless() const 361bool ONetworkInterface::isWireless() const
381{ 362{
382 return ioctl( SIOCGIWNAME ); 363 return ioctl( SIOCGIWNAME );
383} 364}
384 365
385 366
386ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const 367ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const
387{ 368{
388 struct ethtool_drvinfo info; 369 struct ethtool_drvinfo info;
389 info.cmd = ETHTOOL_GDRVINFO; 370 info.cmd = ETHTOOL_GDRVINFO;
390 _ifr.ifr_data = (caddr_t) &info; 371 _ifr.ifr_data = (caddr_t) &info;
391 return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo(); 372 return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo();
392} 373}
393 374
394/*====================================================================================== 375/*======================================================================================
395 * OChannelHopper 376 * OChannelHopper
396 *======================================================================================*/ 377 *======================================================================================*/
397 378
398OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 379OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
399 :QObject( 0, "Mickey's funky hopper" ), 380 :QObject( 0, "Mickey's funky hopper" ),
400 _iface( iface ), _interval( 0 ), _tid( 0 ) 381 _iface( iface ), _interval( 0 ), _tid( 0 )
401{ 382{
402 int _maxChannel = iface->channels(); 383 int _maxChannel = iface->channels();
403 // generate fancy hopping sequence honoring the device capabilities 384 // generate fancy hopping sequence honoring the device capabilities
404 if ( _maxChannel >= 1 ) _channels.append( 1 ); 385 if ( _maxChannel >= 1 ) _channels.append( 1 );
405 if ( _maxChannel >= 7 ) _channels.append( 7 ); 386 if ( _maxChannel >= 7 ) _channels.append( 7 );
406 if ( _maxChannel >= 13 ) _channels.append( 13 ); 387 if ( _maxChannel >= 13 ) _channels.append( 13 );
407 if ( _maxChannel >= 2 ) _channels.append( 2 ); 388 if ( _maxChannel >= 2 ) _channels.append( 2 );
408 if ( _maxChannel >= 8 ) _channels.append( 8 ); 389 if ( _maxChannel >= 8 ) _channels.append( 8 );
409 if ( _maxChannel >= 3 ) _channels.append( 3 ); 390 if ( _maxChannel >= 3 ) _channels.append( 3 );
410 if ( _maxChannel >= 14 ) _channels.append( 14 ); 391 if ( _maxChannel >= 14 ) _channels.append( 14 );
411 if ( _maxChannel >= 9 ) _channels.append( 9 ); 392 if ( _maxChannel >= 9 ) _channels.append( 9 );
412 if ( _maxChannel >= 4 ) _channels.append( 4 ); 393 if ( _maxChannel >= 4 ) _channels.append( 4 );
413 if ( _maxChannel >= 10 ) _channels.append( 10 ); 394 if ( _maxChannel >= 10 ) _channels.append( 10 );
414 if ( _maxChannel >= 5 ) _channels.append( 5 ); 395 if ( _maxChannel >= 5 ) _channels.append( 5 );
415 if ( _maxChannel >= 11 ) _channels.append( 11 ); 396 if ( _maxChannel >= 11 ) _channels.append( 11 );
416 if ( _maxChannel >= 6 ) _channels.append( 6 ); 397 if ( _maxChannel >= 6 ) _channels.append( 6 );
417 if ( _maxChannel >= 12 ) _channels.append( 12 ); 398 if ( _maxChannel >= 12 ) _channels.append( 12 );
418 //FIXME: Add 802.11a/g channels 399 //FIXME: Add 802.11a/g channels
419 _channel = _channels.begin(); 400 _channel = _channels.begin();
420} 401}
421 402
422 403
423OChannelHopper::~OChannelHopper() 404OChannelHopper::~OChannelHopper()
424{ 405{
425} 406}
426 407
427 408
428bool OChannelHopper::isActive() const 409bool OChannelHopper::isActive() const
429{ 410{
430 return _tid; 411 return _tid;
431} 412}
432 413
433 414
434int OChannelHopper::channel() const 415int OChannelHopper::channel() const
435{ 416{
436 return *_channel; 417 return *_channel;
437} 418}
438 419
439 420
440void OChannelHopper::timerEvent( QTimerEvent* ) 421void OChannelHopper::timerEvent( QTimerEvent* )
441{ 422{
442 _iface->setChannel( *_channel ); 423 _iface->setChannel( *_channel );
443 emit( hopped( *_channel ) ); 424 emit( hopped( *_channel ) );
444 odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; 425 odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl;
445 if ( ++_channel == _channels.end() ) _channel = _channels.begin(); 426 if ( ++_channel == _channels.end() ) _channel = _channels.begin();
446} 427}
447 428
448 429
449void OChannelHopper::setInterval( int interval ) 430void OChannelHopper::setInterval( int interval )
450{ 431{
451 if ( interval == _interval ) 432 if ( interval == _interval )
452 return; 433 return;
453 434
454 if ( _interval ) 435 if ( _interval )
455 killTimer( _tid ); 436 killTimer( _tid );
456 437
457 _tid = 0; 438 _tid = 0;
458 _interval = interval; 439 _interval = interval;
459 440
460 if ( _interval ) 441 if ( _interval )
461 { 442 {
462 _tid = startTimer( interval ); 443 _tid = startTimer( interval );
463 } 444 }
464} 445}
465 446
466 447
467int OChannelHopper::interval() const 448int OChannelHopper::interval() const
468{ 449{
469 return _interval; 450 return _interval;
470} 451}
471 452
472 453
473/*====================================================================================== 454/*======================================================================================
474 * OWirelessNetworkInterface 455 * OWirelessNetworkInterface
475 *======================================================================================*/ 456 *======================================================================================*/
476 457
477OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) 458OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
478 :ONetworkInterface( parent, name ), _hopper( 0 ) 459 :ONetworkInterface( parent, name ), _hopper( 0 )
479{ 460{
480 odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; 461 odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl;
481 init(); 462 init();
482} 463}
483 464
484 465
485OWirelessNetworkInterface::~OWirelessNetworkInterface() 466OWirelessNetworkInterface::~OWirelessNetworkInterface()
486{ 467{
487} 468}
488 469
489 470
490struct iwreq& OWirelessNetworkInterface::iwr() const 471struct iwreq& OWirelessNetworkInterface::iwr() const
491{ 472{
492 return _iwr; 473 return _iwr;
493} 474}
494 475
495 476
496void OWirelessNetworkInterface::init() 477void OWirelessNetworkInterface::init()
497{ 478{
498 odebug << "OWirelessNetworkInterface::init()" << oendl; 479 odebug << "OWirelessNetworkInterface::init()" << oendl;
499 memset( &_iwr, 0, sizeof( struct iwreq ) ); 480 memset( &_iwr, 0, sizeof( struct iwreq ) );
500 buildInformation(); 481 buildInformation();
501 buildPrivateList(); 482 buildPrivateList();
502 dumpInformation(); 483 dumpInformation();
503} 484}
504 485
505 486
506bool OWirelessNetworkInterface::isAssociated() const 487bool OWirelessNetworkInterface::isAssociated() const
507{ 488{
508 //FIXME: handle different modes 489 //FIXME: handle different modes
509 return !(associatedAP() == OMacAddress::unknown); 490 return !(associatedAP() == OMacAddress::unknown);
510} 491}
511 492
512 493
513void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const 494void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const
514{ 495{
515 _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; 496 _iwr.u.ap_addr.sa_family = ARPHRD_ETHER;
516 ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); 497 ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN);
517 wioctl( SIOCSIWAP ); 498 wioctl( SIOCSIWAP );
518} 499}
519 500
520 501
521OMacAddress OWirelessNetworkInterface::associatedAP() const 502OMacAddress OWirelessNetworkInterface::associatedAP() const
522{ 503{
523 if ( ioctl( SIOCGIWAP ) ) 504 if ( ioctl( SIOCGIWAP ) )
524 return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; 505 return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0];
525 else 506 else
526 return OMacAddress::unknown; 507 return OMacAddress::unknown;
527} 508}
528 509
529 510
530void OWirelessNetworkInterface::buildInformation() 511void OWirelessNetworkInterface::buildInformation()
531{ 512{
532 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck 513 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck
533 //ML: The HostAP drivers need more than sizeof struct_iw range to complete 514 //ML: The HostAP drivers need more than sizeof struct_iw range to complete
534 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". 515 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length".
535 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate 516 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate
536 //ML: _too much_ space. This is damn shitty crap *sigh* 517 //ML: _too much_ space. This is damn shitty crap *sigh*
537 //ML: We allocate a large memory region in RAM and check whether the 518 //ML: We allocate a large memory region in RAM and check whether the
538 //ML: driver pollutes this extra space. The complaint will be made on stdout, 519 //ML: driver pollutes this extra space. The complaint will be made on stdout,
539 //ML: so please forward this... 520 //ML: so please forward this...
540 521
541 struct iwreq wrq; 522 struct iwreq wrq;
542 int len = sizeof( struct iw_range )*2; 523 int len = sizeof( struct iw_range )*2;
543 char buffer[len]; 524 char buffer[len];
544 memset( buffer, 0, len ); 525 memset( buffer, 0, len );
545 memcpy( wrq.ifr_name, name(), IFNAMSIZ); 526 memcpy( wrq.ifr_name, name(), IFNAMSIZ);
546 wrq.u.data.pointer = (caddr_t) buffer; 527 wrq.u.data.pointer = (caddr_t) buffer;
547 wrq.u.data.length = sizeof buffer; 528 wrq.u.data.length = sizeof buffer;
548 wrq.u.data.flags = 0; 529 wrq.u.data.flags = 0;
549 530
550 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) 531 int result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq );
532 if ( result == -1 )
533 {
534 owarn << "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (" << strerror( errno ) << ") - retrying with smaller buffer..." << oendl;
535 wrq.u.data.length = sizeof( struct iw_range );
536 result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq );
537 }
538
539 if ( result == -1 )
551 { 540 {
552 owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; 541 owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl;
553 _channels.insert( 2412, 1 ); // 2.412 GHz 542 _channels.insert( 2412, 1 ); // 2.412 GHz
554 _channels.insert( 2417, 2 ); // 2.417 GHz 543 _channels.insert( 2417, 2 ); // 2.417 GHz
555 _channels.insert( 2422, 3 ); // 2.422 GHz 544 _channels.insert( 2422, 3 ); // 2.422 GHz
556 _channels.insert( 2427, 4 ); // 2.427 GHz 545 _channels.insert( 2427, 4 ); // 2.427 GHz
557 _channels.insert( 2432, 5 ); // 2.432 GHz 546 _channels.insert( 2432, 5 ); // 2.432 GHz
558 _channels.insert( 2437, 6 ); // 2.437 GHz 547 _channels.insert( 2437, 6 ); // 2.437 GHz
559 _channels.insert( 2442, 7 ); // 2.442 GHz 548 _channels.insert( 2442, 7 ); // 2.442 GHz
560 _channels.insert( 2447, 8 ); // 2.447 GHz 549 _channels.insert( 2447, 8 ); // 2.447 GHz
561 _channels.insert( 2452, 9 ); // 2.452 GHz 550 _channels.insert( 2452, 9 ); // 2.452 GHz
562 _channels.insert( 2457, 10 ); // 2.457 GHz 551 _channels.insert( 2457, 10 ); // 2.457 GHz
563 _channels.insert( 2462, 11 ); // 2.462 GHz 552 _channels.insert( 2462, 11 ); // 2.462 GHz
564 553
565 memset( &_range, 0, sizeof( struct iw_range ) ); 554 memset( &_range, 0, sizeof( struct iw_range ) );
566 } 555 }
567 else 556 else
568 { 557 {
569 // <check if the driver overwrites stuff> 558 // <check if the driver overwrites stuff>
570 int max = 0; 559 int max = 0;
571 for ( int r = sizeof( struct iw_range ); r < len; r++ ) 560 for ( int r = sizeof( struct iw_range ); r < len; r++ )
572 if (buffer[r] != 0) 561 if (buffer[r] != 0)
573 max = r; 562 max = r;
574 if (max > 0) 563 if (max > 0)
575 { 564 {
576 owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() 565 owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name()
577 << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; 566 << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl;
578 } 567 }
579 // </check if the driver overwrites stuff> 568 // </check if the driver overwrites stuff>
580 569
581 struct iw_range range; 570 struct iw_range range;
582 memcpy( &range, buffer, sizeof range ); 571 memcpy( &range, buffer, sizeof range );
583 572
584 odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; 573 odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl;
585 for ( int i = 0; i < range.num_frequency; ++i ) 574 for ( int i = 0; i < range.num_frequency; ++i )
586 { 575 {
587 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); 576 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
588 odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; 577 odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl;
589 _channels.insert( freq, i+1 ); 578 _channels.insert( freq, i+1 );
590 } 579 }
591 } 580 }
592 581
593 memcpy( &_range, buffer, sizeof( struct iw_range ) ); 582 memcpy( &_range, buffer, sizeof( struct iw_range ) );
594 odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; 583 odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl;
595} 584}
596 585
597 586
598short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const 587short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const
599{ 588{
600 return _range.we_version_compiled; 589 return _range.we_version_compiled;
601} 590}
602 591
603 592
604void OWirelessNetworkInterface::buildPrivateList() 593void OWirelessNetworkInterface::buildPrivateList()
605{ 594{
606 odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; 595 odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl;
607 596
608 struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 597 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
609 598
610 _iwr.u.data.pointer = (char*) &priv; 599 _iwr.u.data.pointer = (char*) &priv;
611 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself 600 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
612 _iwr.u.data.flags = 0; 601 _iwr.u.data.flags = 0;
613 602
614 if ( !wioctl( SIOCGIWPRIV ) ) 603 if ( !wioctl( SIOCGIWPRIV ) )
615 { 604 {
616 owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl; 605 owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl;
617 return; 606 return;
618 } 607 }
619 608
620 for ( int i = 0; i < _iwr.u.data.length; ++i ) 609 for ( int i = 0; i < _iwr.u.data.length; ++i )
621 { 610 {
622 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 611 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
623 } 612 }
624 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; 613 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl;
625} 614}
626 615
627 616
628void OWirelessNetworkInterface::dumpInformation() const 617void OWirelessNetworkInterface::dumpInformation() const
629{ 618{
630 odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; 619 odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl;
631 620
632 odebug << " - driver's idea of maximum throughput is " << _range.throughput 621 odebug << " - driver's idea of maximum throughput is " << _range.throughput
633 << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) 622 << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 )
634 << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) 623 << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 )
635 << " Mb/s" << oendl; 624 << " Mb/s" << oendl;
636 625
637 odebug << " - driver for '" << name() << "' (V" << _range.we_version_source 626 odebug << " - driver for '" << name() << "' (V" << _range.we_version_source
638 << ") has been compiled against WE V" << _range.we_version_compiled << oendl; 627 << ") has been compiled against WE V" << _range.we_version_compiled << oendl;
639 628
640 if ( _range.we_version_compiled != WIRELESS_EXT ) 629 if ( _range.we_version_compiled != WIRELESS_EXT )
641 { 630 {
642 owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; 631 owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl;
643 } 632 }
644 633
645 odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; 634 odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl;
646} 635}
647 636
648 637
649int OWirelessNetworkInterface::channel() const 638int OWirelessNetworkInterface::channel() const
650{ 639{
651 //FIXME: When monitoring enabled, then use it 640 //FIXME: When monitoring enabled, then use it
652 //FIXME: to gather the current RF channel 641 //FIXME: to gather the current RF channel
653 //FIXME: Until then, get active channel from hopper. 642 //FIXME: Until then, get active channel from hopper.
654 if ( _hopper && _hopper->isActive() ) 643 if ( _hopper && _hopper->isActive() )
655 return _hopper->channel(); 644 return _hopper->channel();
656 645
657 if ( !wioctl( SIOCGIWFREQ ) ) 646 if ( !wioctl( SIOCGIWFREQ ) )
658 { 647 {
659 return -1; 648 return -1;
660 } 649 }
661 else 650 else
662 { 651 {
663 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; 652 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ];
664 } 653 }
665} 654}
666 655
667 656
668void OWirelessNetworkInterface::setChannel( int c ) const 657void OWirelessNetworkInterface::setChannel( int c ) const
669{ 658{
670 if ( !c ) 659 if ( !c )
671 { 660 {
672 oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; 661 oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl;
673 return; 662 return;
674 } 663 }
675 664
676 if ( !_mon ) 665 if ( !_mon )
677 { 666 {
678 memset( &_iwr, 0, sizeof( struct iwreq ) ); 667 memset( &_iwr, 0, sizeof( struct iwreq ) );
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index f0c4450..b13c7a3 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,348 +1,347 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 11     ._= =}       :
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31#ifndef ONETWORK_H 30#ifndef ONETWORK_H
32#define ONETWORK_H 31#define ONETWORK_H
33 32
34/* OPIE */ 33/* OPIE */
35#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
36#include <opie2/ostation.h> 35#include <opie2/ostation.h>
37 36
38/* QT */ 37/* QT */
39#include <qvaluelist.h> 38#include <qvaluelist.h>
40#include <qdict.h> 39#include <qdict.h>
41#include <qmap.h> 40#include <qmap.h>
42#include <qobject.h> 41#include <qobject.h>
43#include <qhostaddress.h> 42#include <qhostaddress.h>
44 43
45/* STD */ 44/* STD */
46// hacky workarounds until we have a true user space wireless.h 45// hacky workarounds until we have a true user space wireless.h
47#include <net/if.h> 46#include <net/if.h>
48#define _LINUX_IF_H 47#define _LINUX_IF_H
49#include <linux/wireless.h> 48#include <linux/wireless.h>
50#ifndef IW_MAX_PRIV_DEF 49#ifndef IW_MAX_PRIV_DEF
51#define IW_MAX_PRIV_DEF 128 50#define IW_MAX_PRIV_DEF 128
52#endif 51#endif
53 52
54namespace Opie { 53namespace Opie {
55namespace Net { 54namespace Net {
56class ONetworkInterface; 55class ONetworkInterface;
57class OWirelessNetworkInterface; 56class OWirelessNetworkInterface;
58class OChannelHopper; 57class OChannelHopper;
59class OMonitoringInterface; 58class OMonitoringInterface;
60 59
61/*====================================================================================== 60/*======================================================================================
62 * ONetwork 61 * ONetwork
63 *======================================================================================*/ 62 *======================================================================================*/
64 63
65/** 64/**
66 * @brief A container class for all network interfaces 65 * @brief A container class for all network interfaces
67 * 66 *
68 * This class provides access to all available network interfaces of your computer. 67 * This class provides access to all available network interfaces of your computer.
69 * 68 *
70 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 69 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
71 */ 70 */
72class ONetwork : public QObject 71class ONetwork : public QObject
73{ 72{
74 Q_OBJECT 73 Q_OBJECT
75 74
76 public: 75 public:
77 typedef QDict<ONetworkInterface> InterfaceMap; 76 typedef QDict<ONetworkInterface> InterfaceMap;
78 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 77 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
79 78
80 public: 79 public:
81 /** 80 /**
82 * @returns the number of available interfaces 81 * @returns the number of available interfaces
83 */ 82 */
84 int count() const; 83 int count() const;
85 /** 84 /**
86 * @returns a pointer to the (one and only) @ref ONetwork instance. 85 * @returns a pointer to the (one and only) @ref ONetwork instance.
87 */ 86 */
88 static ONetwork* instance(); 87 static ONetwork* instance();
89 /** 88 /**
90 * @returns an iterator usable for iterating through all network interfaces. 89 * @returns an iterator usable for iterating through all network interfaces.
91 */ 90 */
92 InterfaceIterator iterator() const; 91 InterfaceIterator iterator() const;
93 /** 92 /**
94 * @returns true, if the @a interface is present. 93 * @returns true, if the @a interface is present.
95 */ 94 */
96 bool isPresent( const char* interface ) const; 95 bool isPresent( const char* interface ) const;
97 /** 96 /**
98 * @returns true, if the @a interface supports the wireless extension protocol. 97 * @returns true, if the @a interface supports the wireless extension protocol.
99 */ 98 */
100 bool isWirelessInterface( const char* interface ) const; 99 bool isWirelessInterface( const char* interface ) const;
101 /** 100 /**
102 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 101 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
103 * @see ONetworkInterface 102 * @see ONetworkInterface
104 */ 103 */
105 ONetworkInterface* interface( const QString& interface ) const; 104 ONetworkInterface* interface( const QString& interface ) const;
106 /** 105 /**
107 * @internal Rebuild the internal interface database 106 * @internal Rebuild the internal interface database
108 * @note Sometimes it might be useful to call this from client code, 107 * @note Sometimes it might be useful to call this from client code,
109 * e.g. after issuing a cardctl insert 108 * e.g. after issuing a cardctl insert
110 */ 109 */
111 void synchronize(); 110 void synchronize();
112 /** 111 /**
113 * @returns the wireless extension version used at compile time. 112 * @returns the wireless extension version used at compile time.
114 **/ 113 **/
115 static short wirelessExtensionCompileVersion(); 114 static short wirelessExtensionCompileVersion();
116 115
117 protected: 116 protected:
118 ONetwork(); 117 ONetwork();
119 118
120 private: 119 private:
121 static ONetwork* _instance; 120 static ONetwork* _instance;
122 InterfaceMap _interfaces; 121 InterfaceMap _interfaces;
123 class Private; 122 class Private;
124 Private *d; 123 Private *d;
125}; 124};
126 125
127 126
128/*====================================================================================== 127/*======================================================================================
129 * ONetworkInterface 128 * ONetworkInterface
130 *======================================================================================*/ 129 *======================================================================================*/
131 130
132/** 131/**
133 * @brief A network interface wrapper. 132 * @brief A network interface wrapper.
134 * 133 *
135 * This class provides a wrapper for a network interface. All the cumbersume details of 134 * This class provides a wrapper for a network interface. All the cumbersume details of
136 * Linux ioctls are hidden under a convenient high-level interface. 135 * Linux ioctls are hidden under a convenient high-level interface.
137 * @warning Most of the setting methods contained in this class require the appropriate 136 * @warning Most of the setting methods contained in this class require the appropriate
138 * process permissions to work. 137 * process permissions to work.
139 * 138 *
140 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 139 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
141 */ 140 */
142class ONetworkInterface : public QObject 141class ONetworkInterface : public QObject
143{ 142{
144 friend class OMonitoringInterface; 143 friend class OMonitoringInterface;
145 friend class OCiscoMonitoringInterface; 144 friend class OCiscoMonitoringInterface;
146 friend class OWlanNGMonitoringInterface; 145 friend class OWlanNGMonitoringInterface;
147 friend class OHostAPMonitoringInterface; 146 friend class OHostAPMonitoringInterface;
148 friend class OOrinocoMonitoringInterface; 147 friend class OOrinocoMonitoringInterface;
149 148
150 public: 149 public:
151 /** 150 /**
152 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 151 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
153 * but access them via @ref ONetwork::interface(). 152 * but access them via @ref ONetwork::interface().
154 */ 153 */
155 ONetworkInterface( QObject* parent, const char* name ); 154 ONetworkInterface( QObject* parent, const char* name );
156 /** 155 /**
157 * Destructor. 156 * Destructor.
158 */ 157 */
159 virtual ~ONetworkInterface(); 158 virtual ~ONetworkInterface();
160 /** 159 /**
161 * Associates a @a monitoring interface with this network interface. 160 * Associates a @a monitoring interface with this network interface.
162 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 161 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
163 */ 162 */
164 void setMonitoring( OMonitoringInterface* monitoring ); 163 void setMonitoring( OMonitoringInterface* monitoring );
165 /** 164 /**
166 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 165 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
167 */ 166 */
168 OMonitoringInterface* monitoring() const; 167 OMonitoringInterface* monitoring() const;
169 /** 168 /**
170 * Setting an interface to promiscuous mode enables the device to receive 169 * Setting an interface to promiscuous mode enables the device to receive
171 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 170 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
172 */ 171 */
173 bool setPromiscuousMode( bool ); 172 bool setPromiscuousMode( bool );
174 /** 173 /**
175 * @returns true if the interface is set to promiscuous mode. 174 * @returns true if the interface is set to promiscuous mode.
176 */ 175 */
177 bool promiscuousMode() const; 176 bool promiscuousMode() const;
178 /** 177 /**
179 * Setting an interface to up enables it to receive packets. 178 * Setting an interface to up enables it to receive packets.
180 */ 179 */
181 bool setUp( bool ); 180 bool setUp( bool );
182 /** 181 /**
183 * @returns true if the interface is up. 182 * @returns true if the interface is up.
184 */ 183 */
185 bool isUp() const; 184 bool isUp() const;
186 /** 185 /**
187 * @returns true if the interface is a loopback interface. 186 * @returns true if the interface is a loopback interface.
188 */ 187 */
189 bool isLoopback() const; 188 bool isLoopback() const;
190 /** 189 /**
191 * @returns true if the interface is featuring supports the wireless extension protocol. 190 * @returns true if the interface is featuring supports the wireless extension protocol.
192 */ 191 */
193 bool isWireless() const; 192 bool isWireless() const;
194 /** 193 /**
195 * Associate the IP address @ addr with the interface. 194 * Associate the IP address @ addr with the interface.
196 */ 195 */
197 void setIPV4Address( const QHostAddress& addr ); 196 void setIPV4Address( const QHostAddress& addr );
198 /** 197 /**
199 * @returns the IPv4 address associated with the interface. 198 * @returns the IPv4 address associated with the interface.
200 */ 199 */
201 QString ipV4Address() const; //TODO: make this return an OHostAddress 200 OHostAddress ipV4Address() const;
202 /** 201 /**
203 * Associate the MAC address @a addr with the interface. 202 * Associate the MAC address @a addr with the interface.
204 * @note It can be necessary to shut down the interface prior to calling this method. 203 * @note It can be necessary to shut down the interface prior to calling this method.
205 * @note This operation needs root privileges 204 * @note This operation needs root privileges
206 * @warning This is not supported by all drivers. 205 * @warning This is not supported by all drivers.
207 */ 206 */
208 void setMacAddress( const OMacAddress& addr ); 207 void setMacAddress( const OMacAddress& addr );
209 /** 208 /**
210 * @returns the MAC address associated with the interface. 209 * @returns the MAC address associated with the interface.
211 */ 210 */
212 OMacAddress macAddress() const; 211 OMacAddress macAddress() const;
213 /** 212 /**
214 * Associate the IPv4 @a netmask with the interface. 213 * Associate the IPv4 @a netmask with the interface.
215 */ 214 */
216 void setIPV4Netmask( const QHostAddress& netmask ); 215 void setIPV4Netmask( const QHostAddress& netmask );
217 /** 216 /**
218 * @returns the IPv4 netmask associated with the interface. 217 * @returns the IPv4 netmask associated with the interface.
219 */ 218 */
220 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 219 OHostAddress ipV4Netmask() const;
221 /** 220 /**
222 * @returns the data link type currently associated with the interface. 221 * @returns the data link type currently associated with the interface.
223 * @see #include <net/if_arp.h> for possible values. 222 * @see #include <net/if_arp.h> for possible values.
224 */ 223 */
225 int dataLinkType() const; 224 int dataLinkType() const;
226 /** 225 /**
227 * @returns a ONetworkInterfaceDriverInfo driver information block 226 * @returns a ONetworkInterfaceDriverInfo driver information block
228 * @note This operation needs root privileges 227 * @note This operation needs root privileges
229 * @warning This is not supported by all drivers 228 * @warning This is not supported by all drivers
230 */ 229 */
231 ONetworkInterfaceDriverInfo driverInfo() const; 230 ONetworkInterfaceDriverInfo driverInfo() const;
232 231
233 protected: 232 protected:
234 const int _sfd; 233 const int _sfd;
235 mutable ifreq _ifr; 234 mutable ifreq _ifr;
236 OMonitoringInterface* _mon; 235 OMonitoringInterface* _mon;
237 236
238 protected: 237 protected:
239 struct ifreq& ifr() const; 238 struct ifreq& ifr() const;
240 virtual void init(); 239 virtual void init();
241 bool ioctl( int call ) const; 240 bool ioctl( int call ) const;
242 bool ioctl( int call, struct ifreq& ) const; 241 bool ioctl( int call, struct ifreq& ) const;
243 private: 242 private:
244 class Private; 243 class Private;
245 Private *d; 244 Private *d;
246}; 245};
247 246
248/*====================================================================================== 247/*======================================================================================
249 * OChannelHopper 248 * OChannelHopper
250 *======================================================================================*/ 249 *======================================================================================*/
251 250
252/** 251/**
253 * @brief A radio frequency channel hopper. 252 * @brief A radio frequency channel hopper.
254 * 253 *
255 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 254 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
256 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 255 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
257 * This is necessary when in monitoring mode and scanning for other devices, because 256 * This is necessary when in monitoring mode and scanning for other devices, because
258 * the radio frequency hardware can only detect packets sent on the same frequency. 257 * the radio frequency hardware can only detect packets sent on the same frequency.
259 * 258 *
260 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 259 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
261 */ 260 */
262class OChannelHopper : public QObject 261class OChannelHopper : public QObject
263{ 262{
264 Q_OBJECT 263 Q_OBJECT
265 264
266 public: 265 public:
267 /** 266 /**
268 * Constructor. 267 * Constructor.
269 */ 268 */
270 OChannelHopper( OWirelessNetworkInterface* ); 269 OChannelHopper( OWirelessNetworkInterface* );
271 /** 270 /**
272 * Destructor. 271 * Destructor.
273 */ 272 */
274 virtual ~OChannelHopper(); 273 virtual ~OChannelHopper();
275 /** 274 /**
276 * @returns true, if the channel hopper is hopping channels 275 * @returns true, if the channel hopper is hopping channels
277 */ 276 */
278 bool isActive() const; 277 bool isActive() const;
279 /** 278 /**
280 * @returns the last hopped channel 279 * @returns the last hopped channel
281 */ 280 */
282 int channel() const; 281 int channel() const;
283 /** 282 /**
284 * Set the channel hopping @a interval. 283 * Set the channel hopping @a interval.
285 * An interval of 0 deactivates the channel hopper. 284 * An interval of 0 deactivates the channel hopper.
286 */ 285 */
287 void setInterval( int interval ); 286 void setInterval( int interval );
288 /** 287 /**
289 * @returns the channel hopping interval 288 * @returns the channel hopping interval
290 */ 289 */
291 int interval() const; 290 int interval() const;
292 291
293 signals: 292 signals:
294 /** 293 /**
295 * This signal is emitted right after the channel hopper performed a hop 294 * This signal is emitted right after the channel hopper performed a hop
296 */ 295 */
297 void hopped( int ); 296 void hopped( int );
298 297
299 protected: 298 protected:
300 virtual void timerEvent( QTimerEvent* ); 299 virtual void timerEvent( QTimerEvent* );
301 300
302 private: 301 private:
303 OWirelessNetworkInterface* _iface; 302 OWirelessNetworkInterface* _iface;
304 int _interval; 303 int _interval;
305 int _tid; 304 int _tid;
306 QValueList<int> _channels; 305 QValueList<int> _channels;
307 QValueList<int>::Iterator _channel; 306 QValueList<int>::Iterator _channel;
308 class Private; 307 class Private;
309 Private *d; 308 Private *d;
310}; 309};
311 310
312 311
313/*====================================================================================== 312/*======================================================================================
314 * OWirelessNetworkInterface 313 * OWirelessNetworkInterface
315 *======================================================================================*/ 314 *======================================================================================*/
316 315
317/** 316/**
318 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 317 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
319 * 318 *
320 * This class provides a high-level encapsulation of the Linux wireless extension API. 319 * This class provides a high-level encapsulation of the Linux wireless extension API.
321 * 320 *
322 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 321 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
323 */ 322 */
324class OWirelessNetworkInterface : public ONetworkInterface 323class OWirelessNetworkInterface : public ONetworkInterface
325{ 324{
326 friend class OMonitoringInterface; 325 friend class OMonitoringInterface;
327 friend class OCiscoMonitoringInterface; 326 friend class OCiscoMonitoringInterface;
328 friend class OWlanNGMonitoringInterface; 327 friend class OWlanNGMonitoringInterface;
329 friend class OHostAPMonitoringInterface; 328 friend class OHostAPMonitoringInterface;
330 friend class OOrinocoMonitoringInterface; 329 friend class OOrinocoMonitoringInterface;
331 330
332 friend class OPrivateIOCTL; 331 friend class OPrivateIOCTL;
333 332
334 public: 333 public:
335 /** 334 /**
336 * Constructor. 335 * Constructor.
337 */ 336 */
338 OWirelessNetworkInterface( QObject* parent, const char* name ); 337 OWirelessNetworkInterface( QObject* parent, const char* name );
339 /** 338 /**
340 * Destructor. 339 * Destructor.
341 */ 340 */
342 virtual ~OWirelessNetworkInterface(); 341 virtual ~OWirelessNetworkInterface();
343 /** 342 /**
344 * Setting the @a channel of the interface changes the radio frequency (RF) 343 * Setting the @a channel of the interface changes the radio frequency (RF)
345 * of the corresponding wireless network device. 344 * of the corresponding wireless network device.
346 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 345 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
347 * @see channels() 346 * @see channels()
348 */ 347 */