-rw-r--r-- | libopie2/opienet/onetwork.cpp | 45 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 6 | ||||
-rw-r--r-- | libopie2/opienet/ostation.cpp | 49 | ||||
-rw-r--r-- | libopie2/opienet/ostation.h | 67 |
4 files changed, 164 insertions, 3 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 918ba07..a85a510 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,1142 +1,1185 @@ | |||
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 | #include <opie2/ostation.h> | ||
37 | 38 | ||
38 | /* QT */ | 39 | /* QT */ |
39 | 40 | ||
40 | #include <qfile.h> | 41 | #include <qfile.h> |
41 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
42 | 43 | ||
43 | /* UNIX */ | 44 | /* UNIX */ |
44 | 45 | ||
45 | #include <assert.h> | 46 | #include <assert.h> |
46 | #include <arpa/inet.h> | 47 | #include <arpa/inet.h> |
47 | #include <cerrno> | 48 | #include <cerrno> |
48 | #include <cstring> | 49 | #include <cstring> |
49 | #include <cstdlib> | 50 | #include <cstdlib> |
50 | #include <math.h> | 51 | #include <math.h> |
51 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> |
52 | #include <sys/socket.h> | 53 | #include <sys/socket.h> |
53 | #include <sys/types.h> | 54 | #include <sys/types.h> |
54 | #include <unistd.h> | 55 | #include <unistd.h> |
55 | #include <linux/sockios.h> | 56 | #include <linux/sockios.h> |
56 | #include <net/if_arp.h> | 57 | #include <net/if_arp.h> |
57 | #include <stdarg.h> | 58 | #include <stdarg.h> |
58 | 59 | ||
59 | using namespace std; | 60 | using namespace std; |
60 | 61 | ||
61 | #ifndef NODEBUG | 62 | #ifndef NODEBUG |
62 | #include <opie2/oioctlmap.h> | 63 | #include <opie2/oioctlmap.h> |
63 | IntStringMap* _ioctlmap = constructIoctlMap(); | 64 | IntStringMap* _ioctlmap = constructIoctlMap(); |
64 | #endif | 65 | #endif |
65 | 66 | ||
66 | /*====================================================================================== | 67 | /*====================================================================================== |
67 | * ONetwork | 68 | * ONetwork |
68 | *======================================================================================*/ | 69 | *======================================================================================*/ |
69 | 70 | ||
70 | ONetwork* ONetwork::_instance = 0; | 71 | ONetwork* ONetwork::_instance = 0; |
71 | 72 | ||
72 | ONetwork::ONetwork() | 73 | ONetwork::ONetwork() |
73 | { | 74 | { |
74 | qDebug( "ONetwork::ONetwork()" ); | 75 | qDebug( "ONetwork::ONetwork()" ); |
75 | qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); | 76 | qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); |
76 | synchronize(); | 77 | synchronize(); |
77 | } | 78 | } |
78 | 79 | ||
79 | void ONetwork::synchronize() | 80 | void ONetwork::synchronize() |
80 | { | 81 | { |
81 | // gather available interfaces by inspecting /proc/net/dev | 82 | // gather available interfaces by inspecting /proc/net/dev |
82 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 83 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
83 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 84 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
84 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | 85 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev |
85 | 86 | ||
86 | _interfaces.clear(); | 87 | _interfaces.clear(); |
87 | QString str; | 88 | QString str; |
88 | QFile f( "/proc/net/dev" ); | 89 | QFile f( "/proc/net/dev" ); |
89 | bool hasFile = f.open( IO_ReadOnly ); | 90 | bool hasFile = f.open( IO_ReadOnly ); |
90 | if ( !hasFile ) | 91 | if ( !hasFile ) |
91 | { | 92 | { |
92 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 93 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
93 | return; | 94 | return; |
94 | } | 95 | } |
95 | QTextStream s( &f ); | 96 | QTextStream s( &f ); |
96 | s.readLine(); | 97 | s.readLine(); |
97 | s.readLine(); | 98 | s.readLine(); |
98 | while ( !s.atEnd() ) | 99 | while ( !s.atEnd() ) |
99 | { | 100 | { |
100 | s >> str; | 101 | s >> str; |
101 | str.truncate( str.find( ':' ) ); | 102 | str.truncate( str.find( ':' ) ); |
102 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 103 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
103 | ONetworkInterface* iface; | 104 | ONetworkInterface* iface; |
104 | if ( isWirelessInterface( str ) ) | 105 | if ( isWirelessInterface( str ) ) |
105 | { | 106 | { |
106 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 107 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
107 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 108 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
108 | } | 109 | } |
109 | else | 110 | else |
110 | { | 111 | { |
111 | iface = new ONetworkInterface( this, (const char*) str ); | 112 | iface = new ONetworkInterface( this, (const char*) str ); |
112 | } | 113 | } |
113 | _interfaces.insert( str, iface ); | 114 | _interfaces.insert( str, iface ); |
114 | s.readLine(); | 115 | s.readLine(); |
115 | } | 116 | } |
116 | } | 117 | } |
117 | 118 | ||
118 | 119 | ||
119 | short ONetwork::wirelessExtensionVersion() | 120 | short ONetwork::wirelessExtensionVersion() |
120 | { | 121 | { |
121 | return WIRELESS_EXT; | 122 | return WIRELESS_EXT; |
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
125 | int ONetwork::count() const | 126 | int ONetwork::count() const |
126 | { | 127 | { |
127 | return _interfaces.count(); | 128 | return _interfaces.count(); |
128 | } | 129 | } |
129 | 130 | ||
130 | 131 | ||
131 | ONetworkInterface* ONetwork::interface( const QString& iface ) const | 132 | ONetworkInterface* ONetwork::interface( const QString& iface ) const |
132 | { | 133 | { |
133 | return _interfaces[iface]; | 134 | return _interfaces[iface]; |
134 | } | 135 | } |
135 | 136 | ||
136 | 137 | ||
137 | ONetwork* ONetwork::instance() | 138 | ONetwork* ONetwork::instance() |
138 | { | 139 | { |
139 | if ( !_instance ) _instance = new ONetwork(); | 140 | if ( !_instance ) _instance = new ONetwork(); |
140 | return _instance; | 141 | return _instance; |
141 | } | 142 | } |
142 | 143 | ||
143 | 144 | ||
144 | ONetwork::InterfaceIterator ONetwork::iterator() const | 145 | ONetwork::InterfaceIterator ONetwork::iterator() const |
145 | { | 146 | { |
146 | return ONetwork::InterfaceIterator( _interfaces ); | 147 | return ONetwork::InterfaceIterator( _interfaces ); |
147 | } | 148 | } |
148 | 149 | ||
149 | 150 | ||
150 | bool ONetwork::isWirelessInterface( const char* name ) const | 151 | bool ONetwork::isWirelessInterface( const char* name ) const |
151 | { | 152 | { |
152 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 153 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
153 | struct iwreq iwr; | 154 | struct iwreq iwr; |
154 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 155 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
155 | strcpy( (char*) &iwr.ifr_name, name ); | 156 | strcpy( (char*) &iwr.ifr_name, name ); |
156 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 157 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
157 | return result != -1; | 158 | return result != -1; |
158 | } | 159 | } |
159 | 160 | ||
160 | /*====================================================================================== | 161 | /*====================================================================================== |
161 | * ONetworkInterface | 162 | * ONetworkInterface |
162 | *======================================================================================*/ | 163 | *======================================================================================*/ |
163 | 164 | ||
164 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 165 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
165 | :QObject( parent, name ), | 166 | :QObject( parent, name ), |
166 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 167 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
167 | { | 168 | { |
168 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 169 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
169 | init(); | 170 | init(); |
170 | } | 171 | } |
171 | 172 | ||
172 | 173 | ||
173 | struct ifreq& ONetworkInterface::ifr() const | 174 | struct ifreq& ONetworkInterface::ifr() const |
174 | { | 175 | { |
175 | return _ifr; | 176 | return _ifr; |
176 | } | 177 | } |
177 | 178 | ||
178 | 179 | ||
179 | void ONetworkInterface::init() | 180 | void ONetworkInterface::init() |
180 | { | 181 | { |
181 | qDebug( "ONetworkInterface::init()" ); | 182 | qDebug( "ONetworkInterface::init()" ); |
182 | 183 | ||
183 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 184 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
184 | 185 | ||
185 | if ( _sfd == -1 ) | 186 | if ( _sfd == -1 ) |
186 | { | 187 | { |
187 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); | 188 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); |
188 | return; | 189 | return; |
189 | } | 190 | } |
190 | } | 191 | } |
191 | 192 | ||
192 | 193 | ||
193 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 194 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
194 | { | 195 | { |
195 | #ifndef NODEBUG | 196 | #ifndef NODEBUG |
196 | int result = ::ioctl( _sfd, call, &ifreq ); | 197 | int result = ::ioctl( _sfd, call, &ifreq ); |
197 | if ( result == -1 ) | 198 | if ( result == -1 ) |
198 | qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); | 199 | qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); |
199 | else | 200 | else |
200 | qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); | 201 | qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); |
201 | return ( result != -1 ); | 202 | return ( result != -1 ); |
202 | #else | 203 | #else |
203 | return ::ioctl( _sfd, call, &ifreq ) != -1; | 204 | return ::ioctl( _sfd, call, &ifreq ) != -1; |
204 | #endif | 205 | #endif |
205 | } | 206 | } |
206 | 207 | ||
207 | 208 | ||
208 | bool ONetworkInterface::ioctl( int call ) const | 209 | bool ONetworkInterface::ioctl( int call ) const |
209 | { | 210 | { |
210 | strcpy( _ifr.ifr_name, name() ); | 211 | strcpy( _ifr.ifr_name, name() ); |
211 | return ioctl( call, _ifr ); | 212 | return ioctl( call, _ifr ); |
212 | } | 213 | } |
213 | 214 | ||
214 | 215 | ||
215 | bool ONetworkInterface::isLoopback() const | 216 | bool ONetworkInterface::isLoopback() const |
216 | { | 217 | { |
217 | ioctl( SIOCGIFFLAGS ); | 218 | ioctl( SIOCGIFFLAGS ); |
218 | return _ifr.ifr_flags & IFF_LOOPBACK; | 219 | return _ifr.ifr_flags & IFF_LOOPBACK; |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | bool ONetworkInterface::setUp( bool b ) | 223 | bool ONetworkInterface::setUp( bool b ) |
223 | { | 224 | { |
224 | ioctl( SIOCGIFFLAGS ); | 225 | ioctl( SIOCGIFFLAGS ); |
225 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 226 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
226 | else _ifr.ifr_flags &= (~IFF_UP); | 227 | else _ifr.ifr_flags &= (~IFF_UP); |
227 | return ioctl( SIOCSIFFLAGS ); | 228 | return ioctl( SIOCSIFFLAGS ); |
228 | } | 229 | } |
229 | 230 | ||
230 | 231 | ||
231 | bool ONetworkInterface::isUp() const | 232 | bool ONetworkInterface::isUp() const |
232 | { | 233 | { |
233 | ioctl( SIOCGIFFLAGS ); | 234 | ioctl( SIOCGIFFLAGS ); |
234 | return _ifr.ifr_flags & IFF_UP; | 235 | return _ifr.ifr_flags & IFF_UP; |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) | 239 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) |
239 | { | 240 | { |
240 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 241 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
241 | sa->sin_family = AF_INET; | 242 | sa->sin_family = AF_INET; |
242 | sa->sin_port = 0; | 243 | sa->sin_port = 0; |
243 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 244 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
244 | ioctl( SIOCSIFADDR ); | 245 | ioctl( SIOCSIFADDR ); |
245 | } | 246 | } |
246 | 247 | ||
247 | 248 | ||
248 | QString ONetworkInterface::ipV4Address() const | 249 | QString ONetworkInterface::ipV4Address() const |
249 | { | 250 | { |
250 | if ( ioctl( SIOCGIFADDR ) ) | 251 | if ( ioctl( SIOCGIFADDR ) ) |
251 | { | 252 | { |
252 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 253 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
253 | //FIXME: Use QHostAddress here | 254 | //FIXME: Use QHostAddress here |
254 | return QString( inet_ntoa( sa->sin_addr ) ); | 255 | return QString( inet_ntoa( sa->sin_addr ) ); |
255 | } | 256 | } |
256 | else | 257 | else |
257 | return "<unknown>"; | 258 | return "<unknown>"; |
258 | } | 259 | } |
259 | 260 | ||
260 | 261 | ||
261 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 262 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
262 | { | 263 | { |
263 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 264 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
264 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 265 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
265 | ioctl( SIOCSIFHWADDR ); | 266 | ioctl( SIOCSIFHWADDR ); |
266 | } | 267 | } |
267 | 268 | ||
268 | 269 | ||
269 | OMacAddress ONetworkInterface::macAddress() const | 270 | OMacAddress ONetworkInterface::macAddress() const |
270 | { | 271 | { |
271 | if ( ioctl( SIOCGIFHWADDR ) ) | 272 | if ( ioctl( SIOCGIFHWADDR ) ) |
272 | { | 273 | { |
273 | return OMacAddress( _ifr ); | 274 | return OMacAddress( _ifr ); |
274 | } | 275 | } |
275 | else | 276 | else |
276 | { | 277 | { |
277 | return OMacAddress::unknown; | 278 | return OMacAddress::unknown; |
278 | } | 279 | } |
279 | } | 280 | } |
280 | 281 | ||
281 | 282 | ||
282 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) | 283 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) |
283 | { | 284 | { |
284 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 285 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
285 | sa->sin_family = AF_INET; | 286 | sa->sin_family = AF_INET; |
286 | sa->sin_port = 0; | 287 | sa->sin_port = 0; |
287 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 288 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
288 | ioctl( SIOCSIFNETMASK ); | 289 | ioctl( SIOCSIFNETMASK ); |
289 | } | 290 | } |
290 | 291 | ||
291 | 292 | ||
292 | QString ONetworkInterface::ipV4Netmask() const | 293 | QString ONetworkInterface::ipV4Netmask() const |
293 | { | 294 | { |
294 | if ( ioctl( SIOCGIFNETMASK ) ) | 295 | if ( ioctl( SIOCGIFNETMASK ) ) |
295 | { | 296 | { |
296 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 297 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
297 | //FIXME: Use QHostAddress here | 298 | //FIXME: Use QHostAddress here |
298 | return QString( inet_ntoa( sa->sin_addr ) ); | 299 | return QString( inet_ntoa( sa->sin_addr ) ); |
299 | } | 300 | } |
300 | else | 301 | else |
301 | return "<unknown>"; | 302 | return "<unknown>"; |
302 | } | 303 | } |
303 | 304 | ||
304 | 305 | ||
305 | int ONetworkInterface::dataLinkType() const | 306 | int ONetworkInterface::dataLinkType() const |
306 | { | 307 | { |
307 | if ( ioctl( SIOCGIFHWADDR ) ) | 308 | if ( ioctl( SIOCGIFHWADDR ) ) |
308 | { | 309 | { |
309 | return _ifr.ifr_hwaddr.sa_family; | 310 | return _ifr.ifr_hwaddr.sa_family; |
310 | } | 311 | } |
311 | else | 312 | else |
312 | { | 313 | { |
313 | return -1; | 314 | return -1; |
314 | } | 315 | } |
315 | } | 316 | } |
316 | 317 | ||
317 | 318 | ||
318 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 319 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
319 | { | 320 | { |
320 | _mon = m; | 321 | _mon = m; |
321 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 322 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
322 | } | 323 | } |
323 | 324 | ||
324 | 325 | ||
325 | OMonitoringInterface* ONetworkInterface::monitoring() const | 326 | OMonitoringInterface* ONetworkInterface::monitoring() const |
326 | { | 327 | { |
327 | return _mon; | 328 | return _mon; |
328 | } | 329 | } |
329 | 330 | ||
330 | 331 | ||
331 | ONetworkInterface::~ONetworkInterface() | 332 | ONetworkInterface::~ONetworkInterface() |
332 | { | 333 | { |
333 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 334 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
334 | if ( _sfd != -1 ) ::close( _sfd ); | 335 | if ( _sfd != -1 ) ::close( _sfd ); |
335 | } | 336 | } |
336 | 337 | ||
337 | 338 | ||
338 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 339 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
339 | { | 340 | { |
340 | ioctl( SIOCGIFFLAGS ); | 341 | ioctl( SIOCGIFFLAGS ); |
341 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 342 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
342 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 343 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
343 | return ioctl( SIOCSIFFLAGS ); | 344 | return ioctl( SIOCSIFFLAGS ); |
344 | } | 345 | } |
345 | 346 | ||
346 | 347 | ||
347 | bool ONetworkInterface::promiscuousMode() const | 348 | bool ONetworkInterface::promiscuousMode() const |
348 | { | 349 | { |
349 | ioctl( SIOCGIFFLAGS ); | 350 | ioctl( SIOCGIFFLAGS ); |
350 | return _ifr.ifr_flags & IFF_PROMISC; | 351 | return _ifr.ifr_flags & IFF_PROMISC; |
351 | } | 352 | } |
352 | 353 | ||
353 | 354 | ||
354 | bool ONetworkInterface::isWireless() const | 355 | bool ONetworkInterface::isWireless() const |
355 | { | 356 | { |
356 | return ioctl( SIOCGIWNAME ); | 357 | return ioctl( SIOCGIWNAME ); |
357 | } | 358 | } |
358 | 359 | ||
359 | 360 | ||
360 | /*====================================================================================== | 361 | /*====================================================================================== |
361 | * OChannelHopper | 362 | * OChannelHopper |
362 | *======================================================================================*/ | 363 | *======================================================================================*/ |
363 | 364 | ||
364 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 365 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
365 | :QObject( 0, "Mickey's funky hopper" ), | 366 | :QObject( 0, "Mickey's funky hopper" ), |
366 | _iface( iface ), _interval( 0 ), _tid( 0 ) | 367 | _iface( iface ), _interval( 0 ), _tid( 0 ) |
367 | { | 368 | { |
368 | int _maxChannel = iface->channels()+1; | 369 | int _maxChannel = iface->channels()+1; |
369 | // generate fancy hopping sequence honoring the device capabilities | 370 | // generate fancy hopping sequence honoring the device capabilities |
370 | if ( _maxChannel >= 1 ) _channels.append( 1 ); | 371 | if ( _maxChannel >= 1 ) _channels.append( 1 ); |
371 | if ( _maxChannel >= 7 ) _channels.append( 7 ); | 372 | if ( _maxChannel >= 7 ) _channels.append( 7 ); |
372 | if ( _maxChannel >= 13 ) _channels.append( 13 ); | 373 | if ( _maxChannel >= 13 ) _channels.append( 13 ); |
373 | if ( _maxChannel >= 2 ) _channels.append( 2 ); | 374 | if ( _maxChannel >= 2 ) _channels.append( 2 ); |
374 | if ( _maxChannel >= 8 ) _channels.append( 8 ); | 375 | if ( _maxChannel >= 8 ) _channels.append( 8 ); |
375 | if ( _maxChannel >= 3 ) _channels.append( 3 ); | 376 | if ( _maxChannel >= 3 ) _channels.append( 3 ); |
376 | if ( _maxChannel >= 14 ) _channels.append( 14 ); | 377 | if ( _maxChannel >= 14 ) _channels.append( 14 ); |
377 | if ( _maxChannel >= 9 ) _channels.append( 9 ); | 378 | if ( _maxChannel >= 9 ) _channels.append( 9 ); |
378 | if ( _maxChannel >= 4 ) _channels.append( 4 ); | 379 | if ( _maxChannel >= 4 ) _channels.append( 4 ); |
379 | if ( _maxChannel >= 10 ) _channels.append( 10 ); | 380 | if ( _maxChannel >= 10 ) _channels.append( 10 ); |
380 | if ( _maxChannel >= 5 ) _channels.append( 5 ); | 381 | if ( _maxChannel >= 5 ) _channels.append( 5 ); |
381 | if ( _maxChannel >= 11 ) _channels.append( 11 ); | 382 | if ( _maxChannel >= 11 ) _channels.append( 11 ); |
382 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 383 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
383 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 384 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
384 | _channel = _channels.begin(); | 385 | _channel = _channels.begin(); |
385 | 386 | ||
386 | } | 387 | } |
387 | 388 | ||
388 | 389 | ||
389 | OChannelHopper::~OChannelHopper() | 390 | OChannelHopper::~OChannelHopper() |
390 | { | 391 | { |
391 | } | 392 | } |
392 | 393 | ||
393 | 394 | ||
394 | bool OChannelHopper::isActive() const | 395 | bool OChannelHopper::isActive() const |
395 | { | 396 | { |
396 | return _tid; | 397 | return _tid; |
397 | } | 398 | } |
398 | 399 | ||
399 | 400 | ||
400 | int OChannelHopper::channel() const | 401 | int OChannelHopper::channel() const |
401 | { | 402 | { |
402 | return *_channel; | 403 | return *_channel; |
403 | } | 404 | } |
404 | 405 | ||
405 | 406 | ||
406 | void OChannelHopper::timerEvent( QTimerEvent* ) | 407 | void OChannelHopper::timerEvent( QTimerEvent* ) |
407 | { | 408 | { |
408 | _iface->setChannel( *_channel ); | 409 | _iface->setChannel( *_channel ); |
409 | emit( hopped( *_channel ) ); | 410 | emit( hopped( *_channel ) ); |
410 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", | 411 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", |
411 | *_channel, (const char*) _iface->name() ); | 412 | *_channel, (const char*) _iface->name() ); |
412 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 413 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
413 | } | 414 | } |
414 | 415 | ||
415 | 416 | ||
416 | void OChannelHopper::setInterval( int interval ) | 417 | void OChannelHopper::setInterval( int interval ) |
417 | { | 418 | { |
418 | if ( interval == _interval ) | 419 | if ( interval == _interval ) |
419 | return; | 420 | return; |
420 | 421 | ||
421 | if ( _interval ) | 422 | if ( _interval ) |
422 | killTimer( _tid ); | 423 | killTimer( _tid ); |
423 | 424 | ||
424 | _tid = 0; | 425 | _tid = 0; |
425 | _interval = interval; | 426 | _interval = interval; |
426 | 427 | ||
427 | if ( _interval ) | 428 | if ( _interval ) |
428 | { | 429 | { |
429 | _tid = startTimer( interval ); | 430 | _tid = startTimer( interval ); |
430 | } | 431 | } |
431 | } | 432 | } |
432 | 433 | ||
433 | 434 | ||
434 | int OChannelHopper::interval() const | 435 | int OChannelHopper::interval() const |
435 | { | 436 | { |
436 | return _interval; | 437 | return _interval; |
437 | } | 438 | } |
438 | 439 | ||
439 | 440 | ||
440 | /*====================================================================================== | 441 | /*====================================================================================== |
441 | * OWirelessNetworkInterface | 442 | * OWirelessNetworkInterface |
442 | *======================================================================================*/ | 443 | *======================================================================================*/ |
443 | 444 | ||
444 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 445 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
445 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 446 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
446 | { | 447 | { |
447 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 448 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); |
448 | init(); | 449 | init(); |
449 | } | 450 | } |
450 | 451 | ||
451 | 452 | ||
452 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 453 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
453 | { | 454 | { |
454 | } | 455 | } |
455 | 456 | ||
456 | 457 | ||
457 | struct iwreq& OWirelessNetworkInterface::iwr() const | 458 | struct iwreq& OWirelessNetworkInterface::iwr() const |
458 | { | 459 | { |
459 | return _iwr; | 460 | return _iwr; |
460 | } | 461 | } |
461 | 462 | ||
462 | 463 | ||
463 | void OWirelessNetworkInterface::init() | 464 | void OWirelessNetworkInterface::init() |
464 | { | 465 | { |
465 | qDebug( "OWirelessNetworkInterface::init()" ); | 466 | qDebug( "OWirelessNetworkInterface::init()" ); |
466 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 467 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
467 | buildInformation(); | 468 | buildInformation(); |
468 | buildPrivateList(); | 469 | buildPrivateList(); |
469 | dumpInformation(); | 470 | dumpInformation(); |
470 | } | 471 | } |
471 | 472 | ||
472 | 473 | ||
473 | bool OWirelessNetworkInterface::isAssociated() const | 474 | bool OWirelessNetworkInterface::isAssociated() const |
474 | { | 475 | { |
475 | //FIXME: handle different modes | 476 | //FIXME: handle different modes |
476 | return associatedAP() != "44:44:44:44:44:44"; | 477 | return associatedAP() != "44:44:44:44:44:44"; |
477 | } | 478 | } |
478 | 479 | ||
479 | 480 | ||
480 | QString OWirelessNetworkInterface::associatedAP() const | 481 | QString OWirelessNetworkInterface::associatedAP() const |
481 | { | 482 | { |
482 | //FIXME: use OMacAddress | 483 | //FIXME: use OMacAddress |
483 | QString mac; | 484 | QString mac; |
484 | 485 | ||
485 | if ( ioctl( SIOCGIWAP ) ) | 486 | if ( ioctl( SIOCGIWAP ) ) |
486 | { | 487 | { |
487 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 488 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
488 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | 489 | _ifr.ifr_hwaddr.sa_data[0]&0xff, |
489 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | 490 | _ifr.ifr_hwaddr.sa_data[1]&0xff, |
490 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | 491 | _ifr.ifr_hwaddr.sa_data[2]&0xff, |
491 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | 492 | _ifr.ifr_hwaddr.sa_data[3]&0xff, |
492 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | 493 | _ifr.ifr_hwaddr.sa_data[4]&0xff, |
493 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | 494 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); |
494 | } | 495 | } |
495 | else | 496 | else |
496 | { | 497 | { |
497 | mac = "<Unknown>"; | 498 | mac = "<Unknown>"; |
498 | } | 499 | } |
499 | return mac; | 500 | return mac; |
500 | } | 501 | } |
501 | 502 | ||
502 | 503 | ||
503 | void OWirelessNetworkInterface::buildInformation() | 504 | void OWirelessNetworkInterface::buildInformation() |
504 | { | 505 | { |
505 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 506 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
506 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 507 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
507 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 508 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
508 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 509 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
509 | //ML: _too much_ space. This is damn shitty crap *sigh* | 510 | //ML: _too much_ space. This is damn shitty crap *sigh* |
510 | //ML: We allocate a large memory region in RAM and check whether the | 511 | //ML: We allocate a large memory region in RAM and check whether the |
511 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 512 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
512 | //ML: so please forward this... | 513 | //ML: so please forward this... |
513 | 514 | ||
514 | struct iwreq wrq; | 515 | struct iwreq wrq; |
515 | int len = sizeof( struct iw_range )*2; | 516 | int len = sizeof( struct iw_range )*2; |
516 | char *buffer = (char*) malloc( len ); | 517 | char *buffer = (char*) malloc( len ); |
517 | //FIXME: Validate if we actually got the memory block | 518 | //FIXME: Validate if we actually got the memory block |
518 | memset( buffer, 0, len ); | 519 | memset( buffer, 0, len ); |
519 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 520 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
520 | wrq.u.data.pointer = (caddr_t) buffer; | 521 | wrq.u.data.pointer = (caddr_t) buffer; |
521 | wrq.u.data.length = sizeof( struct iw_range ); | 522 | wrq.u.data.length = sizeof( struct iw_range ); |
522 | wrq.u.data.flags = 0; | 523 | wrq.u.data.flags = 0; |
523 | 524 | ||
524 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 525 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
525 | { | 526 | { |
526 | qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); | 527 | qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); |
527 | _channels.insert( 2412, 1 ); // 2.412 GHz | 528 | _channels.insert( 2412, 1 ); // 2.412 GHz |
528 | _channels.insert( 2417, 2 ); // 2.417 GHz | 529 | _channels.insert( 2417, 2 ); // 2.417 GHz |
529 | _channels.insert( 2422, 3 ); // 2.422 GHz | 530 | _channels.insert( 2422, 3 ); // 2.422 GHz |
530 | _channels.insert( 2427, 4 ); // 2.427 GHz | 531 | _channels.insert( 2427, 4 ); // 2.427 GHz |
531 | _channels.insert( 2432, 5 ); // 2.432 GHz | 532 | _channels.insert( 2432, 5 ); // 2.432 GHz |
532 | _channels.insert( 2437, 6 ); // 2.437 GHz | 533 | _channels.insert( 2437, 6 ); // 2.437 GHz |
533 | _channels.insert( 2442, 7 ); // 2.442 GHz | 534 | _channels.insert( 2442, 7 ); // 2.442 GHz |
534 | _channels.insert( 2447, 8 ); // 2.447 GHz | 535 | _channels.insert( 2447, 8 ); // 2.447 GHz |
535 | _channels.insert( 2452, 9 ); // 2.452 GHz | 536 | _channels.insert( 2452, 9 ); // 2.452 GHz |
536 | _channels.insert( 2457, 10 ); // 2.457 GHz | 537 | _channels.insert( 2457, 10 ); // 2.457 GHz |
537 | _channels.insert( 2462, 11 ); // 2.462 GHz | 538 | _channels.insert( 2462, 11 ); // 2.462 GHz |
538 | 539 | ||
539 | memset( &_range, 0, sizeof( struct iw_range ) ); | 540 | memset( &_range, 0, sizeof( struct iw_range ) ); |
540 | } | 541 | } |
541 | else | 542 | else |
542 | { | 543 | { |
543 | // <check if the driver overwrites stuff> | 544 | // <check if the driver overwrites stuff> |
544 | int max = 0; | 545 | int max = 0; |
545 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 546 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
546 | if (buffer[r] != 0) | 547 | if (buffer[r] != 0) |
547 | max = r; | 548 | max = r; |
548 | if (max > 0) | 549 | if (max > 0) |
549 | { | 550 | { |
550 | qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" | 551 | qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" |
551 | "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); | 552 | "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); |
552 | } | 553 | } |
553 | // </check if the driver overwrites stuff> | 554 | // </check if the driver overwrites stuff> |
554 | 555 | ||
555 | struct iw_range range; | 556 | struct iw_range range; |
556 | memcpy( &range, buffer, sizeof range ); | 557 | memcpy( &range, buffer, sizeof range ); |
557 | 558 | ||
558 | qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); | 559 | qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); |
559 | for ( int i = 0; i < range.num_frequency; ++i ) | 560 | for ( int i = 0; i < range.num_frequency; ++i ) |
560 | { | 561 | { |
561 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 562 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
562 | _channels.insert( freq, i+1 ); | 563 | _channels.insert( freq, i+1 ); |
563 | } | 564 | } |
564 | } | 565 | } |
565 | 566 | ||
566 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); | 567 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); |
567 | qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); | 568 | qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); |
568 | free(buffer); | 569 | free(buffer); |
569 | } | 570 | } |
570 | 571 | ||
571 | 572 | ||
572 | void OWirelessNetworkInterface::buildPrivateList() | 573 | void OWirelessNetworkInterface::buildPrivateList() |
573 | { | 574 | { |
574 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); | 575 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); |
575 | 576 | ||
576 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 577 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
577 | 578 | ||
578 | _iwr.u.data.pointer = (char*) &priv; | 579 | _iwr.u.data.pointer = (char*) &priv; |
579 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 580 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
580 | _iwr.u.data.flags = 0; | 581 | _iwr.u.data.flags = 0; |
581 | 582 | ||
582 | if ( !wioctl( SIOCGIWPRIV ) ) | 583 | if ( !wioctl( SIOCGIWPRIV ) ) |
583 | { | 584 | { |
584 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); | 585 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); |
585 | return; | 586 | return; |
586 | } | 587 | } |
587 | 588 | ||
588 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 589 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
589 | { | 590 | { |
590 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 591 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
591 | } | 592 | } |
592 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); | 593 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); |
593 | } | 594 | } |
594 | 595 | ||
595 | 596 | ||
596 | void OWirelessNetworkInterface::dumpInformation() const | 597 | void OWirelessNetworkInterface::dumpInformation() const |
597 | { | 598 | { |
598 | qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); | 599 | qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); |
599 | 600 | ||
600 | qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); | 601 | qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); |
601 | qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); | 602 | qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); |
602 | 603 | ||
603 | qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); | 604 | qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); |
604 | } | 605 | } |
605 | 606 | ||
606 | 607 | ||
607 | int OWirelessNetworkInterface::channel() const | 608 | int OWirelessNetworkInterface::channel() const |
608 | { | 609 | { |
609 | //FIXME: When monitoring enabled, then use it | 610 | //FIXME: When monitoring enabled, then use it |
610 | //FIXME: to gather the current RF channel | 611 | //FIXME: to gather the current RF channel |
611 | //FIXME: Until then, get active channel from hopper. | 612 | //FIXME: Until then, get active channel from hopper. |
612 | if ( _hopper && _hopper->isActive() ) | 613 | if ( _hopper && _hopper->isActive() ) |
613 | return _hopper->channel(); | 614 | return _hopper->channel(); |
614 | 615 | ||
615 | if ( !wioctl( SIOCGIWFREQ ) ) | 616 | if ( !wioctl( SIOCGIWFREQ ) ) |
616 | { | 617 | { |
617 | return -1; | 618 | return -1; |
618 | } | 619 | } |
619 | else | 620 | else |
620 | { | 621 | { |
621 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 622 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
622 | } | 623 | } |
623 | } | 624 | } |
624 | 625 | ||
625 | 626 | ||
626 | void OWirelessNetworkInterface::setChannel( int c ) const | 627 | void OWirelessNetworkInterface::setChannel( int c ) const |
627 | { | 628 | { |
628 | if ( !c ) | 629 | if ( !c ) |
629 | { | 630 | { |
630 | qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); | 631 | qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); |
631 | return; | 632 | return; |
632 | } | 633 | } |
633 | 634 | ||
634 | if ( !_mon ) | 635 | if ( !_mon ) |
635 | { | 636 | { |
636 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 637 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
637 | _iwr.u.freq.m = c; | 638 | _iwr.u.freq.m = c; |
638 | _iwr.u.freq.e = 0; | 639 | _iwr.u.freq.e = 0; |
639 | wioctl( SIOCSIWFREQ ); | 640 | wioctl( SIOCSIWFREQ ); |
640 | } | 641 | } |
641 | else | 642 | else |
642 | { | 643 | { |
643 | _mon->setChannel( c ); | 644 | _mon->setChannel( c ); |
644 | } | 645 | } |
645 | } | 646 | } |
646 | 647 | ||
647 | 648 | ||
648 | double OWirelessNetworkInterface::frequency() const | 649 | double OWirelessNetworkInterface::frequency() const |
649 | { | 650 | { |
650 | if ( !wioctl( SIOCGIWFREQ ) ) | 651 | if ( !wioctl( SIOCGIWFREQ ) ) |
651 | { | 652 | { |
652 | return -1.0; | 653 | return -1.0; |
653 | } | 654 | } |
654 | else | 655 | else |
655 | { | 656 | { |
656 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 657 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
657 | } | 658 | } |
658 | } | 659 | } |
659 | 660 | ||
660 | 661 | ||
661 | int OWirelessNetworkInterface::channels() const | 662 | int OWirelessNetworkInterface::channels() const |
662 | { | 663 | { |
663 | return _channels.count(); | 664 | return _channels.count(); |
664 | } | 665 | } |
665 | 666 | ||
666 | 667 | ||
667 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 668 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
668 | { | 669 | { |
669 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 670 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
670 | _hopper->setInterval( interval ); | 671 | _hopper->setInterval( interval ); |
671 | //FIXME: When and by whom will the channel hopper be deleted? | 672 | //FIXME: When and by whom will the channel hopper be deleted? |
672 | //TODO: rely on QObject hierarchy | 673 | //TODO: rely on QObject hierarchy |
673 | } | 674 | } |
674 | 675 | ||
675 | 676 | ||
676 | int OWirelessNetworkInterface::channelHopping() const | 677 | int OWirelessNetworkInterface::channelHopping() const |
677 | { | 678 | { |
678 | return _hopper->interval(); | 679 | return _hopper->interval(); |
679 | } | 680 | } |
680 | 681 | ||
681 | 682 | ||
682 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 683 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
683 | { | 684 | { |
684 | return _hopper; | 685 | return _hopper; |
685 | } | 686 | } |
686 | 687 | ||
687 | 688 | ||
688 | void OWirelessNetworkInterface::setMode( const QString& mode ) | 689 | void OWirelessNetworkInterface::setMode( const QString& mode ) |
689 | { | 690 | { |
690 | if ( mode == "auto" ) _iwr.u.mode = IW_MODE_AUTO; | 691 | if ( mode == "auto" ) _iwr.u.mode = IW_MODE_AUTO; |
691 | else if ( mode == "adhoc" ) _iwr.u.mode = IW_MODE_ADHOC; | 692 | else if ( mode == "adhoc" ) _iwr.u.mode = IW_MODE_ADHOC; |
692 | else if ( mode == "managed" ) _iwr.u.mode = IW_MODE_INFRA; | 693 | else if ( mode == "managed" ) _iwr.u.mode = IW_MODE_INFRA; |
693 | else if ( mode == "master" ) _iwr.u.mode = IW_MODE_MASTER; | 694 | else if ( mode == "master" ) _iwr.u.mode = IW_MODE_MASTER; |
694 | else if ( mode == "repeater" ) _iwr.u.mode = IW_MODE_REPEAT; | 695 | else if ( mode == "repeater" ) _iwr.u.mode = IW_MODE_REPEAT; |
695 | else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND; | 696 | else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND; |
696 | else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR; | 697 | else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR; |
697 | else | 698 | else |
698 | { | 699 | { |
699 | qDebug( "ONetwork: Warning! Invalid IEEE 802.11 mode '%s' specified.", (const char*) mode ); | 700 | qDebug( "ONetwork: Warning! Invalid IEEE 802.11 mode '%s' specified.", (const char*) mode ); |
700 | return; | 701 | return; |
701 | } | 702 | } |
702 | wioctl( SIOCSIWMODE ); | 703 | wioctl( SIOCSIWMODE ); |
703 | } | 704 | } |
704 | 705 | ||
705 | 706 | ||
706 | QString OWirelessNetworkInterface::mode() const | 707 | QString OWirelessNetworkInterface::mode() const |
707 | { | 708 | { |
708 | if ( !wioctl( SIOCGIWMODE ) ) | 709 | if ( !wioctl( SIOCGIWMODE ) ) |
709 | { | 710 | { |
710 | return "<unknown>"; | 711 | return "<unknown>"; |
711 | } | 712 | } |
712 | switch ( _iwr.u.mode ) | 713 | switch ( _iwr.u.mode ) |
713 | { | 714 | { |
714 | case IW_MODE_AUTO: return "auto"; | 715 | case IW_MODE_AUTO: return "auto"; |
715 | case IW_MODE_ADHOC: return "adhoc"; | 716 | case IW_MODE_ADHOC: return "adhoc"; |
716 | case IW_MODE_INFRA: return "managed"; | 717 | case IW_MODE_INFRA: return "managed"; |
717 | case IW_MODE_MASTER: return "master"; | 718 | case IW_MODE_MASTER: return "master"; |
718 | case IW_MODE_REPEAT: return "repeater"; | 719 | case IW_MODE_REPEAT: return "repeater"; |
719 | case IW_MODE_SECOND: return "secondary"; | 720 | case IW_MODE_SECOND: return "secondary"; |
720 | case IW_MODE_MONITOR: return "monitor"; | 721 | case IW_MODE_MONITOR: return "monitor"; |
721 | default: assert( 0 ); // shouldn't happen | 722 | default: assert( 0 ); // shouldn't happen |
722 | } | 723 | } |
723 | } | 724 | } |
724 | 725 | ||
725 | 726 | ||
726 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 727 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
727 | { | 728 | { |
728 | if ( _mon ) | 729 | if ( _mon ) |
729 | _mon->setEnabled( b ); | 730 | _mon->setEnabled( b ); |
730 | else | 731 | else |
731 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 732 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
732 | } | 733 | } |
733 | 734 | ||
734 | 735 | ||
735 | bool OWirelessNetworkInterface::monitorMode() const | 736 | bool OWirelessNetworkInterface::monitorMode() const |
736 | { | 737 | { |
737 | qDebug( "dataLinkType = %d", dataLinkType() ); | 738 | qDebug( "dataLinkType = %d", dataLinkType() ); |
738 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); | 739 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); |
739 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... | 740 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... |
740 | //FIXME: What is 119, by the way? | 741 | //FIXME: What is 119, by the way? |
741 | } | 742 | } |
742 | 743 | ||
743 | 744 | ||
744 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 745 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
745 | { | 746 | { |
746 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | 747 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); |
747 | _iwr.u.essid.length = nickname.length(); | 748 | _iwr.u.essid.length = nickname.length(); |
748 | wioctl( SIOCSIWNICKN ); | 749 | wioctl( SIOCSIWNICKN ); |
749 | } | 750 | } |
750 | 751 | ||
751 | 752 | ||
752 | QString OWirelessNetworkInterface::nickName() const | 753 | QString OWirelessNetworkInterface::nickName() const |
753 | { | 754 | { |
754 | char str[IW_ESSID_MAX_SIZE]; | 755 | char str[IW_ESSID_MAX_SIZE]; |
755 | _iwr.u.data.pointer = &str[0]; | 756 | _iwr.u.data.pointer = &str[0]; |
756 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 757 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
757 | if ( !wioctl( SIOCGIWNICKN ) ) | 758 | if ( !wioctl( SIOCGIWNICKN ) ) |
758 | { | 759 | { |
759 | return "<unknown>"; | 760 | return "<unknown>"; |
760 | } | 761 | } |
761 | else | 762 | else |
762 | { | 763 | { |
763 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 764 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
764 | return str; | 765 | return str; |
765 | } | 766 | } |
766 | } | 767 | } |
767 | 768 | ||
768 | 769 | ||
769 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 770 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
770 | { | 771 | { |
771 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 772 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
772 | if ( !priv ) | 773 | if ( !priv ) |
773 | { | 774 | { |
774 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); | 775 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); |
775 | return; | 776 | return; |
776 | } | 777 | } |
777 | if ( priv->numberSetArgs() != numargs ) | 778 | if ( priv->numberSetArgs() != numargs ) |
778 | { | 779 | { |
779 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); | 780 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); |
780 | return; | 781 | return; |
781 | } | 782 | } |
782 | 783 | ||
783 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); | 784 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); |
784 | memset( &_iwr, 0, sizeof _iwr ); | 785 | memset( &_iwr, 0, sizeof _iwr ); |
785 | va_list argp; | 786 | va_list argp; |
786 | va_start( argp, numargs ); | 787 | va_start( argp, numargs ); |
787 | for ( int i = 0; i < numargs; ++i ) | 788 | for ( int i = 0; i < numargs; ++i ) |
788 | { | 789 | { |
789 | priv->setParameter( i, va_arg( argp, int ) ); | 790 | priv->setParameter( i, va_arg( argp, int ) ); |
790 | } | 791 | } |
791 | va_end( argp ); | 792 | va_end( argp ); |
792 | priv->invoke(); | 793 | priv->invoke(); |
793 | } | 794 | } |
794 | 795 | ||
795 | 796 | ||
796 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 797 | void OWirelessNetworkInterface::getPrivate( const QString& call ) |
797 | { | 798 | { |
798 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); | 799 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); |
799 | } | 800 | } |
800 | 801 | ||
801 | 802 | ||
802 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 803 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
803 | { | 804 | { |
804 | return child( (const char*) call ); | 805 | return child( (const char*) call ); |
805 | } | 806 | } |
806 | 807 | ||
807 | 808 | ||
808 | QString OWirelessNetworkInterface::SSID() const | 809 | QString OWirelessNetworkInterface::SSID() const |
809 | { | 810 | { |
810 | char str[IW_ESSID_MAX_SIZE]; | 811 | char str[IW_ESSID_MAX_SIZE]; |
811 | _iwr.u.essid.pointer = &str[0]; | 812 | _iwr.u.essid.pointer = &str[0]; |
812 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 813 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
813 | if ( !wioctl( SIOCGIWESSID ) ) | 814 | if ( !wioctl( SIOCGIWESSID ) ) |
814 | { | 815 | { |
815 | return "<unknown>"; | 816 | return "<unknown>"; |
816 | } | 817 | } |
817 | else | 818 | else |
818 | { | 819 | { |
819 | return str; | 820 | return str; |
820 | } | 821 | } |
821 | } | 822 | } |
822 | 823 | ||
823 | 824 | ||
824 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 825 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
825 | { | 826 | { |
826 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 827 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
827 | _iwr.u.essid.length = ssid.length(); | 828 | _iwr.u.essid.length = ssid.length(); |
828 | wioctl( SIOCSIWESSID ); | 829 | wioctl( SIOCSIWESSID ); |
829 | } | 830 | } |
830 | 831 | ||
831 | 832 | ||
832 | int OWirelessNetworkInterface::scanNetwork() | 833 | int OWirelessNetworkInterface::scanNetwork() |
833 | { | 834 | { |
834 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 835 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
835 | _iwr.u.param.value = 0; | 836 | _iwr.u.param.value = 0; |
836 | if ( !wioctl( SIOCSIWSCAN ) ) | 837 | if ( !wioctl( SIOCSIWSCAN ) ) |
837 | { | 838 | { |
838 | return -1; | 839 | return -1; |
839 | } | 840 | } |
840 | 841 | ||
841 | int timeout = 1000000; | 842 | int timeout = 1000000; |
842 | 843 | ||
843 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); | 844 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); |
844 | 845 | ||
845 | bool results = false; | 846 | bool results = false; |
846 | struct timeval tv; | 847 | struct timeval tv; |
847 | tv.tv_sec = 0; | 848 | tv.tv_sec = 0; |
848 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 849 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
849 | char buffer[IW_SCAN_MAX_DATA]; | 850 | char buffer[IW_SCAN_MAX_DATA]; |
850 | 851 | ||
851 | while ( !results && timeout > 0 ) | 852 | while ( !results && timeout > 0 ) |
852 | { | 853 | { |
853 | timeout -= tv.tv_usec; | 854 | timeout -= tv.tv_usec; |
854 | select( 0, 0, 0, 0, &tv ); | 855 | select( 0, 0, 0, 0, &tv ); |
855 | 856 | ||
856 | _iwr.u.data.pointer = &buffer[0]; | 857 | _iwr.u.data.pointer = &buffer[0]; |
857 | _iwr.u.data.flags = 0; | 858 | _iwr.u.data.flags = 0; |
858 | _iwr.u.data.length = sizeof buffer; | 859 | _iwr.u.data.length = sizeof buffer; |
859 | if ( wioctl( SIOCGIWSCAN ) ) | 860 | if ( wioctl( SIOCGIWSCAN ) ) |
860 | { | 861 | { |
861 | results = true; | 862 | results = true; |
862 | continue; | 863 | continue; |
863 | } | 864 | } |
864 | else if ( errno == EAGAIN) | 865 | else if ( errno == EAGAIN) |
865 | { | 866 | { |
866 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); | 867 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); |
867 | #if 0 | 868 | #if 0 |
868 | if ( qApp ) | 869 | if ( qApp ) |
869 | { | 870 | { |
870 | qApp->processEvents( 100 ); | 871 | qApp->processEvents( 100 ); |
871 | continue; | 872 | continue; |
872 | } | 873 | } |
873 | #endif | 874 | #endif |
874 | tv.tv_sec = 0; | 875 | tv.tv_sec = 0; |
875 | tv.tv_usec = 100000; | 876 | tv.tv_usec = 100000; |
876 | continue; | 877 | continue; |
877 | } | 878 | } |
878 | } | 879 | } |
879 | 880 | ||
880 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); | 881 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); |
881 | 882 | ||
882 | if ( results ) | 883 | if ( results ) |
883 | { | 884 | { |
885 | qDebug( " - result length = %d", _iwr.u.data.length ); | ||
886 | if ( !_iwr.u.data.length ) | ||
887 | { | ||
888 | qDebug( " - no results (empty neighbourhood)" ); | ||
889 | return 0; | ||
890 | } | ||
891 | |||
884 | qDebug( " - results are in!" ); | 892 | qDebug( " - results are in!" ); |
893 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); | ||
894 | |||
895 | int stations = 0; | ||
896 | |||
897 | // parse results | ||
898 | |||
899 | int offset = 0; | ||
900 | struct iw_event* we = (struct iw_event*) &buffer[0]; | ||
901 | |||
902 | while ( offset < _iwr.u.data.length ) | ||
903 | { | ||
904 | //const char* cmd = *(*_ioctlmap)[we->cmd]; | ||
905 | //if ( !cmd ) cmd = "<unknown>"; | ||
906 | qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); | ||
907 | switch (we->cmd) | ||
908 | { | ||
909 | case SIOCGIWAP: qDebug( "SIOCGIWAP" ); stations++; break; | ||
910 | case SIOCGIWMODE: qDebug( "SIOCGIWMODE" ); break; | ||
911 | case SIOCGIWFREQ: qDebug( "SIOCGIWFREQ" ); break; | ||
912 | case SIOCGIWESSID: qDebug( "SIOCGIWESSID" ); break; | ||
913 | case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; | ||
914 | case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; | ||
915 | case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ | ||
916 | case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ | ||
917 | case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ | ||
918 | case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ | ||
919 | case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ | ||
920 | default: qDebug( "unhandled event" ); | ||
921 | } | ||
922 | |||
923 | offset += we->len; | ||
924 | we = (struct iw_event*) &buffer[offset]; | ||
925 | } | ||
926 | |||
885 | } | 927 | } |
886 | else | 928 | else |
887 | { | 929 | { |
888 | qDebug( " - no results :(" ); | 930 | qDebug( " - no results (timeout) :(" ); |
931 | return 0; | ||
889 | } | 932 | } |
890 | } | 933 | } |
891 | 934 | ||
892 | 935 | ||
893 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 936 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
894 | { | 937 | { |
895 | #ifndef NODEBUG | 938 | #ifndef NODEBUG |
896 | int result = ::ioctl( _sfd, call, &iwreq ); | 939 | int result = ::ioctl( _sfd, call, &iwreq ); |
897 | if ( result == -1 ) | 940 | if ( result == -1 ) |
898 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); | 941 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); |
899 | else | 942 | else |
900 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); | 943 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); |
901 | return ( result != -1 ); | 944 | return ( result != -1 ); |
902 | #else | 945 | #else |
903 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 946 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
904 | #endif | 947 | #endif |
905 | } | 948 | } |
906 | 949 | ||
907 | 950 | ||
908 | bool OWirelessNetworkInterface::wioctl( int call ) const | 951 | bool OWirelessNetworkInterface::wioctl( int call ) const |
909 | { | 952 | { |
910 | strcpy( _iwr.ifr_name, name() ); | 953 | strcpy( _iwr.ifr_name, name() ); |
911 | return wioctl( call, _iwr ); | 954 | return wioctl( call, _iwr ); |
912 | } | 955 | } |
913 | 956 | ||
914 | 957 | ||
915 | /*====================================================================================== | 958 | /*====================================================================================== |
916 | * OMonitoringInterface | 959 | * OMonitoringInterface |
917 | *======================================================================================*/ | 960 | *======================================================================================*/ |
918 | 961 | ||
919 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 962 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
920 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 963 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
921 | { | 964 | { |
922 | } | 965 | } |
923 | 966 | ||
924 | 967 | ||
925 | OMonitoringInterface::~OMonitoringInterface() | 968 | OMonitoringInterface::~OMonitoringInterface() |
926 | { | 969 | { |
927 | } | 970 | } |
928 | 971 | ||
929 | 972 | ||
930 | void OMonitoringInterface::setChannel( int c ) | 973 | void OMonitoringInterface::setChannel( int c ) |
931 | { | 974 | { |
932 | // use standard WE channel switching protocol | 975 | // use standard WE channel switching protocol |
933 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 976 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
934 | _if->_iwr.u.freq.m = c; | 977 | _if->_iwr.u.freq.m = c; |
935 | _if->_iwr.u.freq.e = 0; | 978 | _if->_iwr.u.freq.e = 0; |
936 | _if->wioctl( SIOCSIWFREQ ); | 979 | _if->wioctl( SIOCSIWFREQ ); |
937 | } | 980 | } |
938 | 981 | ||
939 | 982 | ||
940 | bool OMonitoringInterface::enabled() const | 983 | bool OMonitoringInterface::enabled() const |
941 | { | 984 | { |
942 | return _if->monitorMode(); | 985 | return _if->monitorMode(); |
943 | } | 986 | } |
944 | 987 | ||
945 | 988 | ||
946 | void OMonitoringInterface::setEnabled( bool b ) | 989 | void OMonitoringInterface::setEnabled( bool b ) |
947 | { | 990 | { |
948 | } | 991 | } |
949 | 992 | ||
950 | 993 | ||
951 | /*====================================================================================== | 994 | /*====================================================================================== |
952 | * OCiscoMonitoringInterface | 995 | * OCiscoMonitoringInterface |
953 | *======================================================================================*/ | 996 | *======================================================================================*/ |
954 | 997 | ||
955 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 998 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
956 | :OMonitoringInterface( iface, prismHeader ) | 999 | :OMonitoringInterface( iface, prismHeader ) |
957 | { | 1000 | { |
958 | iface->setMonitoring( this ); | 1001 | iface->setMonitoring( this ); |
959 | } | 1002 | } |
960 | 1003 | ||
961 | 1004 | ||
962 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 1005 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
963 | { | 1006 | { |
964 | } | 1007 | } |
965 | 1008 | ||
966 | 1009 | ||
967 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 1010 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
968 | { | 1011 | { |
969 | QString fname; | 1012 | QString fname; |
970 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 1013 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
971 | QFile f( fname ); | 1014 | QFile f( fname ); |
972 | if ( !f.exists() ) return; | 1015 | if ( !f.exists() ) return; |
973 | 1016 | ||
974 | if ( f.open( IO_WriteOnly ) ) | 1017 | if ( f.open( IO_WriteOnly ) ) |
975 | { | 1018 | { |
976 | QTextStream s( &f ); | 1019 | QTextStream s( &f ); |
977 | s << "Mode: r"; | 1020 | s << "Mode: r"; |
978 | s << "Mode: y"; | 1021 | s << "Mode: y"; |
979 | s << "XmitPower: 1"; | 1022 | s << "XmitPower: 1"; |
980 | } | 1023 | } |
981 | 1024 | ||
982 | // flushing and closing will be done automatically when f goes out of scope | 1025 | // flushing and closing will be done automatically when f goes out of scope |
983 | } | 1026 | } |
984 | 1027 | ||
985 | 1028 | ||
986 | QString OCiscoMonitoringInterface::name() const | 1029 | QString OCiscoMonitoringInterface::name() const |
987 | { | 1030 | { |
988 | return "cisco"; | 1031 | return "cisco"; |
989 | } | 1032 | } |
990 | 1033 | ||
991 | 1034 | ||
992 | void OCiscoMonitoringInterface::setChannel( int ) | 1035 | void OCiscoMonitoringInterface::setChannel( int ) |
993 | { | 1036 | { |
994 | // cisco devices automatically switch channels when in monitor mode | 1037 | // cisco devices automatically switch channels when in monitor mode |
995 | } | 1038 | } |
996 | 1039 | ||
997 | 1040 | ||
998 | /*====================================================================================== | 1041 | /*====================================================================================== |
999 | * OWlanNGMonitoringInterface | 1042 | * OWlanNGMonitoringInterface |
1000 | *======================================================================================*/ | 1043 | *======================================================================================*/ |
1001 | 1044 | ||
1002 | 1045 | ||
1003 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1046 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1004 | :OMonitoringInterface( iface, prismHeader ) | 1047 | :OMonitoringInterface( iface, prismHeader ) |
1005 | { | 1048 | { |
1006 | iface->setMonitoring( this ); | 1049 | iface->setMonitoring( this ); |
1007 | } | 1050 | } |
1008 | 1051 | ||
1009 | 1052 | ||
1010 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 1053 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
1011 | { | 1054 | { |
1012 | } | 1055 | } |
1013 | 1056 | ||
1014 | 1057 | ||
1015 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 1058 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
1016 | { | 1059 | { |
1017 | //FIXME: do nothing if its already in the same mode | 1060 | //FIXME: do nothing if its already in the same mode |
1018 | 1061 | ||
1019 | QString enable = b ? "true" : "false"; | 1062 | QString enable = b ? "true" : "false"; |
1020 | QString prism = _prismHeader ? "true" : "false"; | 1063 | QString prism = _prismHeader ? "true" : "false"; |
1021 | QString cmd; | 1064 | QString cmd; |
1022 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1065 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1023 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); | 1066 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); |
1024 | system( cmd ); | 1067 | system( cmd ); |
1025 | } | 1068 | } |
1026 | 1069 | ||
1027 | 1070 | ||
1028 | QString OWlanNGMonitoringInterface::name() const | 1071 | QString OWlanNGMonitoringInterface::name() const |
1029 | { | 1072 | { |
1030 | return "wlan-ng"; | 1073 | return "wlan-ng"; |
1031 | } | 1074 | } |
1032 | 1075 | ||
1033 | 1076 | ||
1034 | void OWlanNGMonitoringInterface::setChannel( int c ) | 1077 | void OWlanNGMonitoringInterface::setChannel( int c ) |
1035 | { | 1078 | { |
1036 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. | 1079 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. |
1037 | 1080 | ||
1038 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; | 1081 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; |
1039 | QString prism = _prismHeader ? "true" : "false"; | 1082 | QString prism = _prismHeader ? "true" : "false"; |
1040 | QString cmd; | 1083 | QString cmd; |
1041 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1084 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1042 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); | 1085 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); |
1043 | system( cmd ); | 1086 | system( cmd ); |
1044 | } | 1087 | } |
1045 | 1088 | ||
1046 | 1089 | ||
1047 | /*====================================================================================== | 1090 | /*====================================================================================== |
1048 | * OHostAPMonitoringInterface | 1091 | * OHostAPMonitoringInterface |
1049 | *======================================================================================*/ | 1092 | *======================================================================================*/ |
1050 | 1093 | ||
1051 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1094 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1052 | :OMonitoringInterface( iface, prismHeader ) | 1095 | :OMonitoringInterface( iface, prismHeader ) |
1053 | { | 1096 | { |
1054 | iface->setMonitoring( this ); | 1097 | iface->setMonitoring( this ); |
1055 | } | 1098 | } |
1056 | 1099 | ||
1057 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 1100 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
1058 | { | 1101 | { |
1059 | } | 1102 | } |
1060 | 1103 | ||
1061 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 1104 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
1062 | { | 1105 | { |
1063 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 1106 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
1064 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 1107 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
1065 | 1108 | ||
1066 | #if WIRELESS_EXT > 14 | 1109 | #if WIRELESS_EXT > 14 |
1067 | if ( b ) | 1110 | if ( b ) |
1068 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | 1111 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header |
1069 | else | 1112 | else |
1070 | _if->setMode( "managed" ); | 1113 | _if->setMode( "managed" ); |
1071 | #else | 1114 | #else |
1072 | int monitorCode = _prismHeader ? 1 : 2; | 1115 | int monitorCode = _prismHeader ? 1 : 2; |
1073 | if ( b ) | 1116 | if ( b ) |
1074 | { | 1117 | { |
1075 | _if->setPrivate( "monitor", 1, monitorCode ); | 1118 | _if->setPrivate( "monitor", 1, monitorCode ); |
1076 | } | 1119 | } |
1077 | else | 1120 | else |
1078 | { | 1121 | { |
1079 | _if->setPrivate( "monitor", 1, 0 ); | 1122 | _if->setPrivate( "monitor", 1, 0 ); |
1080 | } | 1123 | } |
1081 | #endif | 1124 | #endif |
1082 | } | 1125 | } |
1083 | 1126 | ||
1084 | 1127 | ||
1085 | QString OHostAPMonitoringInterface::name() const | 1128 | QString OHostAPMonitoringInterface::name() const |
1086 | { | 1129 | { |
1087 | return "hostap"; | 1130 | return "hostap"; |
1088 | } | 1131 | } |
1089 | 1132 | ||
1090 | 1133 | ||
1091 | /*====================================================================================== | 1134 | /*====================================================================================== |
1092 | * OOrinocoNetworkInterface | 1135 | * OOrinocoNetworkInterface |
1093 | *======================================================================================*/ | 1136 | *======================================================================================*/ |
1094 | 1137 | ||
1095 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1138 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1096 | :OMonitoringInterface( iface, prismHeader ) | 1139 | :OMonitoringInterface( iface, prismHeader ) |
1097 | { | 1140 | { |
1098 | iface->setMonitoring( this ); | 1141 | iface->setMonitoring( this ); |
1099 | } | 1142 | } |
1100 | 1143 | ||
1101 | 1144 | ||
1102 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1145 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1103 | { | 1146 | { |
1104 | } | 1147 | } |
1105 | 1148 | ||
1106 | 1149 | ||
1107 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1150 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1108 | { | 1151 | { |
1109 | int monitorCode = _prismHeader ? 1 : 2; | 1152 | int monitorCode = _prismHeader ? 1 : 2; |
1110 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1153 | _if->setPrivate( "monitor", 2, monitorCode, c ); |
1111 | } | 1154 | } |
1112 | 1155 | ||
1113 | 1156 | ||
1114 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1157 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1115 | { | 1158 | { |
1116 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 1159 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
1117 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 1160 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
1118 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported | 1161 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported |
1119 | 1162 | ||
1120 | #if 0 | 1163 | #if 0 |
1121 | //#if WIRELESS_EXT > 14 | 1164 | //#if WIRELESS_EXT > 14 |
1122 | if ( b ) | 1165 | if ( b ) |
1123 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | 1166 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header |
1124 | else | 1167 | else |
1125 | _if->setMode( "managed" ); | 1168 | _if->setMode( "managed" ); |
1126 | #else | 1169 | #else |
1127 | if ( b ) | 1170 | if ( b ) |
1128 | { | 1171 | { |
1129 | setChannel( 1 ); | 1172 | setChannel( 1 ); |
1130 | } | 1173 | } |
1131 | else | 1174 | else |
1132 | { | 1175 | { |
1133 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1176 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1134 | } | 1177 | } |
1135 | #endif | 1178 | #endif |
1136 | } | 1179 | } |
1137 | 1180 | ||
1138 | 1181 | ||
1139 | QString OOrinocoMonitoringInterface::name() const | 1182 | QString OOrinocoMonitoringInterface::name() const |
1140 | { | 1183 | { |
1141 | return "orinoco"; | 1184 | return "orinoco"; |
1142 | } | 1185 | } |
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 304d968..d966462 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro | |||
@@ -1,32 +1,34 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = 802_11_user.h \ | 4 | HEADERS = 802_11_user.h \ |
5 | dhcp.h \ | 5 | dhcp.h \ |
6 | udp_ports.h \ | 6 | udp_ports.h \ |
7 | wireless.h \ | 7 | wireless.h \ |
8 | oioctlmap.h \ | 8 | oioctlmap.h \ |
9 | omanufacturerdb.h \ | 9 | omanufacturerdb.h \ |
10 | onetutils.h \ | 10 | onetutils.h \ |
11 | onetwork.h \ | 11 | onetwork.h \ |
12 | opcap.h | 12 | opcap.h \ |
13 | ostation.h | ||
13 | SOURCES = oioctlmap.cpp \ | 14 | SOURCES = oioctlmap.cpp \ |
14 | omanufacturerdb.cpp \ | 15 | omanufacturerdb.cpp \ |
15 | onetutils.cpp \ | 16 | onetutils.cpp \ |
16 | onetwork.cpp \ | 17 | onetwork.cpp \ |
17 | opcap.cpp | 18 | opcap.cpp \ |
19 | ostation.cpp | ||
18 | INTERFACES = | 20 | INTERFACES = |
19 | TARGET = opienet2 | 21 | TARGET = opienet2 |
20 | VERSION = 1.8.1 | 22 | VERSION = 1.8.1 |
21 | INCLUDEPATH += $(OPIEDIR)/include | 23 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 24 | DEPENDPATH += $(OPIEDIR)/include |
23 | LIBS += -lpcap | 25 | LIBS += -lpcap |
24 | 26 | ||
25 | 27 | ||
26 | !contains( platform, x11 ) { | 28 | !contains( platform, x11 ) { |
27 | include ( $(OPIEDIR)/include.pro ) | 29 | include ( $(OPIEDIR)/include.pro ) |
28 | } | 30 | } |
29 | 31 | ||
30 | contains( platform, x11 ) { | 32 | contains( platform, x11 ) { |
31 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 33 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
32 | } | 34 | } |
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp new file mode 100644 index 0000000..3817b31 --- a/dev/null +++ b/libopie2/opienet/ostation.cpp | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #include <opie2/ostation.h> | ||
33 | |||
34 | /*====================================================================================== | ||
35 | * OStation | ||
36 | *======================================================================================*/ | ||
37 | |||
38 | OStation::OStation() | ||
39 | { | ||
40 | qDebug( "OStation::OStation()" ); | ||
41 | } | ||
42 | |||
43 | |||
44 | OStation::~OStation() | ||
45 | { | ||
46 | qDebug( "OStation::~OStation()" ); | ||
47 | } | ||
48 | |||
49 | |||
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h new file mode 100644 index 0000000..f61570b --- a/dev/null +++ b/libopie2/opienet/ostation.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #ifndef OSTATION_H | ||
33 | #define OSTATION_H | ||
34 | |||
35 | #include <opie2/onetutils.h> | ||
36 | |||
37 | #include <qdict.h> | ||
38 | #include <qmap.h> | ||
39 | #include <qstring.h> | ||
40 | #include <qhostaddress.h> | ||
41 | #include <qobject.h> | ||
42 | |||
43 | #include <sys/types.h> | ||
44 | |||
45 | class OStation; | ||
46 | |||
47 | typedef QDict<OStation> OStationDict; | ||
48 | |||
49 | /*====================================================================================== | ||
50 | * OStation | ||
51 | *======================================================================================*/ | ||
52 | |||
53 | class OStation | ||
54 | { | ||
55 | public: | ||
56 | OStation(); | ||
57 | ~OStation(); | ||
58 | |||
59 | private: | ||
60 | OMacAddress macAddress; | ||
61 | QHostAddress ipAddress; | ||
62 | QString ssid; | ||
63 | QString type; | ||
64 | }; | ||
65 | |||
66 | #endif // OSTATION_H | ||
67 | |||