-rw-r--r-- | libopie2/opienet/onetwork.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index a953296..f5fbe1d 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,299 +1,306 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2004 by Michael 'Mickey' Lauer | 3 | Copyright (C) 2003-2004 by Michael 'Mickey' Lauer |
4 | =. <mickey@Vanille.de> | 4 | =. <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef ONETWORK_H | 31 | #ifndef ONETWORK_H |
32 | #define ONETWORK_H | 32 | #define ONETWORK_H |
33 | 33 | ||
34 | #if !defined( OPIE_WE_VERSION ) | 34 | #if !defined( OPIE_WE_VERSION ) |
35 | #error Need to define a wireless extension version to build against! | 35 | #warning No wireless extension specified; autodetecting... |
36 | #endif | 36 | #include <linux/version.h> |
37 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) | ||
38 | #define OPIE_WE_VERSION 15 | ||
39 | #else | ||
40 | #define OPIE_WE_VERSION 16 | ||
41 | #endif // LINUX_VERSION_CODE < KERNEL_VERSION(2.4.23) | ||
42 | #endif // !defined( OPIE_WE_VERSION ) | ||
37 | 43 | ||
38 | #if OPIE_WE_VERSION == 15 | 44 | #if OPIE_WE_VERSION == 15 |
39 | #include "wireless.15.h" | 45 | #include "wireless.15.h" |
46 | #warning Using WE V15 | ||
40 | #endif | 47 | #endif |
41 | |||
42 | #if OPIE_WE_VERSION == 16 | 48 | #if OPIE_WE_VERSION == 16 |
43 | #include "wireless.16.h" | 49 | #include "wireless.16.h" |
50 | #warning Using WE V16 | ||
44 | #endif | 51 | #endif |
45 | 52 | ||
46 | /* OPIE */ | 53 | /* OPIE */ |
47 | 54 | ||
48 | #include <opie2/onetutils.h> | 55 | #include <opie2/onetutils.h> |
49 | #include <opie2/ostation.h> | 56 | #include <opie2/ostation.h> |
50 | 57 | ||
51 | /* QT */ | 58 | /* QT */ |
52 | 59 | ||
53 | #include <qvaluelist.h> | 60 | #include <qvaluelist.h> |
54 | #include <qdict.h> | 61 | #include <qdict.h> |
55 | #include <qmap.h> | 62 | #include <qmap.h> |
56 | #include <qobject.h> | 63 | #include <qobject.h> |
57 | #include <qhostaddress.h> | 64 | #include <qhostaddress.h> |
58 | 65 | ||
59 | namespace Opie { | 66 | namespace Opie { |
60 | namespace Net { | 67 | namespace Net { |
61 | 68 | ||
62 | class ONetworkInterface; | 69 | class ONetworkInterface; |
63 | class OWirelessNetworkInterface; | 70 | class OWirelessNetworkInterface; |
64 | class OChannelHopper; | 71 | class OChannelHopper; |
65 | class OMonitoringInterface; | 72 | class OMonitoringInterface; |
66 | 73 | ||
67 | /*====================================================================================== | 74 | /*====================================================================================== |
68 | * ONetwork | 75 | * ONetwork |
69 | *======================================================================================*/ | 76 | *======================================================================================*/ |
70 | 77 | ||
71 | /** | 78 | /** |
72 | * @brief A container class for all network interfaces | 79 | * @brief A container class for all network interfaces |
73 | * | 80 | * |
74 | * This class provides access to all available network interfaces of your computer. | 81 | * This class provides access to all available network interfaces of your computer. |
75 | * | 82 | * |
76 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 83 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
77 | */ | 84 | */ |
78 | class ONetwork : public QObject | 85 | class ONetwork : public QObject |
79 | { | 86 | { |
80 | Q_OBJECT | 87 | Q_OBJECT |
81 | 88 | ||
82 | public: | 89 | public: |
83 | typedef QDict<ONetworkInterface> InterfaceMap; | 90 | typedef QDict<ONetworkInterface> InterfaceMap; |
84 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 91 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
85 | 92 | ||
86 | public: | 93 | public: |
87 | /** | 94 | /** |
88 | * @returns the number of available interfaces | 95 | * @returns the number of available interfaces |
89 | */ | 96 | */ |
90 | int count() const; | 97 | int count() const; |
91 | /** | 98 | /** |
92 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 99 | * @returns a pointer to the (one and only) @ref ONetwork instance. |
93 | */ | 100 | */ |
94 | static ONetwork* instance(); | 101 | static ONetwork* instance(); |
95 | /** | 102 | /** |
96 | * @returns an iterator usable for iterating through all network interfaces. | 103 | * @returns an iterator usable for iterating through all network interfaces. |
97 | */ | 104 | */ |
98 | InterfaceIterator iterator() const; | 105 | InterfaceIterator iterator() const; |
99 | /** | 106 | /** |
100 | * @returns true, if the @a interface is present. | 107 | * @returns true, if the @a interface is present. |
101 | */ | 108 | */ |
102 | bool isPresent( const char* interface ) const; | 109 | bool isPresent( const char* interface ) const; |
103 | /** | 110 | /** |
104 | * @returns true, if the @a interface supports the wireless extension protocol. | 111 | * @returns true, if the @a interface supports the wireless extension protocol. |
105 | */ | 112 | */ |
106 | bool isWirelessInterface( const char* interface ) const; | 113 | bool isWirelessInterface( const char* interface ) const; |
107 | /** | 114 | /** |
108 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. | 115 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. |
109 | * @see ONetworkInterface | 116 | * @see ONetworkInterface |
110 | */ | 117 | */ |
111 | ONetworkInterface* interface( const QString& interface ) const; | 118 | ONetworkInterface* interface( const QString& interface ) const; |
112 | /** | 119 | /** |
113 | * @internal Rebuild the internal interface database | 120 | * @internal Rebuild the internal interface database |
114 | * @note Sometimes it might be useful to call this from client code, | 121 | * @note Sometimes it might be useful to call this from client code, |
115 | * e.g. after issuing a cardctl insert | 122 | * e.g. after issuing a cardctl insert |
116 | */ | 123 | */ |
117 | void synchronize(); | 124 | void synchronize(); |
118 | /** | 125 | /** |
119 | * @returns the wireless extension version used at compile time. | 126 | * @returns the wireless extension version used at compile time. |
120 | **/ | 127 | **/ |
121 | static short wirelessExtensionVersion(); | 128 | static short wirelessExtensionVersion(); |
122 | 129 | ||
123 | protected: | 130 | protected: |
124 | ONetwork(); | 131 | ONetwork(); |
125 | 132 | ||
126 | private: | 133 | private: |
127 | static ONetwork* _instance; | 134 | static ONetwork* _instance; |
128 | InterfaceMap _interfaces; | 135 | InterfaceMap _interfaces; |
129 | class Private; | 136 | class Private; |
130 | Private *d; | 137 | Private *d; |
131 | }; | 138 | }; |
132 | 139 | ||
133 | 140 | ||
134 | /*====================================================================================== | 141 | /*====================================================================================== |
135 | * ONetworkInterface | 142 | * ONetworkInterface |
136 | *======================================================================================*/ | 143 | *======================================================================================*/ |
137 | 144 | ||
138 | /** | 145 | /** |
139 | * @brief A network interface wrapper. | 146 | * @brief A network interface wrapper. |
140 | * | 147 | * |
141 | * This class provides a wrapper for a network interface. All the cumbersume details of | 148 | * This class provides a wrapper for a network interface. All the cumbersume details of |
142 | * Linux ioctls are hidden under a convenient high-level interface. | 149 | * Linux ioctls are hidden under a convenient high-level interface. |
143 | * @warning Most of the setting methods contained in this class require the appropriate | 150 | * @warning Most of the setting methods contained in this class require the appropriate |
144 | * process permissions to work. | 151 | * process permissions to work. |
145 | * | 152 | * |
146 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 153 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
147 | */ | 154 | */ |
148 | class ONetworkInterface : public QObject | 155 | class ONetworkInterface : public QObject |
149 | { | 156 | { |
150 | friend class OMonitoringInterface; | 157 | friend class OMonitoringInterface; |
151 | friend class OCiscoMonitoringInterface; | 158 | friend class OCiscoMonitoringInterface; |
152 | friend class OWlanNGMonitoringInterface; | 159 | friend class OWlanNGMonitoringInterface; |
153 | friend class OHostAPMonitoringInterface; | 160 | friend class OHostAPMonitoringInterface; |
154 | friend class OOrinocoMonitoringInterface; | 161 | friend class OOrinocoMonitoringInterface; |
155 | 162 | ||
156 | public: | 163 | public: |
157 | /** | 164 | /** |
158 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, | 165 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, |
159 | * but access them via @ref ONetwork::interface(). | 166 | * but access them via @ref ONetwork::interface(). |
160 | */ | 167 | */ |
161 | ONetworkInterface( QObject* parent, const char* name ); | 168 | ONetworkInterface( QObject* parent, const char* name ); |
162 | /** | 169 | /** |
163 | * Destructor. | 170 | * Destructor. |
164 | */ | 171 | */ |
165 | virtual ~ONetworkInterface(); | 172 | virtual ~ONetworkInterface(); |
166 | /** | 173 | /** |
167 | * Associates a @a monitoring interface with this network interface. | 174 | * Associates a @a monitoring interface with this network interface. |
168 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. | 175 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. |
169 | */ | 176 | */ |
170 | void setMonitoring( OMonitoringInterface* monitoring ); | 177 | void setMonitoring( OMonitoringInterface* monitoring ); |
171 | /** | 178 | /** |
172 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. | 179 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. |
173 | */ | 180 | */ |
174 | OMonitoringInterface* monitoring() const; | 181 | OMonitoringInterface* monitoring() const; |
175 | /** | 182 | /** |
176 | * Setting an interface to promiscuous mode enables the device to receive | 183 | * Setting an interface to promiscuous mode enables the device to receive |
177 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. | 184 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. |
178 | */ | 185 | */ |
179 | bool setPromiscuousMode( bool ); | 186 | bool setPromiscuousMode( bool ); |
180 | /** | 187 | /** |
181 | * @returns true if the interface is set to promiscuous mode. | 188 | * @returns true if the interface is set to promiscuous mode. |
182 | */ | 189 | */ |
183 | bool promiscuousMode() const; | 190 | bool promiscuousMode() const; |
184 | /** | 191 | /** |
185 | * Setting an interface to up enables it to receive packets. | 192 | * Setting an interface to up enables it to receive packets. |
186 | */ | 193 | */ |
187 | bool setUp( bool ); | 194 | bool setUp( bool ); |
188 | /** | 195 | /** |
189 | * @returns true if the interface is up. | 196 | * @returns true if the interface is up. |
190 | */ | 197 | */ |
191 | bool isUp() const; | 198 | bool isUp() const; |
192 | /** | 199 | /** |
193 | * @returns true if the interface is a loopback interface. | 200 | * @returns true if the interface is a loopback interface. |
194 | */ | 201 | */ |
195 | bool isLoopback() const; | 202 | bool isLoopback() const; |
196 | /** | 203 | /** |
197 | * @returns true if the interface is featuring supports the wireless extension protocol. | 204 | * @returns true if the interface is featuring supports the wireless extension protocol. |
198 | */ | 205 | */ |
199 | bool isWireless() const; | 206 | bool isWireless() const; |
200 | /** | 207 | /** |
201 | * Associate the IP address @ addr with the interface. | 208 | * Associate the IP address @ addr with the interface. |
202 | */ | 209 | */ |
203 | void setIPV4Address( const QHostAddress& addr ); | 210 | void setIPV4Address( const QHostAddress& addr ); |
204 | /** | 211 | /** |
205 | * @returns the IPv4 address associated with the interface. | 212 | * @returns the IPv4 address associated with the interface. |
206 | */ | 213 | */ |
207 | QString ipV4Address() const; //TODO: make this return an OHostAddress | 214 | QString ipV4Address() const; //TODO: make this return an OHostAddress |
208 | /** | 215 | /** |
209 | * Associate the MAC address @a addr with the interface. | 216 | * Associate the MAC address @a addr with the interface. |
210 | * @note It can be necessary to shut down the interface prior to calling this method. | 217 | * @note It can be necessary to shut down the interface prior to calling this method. |
211 | * @warning This is not supported by all drivers. | 218 | * @warning This is not supported by all drivers. |
212 | */ | 219 | */ |
213 | void setMacAddress( const OMacAddress& addr ); | 220 | void setMacAddress( const OMacAddress& addr ); |
214 | /** | 221 | /** |
215 | * @returns the MAC address associated with the interface. | 222 | * @returns the MAC address associated with the interface. |
216 | */ | 223 | */ |
217 | OMacAddress macAddress() const; | 224 | OMacAddress macAddress() const; |
218 | /** | 225 | /** |
219 | * Associate the IPv4 @a netmask with the interface. | 226 | * Associate the IPv4 @a netmask with the interface. |
220 | */ | 227 | */ |
221 | void setIPV4Netmask( const QHostAddress& netmask ); | 228 | void setIPV4Netmask( const QHostAddress& netmask ); |
222 | /** | 229 | /** |
223 | * @returns the IPv4 netmask associated with the interface. | 230 | * @returns the IPv4 netmask associated with the interface. |
224 | */ | 231 | */ |
225 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress | 232 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress |
226 | /** | 233 | /** |
227 | * @returns the data link type currently associated with the interface. | 234 | * @returns the data link type currently associated with the interface. |
228 | * @see #include <net/if_arp.h> for possible values. | 235 | * @see #include <net/if_arp.h> for possible values. |
229 | */ | 236 | */ |
230 | int dataLinkType() const; | 237 | int dataLinkType() const; |
231 | 238 | ||
232 | protected: | 239 | protected: |
233 | const int _sfd; | 240 | const int _sfd; |
234 | mutable ifreq _ifr; | 241 | mutable ifreq _ifr; |
235 | OMonitoringInterface* _mon; | 242 | OMonitoringInterface* _mon; |
236 | 243 | ||
237 | protected: | 244 | protected: |
238 | struct ifreq& ifr() const; | 245 | struct ifreq& ifr() const; |
239 | virtual void init(); | 246 | virtual void init(); |
240 | bool ioctl( int call ) const; | 247 | bool ioctl( int call ) const; |
241 | bool ioctl( int call, struct ifreq& ) const; | 248 | bool ioctl( int call, struct ifreq& ) const; |
242 | private: | 249 | private: |
243 | class Private; | 250 | class Private; |
244 | Private *d; | 251 | Private *d; |
245 | }; | 252 | }; |
246 | 253 | ||
247 | /*====================================================================================== | 254 | /*====================================================================================== |
248 | * OChannelHopper | 255 | * OChannelHopper |
249 | *======================================================================================*/ | 256 | *======================================================================================*/ |
250 | 257 | ||
251 | /** | 258 | /** |
252 | * @brief A radio frequency channel hopper. | 259 | * @brief A radio frequency channel hopper. |
253 | * | 260 | * |
254 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently | 261 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently |
255 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. | 262 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. |
256 | * This is necessary when in monitoring mode and scanning for other devices, because | 263 | * This is necessary when in monitoring mode and scanning for other devices, because |
257 | * the radio frequency hardware can only detect packets sent on the same frequency. | 264 | * the radio frequency hardware can only detect packets sent on the same frequency. |
258 | * | 265 | * |
259 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 266 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
260 | */ | 267 | */ |
261 | class OChannelHopper : public QObject | 268 | class OChannelHopper : public QObject |
262 | { | 269 | { |
263 | Q_OBJECT | 270 | Q_OBJECT |
264 | 271 | ||
265 | public: | 272 | public: |
266 | /** | 273 | /** |
267 | * Constructor. | 274 | * Constructor. |
268 | */ | 275 | */ |
269 | OChannelHopper( OWirelessNetworkInterface* ); | 276 | OChannelHopper( OWirelessNetworkInterface* ); |
270 | /** | 277 | /** |
271 | * Destructor. | 278 | * Destructor. |
272 | */ | 279 | */ |
273 | virtual ~OChannelHopper(); | 280 | virtual ~OChannelHopper(); |
274 | /** | 281 | /** |
275 | * @returns true, if the channel hopper is hopping channels | 282 | * @returns true, if the channel hopper is hopping channels |
276 | */ | 283 | */ |
277 | bool isActive() const; | 284 | bool isActive() const; |
278 | /** | 285 | /** |
279 | * @returns the last hopped channel | 286 | * @returns the last hopped channel |
280 | */ | 287 | */ |
281 | int channel() const; | 288 | int channel() const; |
282 | /** | 289 | /** |
283 | * Set the channel hopping @a interval. | 290 | * Set the channel hopping @a interval. |
284 | * An interval of 0 deactivates the channel hopper. | 291 | * An interval of 0 deactivates the channel hopper. |
285 | */ | 292 | */ |
286 | void setInterval( int interval ); | 293 | void setInterval( int interval ); |
287 | /** | 294 | /** |
288 | * @returns the channel hopping interval | 295 | * @returns the channel hopping interval |
289 | */ | 296 | */ |
290 | int interval() const; | 297 | int interval() const; |
291 | 298 | ||
292 | signals: | 299 | signals: |
293 | /** | 300 | /** |
294 | * This signal is emitted right after the channel hopper performed a hop | 301 | * This signal is emitted right after the channel hopper performed a hop |
295 | */ | 302 | */ |
296 | void hopped( int ); | 303 | void hopped( int ); |
297 | 304 | ||
298 | protected: | 305 | protected: |
299 | virtual void timerEvent( QTimerEvent* ); | 306 | virtual void timerEvent( QTimerEvent* ); |
@@ -302,289 +309,289 @@ class OChannelHopper : public QObject | |||
302 | OWirelessNetworkInterface* _iface; | 309 | OWirelessNetworkInterface* _iface; |
303 | int _interval; | 310 | int _interval; |
304 | int _tid; | 311 | int _tid; |
305 | QValueList<int> _channels; | 312 | QValueList<int> _channels; |
306 | QValueList<int>::Iterator _channel; | 313 | QValueList<int>::Iterator _channel; |
307 | class Private; | 314 | class Private; |
308 | Private *d; | 315 | Private *d; |
309 | }; | 316 | }; |
310 | 317 | ||
311 | 318 | ||
312 | /*====================================================================================== | 319 | /*====================================================================================== |
313 | * OWirelessNetworkInterface | 320 | * OWirelessNetworkInterface |
314 | *======================================================================================*/ | 321 | *======================================================================================*/ |
315 | 322 | ||
316 | /** | 323 | /** |
317 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. | 324 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. |
318 | * | 325 | * |
319 | * This class provides a high-level encapsulation of the Linux wireless extension API. | 326 | * This class provides a high-level encapsulation of the Linux wireless extension API. |
320 | * | 327 | * |
321 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 328 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
322 | */ | 329 | */ |
323 | class OWirelessNetworkInterface : public ONetworkInterface | 330 | class OWirelessNetworkInterface : public ONetworkInterface |
324 | { | 331 | { |
325 | friend class OMonitoringInterface; | 332 | friend class OMonitoringInterface; |
326 | friend class OCiscoMonitoringInterface; | 333 | friend class OCiscoMonitoringInterface; |
327 | friend class OWlanNGMonitoringInterface; | 334 | friend class OWlanNGMonitoringInterface; |
328 | friend class OHostAPMonitoringInterface; | 335 | friend class OHostAPMonitoringInterface; |
329 | friend class OOrinocoMonitoringInterface; | 336 | friend class OOrinocoMonitoringInterface; |
330 | 337 | ||
331 | friend class OPrivateIOCTL; | 338 | friend class OPrivateIOCTL; |
332 | 339 | ||
333 | public: | 340 | public: |
334 | /** | 341 | /** |
335 | * Constructor. | 342 | * Constructor. |
336 | */ | 343 | */ |
337 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 344 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
338 | /** | 345 | /** |
339 | * Destructor. | 346 | * Destructor. |
340 | */ | 347 | */ |
341 | virtual ~OWirelessNetworkInterface(); | 348 | virtual ~OWirelessNetworkInterface(); |
342 | /** | 349 | /** |
343 | * Setting the @a channel of the interface changes the radio frequency (RF) | 350 | * Setting the @a channel of the interface changes the radio frequency (RF) |
344 | * of the corresponding wireless network device. | 351 | * of the corresponding wireless network device. |
345 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. | 352 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. |
346 | * @see channels() | 353 | * @see channels() |
347 | */ | 354 | */ |
348 | virtual void setChannel( int channel ) const; | 355 | virtual void setChannel( int channel ) const; |
349 | /** | 356 | /** |
350 | * @returns the channel index of the current radio frequency. | 357 | * @returns the channel index of the current radio frequency. |
351 | */ | 358 | */ |
352 | virtual int channel() const; | 359 | virtual int channel() const; |
353 | /** | 360 | /** |
354 | * @returns the current radio frequency (in MHz). | 361 | * @returns the current radio frequency (in MHz). |
355 | */ | 362 | */ |
356 | virtual double frequency() const; | 363 | virtual double frequency() const; |
357 | /** | 364 | /** |
358 | * @returns the number of radio frequency channels for the | 365 | * @returns the number of radio frequency channels for the |
359 | * corresponding wireless network device. | 366 | * corresponding wireless network device. |
360 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 367 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
361 | */ | 368 | */ |
362 | virtual int channels() const; | 369 | virtual int channels() const; |
363 | /** | 370 | /** |
364 | * Set the IEEE 802.11 operation @a mode. | 371 | * Set the IEEE 802.11 operation @a mode. |
365 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master | 372 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master |
366 | * @warning Not all drivers support the all modes. | 373 | * @warning Not all drivers support the all modes. |
367 | * @note You might have to change the SSID to get the operation mode change into effect. | 374 | * @note You might have to change the SSID to get the operation mode change into effect. |
368 | */ | 375 | */ |
369 | virtual void setMode( const QString& mode ); | 376 | virtual void setMode( const QString& mode ); |
370 | /** | 377 | /** |
371 | * @returns the current IEEE 802.11 operation mode. | 378 | * @returns the current IEEE 802.11 operation mode. |
372 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown | 379 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown |
373 | * | 380 | * |
374 | * @note: Important note concerning the 'monitor' mode: | 381 | * @note: Important note concerning the 'monitor' mode: |
375 | * Setting the monitor mode on a wireless network interface enables | 382 | * Setting the monitor mode on a wireless network interface enables |
376 | * listening to IEEE 802.11 data and management frames which normally | 383 | * listening to IEEE 802.11 data and management frames which normally |
377 | * are handled by the device firmware. This can be used to detect | 384 | * are handled by the device firmware. This can be used to detect |
378 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. | 385 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. |
379 | * @warning Standard wireless network drives don't support the monitor mode. | 386 | * @warning Standard wireless network drives don't support the monitor mode. |
380 | * @warning You need a patched driver for this to work. | 387 | * @warning You need a patched driver for this to work. |
381 | * @note Enabling the monitor mode is highly driver dependent and requires | 388 | * @note Enabling the monitor mode is highly driver dependent and requires |
382 | * the proper @ref OMonitoringInterface to be associated with the interface. | 389 | * the proper @ref OMonitoringInterface to be associated with the interface. |
383 | * @see OMonitoringInterface | 390 | * @see OMonitoringInterface |
384 | */ | 391 | */ |
385 | virtual QString mode() const; | 392 | virtual QString mode() const; |
386 | /** | 393 | /** |
387 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 394 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
388 | * @see OChannelHopper | 395 | * @see OChannelHopper |
389 | */ | 396 | */ |
390 | virtual void setChannelHopping( int interval = 0 ); | 397 | virtual void setChannelHopping( int interval = 0 ); |
391 | /** | 398 | /** |
392 | * @returns the channel hopping interval or 0, if channel hopping is disabled. | 399 | * @returns the channel hopping interval or 0, if channel hopping is disabled. |
393 | */ | 400 | */ |
394 | virtual int channelHopping() const; | 401 | virtual int channelHopping() const; |
395 | /** | 402 | /** |
396 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before | 403 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before |
397 | */ | 404 | */ |
398 | virtual OChannelHopper* channelHopper() const; | 405 | virtual OChannelHopper* channelHopper() const; |
399 | /** | 406 | /** |
400 | * Set the station @a nickname. | 407 | * Set the station @a nickname. |
401 | */ | 408 | */ |
402 | virtual void setNickName( const QString& nickname ); | 409 | virtual void setNickName( const QString& nickname ); |
403 | /** | 410 | /** |
404 | * @returns the current station nickname. | 411 | * @returns the current station nickname. |
405 | */ | 412 | */ |
406 | virtual QString nickName() const; | 413 | virtual QString nickName() const; |
407 | /** | 414 | /** |
408 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. | 415 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. |
409 | * @see OPrivateIOCTL | 416 | * @see OPrivateIOCTL |
410 | */ | 417 | */ |
411 | virtual void setPrivate( const QString& command, int number, ... ); | 418 | virtual void setPrivate( const QString& command, int number, ... ); |
412 | /** | 419 | /** |
413 | * @returns true if the interface is featuring the private IOCTL @command. | 420 | * @returns true if the interface is featuring the private IOCTL @command. |
414 | */ | 421 | */ |
415 | virtual bool hasPrivate( const QString& command ); | 422 | virtual bool hasPrivate( const QString& command ); |
416 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 423 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
417 | /** | 424 | /** |
418 | * @returns true if the interface is associated to an access point | 425 | * @returns true if the interface is associated to an access point |
419 | * @note: This information is only valid if the interface is in managed mode. | 426 | * @note: This information is only valid if the interface is in managed mode. |
420 | */ | 427 | */ |
421 | virtual bool isAssociated() const; | 428 | virtual bool isAssociated() const; |
422 | /** | 429 | /** |
423 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. | 430 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. |
424 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. | 431 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. |
425 | */ | 432 | */ |
426 | virtual OMacAddress associatedAP() const; | 433 | virtual OMacAddress associatedAP() const; |
427 | /** | 434 | /** |
428 | * Set the @a ssid (Service Set ID) string. This is used to decide | 435 | * Set the @a ssid (Service Set ID) string. This is used to decide |
429 | * which network to associate with (use "any" to let the driver decide). | 436 | * which network to associate with (use "any" to let the driver decide). |
430 | */ | 437 | */ |
431 | virtual void setSSID( const QString& ssid ); | 438 | virtual void setSSID( const QString& ssid ); |
432 | /** | 439 | /** |
433 | * @returns the current SSID (Service Set ID). | 440 | * @returns the current SSID (Service Set ID). |
434 | */ | 441 | */ |
435 | virtual QString SSID() const; | 442 | virtual QString SSID() const; |
436 | /** | 443 | /** |
437 | * Perform scanning the wireless network neighbourhood. | 444 | * Perform scanning the wireless network neighbourhood. |
438 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! | 445 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! |
439 | */ | 446 | */ |
440 | virtual OStationList* scanNetwork(); | 447 | virtual OStationList* scanNetwork(); |
441 | /** | 448 | /** |
442 | * @return signal strength to associated neighbour (in percent). | 449 | * @return signal strength to associated neighbour (in percent). |
443 | * In infrastructure mode, this is the signal strength of the Access Point. | 450 | * In infrastructure mode, this is the signal strength of the Access Point. |
444 | * In other modes the result is driver dependent. | 451 | * In other modes the result is driver dependent. |
445 | */ | 452 | */ |
446 | virtual int signalStrength() const; | 453 | virtual int signalStrength() const; |
447 | /** @internal commit pending changes to the driver | 454 | /** @internal commit pending changes to the driver |
448 | * | 455 | * |
449 | */ | 456 | */ |
450 | void commit() const; | 457 | void commit() const; |
451 | 458 | ||
452 | protected: | 459 | protected: |
453 | void buildInformation(); | 460 | void buildInformation(); |
454 | void buildPrivateList(); | 461 | void buildPrivateList(); |
455 | void dumpInformation() const; | 462 | void dumpInformation() const; |
456 | virtual void init(); | 463 | virtual void init(); |
457 | struct iwreq& iwr() const; | 464 | struct iwreq& iwr() const; |
458 | bool wioctl( int call ) const; | 465 | bool wioctl( int call ) const; |
459 | bool wioctl( int call, struct iwreq& ) const; | 466 | bool wioctl( int call, struct iwreq& ) const; |
460 | 467 | ||
461 | protected: | 468 | protected: |
462 | mutable struct iwreq _iwr; | 469 | mutable struct iwreq _iwr; |
463 | QMap<int,int> _channels; | 470 | QMap<int,int> _channels; |
464 | struct iw_range _range; | 471 | struct iw_range _range; |
465 | 472 | ||
466 | private: | 473 | private: |
467 | OChannelHopper* _hopper; | 474 | OChannelHopper* _hopper; |
468 | class Private; | 475 | class Private; |
469 | Private *d; | 476 | Private *d; |
470 | }; | 477 | }; |
471 | 478 | ||
472 | 479 | ||
473 | /*====================================================================================== | 480 | /*====================================================================================== |
474 | * OMonitoringInterface | 481 | * OMonitoringInterface |
475 | *======================================================================================*/ | 482 | *======================================================================================*/ |
476 | 483 | ||
477 | 484 | ||
478 | class OMonitoringInterface | 485 | class OMonitoringInterface |
479 | { | 486 | { |
480 | public: | 487 | public: |
481 | OMonitoringInterface(); | 488 | OMonitoringInterface(); |
482 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 489 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
483 | virtual ~OMonitoringInterface(); | 490 | virtual ~OMonitoringInterface(); |
484 | 491 | ||
485 | public: | 492 | public: |
486 | virtual void setEnabled( bool ); | 493 | virtual void setEnabled( bool ); |
487 | virtual void setChannel( int ); | 494 | virtual void setChannel( int ); |
488 | 495 | ||
489 | virtual QString name() const = 0; | 496 | virtual QString name() const = 0; |
490 | 497 | ||
491 | protected: | 498 | protected: |
492 | OWirelessNetworkInterface* _if; | 499 | OWirelessNetworkInterface* _if; |
493 | bool _prismHeader; | 500 | bool _prismHeader; |
494 | private: | 501 | private: |
495 | class Private; | 502 | class Private; |
496 | Private *d; | 503 | Private *d; |
497 | 504 | ||
498 | }; | 505 | }; |
499 | 506 | ||
500 | 507 | ||
501 | /*====================================================================================== | 508 | /*====================================================================================== |
502 | * OCiscoMonitoring | 509 | * OCiscoMonitoring |
503 | *======================================================================================*/ | 510 | *======================================================================================*/ |
504 | 511 | ||
505 | 512 | ||
506 | class OCiscoMonitoringInterface : public OMonitoringInterface | 513 | class OCiscoMonitoringInterface : public OMonitoringInterface |
507 | { | 514 | { |
508 | public: | 515 | public: |
509 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 516 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
510 | virtual ~OCiscoMonitoringInterface(); | 517 | virtual ~OCiscoMonitoringInterface(); |
511 | 518 | ||
512 | virtual void setEnabled( bool ); | 519 | virtual void setEnabled( bool ); |
513 | virtual QString name() const; | 520 | virtual QString name() const; |
514 | virtual void setChannel( int ); | 521 | virtual void setChannel( int ); |
515 | private: | 522 | private: |
516 | class Private; | 523 | class Private; |
517 | Private *d; | 524 | Private *d; |
518 | 525 | ||
519 | }; | 526 | }; |
520 | 527 | ||
521 | 528 | ||
522 | /*====================================================================================== | 529 | /*====================================================================================== |
523 | * OWlanNGMonitoringInterface | 530 | * OWlanNGMonitoringInterface |
524 | *======================================================================================*/ | 531 | *======================================================================================*/ |
525 | 532 | ||
526 | 533 | ||
527 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 534 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
528 | { | 535 | { |
529 | public: | 536 | public: |
530 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 537 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
531 | virtual ~OWlanNGMonitoringInterface(); | 538 | virtual ~OWlanNGMonitoringInterface(); |
532 | 539 | ||
533 | public: | 540 | public: |
534 | virtual void setEnabled( bool ); | 541 | virtual void setEnabled( bool ); |
535 | virtual QString name() const; | 542 | virtual QString name() const; |
536 | virtual void setChannel( int ); | 543 | virtual void setChannel( int ); |
537 | private: | 544 | private: |
538 | class Private; | 545 | class Private; |
539 | Private *d; | 546 | Private *d; |
540 | 547 | ||
541 | }; | 548 | }; |
542 | 549 | ||
543 | 550 | ||
544 | /*====================================================================================== | 551 | /*====================================================================================== |
545 | * OHostAPMonitoringInterface | 552 | * OHostAPMonitoringInterface |
546 | *======================================================================================*/ | 553 | *======================================================================================*/ |
547 | 554 | ||
548 | 555 | ||
549 | class OHostAPMonitoringInterface : public OMonitoringInterface | 556 | class OHostAPMonitoringInterface : public OMonitoringInterface |
550 | { | 557 | { |
551 | public: | 558 | public: |
552 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 559 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
553 | virtual ~OHostAPMonitoringInterface(); | 560 | virtual ~OHostAPMonitoringInterface(); |
554 | 561 | ||
555 | public: | 562 | public: |
556 | virtual void setEnabled( bool ); | 563 | virtual void setEnabled( bool ); |
557 | virtual QString name() const; | 564 | virtual QString name() const; |
558 | 565 | ||
559 | private: | 566 | private: |
560 | class Private; | 567 | class Private; |
561 | Private *d; | 568 | Private *d; |
562 | }; | 569 | }; |
563 | 570 | ||
564 | 571 | ||
565 | /*====================================================================================== | 572 | /*====================================================================================== |
566 | * OOrinocoMonitoringInterface | 573 | * OOrinocoMonitoringInterface |
567 | *======================================================================================*/ | 574 | *======================================================================================*/ |
568 | 575 | ||
569 | 576 | ||
570 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 577 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
571 | { | 578 | { |
572 | public: | 579 | public: |
573 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 580 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
574 | virtual ~OOrinocoMonitoringInterface(); | 581 | virtual ~OOrinocoMonitoringInterface(); |
575 | 582 | ||
576 | public: | 583 | public: |
577 | virtual void setChannel( int ); | 584 | virtual void setChannel( int ); |
578 | virtual void setEnabled( bool ); | 585 | virtual void setEnabled( bool ); |
579 | virtual QString name() const; | 586 | virtual QString name() const; |
580 | 587 | ||
581 | private: | 588 | private: |
582 | class Private; | 589 | class Private; |
583 | Private *d; | 590 | Private *d; |
584 | }; | 591 | }; |
585 | 592 | ||
586 | } | 593 | } |
587 | } | 594 | } |
588 | 595 | ||
589 | #endif // ONETWORK_H | 596 | #endif // ONETWORK_H |
590 | 597 | ||