summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.h30
-rw-r--r--libopie2/opienet/opcap.h5
2 files changed, 28 insertions, 7 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 2348bbc..f052317 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,493 +1,517 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ONETWORK_H 34#ifndef ONETWORK_H
35#define ONETWORK_H 35#define ONETWORK_H
36 36
37/* QT */ 37/* QT */
38 38
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qdict.h> 40#include <qdict.h>
41#include <qmap.h> 41#include <qmap.h>
42#include <qobject.h> 42#include <qobject.h>
43#include <qhostaddress.h> 43#include <qhostaddress.h>
44 44
45/* OPIE */ 45/* OPIE */
46 46
47#include <opie2/onetutils.h> 47#include <opie2/onetutils.h>
48 48
49#ifndef IFNAMSIZ 49#ifndef IFNAMSIZ
50#define IFNAMSIZ 16 50#define IFNAMSIZ 16
51#endif 51#endif
52#ifndef IW_MAX_PRIV_DEF 52#ifndef IW_MAX_PRIV_DEF
53#define IW_MAX_PRIV_DEF 128 53#define IW_MAX_PRIV_DEF 128
54#endif 54#endif
55 55
56// ML: Yeah, I hate to include kernel headers, but it's necessary here 56// ML: Yeah, I hate to include kernel headers, but it's necessary here
57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> 57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h>
58// ML: which conflicts with the user header <net/if.h> 58// ML: which conflicts with the user header <net/if.h>
59// ML: We really need a user header for the Wireless Extensions, something like <net/wireless.h> 59// ML: We really need a user header for the Wireless Extensions, something like <net/wireless.h>
60// ML: I will drop Jean a mail on that subject 60// ML: I will drop Jean a mail on that subject
61 61
62#include <net/if.h> 62#include <net/if.h>
63#define _LINUX_IF_H 63#define _LINUX_IF_H
64#include <linux/wireless.h> 64#include <linux/wireless.h>
65 65
66class ONetworkInterface; 66class ONetworkInterface;
67class OWirelessNetworkInterface; 67class OWirelessNetworkInterface;
68class OChannelHopper; 68class OChannelHopper;
69class OMonitoringInterface; 69class OMonitoringInterface;
70 70
71/*====================================================================================== 71/*======================================================================================
72 * ONetwork 72 * ONetwork
73 *======================================================================================*/ 73 *======================================================================================*/
74 74
75/** 75/**
76 * @brief A container class for all network interfaces 76 * @brief A container class for all network interfaces
77 * 77 *
78 * This class provides access to all available network interfaces of your computer. 78 * This class provides access to all available network interfaces of your computer.
79 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 79 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
80 */ 80 */
81class ONetwork : public QObject 81class ONetwork : public QObject
82{ 82{
83 Q_OBJECT 83 Q_OBJECT
84 84
85 public: 85 public:
86 typedef QDict<ONetworkInterface> InterfaceMap; 86 typedef QDict<ONetworkInterface> InterfaceMap;
87 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 87 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
88 88
89 public: 89 public:
90 /** 90 /**
91 * @returns the number of available interfaces 91 * @returns the number of available interfaces
92 */ 92 */
93 int count() const; 93 int count() const;
94 /** 94 /**
95 * @returns a pointer to the (one and only) @ref ONetwork instance. 95 * @returns a pointer to the (one and only) @ref ONetwork instance.
96 */ 96 */
97 static ONetwork* instance(); 97 static ONetwork* instance();
98 /** 98 /**
99 * @returns an iterator usable for iterating through all network interfaces. 99 * @returns an iterator usable for iterating through all network interfaces.
100 */ 100 */
101 InterfaceIterator iterator() const; 101 InterfaceIterator iterator() const;
102 /** 102 /**
103 * @returns true, if the @p interface supports the wireless extension protocol. 103 * @returns true, if the @p interface supports the wireless extension protocol.
104 */ 104 */
105 // FIXME QString? -zecke 105 // FIXME QString? -zecke
106 bool isWirelessInterface( const char* interface ) const; 106 bool isWirelessInterface( const char* interface ) const;
107 /** 107 /**
108 * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found 108 * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found
109 * @see ONetworkInterface 109 * @see ONetworkInterface
110 */ 110 */
111 // FIXME: const QString& is prefered over QString!!! -zecke 111 // FIXME: const QString& is prefered over QString!!! -zecke
112 ONetworkInterface* interface( const QString& interface ) const; 112 ONetworkInterface* interface( const QString& interface ) const;
113 /** 113 /**
114 * @internal Rebuild the internal interface database 114 * @internal Rebuild the internal interface database
115 * @note Sometimes it might be useful to call this from client code, 115 * @note Sometimes it might be useful to call this from client code,
116 * e.g. after cardctl insert 116 * e.g. after issuing a cardctl insert
117 */ 117 */
118 void synchronize(); 118 void synchronize();
119 119
120 protected: 120 protected:
121 ONetwork(); 121 ONetwork();
122 122
123 private: 123 private:
124 static ONetwork* _instance; 124 static ONetwork* _instance;
125 InterfaceMap _interfaces; 125 InterfaceMap _interfaces;
126}; 126};
127 127
128 128
129/*====================================================================================== 129/*======================================================================================
130 * ONetworkInterface 130 * ONetworkInterface
131 *======================================================================================*/ 131 *======================================================================================*/
132 132
133/** 133/**
134 * @brief A network interface wrapper. 134 * @brief A network interface wrapper.
135 * 135 *
136 * This class provides a wrapper for a network interface. All the cumbersume details of 136 * This class provides a wrapper for a network interface. All the cumbersume details of
137 * Linux ioctls are hidden under a convenient high-level interface. 137 * Linux ioctls are hidden under a convenient high-level interface.
138 * @warning Most of the setting methods contained in this class require the appropriate 138 * @warning Most of the setting methods contained in this class require the appropriate
139 * process permissions to work. 139 * process permissions to work.
140 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 140 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
141 */ 141 */
142class ONetworkInterface : public QObject 142class ONetworkInterface : public QObject
143{ 143{
144 friend class OMonitoringInterface; 144 friend class OMonitoringInterface;
145 friend class OCiscoMonitoringInterface; 145 friend class OCiscoMonitoringInterface;
146 friend class OWlanNGMonitoringInterface; 146 friend class OWlanNGMonitoringInterface;
147 friend class OHostAPMonitoringInterface; 147 friend class OHostAPMonitoringInterface;
148 friend class OOrinocoMonitoringInterface; 148 friend class OOrinocoMonitoringInterface;
149 149
150 public: 150 public:
151 /** 151 /**
152 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 152 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
153 * but access them via @ref ONetwork::interface(). 153 * but access them via @ref ONetwork::interface().
154 */ 154 */
155 ONetworkInterface( QObject* parent, const char* name ); 155 ONetworkInterface( QObject* parent, const char* name );
156 /** 156 /**
157 * Destructor. 157 * Destructor.
158 */ 158 */
159 virtual ~ONetworkInterface(); 159 virtual ~ONetworkInterface();
160 /** 160 /**
161 * Associates a @a monitoring interface with this network interface. 161 * Associates a @a monitoring interface with this network interface.
162 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 162 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
163 */ 163 */
164 void setMonitoring( OMonitoringInterface* monitoring ); 164 void setMonitoring( OMonitoringInterface* monitoring );
165 /** 165 /**
166 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 166 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
167 */ 167 */
168 OMonitoringInterface* monitoring() const; 168 OMonitoringInterface* monitoring() const;
169 /** 169 /**
170 * Setting an interface to promiscuous mode enables the device to receive 170 * Setting an interface to promiscuous mode enables the device to receive
171 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 171 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
172 */ 172 */
173 bool setPromiscuousMode( bool ); 173 bool setPromiscuousMode( bool );
174 /** 174 /**
175 * @returns true if the interface is set to promiscuous mode. 175 * @returns true if the interface is set to promiscuous mode.
176 */ 176 */
177 bool promiscuousMode() const; 177 bool promiscuousMode() const;
178 /** 178 /**
179 * Setting an interface to up enables it to receive packets. 179 * Setting an interface to up enables it to receive packets.
180 */ 180 */
181 bool setUp( bool ); 181 bool setUp( bool );
182 /** 182 /**
183 * @returns true if the interface is up. 183 * @returns true if the interface is up.
184 */ 184 */
185 bool isUp() const; 185 bool isUp() const;
186 /** 186 /**
187 * @returns true if the interface is a loopback interface. 187 * @returns true if the interface is a loopback interface.
188 */ 188 */
189 bool isLoopback() const; 189 bool isLoopback() const;
190 /** 190 /**
191 * @returns true if the interface is featuring supports the wireless extension protocol. 191 * @returns true if the interface is featuring supports the wireless extension protocol.
192 */ 192 */
193 bool isWireless() const; 193 bool isWireless() const;
194 /** 194 /**
195 * Associate the IP address @ addr with the interface. 195 * Associate the IP address @ addr with the interface.
196 */ 196 */
197 void setIPV4Address( const QHostAddress& addr ); 197 void setIPV4Address( const QHostAddress& addr );
198 /** 198 /**
199 * @returns the IPv4 address associated with the interface. 199 * @returns the IPv4 address associated with the interface.
200 */ 200 */
201 QString ipV4Address() const; 201 QString ipV4Address() const;
202 /** 202 /**
203 * Associate the MAC address @a addr with the interface. 203 * Associate the MAC address @a addr with the interface.
204 * @note It can be necessary to shut down the interface prior to calling this method. 204 * @note It can be necessary to shut down the interface prior to calling this method.
205 * @warning This is not supported by all drivers. 205 * @warning This is not supported by all drivers.
206 */ 206 */
207 void setMacAddress( const OMacAddress& addr ); 207 void setMacAddress( const OMacAddress& addr );
208 /** 208 /**
209 * @returns the MAC address associated with the interface. 209 * @returns the MAC address associated with the interface.
210 */ 210 */
211 OMacAddress macAddress() const; 211 OMacAddress macAddress() const;
212 /** 212 /**
213 * Associate the IPv4 @a netmask with the interface. 213 * Associate the IPv4 @a netmask with the interface.
214 */ 214 */
215 void setIPV4Netmask( const QHostAddress& netmask ); 215 void setIPV4Netmask( const QHostAddress& netmask );
216 /** 216 /**
217 * @returns the IPv4 netmask associated with the interface. 217 * @returns the IPv4 netmask associated with the interface.
218 */ 218 */
219 QString ipV4Netmask() const; 219 QString ipV4Netmask() const;
220 /** 220 /**
221 * @returns the data link type currently associated with the interface. 221 * @returns the data link type currently associated with the interface.
222 * @see #include <net/if_arp.h> for possible values. 222 * @see #include <net/if_arp.h> for possible values.
223 */ 223 */
224 int dataLinkType() const; 224 int dataLinkType() const;
225 225
226 protected: 226 protected:
227 const int _sfd; 227 const int _sfd;
228 mutable ifreq _ifr; 228 mutable ifreq _ifr;
229 OMonitoringInterface* _mon; 229 OMonitoringInterface* _mon;
230 230
231 protected: 231 protected:
232 struct ifreq& ifr() const; 232 struct ifreq& ifr() const;
233 virtual void init(); 233 virtual void init();
234 bool ioctl( int call ) const; 234 bool ioctl( int call ) const;
235 bool ioctl( int call, struct ifreq& ) const; 235 bool ioctl( int call, struct ifreq& ) const;
236}; 236};
237 237
238/*====================================================================================== 238/*======================================================================================
239 * OChannelHopper 239 * OChannelHopper
240 *======================================================================================*/ 240 *======================================================================================*/
241 241
242/** 242/**
243 * @brief A radio frequency channel hopper. 243 * @brief A radio frequency channel hopper.
244 * 244 *
245 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 245 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
246 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 246 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
247 * This is necessary when in monitoring mode and scanning for other devices, because 247 * This is necessary when in monitoring mode and scanning for other devices, because
248 * the radio frequency hardware can only detect packets sent on the same frequency. 248 * the radio frequency hardware can only detect packets sent on the same frequency.
249 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 249 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
250 */ 250 */
251class OChannelHopper : public QObject 251class OChannelHopper : public QObject
252{ 252{
253 Q_OBJECT 253 Q_OBJECT
254 254
255 public: 255 public:
256 /**
257 * Constructor.
258 */
256 OChannelHopper( OWirelessNetworkInterface* ); 259 OChannelHopper( OWirelessNetworkInterface* );
260 /**
261 * Destructor.
262 */
257 virtual ~OChannelHopper(); 263 virtual ~OChannelHopper();
264 /**
265 * @returns true, if the channel hopper is hopping channels
266 */
258 bool isActive() const; 267 bool isActive() const;
268 /**
269 * @returns the last hopped channel
270 */
259 int channel() const; 271 int channel() const;
260 virtual void timerEvent( QTimerEvent* ); 272 /**
261 void setInterval( int ); 273 * Set the channel hopping @a interval.
274 * An interval of 0 deactivates the channel hopper.
275 */
276 void setInterval( int interval );
277 /**
278 * @returns the channel hopping interval
279 */
262 int interval() const; 280 int interval() const;
263 281
264 signals: 282 signals:
283 /**
284 * This signal is emitted right after the channel hopper performed a hop
285 */
265 void hopped( int ); 286 void hopped( int );
266 287
288 protected:
289 virtual void timerEvent( QTimerEvent* );
290
267 private: 291 private:
268 OWirelessNetworkInterface* _iface; 292 OWirelessNetworkInterface* _iface;
269 int _interval; 293 int _interval;
270 int _tid; 294 int _tid;
271 QValueList<int> _channels; 295 QValueList<int> _channels;
272 QValueList<int>::Iterator _channel; 296 QValueList<int>::Iterator _channel;
273}; 297};
274 298
275 299
276/*====================================================================================== 300/*======================================================================================
277 * OWirelessNetworkInterface 301 * OWirelessNetworkInterface
278 *======================================================================================*/ 302 *======================================================================================*/
279 303
280/** 304/**
281 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 305 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
282 * 306 *
283 * This class provides a high-level encapsulation of the Linux wireless extension API. 307 * This class provides a high-level encapsulation of the Linux wireless extension API.
284 */ 308 */
285class OWirelessNetworkInterface : public ONetworkInterface 309class OWirelessNetworkInterface : public ONetworkInterface
286{ 310{
287 friend class OMonitoringInterface; 311 friend class OMonitoringInterface;
288 friend class OCiscoMonitoringInterface; 312 friend class OCiscoMonitoringInterface;
289 friend class OWlanNGMonitoringInterface; 313 friend class OWlanNGMonitoringInterface;
290 friend class OHostAPMonitoringInterface; 314 friend class OHostAPMonitoringInterface;
291 friend class OOrinocoMonitoringInterface; 315 friend class OOrinocoMonitoringInterface;
292 316
293 friend class OPrivateIOCTL; 317 friend class OPrivateIOCTL;
294 318
295 public: 319 public:
296 enum Mode { AdHoc, Managed, Monitor }; 320 enum Mode { AdHoc, Managed, Monitor };
297 321
298 /** 322 /**
299 * Constructor. 323 * Constructor.
300 */ 324 */
301 OWirelessNetworkInterface( QObject* parent, const char* name ); 325 OWirelessNetworkInterface( QObject* parent, const char* name );
302 /** 326 /**
303 * Destructor. 327 * Destructor.
304 */ 328 */
305 virtual ~OWirelessNetworkInterface(); 329 virtual ~OWirelessNetworkInterface();
306 /** 330 /**
307 * Setting the @a channel of the interface changes the radio frequency (RF) 331 * Setting the @a channel of the interface changes the radio frequency (RF)
308 * of the corresponding wireless network device. 332 * of the corresponding wireless network device.
309 */ 333 */
310 virtual void setChannel( int channel ) const; 334 virtual void setChannel( int channel ) const;
311 /** 335 /**
312 * @returns the channel index of the current radio frequency. 336 * @returns the channel index of the current radio frequency.
313 */ 337 */
314 virtual int channel() const; 338 virtual int channel() const;
315 /** 339 /**
316 * @returns the current radio frequency (in MHz). 340 * @returns the current radio frequency (in MHz).
317 */ 341 */
318 virtual double frequency() const; 342 virtual double frequency() const;
319 /** 343 /**
320 * @returns the number of radio frequency channels for the 344 * @returns the number of radio frequency channels for the
321 * corresponding wireless network device. 345 * corresponding wireless network device.
322 * @note European devices usually have 14 channels, while American typically feature 11 channels. 346 * @note European devices usually have 14 channels, while American typically feature 11 channels.
323 */ 347 */
324 virtual int channels() const; 348 virtual int channels() const;
325 //virtual double frequency(int) const; 349 //virtual double frequency(int) const;
326 350
327 virtual void setMode( Mode ) {}; //FIXME: Implement and document this 351 virtual void setMode( Mode ) {}; //FIXME: Implement and document this
328 virtual bool mode() const {}; //FIXME: Implement and document this 352 virtual bool mode() const {}; //FIXME: Implement and document this
329 353
330 /** 354 /**
331 * Setting the monitor mode on a wireless network interface enables 355 * Setting the monitor mode on a wireless network interface enables
332 * listening to IEEE 802.11 data and management frames which normally 356 * listening to IEEE 802.11 data and management frames which normally
333 * are handled by the device firmware. This can be used to detect 357 * are handled by the device firmware. This can be used to detect
334 * other wireless network devices, e.g. Access Points or Ad-hoc stations. 358 * other wireless network devices, e.g. Access Points or Ad-hoc stations.
335 * @warning Standard wireless network drives don't support the monitor mode. 359 * @warning Standard wireless network drives don't support the monitor mode.
336 * @warning You need a patched driver for this to work. 360 * @warning You need a patched driver for this to work.
337 * @note Enabling the monitor mode is highly driver dependent and requires 361 * @note Enabling the monitor mode is highly driver dependent and requires
338 * the proper @ref OMonitoringInterface to be associated with the interface. 362 * the proper @ref OMonitoringInterface to be associated with the interface.
339 * @see OMonitoringInterface 363 * @see OMonitoringInterface
340 */ 364 */
341 virtual void setMonitorMode( bool ); 365 virtual void setMonitorMode( bool );
342 /** 366 /**
343 * @returns true if the device is listening in IEEE 802.11 monitor mode 367 * @returns true if the device is listening in IEEE 802.11 monitor mode
344 */ 368 */
345 virtual bool monitorMode() const; 369 virtual bool monitorMode() const;
346 /** 370 /**
347 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. 371 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
348 * @see OChannelHopper 372 * @see OChannelHopper
349 */ 373 */
350 virtual void setChannelHopping( int interval = 0 ); 374 virtual void setChannelHopping( int interval = 0 );
351 /** 375 /**
352 * @returns the channel hopping interval or 0, if channel hopping is disabled. 376 * @returns the channel hopping interval or 0, if channel hopping is disabled.
353 */ 377 */
354 virtual int channelHopping() const; 378 virtual int channelHopping() const;
355 /** 379 /**
356 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before 380 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
357 */ 381 */
358 virtual OChannelHopper* channelHopper() const; 382 virtual OChannelHopper* channelHopper() const;
359 /** 383 /**
360 * Set the station @a nickname. 384 * Set the station @a nickname.
361 */ 385 */
362 virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this 386 virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this
363 /** 387 /**
364 * @returns the current station nickname. 388 * @returns the current station nickname.
365 */ 389 */
366 virtual QString nickName() const; 390 virtual QString nickName() const;
367 /** 391 /**
368 * Invoke the private IOCTL @a command with a @number of parameters on the network interface. 392 * Invoke the private IOCTL @a command with a @number of parameters on the network interface.
369 * @see OPrivateIOCTL 393 * @see OPrivateIOCTL
370 */ 394 */
371 virtual void setPrivate( const QString& command, int number, ... ); 395 virtual void setPrivate( const QString& command, int number, ... );
372 /** 396 /**
373 * @returns true if the interface is featuring the private IOCTL @command. 397 * @returns true if the interface is featuring the private IOCTL @command.
374 */ 398 */
375 virtual bool hasPrivate( const QString& command ); 399 virtual bool hasPrivate( const QString& command );
376 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this 400 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
377 401
378 virtual bool isAssociated() const {}; //FIXME: Implement and document this 402 virtual bool isAssociated() const {}; //FIXME: Implement and document this
379 virtual QString associatedAP() const; //FIXME: Implement and document this 403 virtual QString associatedAP() const; //FIXME: Implement and document this
380 404
381 virtual void setSSID( const QString& ); 405 virtual void setSSID( const QString& );
382 virtual QString SSID() const; 406 virtual QString SSID() const;
383 407
384 protected: 408 protected:
385 void buildChannelList(); 409 void buildChannelList();
386 void buildPrivateList(); 410 void buildPrivateList();
387 virtual void init(); 411 virtual void init();
388 struct iwreq& iwr() const; 412 struct iwreq& iwr() const;
389 bool wioctl( int call ) const; 413 bool wioctl( int call ) const;
390 bool wioctl( int call, struct iwreq& ) const; 414 bool wioctl( int call, struct iwreq& ) const;
391 415
392 protected: 416 protected:
393 mutable struct iwreq _iwr; 417 mutable struct iwreq _iwr;
394 QMap<int,int> _channels; 418 QMap<int,int> _channels;
395 419
396 private: 420 private:
397 OChannelHopper* _hopper; 421 OChannelHopper* _hopper;
398}; 422};
399 423
400 424
401/*====================================================================================== 425/*======================================================================================
402 * OMonitoringInterface 426 * OMonitoringInterface
403 *======================================================================================*/ 427 *======================================================================================*/
404 428
405 429
406class OMonitoringInterface 430class OMonitoringInterface
407{ 431{
408 public: 432 public:
409 OMonitoringInterface(); 433 OMonitoringInterface();
410 OMonitoringInterface( ONetworkInterface* ); 434 OMonitoringInterface( ONetworkInterface* );
411 virtual ~OMonitoringInterface(); 435 virtual ~OMonitoringInterface();
412 436
413 public: 437 public:
414 virtual void setEnabled( bool ); 438 virtual void setEnabled( bool );
415 virtual bool enabled() const; 439 virtual bool enabled() const;
416 virtual void setChannel( int ); 440 virtual void setChannel( int );
417 441
418 virtual QString name() const = 0; 442 virtual QString name() const = 0;
419 443
420 protected: 444 protected:
421 OWirelessNetworkInterface* _if; 445 OWirelessNetworkInterface* _if;
422 446
423}; 447};
424 448
425 449
426/*====================================================================================== 450/*======================================================================================
427 * OCiscoMonitoring 451 * OCiscoMonitoring
428 *======================================================================================*/ 452 *======================================================================================*/
429 453
430 454
431class OCiscoMonitoringInterface : public OMonitoringInterface 455class OCiscoMonitoringInterface : public OMonitoringInterface
432{ 456{
433 public: 457 public:
434 OCiscoMonitoringInterface( ONetworkInterface* ); 458 OCiscoMonitoringInterface( ONetworkInterface* );
435 virtual ~OCiscoMonitoringInterface(); 459 virtual ~OCiscoMonitoringInterface();
436 460
437 virtual void setEnabled( bool ); 461 virtual void setEnabled( bool );
438 virtual QString name() const; 462 virtual QString name() const;
439 virtual void setChannel( int ); 463 virtual void setChannel( int );
440 464
441}; 465};
442 466
443/*====================================================================================== 467/*======================================================================================
444 * OWlanNGMonitoringInterface 468 * OWlanNGMonitoringInterface
445 *======================================================================================*/ 469 *======================================================================================*/
446 470
447class OWlanNGMonitoringInterface : public OMonitoringInterface 471class OWlanNGMonitoringInterface : public OMonitoringInterface
448{ 472{
449 public: 473 public:
450 OWlanNGMonitoringInterface( ONetworkInterface* ); 474 OWlanNGMonitoringInterface( ONetworkInterface* );
451 virtual ~OWlanNGMonitoringInterface(); 475 virtual ~OWlanNGMonitoringInterface();
452 476
453 public: 477 public:
454 virtual void setEnabled( bool ); 478 virtual void setEnabled( bool );
455 virtual QString name() const; 479 virtual QString name() const;
456 virtual void setChannel( int ); 480 virtual void setChannel( int );
457 481
458}; 482};
459 483
460/*====================================================================================== 484/*======================================================================================
461 * OHostAPMonitoringInterface 485 * OHostAPMonitoringInterface
462 *======================================================================================*/ 486 *======================================================================================*/
463 487
464class OHostAPMonitoringInterface : public OMonitoringInterface 488class OHostAPMonitoringInterface : public OMonitoringInterface
465{ 489{
466 public: 490 public:
467 OHostAPMonitoringInterface( ONetworkInterface* ); 491 OHostAPMonitoringInterface( ONetworkInterface* );
468 virtual ~OHostAPMonitoringInterface(); 492 virtual ~OHostAPMonitoringInterface();
469 493
470 public: 494 public:
471 virtual void setEnabled( bool ); 495 virtual void setEnabled( bool );
472 virtual QString name() const; 496 virtual QString name() const;
473 }; 497 };
474 498
475/*====================================================================================== 499/*======================================================================================
476 * OOrinocoMonitoringInterface 500 * OOrinocoMonitoringInterface
477 *======================================================================================*/ 501 *======================================================================================*/
478 502
479class OOrinocoMonitoringInterface : public OMonitoringInterface 503class OOrinocoMonitoringInterface : public OMonitoringInterface
480{ 504{
481 public: 505 public:
482 OOrinocoMonitoringInterface( ONetworkInterface* ); 506 OOrinocoMonitoringInterface( ONetworkInterface* );
483 virtual ~OOrinocoMonitoringInterface(); 507 virtual ~OOrinocoMonitoringInterface();
484 508
485 public: 509 public:
486 virtual void setChannel( int ); 510 virtual void setChannel( int );
487 virtual void setEnabled( bool ); 511 virtual void setEnabled( bool );
488 virtual QString name() const; 512 virtual QString name() const;
489 513
490}; 514};
491 515
492#endif // ONETWORK_H 516#endif // ONETWORK_H
493 517
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 83f7115..bee0ca0 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,569 +1,566 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef OPCAP_H 34#ifndef OPCAP_H
35#define OPCAP_H 35#define OPCAP_H
36 36
37/* LINUX */ 37/* LINUX */
38extern "C" // work around a bpf/pcap conflict in recent headers 38extern "C" // work around a bpf/pcap conflict in recent headers
39{ 39{
40 #include <pcap.h> 40 #include <pcap.h>
41} 41}
42#include <netinet/ether.h> 42#include <netinet/ether.h>
43#include <netinet/ip.h> 43#include <netinet/ip.h>
44#include <netinet/udp.h> 44#include <netinet/udp.h>
45#include <netinet/tcp.h> 45#include <netinet/tcp.h>
46#include <time.h> 46#include <time.h>
47 47
48/* QT */ 48/* QT */
49#include <qevent.h> 49#include <qevent.h>
50#include <qfile.h> 50#include <qfile.h>
51#include <qhostaddress.h> 51#include <qhostaddress.h>
52#include <qobject.h> 52#include <qobject.h>
53#include <qstring.h> 53#include <qstring.h>
54#include <qmap.h> 54#include <qmap.h>
55 55
56/* OPIE */ 56/* OPIE */
57#include <opie2/onetutils.h> 57#include <opie2/onetutils.h>
58#include "802_11_user.h" 58#include "802_11_user.h"
59 59
60/* TYPEDEFS */ 60/* TYPEDEFS */
61typedef struct timeval timevalstruct; 61typedef struct timeval timevalstruct;
62typedef struct pcap_pkthdr packetheaderstruct; 62typedef struct pcap_pkthdr packetheaderstruct;
63 63
64/* FORWARDS */ 64/* FORWARDS */
65class OPacketCapturer; 65class OPacketCapturer;
66class QSocketNotifier; 66class QSocketNotifier;
67 67
68/*====================================================================================== 68/*======================================================================================
69 * OPacket - A frame on the wire 69 * OPacket - A frame on the wire
70 *======================================================================================*/ 70 *======================================================================================*/
71 71
72/** @brief A class representing a data frame on the wire. 72/** @brief A class representing a data frame on the wire.
73 * 73 *
74 * The whole family of the packet classes are used when capturing frames from a network. 74 * The whole family of the packet classes are used when capturing frames from a network.
75 * Most standard network protocols in use share a common architecture, which mostly is 75 * Most standard network protocols in use share a common architecture, which mostly is
76 * a packet header and then the packet payload. In layered architectures, each lower layer 76 * a packet header and then the packet payload. In layered architectures, each lower layer
77 * encapsulates data from its upper layer - that is it 77 * encapsulates data from its upper layer - that is it
78 * treats the data from its upper layer as payload and prepends an own header to the packet, 78 * treats the data from its upper layer as payload and prepends an own header to the packet,
79 * which - again - is treated as the payload for the layer below. The figure below is an 79 * which - again - is treated as the payload for the layer below. The figure below is an
80 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 80 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
81 * 81 *
82 * <pre> 82 * <pre>
83 * | User Data | == Mail Data 83 * | User Data | == Mail Data
84 * | SMTP Header | User Data | == SMTP 84 * | SMTP Header | User Data | == SMTP
85 * | TCP Header | SMTP Header | User Data | == TCP 85 * | TCP Header | SMTP Header | User Data | == TCP
86 * | IP Header | TCP Header | SMTP Header | User Data | == IP 86 * | IP Header | TCP Header | SMTP Header | User Data | == IP
87 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 87 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
88 * 88 *
89 * </pre> 89 * </pre>
90 * 90 *
91 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 91 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
92 * also contains a few more levels of encapsulation. 92 * also contains a few more levels of encapsulation.
93 * Since the type of the payload is more or less independent from the encapsulating protocol, 93 * Since the type of the payload is more or less independent from the encapsulating protocol,
94 * the header must be inspected before attempting to decode the payload. Hence, the 94 * the header must be inspected before attempting to decode the payload. Hence, the
95 * encapsulation level varies and can't be deduced without actually looking into the packets. 95 * encapsulation level varies and can't be deduced without actually looking into the packets.
96 * 96 *
97 * For actually working with captured frames, it's useful to identify the packets via names and 97 * For actually working with captured frames, it's useful to identify the packets via names and
98 * insert them into a parent/child - relationship based on the encapsulation. This is why 98 * insert them into a parent/child - relationship based on the encapsulation. This is why
99 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 99 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
100 * not a problem in this case, because we're talking about a theoratical maximum of about 100 * not a problem in this case, because we're talking about a theoratical maximum of about
101 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 101 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
102 * QObject also cares about destroying the sub-, (child-) packets. 102 * QObject also cares about destroying the sub-, (child-) packets.
103 * 103 *
104 * This enables us to perform a simple look for packets of a certain type: 104 * This enables us to perform a simple look for packets of a certain type:
105 * @code 105 * @code
106 * OPacketCapturer* pcap = new OPacketCapturer(); 106 * OPacketCapturer* pcap = new OPacketCapturer();
107 * pcap->open( "eth0" ); 107 * pcap->open( "eth0" );
108 * OPacket* p = pcap->next(); 108 * OPacket* p = pcap->next();
109 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 109 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
110 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 110 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
111 * 111 *
112 */ 112 */
113 113
114class OPacket : public QObject 114class OPacket : public QObject
115{ 115{
116 Q_OBJECT 116 Q_OBJECT
117 117
118 public: 118 public:
119 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 119 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
120 virtual ~OPacket(); 120 virtual ~OPacket();
121 121
122 timevalstruct timeval() const; 122 timevalstruct timeval() const;
123 123
124 int caplen() const; 124 int caplen() const;
125 int len() const; 125 int len() const;
126 QString dump( int = 32 ) const; 126 QString dump( int = 32 ) const;
127 127
128 void updateStats( QMap<QString,int>&, QObjectList* ); 128 void updateStats( QMap<QString,int>&, QObjectList* );
129 129
130 private: 130 private:
131 const packetheaderstruct _hdr; // pcap packet header 131 const packetheaderstruct _hdr; // pcap packet header
132 const unsigned char* _data; // pcap packet data 132 const unsigned char* _data; // pcap packet data
133 const unsigned char* _end; // end of pcap packet data 133 const unsigned char* _end; // end of pcap packet data
134}; 134};
135 135
136/*====================================================================================== 136/*======================================================================================
137 * OEthernetPacket - DLT_EN10MB frame 137 * OEthernetPacket - DLT_EN10MB frame
138 *======================================================================================*/ 138 *======================================================================================*/
139 139
140class OEthernetPacket : public QObject 140class OEthernetPacket : public QObject
141{ 141{
142 Q_OBJECT 142 Q_OBJECT
143 143
144 public: 144 public:
145 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 145 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
146 virtual ~OEthernetPacket(); 146 virtual ~OEthernetPacket();
147 147
148 OMacAddress sourceAddress() const; 148 OMacAddress sourceAddress() const;
149 OMacAddress destinationAddress() const; 149 OMacAddress destinationAddress() const;
150 int type() const; 150 int type() const;
151 151
152 private: 152 private:
153 const struct ether_header* _ether; 153 const struct ether_header* _ether;
154}; 154};
155 155
156
157/*====================================================================================== 156/*======================================================================================
158 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 157 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
159 *======================================================================================*/ 158 *======================================================================================*/
160 159
161class OPrismHeaderPacket : public QObject 160class OPrismHeaderPacket : public QObject
162{ 161{
163 Q_OBJECT 162 Q_OBJECT
164 163
165 public: 164 public:
166 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 165 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
167 virtual ~OPrismHeaderPacket(); 166 virtual ~OPrismHeaderPacket();
168 167
169 unsigned int signalStrength() const; 168 unsigned int signalStrength() const;
170 169
171 private: 170 private:
172 const struct prism_hdr* _header; 171 const struct prism_hdr* _header;
173}; 172};
174 173
175
176/*====================================================================================== 174/*======================================================================================
177 * OWaveLanPacket - DLT_IEEE802_11 frame 175 * OWaveLanPacket - DLT_IEEE802_11 frame
178 *======================================================================================*/ 176 *======================================================================================*/
179 177
180class OWaveLanPacket : public QObject 178class OWaveLanPacket : public QObject
181{ 179{
182 Q_OBJECT 180 Q_OBJECT
183 181
184 public: 182 public:
185 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 183 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
186 virtual ~OWaveLanPacket(); 184 virtual ~OWaveLanPacket();
187 185
188 int duration() const; 186 int duration() const;
189 bool fromDS() const; 187 bool fromDS() const;
190 bool toDS() const; 188 bool toDS() const;
191 virtual OMacAddress macAddress1() const; 189 virtual OMacAddress macAddress1() const;
192 virtual OMacAddress macAddress2() const; 190 virtual OMacAddress macAddress2() const;
193 virtual OMacAddress macAddress3() const; 191 virtual OMacAddress macAddress3() const;
194 virtual OMacAddress macAddress4() const; 192 virtual OMacAddress macAddress4() const;
195 bool usesPowerManagement() const; 193 bool usesPowerManagement() const;
196 int type() const; 194 int type() const;
197 int subType() const; 195 int subType() const;
198 int version() const; 196 int version() const;
199 bool usesWep() const; 197 bool usesWep() const;
200 198
201 private: 199 private:
202 const struct ieee_802_11_header* _wlanhdr; 200 const struct ieee_802_11_header* _wlanhdr;
203}; 201};
204 202
205 203
206/*====================================================================================== 204/*======================================================================================
207 * OWaveLanManagementPacket - type: management (T_MGMT) 205 * OWaveLanManagementPacket - type: management (T_MGMT)
208 *======================================================================================*/ 206 *======================================================================================*/
209 207
210class OWaveLanManagementPacket : public QObject 208class OWaveLanManagementPacket : public QObject
211{ 209{
212 Q_OBJECT 210 Q_OBJECT
213 211
214 public: 212 public:
215 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 213 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
216 virtual ~OWaveLanManagementPacket(); 214 virtual ~OWaveLanManagementPacket();
217 215
218 QString managementType() const; 216 QString managementType() const;
219 217
220 int beaconInterval() const; 218 int beaconInterval() const;
221 int capabilities() const; // generic 219 int capabilities() const; // generic
222 220
223 bool canESS() const; 221 bool canESS() const;
224 bool canIBSS() const; 222 bool canIBSS() const;
225 bool canCFP() const; 223 bool canCFP() const;
226 bool canCFP_REQ() const; 224 bool canCFP_REQ() const;
227 bool canPrivacy() const; 225 bool canPrivacy() const;
228 226
229 private: 227 private:
230 const struct ieee_802_11_mgmt_header* _header; 228 const struct ieee_802_11_mgmt_header* _header;
231 const struct ieee_802_11_mgmt_body* _body; 229 const struct ieee_802_11_mgmt_body* _body;
232}; 230};
233 231
234 232
235/*====================================================================================== 233/*======================================================================================
236 * OWaveLanManagementSSID 234 * OWaveLanManagementSSID
237 *======================================================================================*/ 235 *======================================================================================*/
238 236
239class OWaveLanManagementSSID : public QObject 237class OWaveLanManagementSSID : public QObject
240{ 238{
241 Q_OBJECT 239 Q_OBJECT
242 240
243 public: 241 public:
244 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 242 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
245 virtual ~OWaveLanManagementSSID(); 243 virtual ~OWaveLanManagementSSID();
246 244
247 QString ID() const; 245 QString ID() const;
248 246
249 private: 247 private:
250 const struct ssid_t* _data; 248 const struct ssid_t* _data;
251}; 249};
252 250
253/*====================================================================================== 251/*======================================================================================
254 * OWaveLanManagementRates 252 * OWaveLanManagementRates
255 *======================================================================================*/ 253 *======================================================================================*/
256 254
257class OWaveLanManagementRates : public QObject 255class OWaveLanManagementRates : public QObject
258{ 256{
259 Q_OBJECT 257 Q_OBJECT
260 258
261 public: 259 public:
262 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 260 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
263 virtual ~OWaveLanManagementRates(); 261 virtual ~OWaveLanManagementRates();
264 262
265 private: 263 private:
266 const struct rates_t* _data; 264 const struct rates_t* _data;
267}; 265};
268 266
269/*====================================================================================== 267/*======================================================================================
270 * OWaveLanManagementCF 268 * OWaveLanManagementCF
271 *======================================================================================*/ 269 *======================================================================================*/
272 270
273class OWaveLanManagementCF : public QObject 271class OWaveLanManagementCF : public QObject
274{ 272{
275 Q_OBJECT 273 Q_OBJECT
276 274
277 public: 275 public:
278 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 276 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
279 virtual ~OWaveLanManagementCF(); 277 virtual ~OWaveLanManagementCF();
280 278
281 private: 279 private:
282 const struct cf_t* _data; 280 const struct cf_t* _data;
283}; 281};
284 282
285/*====================================================================================== 283/*======================================================================================
286 * OWaveLanManagementFH 284 * OWaveLanManagementFH
287 *======================================================================================*/ 285 *======================================================================================*/
288 286
289class OWaveLanManagementFH : public QObject 287class OWaveLanManagementFH : public QObject
290{ 288{
291 Q_OBJECT 289 Q_OBJECT
292 290
293 public: 291 public:
294 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 292 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
295 virtual ~OWaveLanManagementFH(); 293 virtual ~OWaveLanManagementFH();
296 294
297 private: 295 private:
298 const struct fh_t* _data; 296 const struct fh_t* _data;
299}; 297};
300 298
301/*====================================================================================== 299/*======================================================================================
302 * OWaveLanManagementDS 300 * OWaveLanManagementDS
303 *======================================================================================*/ 301 *======================================================================================*/
304 302
305class OWaveLanManagementDS : public QObject 303class OWaveLanManagementDS : public QObject
306{ 304{
307 Q_OBJECT 305 Q_OBJECT
308 306
309 public: 307 public:
310 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 308 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
311 virtual ~OWaveLanManagementDS(); 309 virtual ~OWaveLanManagementDS();
312 310
313 int channel() const; 311 int channel() const;
314 312
315 private: 313 private:
316 const struct ds_t* _data; 314 const struct ds_t* _data;
317}; 315};
318 316
319/*====================================================================================== 317/*======================================================================================
320 * OWaveLanManagementTim 318 * OWaveLanManagementTim
321 *======================================================================================*/ 319 *======================================================================================*/
322 320
323class OWaveLanManagementTim : public QObject 321class OWaveLanManagementTim : public QObject
324{ 322{
325 Q_OBJECT 323 Q_OBJECT
326 324
327 public: 325 public:
328 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 326 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
329 virtual ~OWaveLanManagementTim(); 327 virtual ~OWaveLanManagementTim();
330 328
331 private: 329 private:
332 const struct tim_t* _data; 330 const struct tim_t* _data;
333}; 331};
334 332
335/*====================================================================================== 333/*======================================================================================
336 * OWaveLanManagementIBSS 334 * OWaveLanManagementIBSS
337 *======================================================================================*/ 335 *======================================================================================*/
338 336
339class OWaveLanManagementIBSS : public QObject 337class OWaveLanManagementIBSS : public QObject
340{ 338{
341 Q_OBJECT 339 Q_OBJECT
342 340
343 public: 341 public:
344 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 342 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
345 virtual ~OWaveLanManagementIBSS(); 343 virtual ~OWaveLanManagementIBSS();
346 344
347 private: 345 private:
348 const struct ibss_t* _data; 346 const struct ibss_t* _data;
349}; 347};
350 348
351/*====================================================================================== 349/*======================================================================================
352 * OWaveLanManagementChallenge 350 * OWaveLanManagementChallenge
353 *======================================================================================*/ 351 *======================================================================================*/
354 352
355// Qobject do we need that??
356class OWaveLanManagementChallenge : public QObject 353class OWaveLanManagementChallenge : public QObject
357{ 354{
358 Q_OBJECT 355 Q_OBJECT
359 356
360 public: 357 public:
361 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 358 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
362 virtual ~OWaveLanManagementChallenge(); 359 virtual ~OWaveLanManagementChallenge();
363 360
364 private: 361 private:
365 const struct challenge_t* _data; 362 const struct challenge_t* _data;
366}; 363};
367 364
368/*====================================================================================== 365/*======================================================================================
369 * OWaveLanDataPacket - type: data (T_DATA) 366 * OWaveLanDataPacket - type: data (T_DATA)
370 *======================================================================================*/ 367 *======================================================================================*/
371// Qobject? 368
372class OWaveLanDataPacket : public QObject 369class OWaveLanDataPacket : public QObject
373{ 370{
374 Q_OBJECT 371 Q_OBJECT
375 372
376 public: 373 public:
377 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 374 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
378 virtual ~OWaveLanDataPacket(); 375 virtual ~OWaveLanDataPacket();
379 376
380 private: 377 private:
381 const struct ieee_802_11_data_header* _header; 378 const struct ieee_802_11_data_header* _header;
382}; 379};
383 380
384/*====================================================================================== 381/*======================================================================================
385 * OWaveLanControlPacket - type: control (T_CTRL) 382 * OWaveLanControlPacket - type: control (T_CTRL)
386 *======================================================================================*/ 383 *======================================================================================*/
387 384
388class OWaveLanControlPacket : public QObject 385class OWaveLanControlPacket : public QObject
389{ 386{
390 Q_OBJECT 387 Q_OBJECT
391 388
392 public: 389 public:
393 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 390 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
394 virtual ~OWaveLanControlPacket(); 391 virtual ~OWaveLanControlPacket();
395 392
396 private: 393 private:
397 const struct ieee_802_11_control_header* _header; 394 const struct ieee_802_11_control_header* _header;
398}; 395};
399 396
400/*====================================================================================== 397/*======================================================================================
401 * OLLCPacket - IEEE 802.2 Link Level Control 398 * OLLCPacket - IEEE 802.2 Link Level Control
402 *======================================================================================*/ 399 *======================================================================================*/
403 400
404class OLLCPacket : public QObject 401class OLLCPacket : public QObject
405{ 402{
406 Q_OBJECT 403 Q_OBJECT
407 404
408 public: 405 public:
409 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 406 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
410 virtual ~OLLCPacket(); 407 virtual ~OLLCPacket();
411 408
412 private: 409 private:
413 const struct ieee_802_11_802_2_header* _header; 410 const struct ieee_802_11_802_2_header* _header;
414}; 411};
415 412
416/*====================================================================================== 413/*======================================================================================
417 * OIPPacket 414 * OIPPacket
418 *======================================================================================*/ 415 *======================================================================================*/
419 416
420class OIPPacket : public QObject 417class OIPPacket : public QObject
421{ 418{
422 Q_OBJECT 419 Q_OBJECT
423 420
424 public: 421 public:
425 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 422 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
426 virtual ~OIPPacket(); 423 virtual ~OIPPacket();
427 424
428 QHostAddress fromIPAddress() const; 425 QHostAddress fromIPAddress() const;
429 QHostAddress toIPAddress() const; 426 QHostAddress toIPAddress() const;
430 427
431 int tos() const; 428 int tos() const;
432 int len() const; 429 int len() const;
433 int id() const; 430 int id() const;
434 int offset() const; 431 int offset() const;
435 int ttl() const; 432 int ttl() const;
436 int protocol() const; 433 int protocol() const;
437 int checksum() const; 434 int checksum() const;
438 435
439 private: 436 private:
440 const struct iphdr* _iphdr; 437 const struct iphdr* _iphdr;
441}; 438};
442 439
443/*====================================================================================== 440/*======================================================================================
444 * OUDPPacket 441 * OUDPPacket
445 *======================================================================================*/ 442 *======================================================================================*/
446 443
447class OUDPPacket : public QObject 444class OUDPPacket : public QObject
448{ 445{
449 Q_OBJECT 446 Q_OBJECT
450 447
451 public: 448 public:
452 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 449 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
453 virtual ~OUDPPacket(); 450 virtual ~OUDPPacket();
454 451
455 int fromPort() const; 452 int fromPort() const;
456 int toPort() const; 453 int toPort() const;
457 454
458 private: 455 private:
459 const struct udphdr* _udphdr; 456 const struct udphdr* _udphdr;
460}; 457};
461 458
462/*====================================================================================== 459/*======================================================================================
463 * OTCPPacket 460 * OTCPPacket
464 *======================================================================================*/ 461 *======================================================================================*/
465 462
466class OTCPPacket : public QObject 463class OTCPPacket : public QObject
467{ 464{
468 Q_OBJECT 465 Q_OBJECT
469 466
470 public: 467 public:
471 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 468 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
472 virtual ~OTCPPacket(); 469 virtual ~OTCPPacket();
473 470
474 int fromPort() const; 471 int fromPort() const;
475 int toPort() const; 472 int toPort() const;
476 473
477 private: 474 private:
478 const struct tcphdr* _tcphdr; 475 const struct tcphdr* _tcphdr;
479}; 476};
480 477
481 478
482/*====================================================================================== 479/*======================================================================================
483 * OPacketCapturer 480 * OPacketCapturer
484 *======================================================================================*/ 481 *======================================================================================*/
485 482
486/** 483/**
487 * @brief A class based wrapper for network packet capturing. 484 * @brief A class based wrapper for network packet capturing.
488 * 485 *
489 * This class is the base of a high-level interface to the well known packet capturing 486 * This class is the base of a high-level interface to the well known packet capturing
490 * library libpcap. ... 487 * library libpcap. ...
491 */ 488 */
492class OPacketCapturer : public QObject 489class OPacketCapturer : public QObject
493{ 490{
494 Q_OBJECT 491 Q_OBJECT
495 492
496 public: 493 public:
497 /** 494 /**
498 * Constructor. 495 * Constructor.
499 */ 496 */
500 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 497 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
501 /** 498 /**
502 * Destructor. 499 * Destructor.
503 */ 500 */
504 ~OPacketCapturer(); 501 ~OPacketCapturer();
505 /** 502 /**
506 * Setting the packet capturer to use blocking IO calls can be useful when 503 * Setting the packet capturer to use blocking IO calls can be useful when
507 * not using the socket notifier, e.g. without an application object. 504 * not using the socket notifier, e.g. without an application object.
508 */ 505 */
509 void setBlocking( bool ); 506 void setBlocking( bool );
510 /** 507 /**
511 * @returns true if the packet capturer uses blocking IO calls. 508 * @returns true if the packet capturer uses blocking IO calls.
512 */ 509 */
513 bool blocking() const; 510 bool blocking() const;
514 /** 511 /**
515 * Closes the packet capturer. This is automatically done in the destructor. 512 * Closes the packet capturer. This is automatically done in the destructor.
516 */ 513 */
517 void close(); 514 void close();
518 /** 515 /**
519 * @returns the data link type. 516 * @returns the data link type.
520 * @see <pcap.h> for possible values. 517 * @see <pcap.h> for possible values.
521 */ 518 */
522 int dataLink() const; 519 int dataLink() const;
523 /** 520 /**
524 * @returns the filedescriptor of the packet capturer. This is only useful, if 521 * @returns the filedescriptor of the packet capturer. This is only useful, if
525 * not using the socket notifier, e.g. without an application object. 522 * not using the socket notifier, e.g. without an application object.
526 */ 523 */
527 int fileno() const; 524 int fileno() const;
528 /** 525 /**
529 * @returns the next @ref OPacket from the packet capturer. 526 * @returns the next @ref OPacket from the packet capturer.
530 * @note If blocking mode is true then this call might block. 527 * @note If blocking mode is true then this call might block.
531 */ 528 */
532 OPacket* next(); 529 OPacket* next();
533 /** 530 /**
534 * Open the packet capturer to capture packets in live-mode from @a interface. 531 * Open the packet capturer to capture packets in live-mode from @a interface.
535 * If a @a filename is given, all captured packets are output to a tcpdump-compatible capture file. 532 * If a @a filename is given, all captured packets are output to a tcpdump-compatible capture file.
536 */ 533 */
537 bool open( const QString& interface, const QString& filename = QString::null ); 534 bool open( const QString& interface, const QString& filename = QString::null );
538 /** 535 /**
539 * Open the packet capturer to capture packets in offline-mode from @a file. 536 * Open the packet capturer to capture packets in offline-mode from @a file.
540 */ 537 */
541 bool open( const QFile& file ); 538 bool open( const QFile& file );
542 /** 539 /**
543 * @returns true if the packet capturer is open 540 * @returns true if the packet capturer is open
544 */ 541 */
545 bool isOpen() const; 542 bool isOpen() const;
546 543
547 const QMap<QString,int>& statistics() const; 544 const QMap<QString,int>& statistics() const;
548 545
549 signals: 546 signals:
550 /** 547 /**
551 * This signal is emitted, when a packet has been received. 548 * This signal is emitted, when a packet has been received.
552 */ 549 */
553 void receivedPacket( OPacket* ); 550 void receivedPacket( OPacket* );
554 551
555 protected slots: 552 protected slots:
556 void readyToReceive(); 553 void readyToReceive();
557 554
558 protected: 555 protected:
559 QString _name; // devicename 556 QString _name; // devicename
560 bool _open; // check this before doing pcap calls 557 bool _open; // check this before doing pcap calls
561 pcap_t* _pch; // pcap library handle 558 pcap_t* _pch; // pcap library handle
562 pcap_dumper_t* _pcd; // pcap dumper handle 559 pcap_dumper_t* _pcd; // pcap dumper handle
563 QSocketNotifier* _sn; // socket notifier for main loop 560 QSocketNotifier* _sn; // socket notifier for main loop
564 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 561 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
565 QMap<QString, int> _stats; // statistics; 562 QMap<QString, int> _stats; // statistics;
566}; 563};
567 564
568#endif // OPCAP_H 565#endif // OPCAP_H
569 566