-rw-r--r-- | libopie2/opienet/onetwork.cpp | 7 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index e916c44..73b543b 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,910 +1,917 @@ | |||
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 <net/if_arp.h> | 55 | #include <net/if_arp.h> |
56 | #include <stdarg.h> | 56 | #include <stdarg.h> |
57 | 57 | ||
58 | using namespace std; | 58 | using namespace std; |
59 | 59 | ||
60 | /*====================================================================================== | 60 | /*====================================================================================== |
61 | * ONetwork | 61 | * ONetwork |
62 | *======================================================================================*/ | 62 | *======================================================================================*/ |
63 | 63 | ||
64 | ONetwork* ONetwork::_instance = 0; | 64 | ONetwork* ONetwork::_instance = 0; |
65 | 65 | ||
66 | ONetwork::ONetwork() | 66 | ONetwork::ONetwork() |
67 | { | 67 | { |
68 | qDebug( "ONetwork::ONetwork()" ); | 68 | qDebug( "ONetwork::ONetwork()" ); |
69 | synchronize(); | 69 | synchronize(); |
70 | } | 70 | } |
71 | 71 | ||
72 | void ONetwork::synchronize() | 72 | void ONetwork::synchronize() |
73 | { | 73 | { |
74 | // gather available interfaces by inspecting /proc/net/dev | 74 | // gather available interfaces by inspecting /proc/net/dev |
75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
77 | 77 | ||
78 | _interfaces.clear(); | 78 | _interfaces.clear(); |
79 | QString str; | 79 | QString str; |
80 | QFile f( "/proc/net/dev" ); | 80 | QFile f( "/proc/net/dev" ); |
81 | bool hasFile = f.open( IO_ReadOnly ); | 81 | bool hasFile = f.open( IO_ReadOnly ); |
82 | if ( !hasFile ) | 82 | if ( !hasFile ) |
83 | { | 83 | { |
84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | QTextStream s( &f ); | 87 | QTextStream s( &f ); |
88 | s.readLine(); | 88 | s.readLine(); |
89 | s.readLine(); | 89 | s.readLine(); |
90 | while ( !s.atEnd() ) | 90 | while ( !s.atEnd() ) |
91 | { | 91 | { |
92 | s >> str; | 92 | s >> str; |
93 | str.truncate( str.find( ':' ) ); | 93 | str.truncate( str.find( ':' ) ); |
94 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 94 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
95 | ONetworkInterface* iface; | 95 | ONetworkInterface* iface; |
96 | if ( isWirelessInterface( str ) ) | 96 | if ( isWirelessInterface( str ) ) |
97 | { | 97 | { |
98 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 98 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
99 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 99 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
100 | } | 100 | } |
101 | else | 101 | else |
102 | { | 102 | { |
103 | iface = new ONetworkInterface( this, (const char*) str ); | 103 | iface = new ONetworkInterface( this, (const char*) str ); |
104 | } | 104 | } |
105 | _interfaces.insert( str, iface ); | 105 | _interfaces.insert( str, iface ); |
106 | s.readLine(); | 106 | s.readLine(); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | ONetworkInterface* ONetwork::interface( QString iface ) const | 111 | ONetworkInterface* ONetwork::interface( QString iface ) const |
112 | { | 112 | { |
113 | return _interfaces[iface]; | 113 | return _interfaces[iface]; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | ONetwork* ONetwork::instance() | 117 | ONetwork* ONetwork::instance() |
118 | { | 118 | { |
119 | if ( !_instance ) _instance = new ONetwork(); | 119 | if ( !_instance ) _instance = new ONetwork(); |
120 | return _instance; | 120 | return _instance; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | ONetwork::InterfaceIterator ONetwork::iterator() const | 124 | ONetwork::InterfaceIterator ONetwork::iterator() const |
125 | { | 125 | { |
126 | return ONetwork::InterfaceIterator( _interfaces ); | 126 | return ONetwork::InterfaceIterator( _interfaces ); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | bool ONetwork::isWirelessInterface( const char* name ) const | 130 | bool ONetwork::isWirelessInterface( const char* name ) const |
131 | { | 131 | { |
132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
133 | struct iwreq iwr; | 133 | struct iwreq iwr; |
134 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 134 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
135 | strcpy( (char*) &iwr.ifr_name, name ); | 135 | strcpy( (char*) &iwr.ifr_name, name ); |
136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
137 | return result != -1; | 137 | return result != -1; |
138 | } | 138 | } |
139 | 139 | ||
140 | /*====================================================================================== | 140 | /*====================================================================================== |
141 | * ONetworkInterface | 141 | * ONetworkInterface |
142 | *======================================================================================*/ | 142 | *======================================================================================*/ |
143 | 143 | ||
144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
145 | :QObject( parent, name ), | 145 | :QObject( parent, name ), |
146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
147 | { | 147 | { |
148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
149 | init(); | 149 | init(); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | struct ifreq& ONetworkInterface::ifr() const | 153 | struct ifreq& ONetworkInterface::ifr() const |
154 | { | 154 | { |
155 | return _ifr; | 155 | return _ifr; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | void ONetworkInterface::init() | 159 | void ONetworkInterface::init() |
160 | { | 160 | { |
161 | qDebug( "ONetworkInterface::init()" ); | 161 | qDebug( "ONetworkInterface::init()" ); |
162 | 162 | ||
163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
164 | 164 | ||
165 | if ( _sfd == -1 ) | 165 | if ( _sfd == -1 ) |
166 | { | 166 | { |
167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); | 167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 173 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
174 | { | 174 | { |
175 | int result = ::ioctl( _sfd, call, &ifreq ); | 175 | int result = ::ioctl( _sfd, call, &ifreq ); |
176 | if ( result == -1 ) | 176 | if ( result == -1 ) |
177 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); | 177 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); |
178 | else | 178 | else |
179 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); | 179 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); |
180 | return ( result != -1 ); | 180 | return ( result != -1 ); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | bool ONetworkInterface::ioctl( int call ) const | 184 | bool ONetworkInterface::ioctl( int call ) const |
185 | { | 185 | { |
186 | strcpy( _ifr.ifr_name, name() ); | 186 | strcpy( _ifr.ifr_name, name() ); |
187 | return ioctl( call, _ifr ); | 187 | return ioctl( call, _ifr ); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | bool ONetworkInterface::isLoopback() const | 191 | bool ONetworkInterface::isLoopback() const |
192 | { | 192 | { |
193 | ioctl( SIOCGIFFLAGS ); | 193 | ioctl( SIOCGIFFLAGS ); |
194 | return _ifr.ifr_flags & IFF_LOOPBACK; | 194 | return _ifr.ifr_flags & IFF_LOOPBACK; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | bool ONetworkInterface::setUp( bool b ) | 198 | bool ONetworkInterface::setUp( bool b ) |
199 | { | 199 | { |
200 | ioctl( SIOCGIFFLAGS ); | 200 | ioctl( SIOCGIFFLAGS ); |
201 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 201 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
202 | else _ifr.ifr_flags &= (~IFF_UP); | 202 | else _ifr.ifr_flags &= (~IFF_UP); |
203 | return ioctl( SIOCSIFFLAGS ); | 203 | return ioctl( SIOCSIFFLAGS ); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | bool ONetworkInterface::isUp() const | 207 | bool ONetworkInterface::isUp() const |
208 | { | 208 | { |
209 | ioctl( SIOCGIFFLAGS ); | 209 | ioctl( SIOCGIFFLAGS ); |
210 | return _ifr.ifr_flags & IFF_UP; | 210 | return _ifr.ifr_flags & IFF_UP; |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | QString ONetworkInterface::ipV4Address() const | 214 | QString ONetworkInterface::ipV4Address() const |
215 | { | 215 | { |
216 | if ( ioctl( SIOCGIFADDR ) ) | 216 | if ( ioctl( SIOCGIFADDR ) ) |
217 | { | 217 | { |
218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
219 | //FIXME: Use QHostAddress here | 219 | //FIXME: Use QHostAddress here |
220 | return QString( inet_ntoa( sa->sin_addr ) ); | 220 | return QString( inet_ntoa( sa->sin_addr ) ); |
221 | } | 221 | } |
222 | else | 222 | else |
223 | return "<unknown>"; | 223 | return "<unknown>"; |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 227 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
228 | { | 228 | { |
229 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 229 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
230 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 230 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
231 | ioctl( SIOCSIFHWADDR ); | 231 | ioctl( SIOCSIFHWADDR ); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | OMacAddress ONetworkInterface::macAddress() const | 235 | OMacAddress ONetworkInterface::macAddress() const |
236 | { | 236 | { |
237 | if ( ioctl( SIOCGIFHWADDR ) ) | 237 | if ( ioctl( SIOCGIFHWADDR ) ) |
238 | { | 238 | { |
239 | return OMacAddress( _ifr ); | 239 | return OMacAddress( _ifr ); |
240 | } | 240 | } |
241 | else | 241 | else |
242 | { | 242 | { |
243 | return OMacAddress::unknown; | 243 | return OMacAddress::unknown; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | int ONetworkInterface::dataLinkType() const | 248 | int ONetworkInterface::dataLinkType() const |
249 | { | 249 | { |
250 | if ( ioctl( SIOCGIFHWADDR ) ) | 250 | if ( ioctl( SIOCGIFHWADDR ) ) |
251 | { | 251 | { |
252 | return _ifr.ifr_hwaddr.sa_family; | 252 | return _ifr.ifr_hwaddr.sa_family; |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | return -1; | 256 | return -1; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 261 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
262 | { | 262 | { |
263 | _mon = m; | 263 | _mon = m; |
264 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 264 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | OMonitoringInterface* ONetworkInterface::monitoring() const | 268 | OMonitoringInterface* ONetworkInterface::monitoring() const |
269 | { | 269 | { |
270 | return _mon; | 270 | return _mon; |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | ONetworkInterface::~ONetworkInterface() | 274 | ONetworkInterface::~ONetworkInterface() |
275 | { | 275 | { |
276 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 276 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
277 | if ( _sfd != -1 ) ::close( _sfd ); | 277 | if ( _sfd != -1 ) ::close( _sfd ); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 281 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
282 | { | 282 | { |
283 | ioctl( SIOCGIFFLAGS ); | 283 | ioctl( SIOCGIFFLAGS ); |
284 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 284 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
285 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 285 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
286 | return ioctl( SIOCSIFFLAGS ); | 286 | return ioctl( SIOCSIFFLAGS ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | bool ONetworkInterface::promiscuousMode() const | 290 | bool ONetworkInterface::promiscuousMode() const |
291 | { | 291 | { |
292 | ioctl( SIOCGIFFLAGS ); | 292 | ioctl( SIOCGIFFLAGS ); |
293 | return _ifr.ifr_flags & IFF_PROMISC; | 293 | return _ifr.ifr_flags & IFF_PROMISC; |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | bool ONetworkInterface::isWireless() const | 297 | bool ONetworkInterface::isWireless() const |
298 | { | 298 | { |
299 | return ioctl( SIOCGIWNAME ); | 299 | return ioctl( SIOCGIWNAME ); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | /*====================================================================================== | 303 | /*====================================================================================== |
304 | * OChannelHopper | 304 | * OChannelHopper |
305 | *======================================================================================*/ | 305 | *======================================================================================*/ |
306 | 306 | ||
307 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 307 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
308 | :QObject( 0, "Mickey's funky hopper" ), | 308 | :QObject( 0, "Mickey's funky hopper" ), |
309 | _iface( iface ), _interval( 0 ), _tid( 0 ) | 309 | _iface( iface ), _interval( 0 ), _tid( 0 ) |
310 | { | 310 | { |
311 | int _maxChannel = iface->channels()+1; | 311 | int _maxChannel = iface->channels()+1; |
312 | // generate fancy hopping sequence honoring the device capabilities | 312 | // generate fancy hopping sequence honoring the device capabilities |
313 | if ( _maxChannel >= 1 ) _channels.append( 1 ); | 313 | if ( _maxChannel >= 1 ) _channels.append( 1 ); |
314 | if ( _maxChannel >= 7 ) _channels.append( 7 ); | 314 | if ( _maxChannel >= 7 ) _channels.append( 7 ); |
315 | if ( _maxChannel >= 13 ) _channels.append( 13 ); | 315 | if ( _maxChannel >= 13 ) _channels.append( 13 ); |
316 | if ( _maxChannel >= 2 ) _channels.append( 2 ); | 316 | if ( _maxChannel >= 2 ) _channels.append( 2 ); |
317 | if ( _maxChannel >= 8 ) _channels.append( 8 ); | 317 | if ( _maxChannel >= 8 ) _channels.append( 8 ); |
318 | if ( _maxChannel >= 3 ) _channels.append( 3 ); | 318 | if ( _maxChannel >= 3 ) _channels.append( 3 ); |
319 | if ( _maxChannel >= 14 ) _channels.append( 14 ); | 319 | if ( _maxChannel >= 14 ) _channels.append( 14 ); |
320 | if ( _maxChannel >= 9 ) _channels.append( 9 ); | 320 | if ( _maxChannel >= 9 ) _channels.append( 9 ); |
321 | if ( _maxChannel >= 4 ) _channels.append( 4 ); | 321 | if ( _maxChannel >= 4 ) _channels.append( 4 ); |
322 | if ( _maxChannel >= 10 ) _channels.append( 10 ); | 322 | if ( _maxChannel >= 10 ) _channels.append( 10 ); |
323 | if ( _maxChannel >= 5 ) _channels.append( 5 ); | 323 | if ( _maxChannel >= 5 ) _channels.append( 5 ); |
324 | if ( _maxChannel >= 11 ) _channels.append( 11 ); | 324 | if ( _maxChannel >= 11 ) _channels.append( 11 ); |
325 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 325 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
326 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 326 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
327 | _channel = _channels.begin(); | 327 | _channel = _channels.begin(); |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | OChannelHopper::~OChannelHopper() | 332 | OChannelHopper::~OChannelHopper() |
333 | { | 333 | { |
334 | } | 334 | } |
335 | 335 | ||
336 | 336 | ||
337 | bool OChannelHopper::isActive() const | 337 | bool OChannelHopper::isActive() const |
338 | { | 338 | { |
339 | return _tid; | 339 | return _tid; |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | int OChannelHopper::channel() const | 343 | int OChannelHopper::channel() const |
344 | { | 344 | { |
345 | return *_channel; | 345 | return *_channel; |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | void OChannelHopper::timerEvent( QTimerEvent* ) | 349 | void OChannelHopper::timerEvent( QTimerEvent* ) |
350 | { | 350 | { |
351 | _iface->setChannel( *_channel ); | 351 | _iface->setChannel( *_channel ); |
352 | emit( hopped( *_channel ) ); | ||
352 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", | 353 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", |
353 | *_channel, (const char*) _iface->name() ); | 354 | *_channel, (const char*) _iface->name() ); |
354 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 355 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
355 | } | 356 | } |
356 | 357 | ||
357 | 358 | ||
358 | void OChannelHopper::setInterval( int interval ) | 359 | void OChannelHopper::setInterval( int interval ) |
359 | { | 360 | { |
360 | if ( interval == _interval ) | 361 | if ( interval == _interval ) |
361 | return; | 362 | return; |
362 | 363 | ||
363 | if ( _interval ) | 364 | if ( _interval ) |
364 | killTimer( _tid ); | 365 | killTimer( _tid ); |
365 | 366 | ||
366 | _tid = 0; | 367 | _tid = 0; |
367 | _interval = interval; | 368 | _interval = interval; |
368 | 369 | ||
369 | if ( _interval ) | 370 | if ( _interval ) |
370 | { | 371 | { |
371 | _tid = startTimer( interval ); | 372 | _tid = startTimer( interval ); |
372 | } | 373 | } |
373 | } | 374 | } |
374 | 375 | ||
375 | 376 | ||
376 | int OChannelHopper::interval() const | 377 | int OChannelHopper::interval() const |
377 | { | 378 | { |
378 | return _interval; | 379 | return _interval; |
379 | } | 380 | } |
380 | 381 | ||
381 | 382 | ||
382 | /*====================================================================================== | 383 | /*====================================================================================== |
383 | * OWirelessNetworkInterface | 384 | * OWirelessNetworkInterface |
384 | *======================================================================================*/ | 385 | *======================================================================================*/ |
385 | 386 | ||
386 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 387 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
387 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 388 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
388 | { | 389 | { |
389 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 390 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); |
390 | init(); | 391 | init(); |
391 | } | 392 | } |
392 | 393 | ||
393 | 394 | ||
394 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 395 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
395 | { | 396 | { |
396 | } | 397 | } |
397 | 398 | ||
398 | 399 | ||
399 | struct iwreq& OWirelessNetworkInterface::iwr() const | 400 | struct iwreq& OWirelessNetworkInterface::iwr() const |
400 | { | 401 | { |
401 | return _iwr; | 402 | return _iwr; |
402 | } | 403 | } |
403 | 404 | ||
404 | 405 | ||
405 | void OWirelessNetworkInterface::init() | 406 | void OWirelessNetworkInterface::init() |
406 | { | 407 | { |
407 | qDebug( "OWirelessNetworkInterface::init()" ); | 408 | qDebug( "OWirelessNetworkInterface::init()" ); |
408 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 409 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
409 | buildChannelList(); | 410 | buildChannelList(); |
410 | buildPrivateList(); | 411 | buildPrivateList(); |
411 | } | 412 | } |
412 | 413 | ||
413 | 414 | ||
414 | QString OWirelessNetworkInterface::associatedAP() const | 415 | QString OWirelessNetworkInterface::associatedAP() const |
415 | { | 416 | { |
416 | //FIXME: use OMacAddress | 417 | //FIXME: use OMacAddress |
417 | QString mac; | 418 | QString mac; |
418 | 419 | ||
419 | if ( ioctl( SIOCGIWAP ) ) | 420 | if ( ioctl( SIOCGIWAP ) ) |
420 | { | 421 | { |
421 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 422 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
422 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | 423 | _ifr.ifr_hwaddr.sa_data[0]&0xff, |
423 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | 424 | _ifr.ifr_hwaddr.sa_data[1]&0xff, |
424 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | 425 | _ifr.ifr_hwaddr.sa_data[2]&0xff, |
425 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | 426 | _ifr.ifr_hwaddr.sa_data[3]&0xff, |
426 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | 427 | _ifr.ifr_hwaddr.sa_data[4]&0xff, |
427 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | 428 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); |
428 | } | 429 | } |
429 | else | 430 | else |
430 | { | 431 | { |
431 | mac = "<Unknown>"; | 432 | mac = "<Unknown>"; |
432 | } | 433 | } |
433 | return mac; | 434 | return mac; |
434 | } | 435 | } |
435 | 436 | ||
436 | 437 | ||
437 | void OWirelessNetworkInterface::buildChannelList() | 438 | void OWirelessNetworkInterface::buildChannelList() |
438 | { | 439 | { |
439 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 440 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
440 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 441 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
441 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 442 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
442 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 443 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
443 | //ML: _too much_ space. This is damn shitty crap *sigh* | 444 | //ML: _too much_ space. This is damn shitty crap *sigh* |
444 | //ML: We allocate a large memory region in RAM and check whether the | 445 | //ML: We allocate a large memory region in RAM and check whether the |
445 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 446 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
446 | //ML: so please forward this... | 447 | //ML: so please forward this... |
447 | 448 | ||
448 | struct iwreq wrq; | 449 | struct iwreq wrq; |
449 | int len = sizeof( struct iw_range )*2; | 450 | int len = sizeof( struct iw_range )*2; |
450 | char *buffer = (char*) malloc( len ); | 451 | char *buffer = (char*) malloc( len ); |
451 | //FIXME: Validate if we actually got the memory block | 452 | //FIXME: Validate if we actually got the memory block |
452 | memset( buffer, 0, len ); | 453 | memset( buffer, 0, len ); |
453 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 454 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
454 | wrq.u.data.pointer = (caddr_t) buffer; | 455 | wrq.u.data.pointer = (caddr_t) buffer; |
455 | wrq.u.data.length = sizeof( struct iw_range ); | 456 | wrq.u.data.length = sizeof( struct iw_range ); |
456 | wrq.u.data.flags = 0; | 457 | wrq.u.data.flags = 0; |
457 | 458 | ||
458 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 459 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
459 | { | 460 | { |
460 | qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) ); | 461 | qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) ); |
461 | _channels.insert( 2412, 1 ); // 2.412 GHz | 462 | _channels.insert( 2412, 1 ); // 2.412 GHz |
462 | _channels.insert( 2417, 2 ); // 2.417 GHz | 463 | _channels.insert( 2417, 2 ); // 2.417 GHz |
463 | _channels.insert( 2422, 3 ); // 2.422 GHz | 464 | _channels.insert( 2422, 3 ); // 2.422 GHz |
464 | _channels.insert( 2427, 4 ); // 2.427 GHz | 465 | _channels.insert( 2427, 4 ); // 2.427 GHz |
465 | _channels.insert( 2432, 5 ); // 2.432 GHz | 466 | _channels.insert( 2432, 5 ); // 2.432 GHz |
466 | _channels.insert( 2437, 6 ); // 2.437 GHz | 467 | _channels.insert( 2437, 6 ); // 2.437 GHz |
467 | _channels.insert( 2442, 7 ); // 2.442 GHz | 468 | _channels.insert( 2442, 7 ); // 2.442 GHz |
468 | _channels.insert( 2447, 8 ); // 2.447 GHz | 469 | _channels.insert( 2447, 8 ); // 2.447 GHz |
469 | _channels.insert( 2452, 9 ); // 2.452 GHz | 470 | _channels.insert( 2452, 9 ); // 2.452 GHz |
470 | _channels.insert( 2457, 10 ); // 2.457 GHz | 471 | _channels.insert( 2457, 10 ); // 2.457 GHz |
471 | _channels.insert( 2462, 11 ); // 2.462 GHz | 472 | _channels.insert( 2462, 11 ); // 2.462 GHz |
472 | } | 473 | } |
473 | else | 474 | else |
474 | { | 475 | { |
475 | // <check if the driver overwrites stuff> | 476 | // <check if the driver overwrites stuff> |
476 | int max = 0; | 477 | int max = 0; |
477 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 478 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
478 | if (buffer[r] != 0) | 479 | if (buffer[r] != 0) |
479 | max = r; | 480 | max = r; |
480 | if (max > 0) | 481 | if (max > 0) |
481 | { | 482 | { |
482 | qWarning( "OWirelessNetworkInterface::buildChannelList(): Driver for wireless interface '%s'" | 483 | qWarning( "OWirelessNetworkInterface::buildChannelList(): Driver for wireless interface '%s'" |
483 | "overwrote buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); | 484 | "overwrote buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); |
484 | } | 485 | } |
485 | // </check if the driver overwrites stuff> | 486 | // </check if the driver overwrites stuff> |
486 | 487 | ||
487 | struct iw_range range; | 488 | struct iw_range range; |
488 | memcpy( &range, buffer, sizeof range ); | 489 | memcpy( &range, buffer, sizeof range ); |
489 | 490 | ||
490 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency ); | 491 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency ); |
491 | for ( int i = 0; i < range.num_frequency; ++i ) | 492 | for ( int i = 0; i < range.num_frequency; ++i ) |
492 | { | 493 | { |
493 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 494 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
494 | _channels.insert( freq, i+1 ); | 495 | _channels.insert( freq, i+1 ); |
495 | } | 496 | } |
496 | } | 497 | } |
497 | 498 | ||
498 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Channel list constructed." ); | 499 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Channel list constructed." ); |
499 | free(buffer); | 500 | free(buffer); |
500 | } | 501 | } |
501 | 502 | ||
502 | 503 | ||
503 | void OWirelessNetworkInterface::buildPrivateList() | 504 | void OWirelessNetworkInterface::buildPrivateList() |
504 | { | 505 | { |
505 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); | 506 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); |
506 | 507 | ||
507 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 508 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
508 | 509 | ||
509 | _iwr.u.data.pointer = (char*) &priv; | 510 | _iwr.u.data.pointer = (char*) &priv; |
510 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 511 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
511 | _iwr.u.data.flags = 0; | 512 | _iwr.u.data.flags = 0; |
512 | 513 | ||
513 | if ( !wioctl( SIOCGIWPRIV ) ) | 514 | if ( !wioctl( SIOCGIWPRIV ) ) |
514 | { | 515 | { |
515 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); | 516 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); |
516 | return; | 517 | return; |
517 | } | 518 | } |
518 | 519 | ||
519 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 520 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
520 | { | 521 | { |
521 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 522 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
522 | } | 523 | } |
523 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); | 524 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); |
524 | } | 525 | } |
525 | 526 | ||
526 | 527 | ||
527 | int OWirelessNetworkInterface::channel() const | 528 | int OWirelessNetworkInterface::channel() const |
528 | { | 529 | { |
529 | //FIXME: When monitoring enabled, then use it | 530 | //FIXME: When monitoring enabled, then use it |
530 | //FIXME: to gather the current RF channel | 531 | //FIXME: to gather the current RF channel |
531 | //FIXME: Until then, get active channel from hopper. | 532 | //FIXME: Until then, get active channel from hopper. |
532 | if ( _hopper && _hopper->isActive() ) | 533 | if ( _hopper && _hopper->isActive() ) |
533 | return _hopper->channel(); | 534 | return _hopper->channel(); |
534 | 535 | ||
535 | if ( !wioctl( SIOCGIWFREQ ) ) | 536 | if ( !wioctl( SIOCGIWFREQ ) ) |
536 | { | 537 | { |
537 | return -1; | 538 | return -1; |
538 | } | 539 | } |
539 | else | 540 | else |
540 | { | 541 | { |
541 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 542 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
542 | } | 543 | } |
543 | } | 544 | } |
544 | 545 | ||
545 | 546 | ||
546 | void OWirelessNetworkInterface::setChannel( int c ) const | 547 | void OWirelessNetworkInterface::setChannel( int c ) const |
547 | { | 548 | { |
548 | if ( !_mon ) | 549 | if ( !_mon ) |
549 | { | 550 | { |
550 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 551 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
551 | _iwr.u.freq.m = c; | 552 | _iwr.u.freq.m = c; |
552 | _iwr.u.freq.e = 0; | 553 | _iwr.u.freq.e = 0; |
553 | wioctl( SIOCSIWFREQ ); | 554 | wioctl( SIOCSIWFREQ ); |
554 | } | 555 | } |
555 | else | 556 | else |
556 | { | 557 | { |
557 | _mon->setChannel( c ); | 558 | _mon->setChannel( c ); |
558 | } | 559 | } |
559 | } | 560 | } |
560 | 561 | ||
561 | 562 | ||
562 | double OWirelessNetworkInterface::frequency() const | 563 | double OWirelessNetworkInterface::frequency() const |
563 | { | 564 | { |
564 | if ( !wioctl( SIOCGIWFREQ ) ) | 565 | if ( !wioctl( SIOCGIWFREQ ) ) |
565 | { | 566 | { |
566 | return -1.0; | 567 | return -1.0; |
567 | } | 568 | } |
568 | else | 569 | else |
569 | { | 570 | { |
570 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 571 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
571 | } | 572 | } |
572 | } | 573 | } |
573 | 574 | ||
574 | 575 | ||
575 | int OWirelessNetworkInterface::channels() const | 576 | int OWirelessNetworkInterface::channels() const |
576 | { | 577 | { |
577 | return _channels.count(); | 578 | return _channels.count(); |
578 | } | 579 | } |
579 | 580 | ||
580 | 581 | ||
581 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 582 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
582 | { | 583 | { |
583 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 584 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
584 | _hopper->setInterval( interval ); | 585 | _hopper->setInterval( interval ); |
585 | //FIXME: When and by whom will the channel hopper be deleted? | 586 | //FIXME: When and by whom will the channel hopper be deleted? |
586 | //TODO: rely on QObject hierarchy | 587 | //TODO: rely on QObject hierarchy |
587 | } | 588 | } |
588 | 589 | ||
589 | 590 | ||
590 | int OWirelessNetworkInterface::channelHopping() const | 591 | int OWirelessNetworkInterface::channelHopping() const |
591 | { | 592 | { |
592 | return _hopper->interval(); | 593 | return _hopper->interval(); |
593 | } | 594 | } |
594 | 595 | ||
595 | 596 | ||
597 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | ||
598 | { | ||
599 | return _hopper; | ||
600 | } | ||
601 | |||
602 | |||
596 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 603 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
597 | { | 604 | { |
598 | if ( _mon ) | 605 | if ( _mon ) |
599 | _mon->setEnabled( b ); | 606 | _mon->setEnabled( b ); |
600 | else | 607 | else |
601 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 608 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
602 | } | 609 | } |
603 | 610 | ||
604 | 611 | ||
605 | bool OWirelessNetworkInterface::monitorMode() const | 612 | bool OWirelessNetworkInterface::monitorMode() const |
606 | { | 613 | { |
607 | qDebug( "dataLinkType = %d", dataLinkType() ); | 614 | qDebug( "dataLinkType = %d", dataLinkType() ); |
608 | return dataLinkType() == ARPHRD_IEEE80211; | 615 | return dataLinkType() == ARPHRD_IEEE80211; |
609 | } | 616 | } |
610 | 617 | ||
611 | 618 | ||
612 | QString OWirelessNetworkInterface::nickName() const | 619 | QString OWirelessNetworkInterface::nickName() const |
613 | { | 620 | { |
614 | char str[IW_ESSID_MAX_SIZE]; | 621 | char str[IW_ESSID_MAX_SIZE]; |
615 | _iwr.u.data.pointer = &str[0]; | 622 | _iwr.u.data.pointer = &str[0]; |
616 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 623 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
617 | if ( !wioctl( SIOCGIWNICKN ) ) | 624 | if ( !wioctl( SIOCGIWNICKN ) ) |
618 | { | 625 | { |
619 | return "<unknown>"; | 626 | return "<unknown>"; |
620 | } | 627 | } |
621 | else | 628 | else |
622 | { | 629 | { |
623 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 630 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
624 | return str; | 631 | return str; |
625 | } | 632 | } |
626 | } | 633 | } |
627 | 634 | ||
628 | 635 | ||
629 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 636 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
630 | { | 637 | { |
631 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 638 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
632 | if ( !priv ) | 639 | if ( !priv ) |
633 | { | 640 | { |
634 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); | 641 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); |
635 | return; | 642 | return; |
636 | } | 643 | } |
637 | if ( priv->numberSetArgs() != numargs ) | 644 | if ( priv->numberSetArgs() != numargs ) |
638 | { | 645 | { |
639 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); | 646 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); |
640 | return; | 647 | return; |
641 | } | 648 | } |
642 | 649 | ||
643 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); | 650 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); |
644 | memset( &_iwr, 0, sizeof _iwr ); | 651 | memset( &_iwr, 0, sizeof _iwr ); |
645 | va_list argp; | 652 | va_list argp; |
646 | va_start( argp, numargs ); | 653 | va_start( argp, numargs ); |
647 | for ( int i = 0; i < numargs; ++i ) | 654 | for ( int i = 0; i < numargs; ++i ) |
648 | { | 655 | { |
649 | priv->setParameter( i, va_arg( argp, int ) ); | 656 | priv->setParameter( i, va_arg( argp, int ) ); |
650 | } | 657 | } |
651 | va_end( argp ); | 658 | va_end( argp ); |
652 | priv->invoke(); | 659 | priv->invoke(); |
653 | } | 660 | } |
654 | 661 | ||
655 | 662 | ||
656 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 663 | void OWirelessNetworkInterface::getPrivate( const QString& call ) |
657 | { | 664 | { |
658 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); | 665 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); |
659 | } | 666 | } |
660 | 667 | ||
661 | 668 | ||
662 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 669 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
663 | { | 670 | { |
664 | return child( (const char*) call ); | 671 | return child( (const char*) call ); |
665 | } | 672 | } |
666 | 673 | ||
667 | 674 | ||
668 | QString OWirelessNetworkInterface::SSID() const | 675 | QString OWirelessNetworkInterface::SSID() const |
669 | { | 676 | { |
670 | char str[IW_ESSID_MAX_SIZE]; | 677 | char str[IW_ESSID_MAX_SIZE]; |
671 | _iwr.u.essid.pointer = &str[0]; | 678 | _iwr.u.essid.pointer = &str[0]; |
672 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 679 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
673 | if ( !wioctl( SIOCGIWESSID ) ) | 680 | if ( !wioctl( SIOCGIWESSID ) ) |
674 | { | 681 | { |
675 | return "<unknown>"; | 682 | return "<unknown>"; |
676 | } | 683 | } |
677 | else | 684 | else |
678 | { | 685 | { |
679 | return str; | 686 | return str; |
680 | } | 687 | } |
681 | } | 688 | } |
682 | 689 | ||
683 | 690 | ||
684 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 691 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
685 | { | 692 | { |
686 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 693 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
687 | _iwr.u.essid.length = ssid.length(); | 694 | _iwr.u.essid.length = ssid.length(); |
688 | wioctl( SIOCSIWESSID ); | 695 | wioctl( SIOCSIWESSID ); |
689 | } | 696 | } |
690 | 697 | ||
691 | 698 | ||
692 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 699 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
693 | { | 700 | { |
694 | int result = ::ioctl( _sfd, call, &iwreq ); | 701 | int result = ::ioctl( _sfd, call, &iwreq ); |
695 | if ( result == -1 ) | 702 | if ( result == -1 ) |
696 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); | 703 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); |
697 | else | 704 | else |
698 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); | 705 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); |
699 | return ( result != -1 ); | 706 | return ( result != -1 ); |
700 | } | 707 | } |
701 | 708 | ||
702 | 709 | ||
703 | bool OWirelessNetworkInterface::wioctl( int call ) const | 710 | bool OWirelessNetworkInterface::wioctl( int call ) const |
704 | { | 711 | { |
705 | strcpy( _iwr.ifr_name, name() ); | 712 | strcpy( _iwr.ifr_name, name() ); |
706 | return wioctl( call, _iwr ); | 713 | return wioctl( call, _iwr ); |
707 | } | 714 | } |
708 | 715 | ||
709 | 716 | ||
710 | /*====================================================================================== | 717 | /*====================================================================================== |
711 | * OMonitoringInterface | 718 | * OMonitoringInterface |
712 | *======================================================================================*/ | 719 | *======================================================================================*/ |
713 | 720 | ||
714 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) | 721 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) |
715 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ) | 722 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ) |
716 | { | 723 | { |
717 | } | 724 | } |
718 | 725 | ||
719 | 726 | ||
720 | OMonitoringInterface::~OMonitoringInterface() | 727 | OMonitoringInterface::~OMonitoringInterface() |
721 | { | 728 | { |
722 | } | 729 | } |
723 | 730 | ||
724 | 731 | ||
725 | void OMonitoringInterface::setChannel( int c ) | 732 | void OMonitoringInterface::setChannel( int c ) |
726 | { | 733 | { |
727 | // use standard WE channel switching protocol | 734 | // use standard WE channel switching protocol |
728 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 735 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
729 | _if->_iwr.u.freq.m = c; | 736 | _if->_iwr.u.freq.m = c; |
730 | _if->_iwr.u.freq.e = 0; | 737 | _if->_iwr.u.freq.e = 0; |
731 | _if->wioctl( SIOCSIWFREQ ); | 738 | _if->wioctl( SIOCSIWFREQ ); |
732 | } | 739 | } |
733 | 740 | ||
734 | 741 | ||
735 | bool OMonitoringInterface::enabled() const | 742 | bool OMonitoringInterface::enabled() const |
736 | { | 743 | { |
737 | return _if->monitorMode(); | 744 | return _if->monitorMode(); |
738 | } | 745 | } |
739 | 746 | ||
740 | 747 | ||
741 | void OMonitoringInterface::setEnabled( bool b ) | 748 | void OMonitoringInterface::setEnabled( bool b ) |
742 | { | 749 | { |
743 | } | 750 | } |
744 | 751 | ||
745 | 752 | ||
746 | /*====================================================================================== | 753 | /*====================================================================================== |
747 | * OCiscoMonitoringInterface | 754 | * OCiscoMonitoringInterface |
748 | *======================================================================================*/ | 755 | *======================================================================================*/ |
749 | 756 | ||
750 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) | 757 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) |
751 | :OMonitoringInterface( iface ) | 758 | :OMonitoringInterface( iface ) |
752 | { | 759 | { |
753 | iface->setMonitoring( this ); | 760 | iface->setMonitoring( this ); |
754 | } | 761 | } |
755 | 762 | ||
756 | 763 | ||
757 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 764 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
758 | { | 765 | { |
759 | } | 766 | } |
760 | 767 | ||
761 | 768 | ||
762 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 769 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
763 | { | 770 | { |
764 | QString fname; | 771 | QString fname; |
765 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 772 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
766 | QFile f( fname ); | 773 | QFile f( fname ); |
767 | if ( !f.exists() ) return; | 774 | if ( !f.exists() ) return; |
768 | 775 | ||
769 | if ( f.open( IO_WriteOnly ) ) | 776 | if ( f.open( IO_WriteOnly ) ) |
770 | { | 777 | { |
771 | QTextStream s( &f ); | 778 | QTextStream s( &f ); |
772 | s << "Mode: r"; | 779 | s << "Mode: r"; |
773 | s << "Mode: y"; | 780 | s << "Mode: y"; |
774 | s << "XmitPower: 1"; | 781 | s << "XmitPower: 1"; |
775 | } | 782 | } |
776 | 783 | ||
777 | // flushing and closing will be done automatically when f goes out of scope | 784 | // flushing and closing will be done automatically when f goes out of scope |
778 | } | 785 | } |
779 | 786 | ||
780 | 787 | ||
781 | QString OCiscoMonitoringInterface::name() const | 788 | QString OCiscoMonitoringInterface::name() const |
782 | { | 789 | { |
783 | return "cisco"; | 790 | return "cisco"; |
784 | } | 791 | } |
785 | 792 | ||
786 | 793 | ||
787 | void OCiscoMonitoringInterface::setChannel( int ) | 794 | void OCiscoMonitoringInterface::setChannel( int ) |
788 | { | 795 | { |
789 | // cisco devices automatically switch channels when in monitor mode | 796 | // cisco devices automatically switch channels when in monitor mode |
790 | } | 797 | } |
791 | 798 | ||
792 | 799 | ||
793 | /*====================================================================================== | 800 | /*====================================================================================== |
794 | * OWlanNGMonitoringInterface | 801 | * OWlanNGMonitoringInterface |
795 | *======================================================================================*/ | 802 | *======================================================================================*/ |
796 | 803 | ||
797 | 804 | ||
798 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) | 805 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) |
799 | :OMonitoringInterface( iface ) | 806 | :OMonitoringInterface( iface ) |
800 | { | 807 | { |
801 | iface->setMonitoring( this ); | 808 | iface->setMonitoring( this ); |
802 | } | 809 | } |
803 | 810 | ||
804 | 811 | ||
805 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 812 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
806 | { | 813 | { |
807 | } | 814 | } |
808 | 815 | ||
809 | 816 | ||
810 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 817 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
811 | { | 818 | { |
812 | //FIXME: do nothing if its already in the same mode | 819 | //FIXME: do nothing if its already in the same mode |
813 | 820 | ||
814 | QString enable = b ? "true" : "false"; | 821 | QString enable = b ? "true" : "false"; |
815 | QString cmd; | 822 | QString cmd; |
816 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); | 823 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); |
817 | system( cmd ); | 824 | system( cmd ); |
818 | } | 825 | } |
819 | 826 | ||
820 | 827 | ||
821 | QString OWlanNGMonitoringInterface::name() const | 828 | QString OWlanNGMonitoringInterface::name() const |
822 | { | 829 | { |
823 | return "wlan-ng"; | 830 | return "wlan-ng"; |
824 | } | 831 | } |
825 | 832 | ||
826 | 833 | ||
827 | void OWlanNGMonitoringInterface::setChannel( int ) | 834 | void OWlanNGMonitoringInterface::setChannel( int ) |
828 | { | 835 | { |
829 | // wlan-ng devices automatically switch channels when in monitor mode | 836 | // wlan-ng devices automatically switch channels when in monitor mode |
830 | } | 837 | } |
831 | 838 | ||
832 | 839 | ||
833 | /*====================================================================================== | 840 | /*====================================================================================== |
834 | * OHostAPMonitoringInterface | 841 | * OHostAPMonitoringInterface |
835 | *======================================================================================*/ | 842 | *======================================================================================*/ |
836 | 843 | ||
837 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) | 844 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) |
838 | :OMonitoringInterface( iface ) | 845 | :OMonitoringInterface( iface ) |
839 | { | 846 | { |
840 | iface->setMonitoring( this ); | 847 | iface->setMonitoring( this ); |
841 | } | 848 | } |
842 | 849 | ||
843 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 850 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
844 | { | 851 | { |
845 | } | 852 | } |
846 | 853 | ||
847 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 854 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
848 | { | 855 | { |
849 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 856 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
850 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 857 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
851 | 858 | ||
852 | //TODO: check wireless extensions version on runtime and use | 859 | //TODO: check wireless extensions version on runtime and use |
853 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 | 860 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 |
854 | 861 | ||
855 | if ( b ) | 862 | if ( b ) |
856 | { | 863 | { |
857 | _if->setPrivate( "monitor", 1, 2 ); | 864 | _if->setPrivate( "monitor", 1, 2 ); |
858 | } | 865 | } |
859 | else | 866 | else |
860 | { | 867 | { |
861 | _if->setPrivate( "monitor", 1, 0 ); | 868 | _if->setPrivate( "monitor", 1, 0 ); |
862 | } | 869 | } |
863 | } | 870 | } |
864 | 871 | ||
865 | 872 | ||
866 | QString OHostAPMonitoringInterface::name() const | 873 | QString OHostAPMonitoringInterface::name() const |
867 | { | 874 | { |
868 | return "hostap"; | 875 | return "hostap"; |
869 | } | 876 | } |
870 | 877 | ||
871 | 878 | ||
872 | /*====================================================================================== | 879 | /*====================================================================================== |
873 | * OOrinocoNetworkInterface | 880 | * OOrinocoNetworkInterface |
874 | *======================================================================================*/ | 881 | *======================================================================================*/ |
875 | 882 | ||
876 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) | 883 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) |
877 | :OMonitoringInterface( iface ) | 884 | :OMonitoringInterface( iface ) |
878 | { | 885 | { |
879 | iface->setMonitoring( this ); | 886 | iface->setMonitoring( this ); |
880 | } | 887 | } |
881 | 888 | ||
882 | 889 | ||
883 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 890 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
884 | { | 891 | { |
885 | } | 892 | } |
886 | 893 | ||
887 | 894 | ||
888 | void OOrinocoMonitoringInterface::setChannel( int c ) | 895 | void OOrinocoMonitoringInterface::setChannel( int c ) |
889 | { | 896 | { |
890 | _if->setPrivate( "monitor", 2, 2, c ); | 897 | _if->setPrivate( "monitor", 2, 2, c ); |
891 | } | 898 | } |
892 | 899 | ||
893 | 900 | ||
894 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 901 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
895 | { | 902 | { |
896 | if ( b ) | 903 | if ( b ) |
897 | { | 904 | { |
898 | setChannel( 1 ); | 905 | setChannel( 1 ); |
899 | } | 906 | } |
900 | else | 907 | else |
901 | { | 908 | { |
902 | _if->setPrivate( "monitor", 2, 0, 0 ); | 909 | _if->setPrivate( "monitor", 2, 0, 0 ); |
903 | } | 910 | } |
904 | } | 911 | } |
905 | 912 | ||
906 | 913 | ||
907 | QString OOrinocoMonitoringInterface::name() const | 914 | QString OOrinocoMonitoringInterface::name() const |
908 | { | 915 | { |
909 | return "orinoco"; | 916 | return "orinoco"; |
910 | } | 917 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 10f52b8..d2cc25d 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,461 +1,470 @@ | |||
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 <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qdict.h> | 40 | #include <qdict.h> |
41 | #include <qmap.h> | 41 | #include <qmap.h> |
42 | #include <qobject.h> | 42 | #include <qobject.h> |
43 | #include <qhostaddress.h> | 43 | #include <qhostaddress.h> |
44 | 44 | ||
45 | /* OPIE */ | 45 | /* OPIE */ |
46 | 46 | ||
47 | #include <opie2/onetutils.h> | 47 | #include <opie2/onetutils.h> |
48 | 48 | ||
49 | #ifndef IFNAMSIZ | 49 | #ifndef IFNAMSIZ |
50 | #define IFNAMSIZ 16 | 50 | #define IFNAMSIZ 16 |
51 | #endif | 51 | #endif |
52 | #ifndef IW_MAX_PRIV_DEF | 52 | #ifndef IW_MAX_PRIV_DEF |
53 | #define IW_MAX_PRIV_DEF 128 | 53 | #define IW_MAX_PRIV_DEF 128 |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here | 56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here |
57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> | 57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> |
58 | // ML: which conflicts with the user header <net/if.h> | 58 | // ML: which conflicts with the user header <net/if.h> |
59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> | 59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> |
60 | // ML: I will drop Jean an mail on that subject | 60 | // ML: I will drop Jean an mail on that subject |
61 | 61 | ||
62 | #include <net/if.h> | 62 | #include <net/if.h> |
63 | #define _LINUX_IF_H | 63 | #define _LINUX_IF_H |
64 | #include <linux/wireless.h> | 64 | #include <linux/wireless.h> |
65 | 65 | ||
66 | class ONetworkInterface; | 66 | class ONetworkInterface; |
67 | class OWirelessNetworkInterface; | 67 | class OWirelessNetworkInterface; |
68 | class OChannelHopper; | 68 | class OChannelHopper; |
69 | class OMonitoringInterface; | 69 | class OMonitoringInterface; |
70 | 70 | ||
71 | /*====================================================================================== | 71 | /*====================================================================================== |
72 | * ONetwork | 72 | * ONetwork |
73 | *======================================================================================*/ | 73 | *======================================================================================*/ |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * @brief A container class for all network devices. | 76 | * @brief A container class for all network devices. |
77 | * | 77 | * |
78 | * This class provides access to all available network devices of your computer. | 78 | * This class provides access to all available network devices of your computer. |
79 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 79 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
80 | */ | 80 | */ |
81 | class ONetwork : public QObject | 81 | class ONetwork : public QObject |
82 | { | 82 | { |
83 | Q_OBJECT | 83 | Q_OBJECT |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QDict<ONetworkInterface> InterfaceMap; | 86 | typedef QDict<ONetworkInterface> InterfaceMap; |
87 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 87 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
88 | 88 | ||
89 | public: | 89 | public: |
90 | /** | 90 | /** |
91 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 91 | * @returns a pointer to the (one and only) @ref ONetwork instance. |
92 | */ | 92 | */ |
93 | static ONetwork* instance(); | 93 | static ONetwork* instance(); |
94 | /** | 94 | /** |
95 | * @returns an iterator usable for iterating through all network interfaces. | 95 | * @returns an iterator usable for iterating through all network interfaces. |
96 | */ | 96 | */ |
97 | InterfaceIterator iterator() const; | 97 | InterfaceIterator iterator() const; |
98 | /** | 98 | /** |
99 | * @returns true, if the @p interface supports the wireless extension protocol. | 99 | * @returns true, if the @p interface supports the wireless extension protocol. |
100 | */ | 100 | */ |
101 | bool isWirelessInterface( const char* interface ) const; | 101 | bool isWirelessInterface( const char* interface ) const; |
102 | /** | 102 | /** |
103 | * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found | 103 | * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found |
104 | * @see ONetworkInterface | 104 | * @see ONetworkInterface |
105 | */ | 105 | */ |
106 | ONetworkInterface* interface( QString interface ) const; | 106 | ONetworkInterface* interface( QString interface ) const; |
107 | 107 | ||
108 | protected: | 108 | protected: |
109 | ONetwork(); | 109 | ONetwork(); |
110 | void synchronize(); | 110 | void synchronize(); |
111 | 111 | ||
112 | private: | 112 | private: |
113 | static ONetwork* _instance; | 113 | static ONetwork* _instance; |
114 | InterfaceMap _interfaces; | 114 | InterfaceMap _interfaces; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | 117 | ||
118 | /*====================================================================================== | 118 | /*====================================================================================== |
119 | * ONetworkInterface | 119 | * ONetworkInterface |
120 | *======================================================================================*/ | 120 | *======================================================================================*/ |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * @brief A network interface wrapper. | 123 | * @brief A network interface wrapper. |
124 | * | 124 | * |
125 | * This class provides a wrapper for a network interface. All the cumbersume details of | 125 | * This class provides a wrapper for a network interface. All the cumbersume details of |
126 | * Linux ioctls are hidden under a convenient high-level interface. | 126 | * Linux ioctls are hidden under a convenient high-level interface. |
127 | * @warning Most of the setting methods contained in this class require the appropriate | 127 | * @warning Most of the setting methods contained in this class require the appropriate |
128 | * process permissions to work. | 128 | * process permissions to work. |
129 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 129 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
130 | */ | 130 | */ |
131 | class ONetworkInterface : public QObject | 131 | class ONetworkInterface : public QObject |
132 | { | 132 | { |
133 | friend class OMonitoringInterface; | 133 | friend class OMonitoringInterface; |
134 | friend class OCiscoMonitoringInterface; | 134 | friend class OCiscoMonitoringInterface; |
135 | friend class OWlanNGMonitoringInterface; | 135 | friend class OWlanNGMonitoringInterface; |
136 | friend class OHostAPMonitoringInterface; | 136 | friend class OHostAPMonitoringInterface; |
137 | friend class OOrinocoMonitoringInterface; | 137 | friend class OOrinocoMonitoringInterface; |
138 | 138 | ||
139 | public: | 139 | public: |
140 | /** | 140 | /** |
141 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, | 141 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, |
142 | * but access them via @ref ONetwork::interface(). | 142 | * but access them via @ref ONetwork::interface(). |
143 | */ | 143 | */ |
144 | ONetworkInterface( QObject* parent, const char* name ); | 144 | ONetworkInterface( QObject* parent, const char* name ); |
145 | /** | 145 | /** |
146 | * Destructor. | 146 | * Destructor. |
147 | */ | 147 | */ |
148 | virtual ~ONetworkInterface(); | 148 | virtual ~ONetworkInterface(); |
149 | /** | 149 | /** |
150 | * Associates a @a monitoring interface with this network interface. | 150 | * Associates a @a monitoring interface with this network interface. |
151 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. | 151 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. |
152 | */ | 152 | */ |
153 | void setMonitoring( OMonitoringInterface* monitoring ); | 153 | void setMonitoring( OMonitoringInterface* monitoring ); |
154 | /** | 154 | /** |
155 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. | 155 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. |
156 | */ | 156 | */ |
157 | OMonitoringInterface* monitoring() const; | 157 | OMonitoringInterface* monitoring() const; |
158 | /** | 158 | /** |
159 | * Setting an interface to promiscuous mode enables the device to receive | 159 | * Setting an interface to promiscuous mode enables the device to receive |
160 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. | 160 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. |
161 | */ | 161 | */ |
162 | bool setPromiscuousMode( bool ); | 162 | bool setPromiscuousMode( bool ); |
163 | /** | 163 | /** |
164 | * @returns true if the interface is set to promiscuous mode. | 164 | * @returns true if the interface is set to promiscuous mode. |
165 | */ | 165 | */ |
166 | bool promiscuousMode() const; | 166 | bool promiscuousMode() const; |
167 | /** | 167 | /** |
168 | * Setting an interface to up enables it to receive packets. | 168 | * Setting an interface to up enables it to receive packets. |
169 | */ | 169 | */ |
170 | bool setUp( bool ); | 170 | bool setUp( bool ); |
171 | /** | 171 | /** |
172 | * @returns true if the interface is up. | 172 | * @returns true if the interface is up. |
173 | */ | 173 | */ |
174 | bool isUp() const; | 174 | bool isUp() const; |
175 | /* | 175 | /* |
176 | * @returns true if the interface is a loopback interface. | 176 | * @returns true if the interface is a loopback interface. |
177 | */ | 177 | */ |
178 | bool isLoopback() const; | 178 | bool isLoopback() const; |
179 | /* | 179 | /* |
180 | * @returns true if the interface is featuring supports the wireless extension protocol. | 180 | * @returns true if the interface is featuring supports the wireless extension protocol. |
181 | */ | 181 | */ |
182 | bool isWireless() const; | 182 | bool isWireless() const; |
183 | /* | 183 | /* |
184 | * @returns the IPv4 address associated with this interface. | 184 | * @returns the IPv4 address associated with this interface. |
185 | */ | 185 | */ |
186 | QString ipV4Address() const; | 186 | QString ipV4Address() const; |
187 | /* | 187 | /* |
188 | * Associate the MAC address @a addr with the interface. | 188 | * Associate the MAC address @a addr with the interface. |
189 | * @note It can be necessary to shut down the interface prior to calling this method. | 189 | * @note It can be necessary to shut down the interface prior to calling this method. |
190 | * @warning This is not supported by all drivers. | 190 | * @warning This is not supported by all drivers. |
191 | */ | 191 | */ |
192 | void setMacAddress( const OMacAddress& addr ); | 192 | void setMacAddress( const OMacAddress& addr ); |
193 | /* | 193 | /* |
194 | * @returns the MAC address associated with this interface. | 194 | * @returns the MAC address associated with this interface. |
195 | */ | 195 | */ |
196 | OMacAddress macAddress() const; | 196 | OMacAddress macAddress() const; |
197 | /* | 197 | /* |
198 | * @returns the data link type currently associated with this interface. | 198 | * @returns the data link type currently associated with this interface. |
199 | * @see #include <net/if_arp.h> for possible values. | 199 | * @see #include <net/if_arp.h> for possible values. |
200 | */ | 200 | */ |
201 | int dataLinkType() const; | 201 | int dataLinkType() const; |
202 | 202 | ||
203 | protected: | 203 | protected: |
204 | const int _sfd; | 204 | const int _sfd; |
205 | mutable ifreq _ifr; | 205 | mutable ifreq _ifr; |
206 | OMonitoringInterface* _mon; | 206 | OMonitoringInterface* _mon; |
207 | 207 | ||
208 | protected: | 208 | protected: |
209 | struct ifreq& ifr() const; | 209 | struct ifreq& ifr() const; |
210 | virtual void init(); | 210 | virtual void init(); |
211 | bool ioctl( int call ) const; | 211 | bool ioctl( int call ) const; |
212 | bool ioctl( int call, struct ifreq& ) const; | 212 | bool ioctl( int call, struct ifreq& ) const; |
213 | }; | 213 | }; |
214 | 214 | ||
215 | /*====================================================================================== | 215 | /*====================================================================================== |
216 | * OChannelHopper | 216 | * OChannelHopper |
217 | *======================================================================================*/ | 217 | *======================================================================================*/ |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * @brief A radio frequency channel hopper. | 220 | * @brief A radio frequency channel hopper. |
221 | * | 221 | * |
222 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently | 222 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently |
223 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. | 223 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. |
224 | * This is necessary when in monitoring mode and scanning for other devices, because | 224 | * This is necessary when in monitoring mode and scanning for other devices, because |
225 | * the radio frequency hardware can only detect packets sent on the same frequency. | 225 | * the radio frequency hardware can only detect packets sent on the same frequency. |
226 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 226 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
227 | */ | 227 | */ |
228 | class OChannelHopper : public QObject | 228 | class OChannelHopper : public QObject |
229 | { | 229 | { |
230 | Q_OBJECT | ||
231 | |||
230 | public: | 232 | public: |
231 | OChannelHopper( OWirelessNetworkInterface* ); | 233 | OChannelHopper( OWirelessNetworkInterface* ); |
232 | virtual ~OChannelHopper(); | 234 | virtual ~OChannelHopper(); |
233 | bool isActive() const; | 235 | bool isActive() const; |
234 | int channel() const; | 236 | int channel() const; |
235 | virtual void timerEvent( QTimerEvent* ); | 237 | virtual void timerEvent( QTimerEvent* ); |
236 | void setInterval( int ); | 238 | void setInterval( int ); |
237 | int interval() const; | 239 | int interval() const; |
238 | 240 | ||
241 | signals: | ||
242 | void hopped( int ); | ||
243 | |||
239 | private: | 244 | private: |
240 | OWirelessNetworkInterface* _iface; | 245 | OWirelessNetworkInterface* _iface; |
241 | int _interval; | 246 | int _interval; |
242 | int _tid; | 247 | int _tid; |
243 | QValueList<int> _channels; | 248 | QValueList<int> _channels; |
244 | QValueList<int>::Iterator _channel; | 249 | QValueList<int>::Iterator _channel; |
245 | }; | 250 | }; |
246 | 251 | ||
247 | 252 | ||
248 | /*====================================================================================== | 253 | /*====================================================================================== |
249 | * OWirelessNetworkInterface | 254 | * OWirelessNetworkInterface |
250 | *======================================================================================*/ | 255 | *======================================================================================*/ |
251 | 256 | ||
252 | /** | 257 | /** |
253 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. | 258 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. |
254 | * | 259 | * |
255 | * This class provides a high-level encapsulation of the Linux wireless extension API. | 260 | * This class provides a high-level encapsulation of the Linux wireless extension API. |
256 | */ | 261 | */ |
257 | class OWirelessNetworkInterface : public ONetworkInterface | 262 | class OWirelessNetworkInterface : public ONetworkInterface |
258 | { | 263 | { |
259 | friend class OMonitoringInterface; | 264 | friend class OMonitoringInterface; |
260 | friend class OCiscoMonitoringInterface; | 265 | friend class OCiscoMonitoringInterface; |
261 | friend class OWlanNGMonitoringInterface; | 266 | friend class OWlanNGMonitoringInterface; |
262 | friend class OHostAPMonitoringInterface; | 267 | friend class OHostAPMonitoringInterface; |
263 | friend class OOrinocoMonitoringInterface; | 268 | friend class OOrinocoMonitoringInterface; |
264 | 269 | ||
265 | friend class OPrivateIOCTL; | 270 | friend class OPrivateIOCTL; |
266 | 271 | ||
267 | public: | 272 | public: |
268 | enum Mode { AdHoc, Managed, Monitor }; | 273 | enum Mode { AdHoc, Managed, Monitor }; |
269 | 274 | ||
270 | /** | 275 | /** |
271 | * Constructor. | 276 | * Constructor. |
272 | */ | 277 | */ |
273 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 278 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
274 | /** | 279 | /** |
275 | * Destructor. | 280 | * Destructor. |
276 | */ | 281 | */ |
277 | virtual ~OWirelessNetworkInterface(); | 282 | virtual ~OWirelessNetworkInterface(); |
278 | /** | 283 | /** |
279 | * Setting the @a channel of the interface changes the radio frequency (RF) | 284 | * Setting the @a channel of the interface changes the radio frequency (RF) |
280 | * of the corresponding wireless network device. | 285 | * of the corresponding wireless network device. |
281 | */ | 286 | */ |
282 | virtual void setChannel( int channel ) const; | 287 | virtual void setChannel( int channel ) const; |
283 | /** | 288 | /** |
284 | * @returns the channel index of the current radio frequency. | 289 | * @returns the channel index of the current radio frequency. |
285 | */ | 290 | */ |
286 | virtual int channel() const; | 291 | virtual int channel() const; |
287 | /** | 292 | /** |
288 | * @returns the current radio frequency (in MHz). | 293 | * @returns the current radio frequency (in MHz). |
289 | */ | 294 | */ |
290 | virtual double frequency() const; | 295 | virtual double frequency() const; |
291 | /** | 296 | /** |
292 | * @returns the number of radio frequency channels for the | 297 | * @returns the number of radio frequency channels for the |
293 | * corresponding wireless network device. | 298 | * corresponding wireless network device. |
294 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 299 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
295 | */ | 300 | */ |
296 | virtual int channels() const; | 301 | virtual int channels() const; |
297 | //virtual double frequency(int) const; | 302 | //virtual double frequency(int) const; |
298 | 303 | ||
299 | virtual void setMode( Mode ) {}; //FIXME: Implement and document this | 304 | virtual void setMode( Mode ) {}; //FIXME: Implement and document this |
300 | virtual bool mode() const {}; //FIXME: Implement and document this | 305 | virtual bool mode() const {}; //FIXME: Implement and document this |
301 | 306 | ||
302 | /** | 307 | /** |
303 | * Setting the monitor mode on a wireless network interface enables | 308 | * Setting the monitor mode on a wireless network interface enables |
304 | * listening to IEEE 802.11 data and management frames which normally | 309 | * listening to IEEE 802.11 data and management frames which normally |
305 | * are handled by the device firmware. This can be used to detect | 310 | * are handled by the device firmware. This can be used to detect |
306 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. | 311 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. |
307 | * @warning Standard wireless network drives don't support the monitor mode. | 312 | * @warning Standard wireless network drives don't support the monitor mode. |
308 | * @warning You need a patched driver for this to work. | 313 | * @warning You need a patched driver for this to work. |
309 | * @note Enabling the monitor mode is highly driver dependent and requires | 314 | * @note Enabling the monitor mode is highly driver dependent and requires |
310 | * the proper @ref OMonitoringInterface to be associated with the interface. | 315 | * the proper @ref OMonitoringInterface to be associated with the interface. |
311 | * @see OMonitoringInterface | 316 | * @see OMonitoringInterface |
312 | */ | 317 | */ |
313 | virtual void setMonitorMode( bool ); | 318 | virtual void setMonitorMode( bool ); |
314 | /** | 319 | /** |
315 | * @returns true if the device is listening in IEEE 802.11 monitor mode | 320 | * @returns true if the device is listening in IEEE 802.11 monitor mode |
316 | */ | 321 | */ |
317 | virtual bool monitorMode() const; | 322 | virtual bool monitorMode() const; |
318 | /** | 323 | /** |
319 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 324 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
320 | * @see OChannelHopper | 325 | * @see OChannelHopper |
321 | */ | 326 | */ |
322 | virtual void setChannelHopping( int interval = 0 ); | 327 | virtual void setChannelHopping( int interval = 0 ); |
323 | /** | 328 | /** |
324 | * @returns the channel hopping interval or 0, if channel hopping is disabled. | 329 | * @returns the channel hopping interval or 0, if channel hopping is disabled. |
325 | */ | 330 | */ |
326 | virtual int channelHopping() const; | 331 | virtual int channelHopping() const; |
327 | /** | 332 | /** |
333 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before | ||
334 | */ | ||
335 | virtual OChannelHopper* channelHopper() const; | ||
336 | /** | ||
328 | * Set the station @a nickname. | 337 | * Set the station @a nickname. |
329 | */ | 338 | */ |
330 | virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this | 339 | virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this |
331 | /** | 340 | /** |
332 | * @returns the current station nickname. | 341 | * @returns the current station nickname. |
333 | */ | 342 | */ |
334 | virtual QString nickName() const; | 343 | virtual QString nickName() const; |
335 | /** | 344 | /** |
336 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. | 345 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. |
337 | * @see OPrivateIOCTL | 346 | * @see OPrivateIOCTL |
338 | */ | 347 | */ |
339 | virtual void setPrivate( const QString& command, int number, ... ); | 348 | virtual void setPrivate( const QString& command, int number, ... ); |
340 | /** | 349 | /** |
341 | * @returns true if the interface is featuring the private IOCTL @command. | 350 | * @returns true if the interface is featuring the private IOCTL @command. |
342 | */ | 351 | */ |
343 | virtual bool hasPrivate( const QString& command ); | 352 | virtual bool hasPrivate( const QString& command ); |
344 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 353 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
345 | 354 | ||
346 | virtual bool isAssociated() const {}; //FIXME: Implement and document this | 355 | virtual bool isAssociated() const {}; //FIXME: Implement and document this |
347 | virtual QString associatedAP() const; //FIXME: Implement and document this | 356 | virtual QString associatedAP() const; //FIXME: Implement and document this |
348 | 357 | ||
349 | virtual void setSSID( const QString& ); | 358 | virtual void setSSID( const QString& ); |
350 | virtual QString SSID() const; | 359 | virtual QString SSID() const; |
351 | 360 | ||
352 | protected: | 361 | protected: |
353 | void buildChannelList(); | 362 | void buildChannelList(); |
354 | void buildPrivateList(); | 363 | void buildPrivateList(); |
355 | virtual void init(); | 364 | virtual void init(); |
356 | struct iwreq& iwr() const; | 365 | struct iwreq& iwr() const; |
357 | bool wioctl( int call ) const; | 366 | bool wioctl( int call ) const; |
358 | bool wioctl( int call, struct iwreq& ) const; | 367 | bool wioctl( int call, struct iwreq& ) const; |
359 | 368 | ||
360 | protected: | 369 | protected: |
361 | mutable struct iwreq _iwr; | 370 | mutable struct iwreq _iwr; |
362 | QMap<int,int> _channels; | 371 | QMap<int,int> _channels; |
363 | 372 | ||
364 | private: | 373 | private: |
365 | OChannelHopper* _hopper; | 374 | OChannelHopper* _hopper; |
366 | }; | 375 | }; |
367 | 376 | ||
368 | 377 | ||
369 | /*====================================================================================== | 378 | /*====================================================================================== |
370 | * OMonitoringInterface | 379 | * OMonitoringInterface |
371 | *======================================================================================*/ | 380 | *======================================================================================*/ |
372 | 381 | ||
373 | 382 | ||
374 | class OMonitoringInterface | 383 | class OMonitoringInterface |
375 | { | 384 | { |
376 | public: | 385 | public: |
377 | OMonitoringInterface(); | 386 | OMonitoringInterface(); |
378 | OMonitoringInterface( ONetworkInterface* ); | 387 | OMonitoringInterface( ONetworkInterface* ); |
379 | virtual ~OMonitoringInterface(); | 388 | virtual ~OMonitoringInterface(); |
380 | 389 | ||
381 | public: | 390 | public: |
382 | virtual void setEnabled( bool ); | 391 | virtual void setEnabled( bool ); |
383 | virtual bool enabled() const; | 392 | virtual bool enabled() const; |
384 | virtual void setChannel( int ); | 393 | virtual void setChannel( int ); |
385 | 394 | ||
386 | virtual QString name() const = 0; | 395 | virtual QString name() const = 0; |
387 | 396 | ||
388 | protected: | 397 | protected: |
389 | OWirelessNetworkInterface* _if; | 398 | OWirelessNetworkInterface* _if; |
390 | 399 | ||
391 | }; | 400 | }; |
392 | 401 | ||
393 | 402 | ||
394 | /*====================================================================================== | 403 | /*====================================================================================== |
395 | * OCiscoMonitoring | 404 | * OCiscoMonitoring |
396 | *======================================================================================*/ | 405 | *======================================================================================*/ |
397 | 406 | ||
398 | 407 | ||
399 | class OCiscoMonitoringInterface : public OMonitoringInterface | 408 | class OCiscoMonitoringInterface : public OMonitoringInterface |
400 | { | 409 | { |
401 | public: | 410 | public: |
402 | OCiscoMonitoringInterface( ONetworkInterface* ); | 411 | OCiscoMonitoringInterface( ONetworkInterface* ); |
403 | virtual ~OCiscoMonitoringInterface(); | 412 | virtual ~OCiscoMonitoringInterface(); |
404 | 413 | ||
405 | virtual void setEnabled( bool ); | 414 | virtual void setEnabled( bool ); |
406 | virtual QString name() const; | 415 | virtual QString name() const; |
407 | virtual void setChannel( int ); | 416 | virtual void setChannel( int ); |
408 | 417 | ||
409 | }; | 418 | }; |
410 | 419 | ||
411 | /*====================================================================================== | 420 | /*====================================================================================== |
412 | * OWlanNGMonitoringInterface | 421 | * OWlanNGMonitoringInterface |
413 | *======================================================================================*/ | 422 | *======================================================================================*/ |
414 | 423 | ||
415 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 424 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
416 | { | 425 | { |
417 | public: | 426 | public: |
418 | OWlanNGMonitoringInterface( ONetworkInterface* ); | 427 | OWlanNGMonitoringInterface( ONetworkInterface* ); |
419 | virtual ~OWlanNGMonitoringInterface(); | 428 | virtual ~OWlanNGMonitoringInterface(); |
420 | 429 | ||
421 | public: | 430 | public: |
422 | virtual void setEnabled( bool ); | 431 | virtual void setEnabled( bool ); |
423 | virtual QString name() const; | 432 | virtual QString name() const; |
424 | virtual void setChannel( int ); | 433 | virtual void setChannel( int ); |
425 | 434 | ||
426 | }; | 435 | }; |
427 | 436 | ||
428 | /*====================================================================================== | 437 | /*====================================================================================== |
429 | * OHostAPMonitoringInterface | 438 | * OHostAPMonitoringInterface |
430 | *======================================================================================*/ | 439 | *======================================================================================*/ |
431 | 440 | ||
432 | class OHostAPMonitoringInterface : public OMonitoringInterface | 441 | class OHostAPMonitoringInterface : public OMonitoringInterface |
433 | { | 442 | { |
434 | public: | 443 | public: |
435 | OHostAPMonitoringInterface( ONetworkInterface* ); | 444 | OHostAPMonitoringInterface( ONetworkInterface* ); |
436 | virtual ~OHostAPMonitoringInterface(); | 445 | virtual ~OHostAPMonitoringInterface(); |
437 | 446 | ||
438 | public: | 447 | public: |
439 | virtual void setEnabled( bool ); | 448 | virtual void setEnabled( bool ); |
440 | virtual QString name() const; | 449 | virtual QString name() const; |
441 | }; | 450 | }; |
442 | 451 | ||
443 | /*====================================================================================== | 452 | /*====================================================================================== |
444 | * OOrinocoMonitoringInterface | 453 | * OOrinocoMonitoringInterface |
445 | *======================================================================================*/ | 454 | *======================================================================================*/ |
446 | 455 | ||
447 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 456 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
448 | { | 457 | { |
449 | public: | 458 | public: |
450 | OOrinocoMonitoringInterface( ONetworkInterface* ); | 459 | OOrinocoMonitoringInterface( ONetworkInterface* ); |
451 | virtual ~OOrinocoMonitoringInterface(); | 460 | virtual ~OOrinocoMonitoringInterface(); |
452 | 461 | ||
453 | public: | 462 | public: |
454 | virtual void setChannel( int ); | 463 | virtual void setChannel( int ); |
455 | virtual void setEnabled( bool ); | 464 | virtual void setEnabled( bool ); |
456 | virtual QString name() const; | 465 | virtual QString name() const; |
457 | 466 | ||
458 | }; | 467 | }; |
459 | 468 | ||
460 | #endif // ONETWORK_H | 469 | #endif // ONETWORK_H |
461 | 470 | ||