author | mickeyl <mickeyl> | 2003-03-30 13:52:20 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 13:52:20 (UTC) |
commit | 9e3dc048e171af6d88f0cc3f16ad0c9fb6a15ce2 (patch) (unidiff) | |
tree | 2d3bd9b940729878f96d5dc2f2ef9fd22478f3f0 | |
parent | 3065a1c13bec5d0b101bec48ff666d45a02ce8a6 (diff) | |
download | opie-9e3dc048e171af6d88f0cc3f16ad0c9fb6a15ce2.zip opie-9e3dc048e171af6d88f0cc3f16ad0c9fb6a15ce2.tar.gz opie-9e3dc048e171af6d88f0cc3f16ad0c9fb6a15ce2.tar.bz2 |
introduce a workaround for conflicting user and kernel headers like
<linux/if.h> and <net/if.h>. I really don't like including kernel headers,
but in the case of <linux/wireless.h> there is no other option yet.
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 1 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 998b50e..21fa390 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,793 +1,792 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
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 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/onetwork.h> | 36 | #include <opie2/onetwork.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* UNIX */ | 43 | /* UNIX */ |
44 | 44 | ||
45 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
46 | #include <cerrno> | 46 | #include <cerrno> |
47 | #include <cstring> | 47 | #include <cstring> |
48 | #include <cstdlib> | 48 | #include <cstdlib> |
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 54 | #include <linux/sockios.h> |
55 | #include <linux/wireless.h> | ||
56 | 55 | ||
57 | using namespace std; | 56 | using namespace std; |
58 | 57 | ||
59 | /*====================================================================================== | 58 | /*====================================================================================== |
60 | * ONetwork | 59 | * ONetwork |
61 | *======================================================================================*/ | 60 | *======================================================================================*/ |
62 | 61 | ||
63 | ONetwork* ONetwork::_instance = 0; | 62 | ONetwork* ONetwork::_instance = 0; |
64 | 63 | ||
65 | ONetwork::ONetwork() | 64 | ONetwork::ONetwork() |
66 | { | 65 | { |
67 | qDebug( "ONetwork::ONetwork()" ); | 66 | qDebug( "ONetwork::ONetwork()" ); |
68 | synchronize(); | 67 | synchronize(); |
69 | } | 68 | } |
70 | 69 | ||
71 | void ONetwork::synchronize() | 70 | void ONetwork::synchronize() |
72 | { | 71 | { |
73 | // gather available interfaces by inspecting /proc/net/dev | 72 | // gather available interfaces by inspecting /proc/net/dev |
74 | // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 73 | // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
75 | 74 | ||
76 | _interfaces.clear(); | 75 | _interfaces.clear(); |
77 | QString str; | 76 | QString str; |
78 | QFile f( "/proc/net/dev" ); | 77 | QFile f( "/proc/net/dev" ); |
79 | bool hasFile = f.open( IO_ReadOnly ); | 78 | bool hasFile = f.open( IO_ReadOnly ); |
80 | if ( !hasFile ) | 79 | if ( !hasFile ) |
81 | { | 80 | { |
82 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 81 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
83 | return; | 82 | return; |
84 | } | 83 | } |
85 | QTextStream s( &f ); | 84 | QTextStream s( &f ); |
86 | s.readLine(); | 85 | s.readLine(); |
87 | s.readLine(); | 86 | s.readLine(); |
88 | while ( !s.atEnd() ) | 87 | while ( !s.atEnd() ) |
89 | { | 88 | { |
90 | s >> str; | 89 | s >> str; |
91 | str.truncate( str.find( ':' ) ); | 90 | str.truncate( str.find( ':' ) ); |
92 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 91 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
93 | ONetworkInterface* iface; | 92 | ONetworkInterface* iface; |
94 | if ( isWirelessInterface( str ) ) | 93 | if ( isWirelessInterface( str ) ) |
95 | { | 94 | { |
96 | iface = new OWirelessNetworkInterface( str ); | 95 | iface = new OWirelessNetworkInterface( str ); |
97 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 96 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
98 | } | 97 | } |
99 | else | 98 | else |
100 | { | 99 | { |
101 | iface = new ONetworkInterface( str ); | 100 | iface = new ONetworkInterface( str ); |
102 | } | 101 | } |
103 | _interfaces.insert( str, iface ); | 102 | _interfaces.insert( str, iface ); |
104 | s.readLine(); | 103 | s.readLine(); |
105 | } | 104 | } |
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
109 | ONetworkInterface* ONetwork::interface( QString iface ) const | 108 | ONetworkInterface* ONetwork::interface( QString iface ) const |
110 | { | 109 | { |
111 | return _interfaces[iface]; | 110 | return _interfaces[iface]; |
112 | } | 111 | } |
113 | 112 | ||
114 | 113 | ||
115 | ONetwork* ONetwork::instance() | 114 | ONetwork* ONetwork::instance() |
116 | { | 115 | { |
117 | if ( !_instance ) _instance = new ONetwork(); | 116 | if ( !_instance ) _instance = new ONetwork(); |
118 | return _instance; | 117 | return _instance; |
119 | } | 118 | } |
120 | 119 | ||
121 | 120 | ||
122 | ONetwork::InterfaceIterator ONetwork::iterator() const | 121 | ONetwork::InterfaceIterator ONetwork::iterator() const |
123 | { | 122 | { |
124 | return ONetwork::InterfaceIterator( _interfaces ); | 123 | return ONetwork::InterfaceIterator( _interfaces ); |
125 | } | 124 | } |
126 | 125 | ||
127 | 126 | ||
128 | bool ONetwork::isWirelessInterface( const char* name ) const | 127 | bool ONetwork::isWirelessInterface( const char* name ) const |
129 | { | 128 | { |
130 | int sfd = socket( AF_INET, SOCK_DGRAM, 0 ); | 129 | int sfd = socket( AF_INET, SOCK_DGRAM, 0 ); |
131 | iwreqstruct iwr; | 130 | iwreqstruct iwr; |
132 | memset( &iwr, 0, sizeof( iwreqstruct ) ); | 131 | memset( &iwr, 0, sizeof( iwreqstruct ) ); |
133 | strcpy( (char*) &iwr.ifr_name, name ); | 132 | strcpy( (char*) &iwr.ifr_name, name ); |
134 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 133 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
135 | if ( result == -1 ) | 134 | if ( result == -1 ) |
136 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); | 135 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); |
137 | else | 136 | else |
138 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); | 137 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); |
139 | return ( result != -1 ); | 138 | return ( result != -1 ); |
140 | } | 139 | } |
141 | 140 | ||
142 | /*====================================================================================== | 141 | /*====================================================================================== |
143 | * ONetworkInterface | 142 | * ONetworkInterface |
144 | *======================================================================================*/ | 143 | *======================================================================================*/ |
145 | 144 | ||
146 | ONetworkInterface::ONetworkInterface( const QString& name ) | 145 | ONetworkInterface::ONetworkInterface( const QString& name ) |
147 | :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 146 | :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
148 | { | 147 | { |
149 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
150 | init(); | 149 | init(); |
151 | } | 150 | } |
152 | 151 | ||
153 | 152 | ||
154 | ifreqstruct& ONetworkInterface::ifr() const | 153 | ifreqstruct& ONetworkInterface::ifr() const |
155 | { | 154 | { |
156 | return _ifr; | 155 | return _ifr; |
157 | } | 156 | } |
158 | 157 | ||
159 | 158 | ||
160 | void ONetworkInterface::init() | 159 | void ONetworkInterface::init() |
161 | { | 160 | { |
162 | qDebug( "ONetworkInterface::init()" ); | 161 | qDebug( "ONetworkInterface::init()" ); |
163 | 162 | ||
164 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
165 | 164 | ||
166 | if ( _sfd == -1 ) | 165 | if ( _sfd == -1 ) |
167 | { | 166 | { |
168 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", (const char*) _name ); | 167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", (const char*) _name ); |
169 | return; | 168 | return; |
170 | } | 169 | } |
171 | } | 170 | } |
172 | 171 | ||
173 | 172 | ||
174 | bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const | 173 | bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const |
175 | { | 174 | { |
176 | int result = ::ioctl( _sfd, call, &ifreq ); | 175 | int result = ::ioctl( _sfd, call, &ifreq ); |
177 | if ( result == -1 ) | 176 | if ( result == -1 ) |
178 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); | 177 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); |
179 | else | 178 | else |
180 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call ); | 179 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call ); |
181 | return ( result != -1 ); | 180 | return ( result != -1 ); |
182 | } | 181 | } |
183 | 182 | ||
184 | 183 | ||
185 | bool ONetworkInterface::ioctl( int call ) const | 184 | bool ONetworkInterface::ioctl( int call ) const |
186 | { | 185 | { |
187 | strcpy( _ifr.ifr_name, (const char*) _name ); | 186 | strcpy( _ifr.ifr_name, (const char*) _name ); |
188 | return ioctl( call, _ifr ); | 187 | return ioctl( call, _ifr ); |
189 | } | 188 | } |
190 | 189 | ||
191 | 190 | ||
192 | bool ONetworkInterface::isLoopback() const | 191 | bool ONetworkInterface::isLoopback() const |
193 | { | 192 | { |
194 | ioctl( SIOCGIFFLAGS ); | 193 | ioctl( SIOCGIFFLAGS ); |
195 | return _ifr.ifr_flags & IFF_LOOPBACK; | 194 | return _ifr.ifr_flags & IFF_LOOPBACK; |
196 | } | 195 | } |
197 | 196 | ||
198 | 197 | ||
199 | bool ONetworkInterface::setUp( bool b ) | 198 | bool ONetworkInterface::setUp( bool b ) |
200 | { | 199 | { |
201 | ioctl( SIOCGIFFLAGS ); | 200 | ioctl( SIOCGIFFLAGS ); |
202 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 201 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
203 | else _ifr.ifr_flags &= (~IFF_UP); | 202 | else _ifr.ifr_flags &= (~IFF_UP); |
204 | return ioctl( SIOCSIFFLAGS ); | 203 | return ioctl( SIOCSIFFLAGS ); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | bool ONetworkInterface::isUp() const | 207 | bool ONetworkInterface::isUp() const |
209 | { | 208 | { |
210 | ioctl( SIOCGIFFLAGS ); | 209 | ioctl( SIOCGIFFLAGS ); |
211 | return _ifr.ifr_flags & IFF_UP; | 210 | return _ifr.ifr_flags & IFF_UP; |
212 | } | 211 | } |
213 | 212 | ||
214 | 213 | ||
215 | QString ONetworkInterface::ipV4Address() const | 214 | QString ONetworkInterface::ipV4Address() const |
216 | { | 215 | { |
217 | if ( ioctl( SIOCGIFADDR ) ) | 216 | if ( ioctl( SIOCGIFADDR ) ) |
218 | { | 217 | { |
219 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
220 | //FIXME: Use QHostAddress here | 219 | //FIXME: Use QHostAddress here |
221 | return QString( inet_ntoa( sa->sin_addr ) ); | 220 | return QString( inet_ntoa( sa->sin_addr ) ); |
222 | } | 221 | } |
223 | else | 222 | else |
224 | return "<unknown>"; | 223 | return "<unknown>"; |
225 | } | 224 | } |
226 | 225 | ||
227 | 226 | ||
228 | OMacAddress ONetworkInterface::macAddress() const | 227 | OMacAddress ONetworkInterface::macAddress() const |
229 | { | 228 | { |
230 | if ( ioctl( SIOCGIFHWADDR ) ) | 229 | if ( ioctl( SIOCGIFHWADDR ) ) |
231 | { | 230 | { |
232 | return OMacAddress( _ifr ); | 231 | return OMacAddress( _ifr ); |
233 | } | 232 | } |
234 | else | 233 | else |
235 | { | 234 | { |
236 | return OMacAddress::unknown; | 235 | return OMacAddress::unknown; |
237 | } | 236 | } |
238 | } | 237 | } |
239 | 238 | ||
240 | 239 | ||
241 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 240 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
242 | { | 241 | { |
243 | _mon = m; | 242 | _mon = m; |
244 | qDebug( "ONetwork::setMonitoring(): Installed monitoring interface '%s'", (const char*) m->name() ); | 243 | qDebug( "ONetwork::setMonitoring(): Installed monitoring interface '%s'", (const char*) m->name() ); |
245 | } | 244 | } |
246 | 245 | ||
247 | 246 | ||
248 | OMonitoringInterface* ONetworkInterface::monitoring() const | 247 | OMonitoringInterface* ONetworkInterface::monitoring() const |
249 | { | 248 | { |
250 | return _mon; | 249 | return _mon; |
251 | } | 250 | } |
252 | 251 | ||
253 | 252 | ||
254 | const QString& ONetworkInterface::name() const | 253 | const QString& ONetworkInterface::name() const |
255 | { | 254 | { |
256 | return _name; | 255 | return _name; |
257 | } | 256 | } |
258 | 257 | ||
259 | 258 | ||
260 | ONetworkInterface::~ONetworkInterface() | 259 | ONetworkInterface::~ONetworkInterface() |
261 | { | 260 | { |
262 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 261 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
263 | if ( _sfd != -1 ) ::close( _sfd ); | 262 | if ( _sfd != -1 ) ::close( _sfd ); |
264 | } | 263 | } |
265 | 264 | ||
266 | 265 | ||
267 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 266 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
268 | { | 267 | { |
269 | ioctl( SIOCGIFFLAGS ); | 268 | ioctl( SIOCGIFFLAGS ); |
270 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 269 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
271 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 270 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
272 | return ioctl( SIOCSIFFLAGS ); | 271 | return ioctl( SIOCSIFFLAGS ); |
273 | } | 272 | } |
274 | 273 | ||
275 | 274 | ||
276 | bool ONetworkInterface::promiscuousMode() const | 275 | bool ONetworkInterface::promiscuousMode() const |
277 | { | 276 | { |
278 | ioctl( SIOCGIFFLAGS ); | 277 | ioctl( SIOCGIFFLAGS ); |
279 | return _ifr.ifr_flags & IFF_PROMISC; | 278 | return _ifr.ifr_flags & IFF_PROMISC; |
280 | } | 279 | } |
281 | 280 | ||
282 | 281 | ||
283 | bool ONetworkInterface::isWireless() const | 282 | bool ONetworkInterface::isWireless() const |
284 | { | 283 | { |
285 | return ioctl( SIOCGIWNAME ); | 284 | return ioctl( SIOCGIWNAME ); |
286 | } | 285 | } |
287 | 286 | ||
288 | 287 | ||
289 | /*====================================================================================== | 288 | /*====================================================================================== |
290 | * OChannelHopper | 289 | * OChannelHopper |
291 | *======================================================================================*/ | 290 | *======================================================================================*/ |
292 | 291 | ||
293 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 292 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
294 | :QObject( 0, "Mickey's funky hopper" ), | 293 | :QObject( 0, "Mickey's funky hopper" ), |
295 | _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ), | 294 | _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ), |
296 | _maxChannel( iface->channels()+1 ) | 295 | _maxChannel( iface->channels()+1 ) |
297 | { | 296 | { |
298 | } | 297 | } |
299 | 298 | ||
300 | 299 | ||
301 | OChannelHopper::~OChannelHopper() | 300 | OChannelHopper::~OChannelHopper() |
302 | { | 301 | { |
303 | } | 302 | } |
304 | 303 | ||
305 | 304 | ||
306 | bool OChannelHopper::isActive() const | 305 | bool OChannelHopper::isActive() const |
307 | { | 306 | { |
308 | return _tid; | 307 | return _tid; |
309 | } | 308 | } |
310 | 309 | ||
311 | 310 | ||
312 | int OChannelHopper::channel() const | 311 | int OChannelHopper::channel() const |
313 | { | 312 | { |
314 | return _channel; | 313 | return _channel; |
315 | } | 314 | } |
316 | 315 | ||
317 | 316 | ||
318 | void OChannelHopper::timerEvent( QTimerEvent* ) | 317 | void OChannelHopper::timerEvent( QTimerEvent* ) |
319 | { | 318 | { |
320 | if ( !--_channel ) _channel = _maxChannel; | 319 | if ( !--_channel ) _channel = _maxChannel; |
321 | _iface->setChannel( _channel ); | 320 | _iface->setChannel( _channel ); |
322 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", | 321 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", |
323 | _channel, (const char*) _iface->name() ); | 322 | _channel, (const char*) _iface->name() ); |
324 | } | 323 | } |
325 | 324 | ||
326 | 325 | ||
327 | void OChannelHopper::setInterval( int interval ) | 326 | void OChannelHopper::setInterval( int interval ) |
328 | { | 327 | { |
329 | if ( interval == _interval ) | 328 | if ( interval == _interval ) |
330 | return; | 329 | return; |
331 | 330 | ||
332 | if ( _interval ) | 331 | if ( _interval ) |
333 | killTimer( _tid ); | 332 | killTimer( _tid ); |
334 | 333 | ||
335 | _tid = 0; | 334 | _tid = 0; |
336 | _interval = interval; | 335 | _interval = interval; |
337 | 336 | ||
338 | if ( _interval ) | 337 | if ( _interval ) |
339 | { | 338 | { |
340 | _tid = startTimer( interval ); | 339 | _tid = startTimer( interval ); |
341 | } | 340 | } |
342 | } | 341 | } |
343 | 342 | ||
344 | 343 | ||
345 | int OChannelHopper::interval() const | 344 | int OChannelHopper::interval() const |
346 | { | 345 | { |
347 | return _interval; | 346 | return _interval; |
348 | } | 347 | } |
349 | 348 | ||
350 | 349 | ||
351 | /*====================================================================================== | 350 | /*====================================================================================== |
352 | * OWirelessNetworkInterface | 351 | * OWirelessNetworkInterface |
353 | *======================================================================================*/ | 352 | *======================================================================================*/ |
354 | 353 | ||
355 | OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) | 354 | OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) |
356 | :ONetworkInterface( name ), _hopper( 0 ) | 355 | :ONetworkInterface( name ), _hopper( 0 ) |
357 | { | 356 | { |
358 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 357 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); |
359 | init(); | 358 | init(); |
360 | } | 359 | } |
361 | 360 | ||
362 | 361 | ||
363 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 362 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
364 | { | 363 | { |
365 | } | 364 | } |
366 | 365 | ||
367 | 366 | ||
368 | iwreqstruct& OWirelessNetworkInterface::iwr() const | 367 | iwreqstruct& OWirelessNetworkInterface::iwr() const |
369 | { | 368 | { |
370 | return _iwr; | 369 | return _iwr; |
371 | } | 370 | } |
372 | 371 | ||
373 | 372 | ||
374 | void OWirelessNetworkInterface::init() | 373 | void OWirelessNetworkInterface::init() |
375 | { | 374 | { |
376 | qDebug( "OWirelessNetworkInterface::init()" ); | 375 | qDebug( "OWirelessNetworkInterface::init()" ); |
377 | 376 | ||
378 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 377 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
379 | 378 | ||
380 | // IEEE802.11(b) radio frequency channels | 379 | // IEEE802.11(b) radio frequency channels |
381 | //FIXME: get these directly from the interface | 380 | //FIXME: get these directly from the interface |
382 | //FIXME: check if these channels are off-by-one | 381 | //FIXME: check if these channels are off-by-one |
383 | 382 | ||
384 | iwrangestruct range; | 383 | iwrangestruct range; |
385 | _iwr.u.data.pointer = (char*) ⦥ | 384 | _iwr.u.data.pointer = (char*) ⦥ |
386 | _iwr.u.data.length = sizeof( iwrangestruct ); | 385 | _iwr.u.data.length = sizeof( iwrangestruct ); |
387 | if ( !wioctl( SIOCGIWRANGE ) ) | 386 | if ( !wioctl( SIOCGIWRANGE ) ) |
388 | { | 387 | { |
389 | qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) ); | 388 | qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) ); |
390 | return; | 389 | return; |
391 | } | 390 | } |
392 | 391 | ||
393 | for ( int i = 0; i < range.num_frequency; ++i ) | 392 | for ( int i = 0; i < range.num_frequency; ++i ) |
394 | { | 393 | { |
395 | int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); | 394 | int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); |
396 | _channels.insert( freq, i+1 ); | 395 | _channels.insert( freq, i+1 ); |
397 | } | 396 | } |
398 | } | 397 | } |
399 | 398 | ||
400 | 399 | ||
401 | QString OWirelessNetworkInterface::associatedAP() const | 400 | QString OWirelessNetworkInterface::associatedAP() const |
402 | { | 401 | { |
403 | //FIXME: use OMacAddress | 402 | //FIXME: use OMacAddress |
404 | QString mac; | 403 | QString mac; |
405 | 404 | ||
406 | if ( ioctl( SIOCGIWAP ) ) | 405 | if ( ioctl( SIOCGIWAP ) ) |
407 | { | 406 | { |
408 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 407 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
409 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | 408 | _ifr.ifr_hwaddr.sa_data[0]&0xff, |
410 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | 409 | _ifr.ifr_hwaddr.sa_data[1]&0xff, |
411 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | 410 | _ifr.ifr_hwaddr.sa_data[2]&0xff, |
412 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | 411 | _ifr.ifr_hwaddr.sa_data[3]&0xff, |
413 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | 412 | _ifr.ifr_hwaddr.sa_data[4]&0xff, |
414 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | 413 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); |
415 | } | 414 | } |
416 | else | 415 | else |
417 | { | 416 | { |
418 | mac = "<Unknown>"; | 417 | mac = "<Unknown>"; |
419 | } | 418 | } |
420 | return mac; | 419 | return mac; |
421 | } | 420 | } |
422 | 421 | ||
423 | 422 | ||
424 | int OWirelessNetworkInterface::channel() const | 423 | int OWirelessNetworkInterface::channel() const |
425 | { | 424 | { |
426 | //FIXME: When monitoring enabled, then use it | 425 | //FIXME: When monitoring enabled, then use it |
427 | //FIXME: to gather the current RF channel | 426 | //FIXME: to gather the current RF channel |
428 | //FIXME: Until then, get active channel from hopper. | 427 | //FIXME: Until then, get active channel from hopper. |
429 | if ( _hopper && _hopper->isActive() ) | 428 | if ( _hopper && _hopper->isActive() ) |
430 | return _hopper->channel(); | 429 | return _hopper->channel(); |
431 | 430 | ||
432 | if ( !wioctl( SIOCGIWFREQ ) ) | 431 | if ( !wioctl( SIOCGIWFREQ ) ) |
433 | { | 432 | { |
434 | return -1; | 433 | return -1; |
435 | } | 434 | } |
436 | else | 435 | else |
437 | { | 436 | { |
438 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ]; | 437 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ]; |
439 | } | 438 | } |
440 | } | 439 | } |
441 | 440 | ||
442 | 441 | ||
443 | void OWirelessNetworkInterface::setChannel( int c ) const | 442 | void OWirelessNetworkInterface::setChannel( int c ) const |
444 | { | 443 | { |
445 | if ( !_mon ) | 444 | if ( !_mon ) |
446 | { | 445 | { |
447 | memset( &_iwr, 0, sizeof( iwreqstruct ) ); | 446 | memset( &_iwr, 0, sizeof( iwreqstruct ) ); |
448 | _iwr.u.freq.m = c; | 447 | _iwr.u.freq.m = c; |
449 | _iwr.u.freq.e = 0; | 448 | _iwr.u.freq.e = 0; |
450 | wioctl( SIOCSIWFREQ ); | 449 | wioctl( SIOCSIWFREQ ); |
451 | } | 450 | } |
452 | else | 451 | else |
453 | { | 452 | { |
454 | _mon->setChannel( c ); | 453 | _mon->setChannel( c ); |
455 | } | 454 | } |
456 | } | 455 | } |
457 | 456 | ||
458 | 457 | ||
459 | double OWirelessNetworkInterface::frequency() const | 458 | double OWirelessNetworkInterface::frequency() const |
460 | { | 459 | { |
461 | if ( !wioctl( SIOCGIWFREQ ) ) | 460 | if ( !wioctl( SIOCGIWFREQ ) ) |
462 | { | 461 | { |
463 | return -1.0; | 462 | return -1.0; |
464 | } | 463 | } |
465 | else | 464 | else |
466 | { | 465 | { |
467 | return double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000000.0; | 466 | return double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000000.0; |
468 | } | 467 | } |
469 | } | 468 | } |
470 | 469 | ||
471 | 470 | ||
472 | int OWirelessNetworkInterface::channels() const | 471 | int OWirelessNetworkInterface::channels() const |
473 | { | 472 | { |
474 | return _channels.count(); | 473 | return _channels.count(); |
475 | } | 474 | } |
476 | 475 | ||
477 | 476 | ||
478 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 477 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
479 | { | 478 | { |
480 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 479 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
481 | _hopper->setInterval( interval ); | 480 | _hopper->setInterval( interval ); |
482 | //FIXME: When and by whom will the channel hopper be deleted? | 481 | //FIXME: When and by whom will the channel hopper be deleted? |
483 | } | 482 | } |
484 | 483 | ||
485 | 484 | ||
486 | int OWirelessNetworkInterface::channelHopping() const | 485 | int OWirelessNetworkInterface::channelHopping() const |
487 | { | 486 | { |
488 | return _hopper->interval(); | 487 | return _hopper->interval(); |
489 | } | 488 | } |
490 | 489 | ||
491 | 490 | ||
492 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 491 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
493 | { | 492 | { |
494 | if ( _mon ) | 493 | if ( _mon ) |
495 | _mon->setEnabled( b ); | 494 | _mon->setEnabled( b ); |
496 | else | 495 | else |
497 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 496 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
498 | } | 497 | } |
499 | 498 | ||
500 | 499 | ||
501 | bool OWirelessNetworkInterface::monitorMode() const | 500 | bool OWirelessNetworkInterface::monitorMode() const |
502 | { | 501 | { |
503 | return _mon ? _mon->enabled() : false; | 502 | return _mon ? _mon->enabled() : false; |
504 | } | 503 | } |
505 | 504 | ||
506 | 505 | ||
507 | QString OWirelessNetworkInterface::nickName() const | 506 | QString OWirelessNetworkInterface::nickName() const |
508 | { | 507 | { |
509 | char str[IW_ESSID_MAX_SIZE]; | 508 | char str[IW_ESSID_MAX_SIZE]; |
510 | _iwr.u.data.pointer = &str[0]; | 509 | _iwr.u.data.pointer = &str[0]; |
511 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 510 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
512 | if ( !wioctl( SIOCGIWNICKN ) ) | 511 | if ( !wioctl( SIOCGIWNICKN ) ) |
513 | { | 512 | { |
514 | return "<unknown>"; | 513 | return "<unknown>"; |
515 | } | 514 | } |
516 | else | 515 | else |
517 | { | 516 | { |
518 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 517 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
519 | return str; | 518 | return str; |
520 | } | 519 | } |
521 | } | 520 | } |
522 | 521 | ||
523 | 522 | ||
524 | QString OWirelessNetworkInterface::SSID() const | 523 | QString OWirelessNetworkInterface::SSID() const |
525 | { | 524 | { |
526 | char str[IW_ESSID_MAX_SIZE]; | 525 | char str[IW_ESSID_MAX_SIZE]; |
527 | _iwr.u.essid.pointer = &str[0]; | 526 | _iwr.u.essid.pointer = &str[0]; |
528 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 527 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
529 | if ( !wioctl( SIOCGIWESSID ) ) | 528 | if ( !wioctl( SIOCGIWESSID ) ) |
530 | { | 529 | { |
531 | return "<unknown>"; | 530 | return "<unknown>"; |
532 | } | 531 | } |
533 | else | 532 | else |
534 | { | 533 | { |
535 | return str; | 534 | return str; |
536 | } | 535 | } |
537 | } | 536 | } |
538 | 537 | ||
539 | 538 | ||
540 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 539 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
541 | { | 540 | { |
542 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 541 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
543 | _iwr.u.essid.length = ssid.length(); | 542 | _iwr.u.essid.length = ssid.length(); |
544 | wioctl( SIOCSIWESSID ); | 543 | wioctl( SIOCSIWESSID ); |
545 | } | 544 | } |
546 | 545 | ||
547 | 546 | ||
548 | bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const | 547 | bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const |
549 | { | 548 | { |
550 | int result = ::ioctl( _sfd, call, &iwreq ); | 549 | int result = ::ioctl( _sfd, call, &iwreq ); |
551 | if ( result == -1 ) | 550 | if ( result == -1 ) |
552 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); | 551 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); |
553 | else | 552 | else |
554 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call ); | 553 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call ); |
555 | return ( result != -1 ); | 554 | return ( result != -1 ); |
556 | } | 555 | } |
557 | 556 | ||
558 | 557 | ||
559 | bool OWirelessNetworkInterface::wioctl( int call ) const | 558 | bool OWirelessNetworkInterface::wioctl( int call ) const |
560 | { | 559 | { |
561 | strcpy( _iwr.ifr_name, (const char*) _name ); | 560 | strcpy( _iwr.ifr_name, (const char*) _name ); |
562 | return wioctl( call, _iwr ); | 561 | return wioctl( call, _iwr ); |
563 | } | 562 | } |
564 | 563 | ||
565 | 564 | ||
566 | /*====================================================================================== | 565 | /*====================================================================================== |
567 | * OMonitoringInterface | 566 | * OMonitoringInterface |
568 | *======================================================================================*/ | 567 | *======================================================================================*/ |
569 | 568 | ||
570 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) | 569 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) |
571 | :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) ) | 570 | :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) ) |
572 | { | 571 | { |
573 | } | 572 | } |
574 | 573 | ||
575 | 574 | ||
576 | OMonitoringInterface::~OMonitoringInterface() | 575 | OMonitoringInterface::~OMonitoringInterface() |
577 | { | 576 | { |
578 | } | 577 | } |
579 | 578 | ||
580 | 579 | ||
581 | void OMonitoringInterface::setChannel( int c ) | 580 | void OMonitoringInterface::setChannel( int c ) |
582 | { | 581 | { |
583 | // use standard WE channel switching protocol | 582 | // use standard WE channel switching protocol |
584 | memset( &_if->_iwr, 0, sizeof( iwreqstruct ) ); | 583 | memset( &_if->_iwr, 0, sizeof( iwreqstruct ) ); |
585 | _if->_iwr.u.freq.m = c; | 584 | _if->_iwr.u.freq.m = c; |
586 | _if->_iwr.u.freq.e = 0; | 585 | _if->_iwr.u.freq.e = 0; |
587 | _if->wioctl( SIOCSIWFREQ ); | 586 | _if->wioctl( SIOCSIWFREQ ); |
588 | } | 587 | } |
589 | 588 | ||
590 | 589 | ||
591 | bool OMonitoringInterface::enabled() const | 590 | bool OMonitoringInterface::enabled() const |
592 | { | 591 | { |
593 | return _enabled; | 592 | return _enabled; |
594 | } | 593 | } |
595 | 594 | ||
596 | void OMonitoringInterface::setEnabled( bool b ) | 595 | void OMonitoringInterface::setEnabled( bool b ) |
597 | { | 596 | { |
598 | // open a packet capturer here or leave this to | 597 | // open a packet capturer here or leave this to |
599 | // the client code? | 598 | // the client code? |
600 | 599 | ||
601 | /* | 600 | /* |
602 | 601 | ||
603 | if ( b ) | 602 | if ( b ) |
604 | { | 603 | { |
605 | OPacketCapturer* opcap = new OPacketCapturer(); | 604 | OPacketCapturer* opcap = new OPacketCapturer(); |
606 | opcap->open( _if->name() ); | 605 | opcap->open( _if->name() ); |
607 | } | 606 | } |
608 | */ | 607 | */ |
609 | 608 | ||
610 | _enabled = b; | 609 | _enabled = b; |
611 | 610 | ||
612 | } | 611 | } |
613 | 612 | ||
614 | /*====================================================================================== | 613 | /*====================================================================================== |
615 | * OCiscoMonitoringInterface | 614 | * OCiscoMonitoringInterface |
616 | *======================================================================================*/ | 615 | *======================================================================================*/ |
617 | 616 | ||
618 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) | 617 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) |
619 | :OMonitoringInterface( iface ) | 618 | :OMonitoringInterface( iface ) |
620 | { | 619 | { |
621 | iface->setMonitoring( this ); | 620 | iface->setMonitoring( this ); |
622 | } | 621 | } |
623 | 622 | ||
624 | 623 | ||
625 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 624 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
626 | { | 625 | { |
627 | } | 626 | } |
628 | 627 | ||
629 | 628 | ||
630 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 629 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
631 | { | 630 | { |
632 | QString fname; | 631 | QString fname; |
633 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 632 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
634 | QFile f( fname ); | 633 | QFile f( fname ); |
635 | if ( !f.exists() ) return; | 634 | if ( !f.exists() ) return; |
636 | 635 | ||
637 | if ( f.open( IO_WriteOnly ) ) | 636 | if ( f.open( IO_WriteOnly ) ) |
638 | { | 637 | { |
639 | QTextStream s( &f ); | 638 | QTextStream s( &f ); |
640 | s << "Mode: r"; | 639 | s << "Mode: r"; |
641 | s << "Mode: y"; | 640 | s << "Mode: y"; |
642 | s << "XmitPower: 1"; | 641 | s << "XmitPower: 1"; |
643 | 642 | ||
644 | OMonitoringInterface::setEnabled( b ); | 643 | OMonitoringInterface::setEnabled( b ); |
645 | 644 | ||
646 | } | 645 | } |
647 | 646 | ||
648 | // flushing and closing will be done automatically when f goes out of scope | 647 | // flushing and closing will be done automatically when f goes out of scope |
649 | } | 648 | } |
650 | 649 | ||
651 | 650 | ||
652 | QString OCiscoMonitoringInterface::name() const | 651 | QString OCiscoMonitoringInterface::name() const |
653 | { | 652 | { |
654 | return "cisco"; | 653 | return "cisco"; |
655 | } | 654 | } |
656 | 655 | ||
657 | 656 | ||
658 | void OCiscoMonitoringInterface::setChannel( int ) | 657 | void OCiscoMonitoringInterface::setChannel( int ) |
659 | { | 658 | { |
660 | // cisco devices automatically switch channels when in monitor mode | 659 | // cisco devices automatically switch channels when in monitor mode |
661 | } | 660 | } |
662 | 661 | ||
663 | 662 | ||
664 | /*====================================================================================== | 663 | /*====================================================================================== |
665 | * OWlanNGMonitoringInterface | 664 | * OWlanNGMonitoringInterface |
666 | *======================================================================================*/ | 665 | *======================================================================================*/ |
667 | 666 | ||
668 | 667 | ||
669 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) | 668 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) |
670 | :OMonitoringInterface( iface ) | 669 | :OMonitoringInterface( iface ) |
671 | { | 670 | { |
672 | iface->setMonitoring( this ); | 671 | iface->setMonitoring( this ); |
673 | } | 672 | } |
674 | 673 | ||
675 | 674 | ||
676 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 675 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
677 | { | 676 | { |
678 | } | 677 | } |
679 | 678 | ||
680 | 679 | ||
681 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 680 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
682 | { | 681 | { |
683 | //FIXME: do nothing if its already in the same mode | 682 | //FIXME: do nothing if its already in the same mode |
684 | 683 | ||
685 | QString enable = b ? "true" : "false"; | 684 | QString enable = b ? "true" : "false"; |
686 | QString cmd; | 685 | QString cmd; |
687 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); | 686 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); |
688 | system( cmd ); | 687 | system( cmd ); |
689 | 688 | ||
690 | OMonitoringInterface::setEnabled( b ); | 689 | OMonitoringInterface::setEnabled( b ); |
691 | } | 690 | } |
692 | 691 | ||
693 | 692 | ||
694 | QString OWlanNGMonitoringInterface::name() const | 693 | QString OWlanNGMonitoringInterface::name() const |
695 | { | 694 | { |
696 | return "wlan-ng"; | 695 | return "wlan-ng"; |
697 | } | 696 | } |
698 | 697 | ||
699 | 698 | ||
700 | void OWlanNGMonitoringInterface::setChannel( int ) | 699 | void OWlanNGMonitoringInterface::setChannel( int ) |
701 | { | 700 | { |
702 | // wlan-ng devices automatically switch channels when in monitor mode | 701 | // wlan-ng devices automatically switch channels when in monitor mode |
703 | } | 702 | } |
704 | 703 | ||
705 | 704 | ||
706 | /*====================================================================================== | 705 | /*====================================================================================== |
707 | * OHostAPMonitoringInterface | 706 | * OHostAPMonitoringInterface |
708 | *======================================================================================*/ | 707 | *======================================================================================*/ |
709 | 708 | ||
710 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) | 709 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) |
711 | :OMonitoringInterface( iface ) | 710 | :OMonitoringInterface( iface ) |
712 | { | 711 | { |
713 | iface->setMonitoring( this ); | 712 | iface->setMonitoring( this ); |
714 | } | 713 | } |
715 | 714 | ||
716 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 715 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
717 | { | 716 | { |
718 | } | 717 | } |
719 | 718 | ||
720 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 719 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
721 | { | 720 | { |
722 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 721 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
723 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 722 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
724 | 723 | ||
725 | #if WIRELESS_EXT > 14 | 724 | #if WIRELESS_EXT > 14 |
726 | _if->_iwr.u.mode = IW_MODE_MONITOR; | 725 | _if->_iwr.u.mode = IW_MODE_MONITOR; |
727 | _if->wioctl( SIOCSIWMODE ); | 726 | _if->wioctl( SIOCSIWMODE ); |
728 | #else | 727 | #else |
729 | int* args = (int*) &_if->_iwr.u.name; | 728 | int* args = (int*) &_if->_iwr.u.name; |
730 | args[0] = 2; | 729 | args[0] = 2; |
731 | args[1] = 0; | 730 | args[1] = 0; |
732 | _if->wioctl( SIOCDEVPRIVATE ); | 731 | _if->wioctl( SIOCDEVPRIVATE ); |
733 | #endif | 732 | #endif |
734 | 733 | ||
735 | OMonitoringInterface::setEnabled( b ); | 734 | OMonitoringInterface::setEnabled( b ); |
736 | } | 735 | } |
737 | 736 | ||
738 | 737 | ||
739 | QString OHostAPMonitoringInterface::name() const | 738 | QString OHostAPMonitoringInterface::name() const |
740 | { | 739 | { |
741 | return "hostap"; | 740 | return "hostap"; |
742 | } | 741 | } |
743 | 742 | ||
744 | 743 | ||
745 | /*====================================================================================== | 744 | /*====================================================================================== |
746 | * OOrinocoNetworkInterface | 745 | * OOrinocoNetworkInterface |
747 | *======================================================================================*/ | 746 | *======================================================================================*/ |
748 | 747 | ||
749 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) | 748 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) |
750 | :OMonitoringInterface( iface ) | 749 | :OMonitoringInterface( iface ) |
751 | { | 750 | { |
752 | iface->setMonitoring( this ); | 751 | iface->setMonitoring( this ); |
753 | } | 752 | } |
754 | 753 | ||
755 | 754 | ||
756 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 755 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
757 | { | 756 | { |
758 | } | 757 | } |
759 | 758 | ||
760 | 759 | ||
761 | void OOrinocoMonitoringInterface::setChannel( int c ) | 760 | void OOrinocoMonitoringInterface::setChannel( int c ) |
762 | { | 761 | { |
763 | // call iwpriv <device> monitor 2 <channel> | 762 | // call iwpriv <device> monitor 2 <channel> |
764 | int* args = (int*) &_if->_iwr.u.name; | 763 | int* args = (int*) &_if->_iwr.u.name; |
765 | args[0] = 2; | 764 | args[0] = 2; |
766 | args[1] = c; | 765 | args[1] = c; |
767 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); | 766 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); |
768 | } | 767 | } |
769 | 768 | ||
770 | 769 | ||
771 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 770 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
772 | { | 771 | { |
773 | if ( b ) | 772 | if ( b ) |
774 | { | 773 | { |
775 | setChannel( 1 ); | 774 | setChannel( 1 ); |
776 | } | 775 | } |
777 | else | 776 | else |
778 | { | 777 | { |
779 | // call iwpriv <device> monitor 0 0 | 778 | // call iwpriv <device> monitor 0 0 |
780 | int* args = (int*) &_if->_iwr.u.name; | 779 | int* args = (int*) &_if->_iwr.u.name; |
781 | args[0] = 0; | 780 | args[0] = 0; |
782 | args[1] = 0; | 781 | args[1] = 0; |
783 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); | 782 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); |
784 | } | 783 | } |
785 | 784 | ||
786 | OMonitoringInterface::setEnabled( b ); | 785 | OMonitoringInterface::setEnabled( b ); |
787 | } | 786 | } |
788 | 787 | ||
789 | 788 | ||
790 | QString OOrinocoMonitoringInterface::name() const | 789 | QString OOrinocoMonitoringInterface::name() const |
791 | { | 790 | { |
792 | return "orinoco"; | 791 | return "orinoco"; |
793 | } | 792 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 56da5f4..c544454 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,318 +1,321 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
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 <qdict.h> | 39 | #include <qdict.h> |
40 | #include <qmap.h> | 40 | #include <qmap.h> |
41 | #include <qobject.h> | 41 | #include <qobject.h> |
42 | #include <qhostaddress.h> | 42 | #include <qhostaddress.h> |
43 | 43 | ||
44 | /* OPIE */ | 44 | /* OPIE */ |
45 | 45 | ||
46 | #include <opie2/onetutils.h> | 46 | #include <opie2/onetutils.h> |
47 | 47 | ||
48 | // ML: Yeah, I hate to include kernel headers, but it's necessary here | ||
49 | // ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something | ||
50 | // ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h> | ||
51 | |||
52 | #ifndef IFNAMSIZ | 48 | #ifndef IFNAMSIZ |
53 | #define IFNAMSIZ 16 | 49 | #define IFNAMSIZ 16 |
54 | #endif | 50 | #endif |
55 | 51 | ||
56 | #include <linux/wireless.h> | 52 | // ML: Yeah, I hate to include kernel headers, but it's necessary here |
53 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> | ||
54 | // ML: which conflicts with the user header <net/if.h> | ||
55 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> | ||
56 | // ML: I will drop Jean an mail on that subject | ||
57 | |||
57 | #include <net/if.h> | 58 | #include <net/if.h> |
59 | #define _LINUX_IF_H | ||
60 | #include <linux/wireless.h> | ||
58 | 61 | ||
59 | #ifndef SIOCIWFIRSTPRIV | 62 | #ifndef SIOCIWFIRSTPRIV |
60 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | 63 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE |
61 | #endif | 64 | #endif |
62 | 65 | ||
63 | class ONetworkInterface; | 66 | class ONetworkInterface; |
64 | class OWirelessNetworkInterface; | 67 | class OWirelessNetworkInterface; |
65 | class OChannelHopper; | 68 | class OChannelHopper; |
66 | class OMonitoringInterface; | 69 | class OMonitoringInterface; |
67 | 70 | ||
68 | typedef struct ifreq ifreqstruct; | 71 | typedef struct ifreq ifreqstruct; |
69 | typedef struct iwreq iwreqstruct; | 72 | typedef struct iwreq iwreqstruct; |
70 | typedef struct iw_event iweventstruct; | 73 | typedef struct iw_event iweventstruct; |
71 | typedef struct iw_freq iwfreqstruct; | 74 | typedef struct iw_freq iwfreqstruct; |
72 | typedef struct iw_priv_args iwprivargsstruct; | 75 | typedef struct iw_priv_args iwprivargsstruct; |
73 | typedef struct iw_range iwrangestruct; | 76 | typedef struct iw_range iwrangestruct; |
74 | 77 | ||
75 | /*====================================================================================== | 78 | /*====================================================================================== |
76 | * ONetwork | 79 | * ONetwork |
77 | *======================================================================================*/ | 80 | *======================================================================================*/ |
78 | 81 | ||
79 | class ONetwork : public QObject | 82 | class ONetwork : public QObject |
80 | { | 83 | { |
81 | Q_OBJECT | 84 | Q_OBJECT |
82 | 85 | ||
83 | public: | 86 | public: |
84 | typedef QDict<ONetworkInterface> InterfaceMap; | 87 | typedef QDict<ONetworkInterface> InterfaceMap; |
85 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 88 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
86 | 89 | ||
87 | public: | 90 | public: |
88 | static ONetwork* instance(); | 91 | static ONetwork* instance(); |
89 | InterfaceIterator iterator() const; | 92 | InterfaceIterator iterator() const; |
90 | bool isWirelessInterface( const char* ) const; | 93 | bool isWirelessInterface( const char* ) const; |
91 | ONetworkInterface* interface( QString ) const; | 94 | ONetworkInterface* interface( QString ) const; |
92 | 95 | ||
93 | protected: | 96 | protected: |
94 | ONetwork(); | 97 | ONetwork(); |
95 | void synchronize(); | 98 | void synchronize(); |
96 | 99 | ||
97 | private: | 100 | private: |
98 | static ONetwork* _instance; | 101 | static ONetwork* _instance; |
99 | InterfaceMap _interfaces; | 102 | InterfaceMap _interfaces; |
100 | }; | 103 | }; |
101 | 104 | ||
102 | 105 | ||
103 | /*====================================================================================== | 106 | /*====================================================================================== |
104 | * ONetworkInterface | 107 | * ONetworkInterface |
105 | *======================================================================================*/ | 108 | *======================================================================================*/ |
106 | 109 | ||
107 | class ONetworkInterface | 110 | class ONetworkInterface |
108 | { | 111 | { |
109 | friend class OMonitoringInterface; | 112 | friend class OMonitoringInterface; |
110 | friend class OCiscoMonitoringInterface; | 113 | friend class OCiscoMonitoringInterface; |
111 | friend class OWlanNGMonitoringInterface; | 114 | friend class OWlanNGMonitoringInterface; |
112 | friend class OHostAPMonitoringInterface; | 115 | friend class OHostAPMonitoringInterface; |
113 | friend class OOrinocoMonitoringInterface; | 116 | friend class OOrinocoMonitoringInterface; |
114 | 117 | ||
115 | public: | 118 | public: |
116 | ONetworkInterface( const QString& name ); | 119 | ONetworkInterface( const QString& name ); |
117 | virtual ~ONetworkInterface(); | 120 | virtual ~ONetworkInterface(); |
118 | 121 | ||
119 | const QString& name() const; | 122 | const QString& name() const; |
120 | void setMonitoring( OMonitoringInterface* ); | 123 | void setMonitoring( OMonitoringInterface* ); |
121 | OMonitoringInterface* monitoring() const; | 124 | OMonitoringInterface* monitoring() const; |
122 | bool setPromiscuousMode( bool ); | 125 | bool setPromiscuousMode( bool ); |
123 | bool promiscuousMode() const; | 126 | bool promiscuousMode() const; |
124 | bool setUp( bool ); | 127 | bool setUp( bool ); |
125 | bool isUp() const; | 128 | bool isUp() const; |
126 | bool isLoopback() const; | 129 | bool isLoopback() const; |
127 | bool isWireless() const; | 130 | bool isWireless() const; |
128 | QString ipV4Address() const; | 131 | QString ipV4Address() const; |
129 | OMacAddress macAddress() const; | 132 | OMacAddress macAddress() const; |
130 | 133 | ||
131 | protected: | 134 | protected: |
132 | const QString _name; | 135 | const QString _name; |
133 | const int _sfd; | 136 | const int _sfd; |
134 | mutable ifreqstruct _ifr; | 137 | mutable ifreqstruct _ifr; |
135 | OMonitoringInterface* _mon; | 138 | OMonitoringInterface* _mon; |
136 | 139 | ||
137 | protected: | 140 | protected: |
138 | ifreqstruct& ifr() const; | 141 | ifreqstruct& ifr() const; |
139 | virtual void init(); | 142 | virtual void init(); |
140 | bool ioctl( int call ) const; | 143 | bool ioctl( int call ) const; |
141 | bool ioctl( int call, ifreqstruct& ) const; | 144 | bool ioctl( int call, ifreqstruct& ) const; |
142 | }; | 145 | }; |
143 | 146 | ||
144 | /*====================================================================================== | 147 | /*====================================================================================== |
145 | * OChannelHopper | 148 | * OChannelHopper |
146 | *======================================================================================*/ | 149 | *======================================================================================*/ |
147 | 150 | ||
148 | class OChannelHopper : public QObject | 151 | class OChannelHopper : public QObject |
149 | { | 152 | { |
150 | public: | 153 | public: |
151 | OChannelHopper( OWirelessNetworkInterface* ); | 154 | OChannelHopper( OWirelessNetworkInterface* ); |
152 | virtual ~OChannelHopper(); | 155 | virtual ~OChannelHopper(); |
153 | bool isActive() const; | 156 | bool isActive() const; |
154 | int channel() const; | 157 | int channel() const; |
155 | virtual void timerEvent( QTimerEvent* ); | 158 | virtual void timerEvent( QTimerEvent* ); |
156 | void setInterval( int ); | 159 | void setInterval( int ); |
157 | int interval() const; | 160 | int interval() const; |
158 | 161 | ||
159 | private: | 162 | private: |
160 | OWirelessNetworkInterface* _iface; | 163 | OWirelessNetworkInterface* _iface; |
161 | int _interval; | 164 | int _interval; |
162 | int _channel; | 165 | int _channel; |
163 | int _tid; | 166 | int _tid; |
164 | int _maxChannel; | 167 | int _maxChannel; |
165 | }; | 168 | }; |
166 | 169 | ||
167 | 170 | ||
168 | /*====================================================================================== | 171 | /*====================================================================================== |
169 | * OWirelessNetworkInterface | 172 | * OWirelessNetworkInterface |
170 | *======================================================================================*/ | 173 | *======================================================================================*/ |
171 | 174 | ||
172 | class OWirelessNetworkInterface : public ONetworkInterface | 175 | class OWirelessNetworkInterface : public ONetworkInterface |
173 | { | 176 | { |
174 | friend class OMonitoringInterface; | 177 | friend class OMonitoringInterface; |
175 | friend class OCiscoMonitoringInterface; | 178 | friend class OCiscoMonitoringInterface; |
176 | friend class OWlanNGMonitoringInterface; | 179 | friend class OWlanNGMonitoringInterface; |
177 | friend class OHostAPMonitoringInterface; | 180 | friend class OHostAPMonitoringInterface; |
178 | friend class OOrinocoMonitoringInterface; | 181 | friend class OOrinocoMonitoringInterface; |
179 | 182 | ||
180 | public: | 183 | public: |
181 | enum Mode { AdHoc, Managed, Monitor }; | 184 | enum Mode { AdHoc, Managed, Monitor }; |
182 | 185 | ||
183 | OWirelessNetworkInterface( const QString& name ); | 186 | OWirelessNetworkInterface( const QString& name ); |
184 | virtual ~OWirelessNetworkInterface(); | 187 | virtual ~OWirelessNetworkInterface(); |
185 | 188 | ||
186 | virtual void setChannel( int ) const; | 189 | virtual void setChannel( int ) const; |
187 | virtual int channel() const; | 190 | virtual int channel() const; |
188 | virtual double frequency() const; | 191 | virtual double frequency() const; |
189 | virtual int channels() const; | 192 | virtual int channels() const; |
190 | //virtual double frequency(int) const; | 193 | //virtual double frequency(int) const; |
191 | 194 | ||
192 | virtual void setMode( Mode ) {}; | 195 | virtual void setMode( Mode ) {}; |
193 | virtual bool mode() const {}; | 196 | virtual bool mode() const {}; |
194 | 197 | ||
195 | virtual void setMonitorMode( bool ); | 198 | virtual void setMonitorMode( bool ); |
196 | virtual bool monitorMode() const; | 199 | virtual bool monitorMode() const; |
197 | 200 | ||
198 | virtual void setChannelHopping( int interval = 0 ); | 201 | virtual void setChannelHopping( int interval = 0 ); |
199 | virtual int channelHopping() const; | 202 | virtual int channelHopping() const; |
200 | 203 | ||
201 | virtual void setNickName( const QString& ) {}; | 204 | virtual void setNickName( const QString& ) {}; |
202 | virtual QString nickName() const; | 205 | virtual QString nickName() const; |
203 | 206 | ||
204 | virtual bool isAssociated() const {}; | 207 | virtual bool isAssociated() const {}; |
205 | virtual QString associatedAP() const; | 208 | virtual QString associatedAP() const; |
206 | 209 | ||
207 | virtual void setSSID( const QString& ); | 210 | virtual void setSSID( const QString& ); |
208 | virtual QString SSID() const; | 211 | virtual QString SSID() const; |
209 | 212 | ||
210 | protected: | 213 | protected: |
211 | mutable iwreqstruct _iwr; | 214 | mutable iwreqstruct _iwr; |
212 | QMap<int,int> _channels; | 215 | QMap<int,int> _channels; |
213 | 216 | ||
214 | protected: | 217 | protected: |
215 | virtual void init(); | 218 | virtual void init(); |
216 | iwreqstruct& iwr() const; | 219 | iwreqstruct& iwr() const; |
217 | bool wioctl( int call ) const; | 220 | bool wioctl( int call ) const; |
218 | bool wioctl( int call, iwreqstruct& ) const; | 221 | bool wioctl( int call, iwreqstruct& ) const; |
219 | 222 | ||
220 | private: | 223 | private: |
221 | OChannelHopper* _hopper; | 224 | OChannelHopper* _hopper; |
222 | }; | 225 | }; |
223 | 226 | ||
224 | 227 | ||
225 | /*====================================================================================== | 228 | /*====================================================================================== |
226 | * OMonitoringInterface | 229 | * OMonitoringInterface |
227 | *======================================================================================*/ | 230 | *======================================================================================*/ |
228 | 231 | ||
229 | 232 | ||
230 | class OMonitoringInterface | 233 | class OMonitoringInterface |
231 | { | 234 | { |
232 | public: | 235 | public: |
233 | OMonitoringInterface(); | 236 | OMonitoringInterface(); |
234 | OMonitoringInterface( ONetworkInterface* ); | 237 | OMonitoringInterface( ONetworkInterface* ); |
235 | virtual ~OMonitoringInterface(); | 238 | virtual ~OMonitoringInterface(); |
236 | 239 | ||
237 | public: | 240 | public: |
238 | virtual void setEnabled( bool ); | 241 | virtual void setEnabled( bool ); |
239 | virtual bool enabled() const; | 242 | virtual bool enabled() const; |
240 | virtual void setChannel( int ); | 243 | virtual void setChannel( int ); |
241 | 244 | ||
242 | virtual QString name() const = 0; | 245 | virtual QString name() const = 0; |
243 | 246 | ||
244 | protected: | 247 | protected: |
245 | bool _enabled; | 248 | bool _enabled; |
246 | const OWirelessNetworkInterface* _if; | 249 | const OWirelessNetworkInterface* _if; |
247 | 250 | ||
248 | }; | 251 | }; |
249 | 252 | ||
250 | 253 | ||
251 | /*====================================================================================== | 254 | /*====================================================================================== |
252 | * OCiscoMonitoring | 255 | * OCiscoMonitoring |
253 | *======================================================================================*/ | 256 | *======================================================================================*/ |
254 | 257 | ||
255 | 258 | ||
256 | class OCiscoMonitoringInterface : public OMonitoringInterface | 259 | class OCiscoMonitoringInterface : public OMonitoringInterface |
257 | { | 260 | { |
258 | public: | 261 | public: |
259 | OCiscoMonitoringInterface( ONetworkInterface* ); | 262 | OCiscoMonitoringInterface( ONetworkInterface* ); |
260 | virtual ~OCiscoMonitoringInterface(); | 263 | virtual ~OCiscoMonitoringInterface(); |
261 | 264 | ||
262 | virtual void setEnabled( bool ); | 265 | virtual void setEnabled( bool ); |
263 | virtual QString name() const; | 266 | virtual QString name() const; |
264 | virtual void setChannel( int ); | 267 | virtual void setChannel( int ); |
265 | 268 | ||
266 | }; | 269 | }; |
267 | 270 | ||
268 | /*====================================================================================== | 271 | /*====================================================================================== |
269 | * OWlanNGMonitoringInterface | 272 | * OWlanNGMonitoringInterface |
270 | *======================================================================================*/ | 273 | *======================================================================================*/ |
271 | 274 | ||
272 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 275 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
273 | { | 276 | { |
274 | public: | 277 | public: |
275 | OWlanNGMonitoringInterface( ONetworkInterface* ); | 278 | OWlanNGMonitoringInterface( ONetworkInterface* ); |
276 | virtual ~OWlanNGMonitoringInterface(); | 279 | virtual ~OWlanNGMonitoringInterface(); |
277 | 280 | ||
278 | public: | 281 | public: |
279 | virtual void setEnabled( bool ); | 282 | virtual void setEnabled( bool ); |
280 | virtual QString name() const; | 283 | virtual QString name() const; |
281 | virtual void setChannel( int ); | 284 | virtual void setChannel( int ); |
282 | 285 | ||
283 | }; | 286 | }; |
284 | 287 | ||
285 | /*====================================================================================== | 288 | /*====================================================================================== |
286 | * OHostAPMonitoringInterface | 289 | * OHostAPMonitoringInterface |
287 | *======================================================================================*/ | 290 | *======================================================================================*/ |
288 | 291 | ||
289 | class OHostAPMonitoringInterface : public OMonitoringInterface | 292 | class OHostAPMonitoringInterface : public OMonitoringInterface |
290 | { | 293 | { |
291 | public: | 294 | public: |
292 | OHostAPMonitoringInterface( ONetworkInterface* ); | 295 | OHostAPMonitoringInterface( ONetworkInterface* ); |
293 | virtual ~OHostAPMonitoringInterface(); | 296 | virtual ~OHostAPMonitoringInterface(); |
294 | 297 | ||
295 | public: | 298 | public: |
296 | virtual void setEnabled( bool ); | 299 | virtual void setEnabled( bool ); |
297 | virtual QString name() const; | 300 | virtual QString name() const; |
298 | }; | 301 | }; |
299 | 302 | ||
300 | /*====================================================================================== | 303 | /*====================================================================================== |
301 | * OOrinocoMonitoringInterface | 304 | * OOrinocoMonitoringInterface |
302 | *======================================================================================*/ | 305 | *======================================================================================*/ |
303 | 306 | ||
304 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 307 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
305 | { | 308 | { |
306 | public: | 309 | public: |
307 | OOrinocoMonitoringInterface( ONetworkInterface* ); | 310 | OOrinocoMonitoringInterface( ONetworkInterface* ); |
308 | virtual ~OOrinocoMonitoringInterface(); | 311 | virtual ~OOrinocoMonitoringInterface(); |
309 | 312 | ||
310 | public: | 313 | public: |
311 | virtual void setChannel( int ); | 314 | virtual void setChannel( int ); |
312 | virtual void setEnabled( bool ); | 315 | virtual void setEnabled( bool ); |
313 | virtual QString name() const; | 316 | virtual QString name() const; |
314 | 317 | ||
315 | }; | 318 | }; |
316 | 319 | ||
317 | #endif // ONETWORK_H | 320 | #endif // ONETWORK_H |
318 | 321 | ||