summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.h
Unidiff
Diffstat (limited to 'libopie2/opienet/onetwork.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 93b129f..a953296 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -35,48 +35,51 @@
35#error Need to define a wireless extension version to build against! 35#error Need to define a wireless extension version to build against!
36#endif 36#endif
37 37
38#if OPIE_WE_VERSION == 15 38#if OPIE_WE_VERSION == 15
39#include "wireless.15.h" 39#include "wireless.15.h"
40#endif 40#endif
41 41
42#if OPIE_WE_VERSION == 16 42#if OPIE_WE_VERSION == 16
43#include "wireless.16.h" 43#include "wireless.16.h"
44#endif 44#endif
45 45
46/* OPIE */ 46/* OPIE */
47 47
48#include <opie2/onetutils.h> 48#include <opie2/onetutils.h>
49#include <opie2/ostation.h> 49#include <opie2/ostation.h>
50 50
51/* QT */ 51/* QT */
52 52
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qdict.h> 54#include <qdict.h>
55#include <qmap.h> 55#include <qmap.h>
56#include <qobject.h> 56#include <qobject.h>
57#include <qhostaddress.h> 57#include <qhostaddress.h>
58 58
59namespace Opie {
60namespace Net {
61
59class ONetworkInterface; 62class ONetworkInterface;
60class OWirelessNetworkInterface; 63class OWirelessNetworkInterface;
61class OChannelHopper; 64class OChannelHopper;
62class OMonitoringInterface; 65class OMonitoringInterface;
63 66
64/*====================================================================================== 67/*======================================================================================
65 * ONetwork 68 * ONetwork
66 *======================================================================================*/ 69 *======================================================================================*/
67 70
68/** 71/**
69 * @brief A container class for all network interfaces 72 * @brief A container class for all network interfaces
70 * 73 *
71 * This class provides access to all available network interfaces of your computer. 74 * This class provides access to all available network interfaces of your computer.
72 * 75 *
73 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 76 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
74 */ 77 */
75class ONetwork : public QObject 78class ONetwork : public QObject
76{ 79{
77 Q_OBJECT 80 Q_OBJECT
78 81
79 public: 82 public:
80 typedef QDict<ONetworkInterface> InterfaceMap; 83 typedef QDict<ONetworkInterface> InterfaceMap;
81 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 84 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
82 85
@@ -102,48 +105,50 @@ class ONetwork : public QObject
102 */ 105 */
103 bool isWirelessInterface( const char* interface ) const; 106 bool isWirelessInterface( const char* interface ) const;
104 /** 107 /**
105 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 108 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
106 * @see ONetworkInterface 109 * @see ONetworkInterface
107 */ 110 */
108 ONetworkInterface* interface( const QString& interface ) const; 111 ONetworkInterface* interface( const QString& interface ) const;
109 /** 112 /**
110 * @internal Rebuild the internal interface database 113 * @internal Rebuild the internal interface database
111 * @note Sometimes it might be useful to call this from client code, 114 * @note Sometimes it might be useful to call this from client code,
112 * e.g. after issuing a cardctl insert 115 * e.g. after issuing a cardctl insert
113 */ 116 */
114 void synchronize(); 117 void synchronize();
115 /** 118 /**
116 * @returns the wireless extension version used at compile time. 119 * @returns the wireless extension version used at compile time.
117 **/ 120 **/
118 static short wirelessExtensionVersion(); 121 static short wirelessExtensionVersion();
119 122
120 protected: 123 protected:
121 ONetwork(); 124 ONetwork();
122 125
123 private: 126 private:
124 static ONetwork* _instance; 127 static ONetwork* _instance;
125 InterfaceMap _interfaces; 128 InterfaceMap _interfaces;
129 class Private;
130 Private *d;
126}; 131};
127 132
128 133
129/*====================================================================================== 134/*======================================================================================
130 * ONetworkInterface 135 * ONetworkInterface
131 *======================================================================================*/ 136 *======================================================================================*/
132 137
133/** 138/**
134 * @brief A network interface wrapper. 139 * @brief A network interface wrapper.
135 * 140 *
136 * This class provides a wrapper for a network interface. All the cumbersume details of 141 * 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. 142 * Linux ioctls are hidden under a convenient high-level interface.
138 * @warning Most of the setting methods contained in this class require the appropriate 143 * @warning Most of the setting methods contained in this class require the appropriate
139 * process permissions to work. 144 * process permissions to work.
140 * 145 *
141 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 146 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
142 */ 147 */
143class ONetworkInterface : public QObject 148class ONetworkInterface : public QObject
144{ 149{
145 friend class OMonitoringInterface; 150 friend class OMonitoringInterface;
146 friend class OCiscoMonitoringInterface; 151 friend class OCiscoMonitoringInterface;
147 friend class OWlanNGMonitoringInterface; 152 friend class OWlanNGMonitoringInterface;
148 friend class OHostAPMonitoringInterface; 153 friend class OHostAPMonitoringInterface;
149 friend class OOrinocoMonitoringInterface; 154 friend class OOrinocoMonitoringInterface;
@@ -213,48 +218,51 @@ class ONetworkInterface : public QObject
213 /** 218 /**
214 * Associate the IPv4 @a netmask with the interface. 219 * Associate the IPv4 @a netmask with the interface.
215 */ 220 */
216 void setIPV4Netmask( const QHostAddress& netmask ); 221 void setIPV4Netmask( const QHostAddress& netmask );
217 /** 222 /**
218 * @returns the IPv4 netmask associated with the interface. 223 * @returns the IPv4 netmask associated with the interface.
219 */ 224 */
220 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 225 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
221 /** 226 /**
222 * @returns the data link type currently associated with the interface. 227 * @returns the data link type currently associated with the interface.
223 * @see #include <net/if_arp.h> for possible values. 228 * @see #include <net/if_arp.h> for possible values.
224 */ 229 */
225 int dataLinkType() const; 230 int dataLinkType() const;
226 231
227 protected: 232 protected:
228 const int _sfd; 233 const int _sfd;
229 mutable ifreq _ifr; 234 mutable ifreq _ifr;
230 OMonitoringInterface* _mon; 235 OMonitoringInterface* _mon;
231 236
232 protected: 237 protected:
233 struct ifreq& ifr() const; 238 struct ifreq& ifr() const;
234 virtual void init(); 239 virtual void init();
235 bool ioctl( int call ) const; 240 bool ioctl( int call ) const;
236 bool ioctl( int call, struct ifreq& ) const; 241 bool ioctl( int call, struct ifreq& ) const;
242 private:
243 class Private;
244 Private *d;
237}; 245};
238 246
239/*====================================================================================== 247/*======================================================================================
240 * OChannelHopper 248 * OChannelHopper
241 *======================================================================================*/ 249 *======================================================================================*/
242 250
243/** 251/**
244 * @brief A radio frequency channel hopper. 252 * @brief A radio frequency channel hopper.
245 * 253 *
246 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 254 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
247 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 255 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
248 * This is necessary when in monitoring mode and scanning for other devices, because 256 * This is necessary when in monitoring mode and scanning for other devices, because
249 * the radio frequency hardware can only detect packets sent on the same frequency. 257 * the radio frequency hardware can only detect packets sent on the same frequency.
250 * 258 *
251 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 259 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
252 */ 260 */
253class OChannelHopper : public QObject 261class OChannelHopper : public QObject
254{ 262{
255 Q_OBJECT 263 Q_OBJECT
256 264
257 public: 265 public:
258 /** 266 /**
259 * Constructor. 267 * Constructor.
260 */ 268 */
@@ -275,48 +283,50 @@ class OChannelHopper : public QObject
275 * Set the channel hopping @a interval. 283 * Set the channel hopping @a interval.
276 * An interval of 0 deactivates the channel hopper. 284 * An interval of 0 deactivates the channel hopper.
277 */ 285 */
278 void setInterval( int interval ); 286 void setInterval( int interval );
279 /** 287 /**
280 * @returns the channel hopping interval 288 * @returns the channel hopping interval
281 */ 289 */
282 int interval() const; 290 int interval() const;
283 291
284 signals: 292 signals:
285 /** 293 /**
286 * This signal is emitted right after the channel hopper performed a hop 294 * This signal is emitted right after the channel hopper performed a hop
287 */ 295 */
288 void hopped( int ); 296 void hopped( int );
289 297
290 protected: 298 protected:
291 virtual void timerEvent( QTimerEvent* ); 299 virtual void timerEvent( QTimerEvent* );
292 300
293 private: 301 private:
294 OWirelessNetworkInterface* _iface; 302 OWirelessNetworkInterface* _iface;
295 int _interval; 303 int _interval;
296 int _tid; 304 int _tid;
297 QValueList<int> _channels; 305 QValueList<int> _channels;
298 QValueList<int>::Iterator _channel; 306 QValueList<int>::Iterator _channel;
307 class Private;
308 Private *d;
299}; 309};
300 310
301 311
302/*====================================================================================== 312/*======================================================================================
303 * OWirelessNetworkInterface 313 * OWirelessNetworkInterface
304 *======================================================================================*/ 314 *======================================================================================*/
305 315
306/** 316/**
307 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 317 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
308 * 318 *
309 * This class provides a high-level encapsulation of the Linux wireless extension API. 319 * This class provides a high-level encapsulation of the Linux wireless extension API.
310 * 320 *
311 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 321 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
312 */ 322 */
313class OWirelessNetworkInterface : public ONetworkInterface 323class OWirelessNetworkInterface : public ONetworkInterface
314{ 324{
315 friend class OMonitoringInterface; 325 friend class OMonitoringInterface;
316 friend class OCiscoMonitoringInterface; 326 friend class OCiscoMonitoringInterface;
317 friend class OWlanNGMonitoringInterface; 327 friend class OWlanNGMonitoringInterface;
318 friend class OHostAPMonitoringInterface; 328 friend class OHostAPMonitoringInterface;
319 friend class OOrinocoMonitoringInterface; 329 friend class OOrinocoMonitoringInterface;
320 330
321 friend class OPrivateIOCTL; 331 friend class OPrivateIOCTL;
322 332
@@ -434,126 +444,147 @@ class OWirelessNetworkInterface : public ONetworkInterface
434 * In other modes the result is driver dependent. 444 * In other modes the result is driver dependent.
435 */ 445 */
436 virtual int signalStrength() const; 446 virtual int signalStrength() const;
437 /** @internal commit pending changes to the driver 447 /** @internal commit pending changes to the driver
438 * 448 *
439 */ 449 */
440 void commit() const; 450 void commit() const;
441 451
442 protected: 452 protected:
443 void buildInformation(); 453 void buildInformation();
444 void buildPrivateList(); 454 void buildPrivateList();
445 void dumpInformation() const; 455 void dumpInformation() const;
446 virtual void init(); 456 virtual void init();
447 struct iwreq& iwr() const; 457 struct iwreq& iwr() const;
448 bool wioctl( int call ) const; 458 bool wioctl( int call ) const;
449 bool wioctl( int call, struct iwreq& ) const; 459 bool wioctl( int call, struct iwreq& ) const;
450 460
451 protected: 461 protected:
452 mutable struct iwreq _iwr; 462 mutable struct iwreq _iwr;
453 QMap<int,int> _channels; 463 QMap<int,int> _channels;
454 struct iw_range _range; 464 struct iw_range _range;
455 465
456 private: 466 private:
457 OChannelHopper* _hopper; 467 OChannelHopper* _hopper;
468 class Private;
469 Private *d;
458}; 470};
459 471
460 472
461/*====================================================================================== 473/*======================================================================================
462 * OMonitoringInterface 474 * OMonitoringInterface
463 *======================================================================================*/ 475 *======================================================================================*/
464 476
465 477
466class OMonitoringInterface 478class OMonitoringInterface
467{ 479{
468 public: 480 public:
469 OMonitoringInterface(); 481 OMonitoringInterface();
470 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 482 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
471 virtual ~OMonitoringInterface(); 483 virtual ~OMonitoringInterface();
472 484
473 public: 485 public:
474 virtual void setEnabled( bool ); 486 virtual void setEnabled( bool );
475 virtual void setChannel( int ); 487 virtual void setChannel( int );
476 488
477 virtual QString name() const = 0; 489 virtual QString name() const = 0;
478 490
479 protected: 491 protected:
480 OWirelessNetworkInterface* _if; 492 OWirelessNetworkInterface* _if;
481 bool _prismHeader; 493 bool _prismHeader;
494 private:
495 class Private;
496 Private *d;
482 497
483}; 498};
484 499
485 500
486/*====================================================================================== 501/*======================================================================================
487 * OCiscoMonitoring 502 * OCiscoMonitoring
488 *======================================================================================*/ 503 *======================================================================================*/
489 504
490 505
491class OCiscoMonitoringInterface : public OMonitoringInterface 506class OCiscoMonitoringInterface : public OMonitoringInterface
492{ 507{
493 public: 508 public:
494 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 509 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
495 virtual ~OCiscoMonitoringInterface(); 510 virtual ~OCiscoMonitoringInterface();
496 511
497 virtual void setEnabled( bool ); 512 virtual void setEnabled( bool );
498 virtual QString name() const; 513 virtual QString name() const;
499 virtual void setChannel( int ); 514 virtual void setChannel( int );
515 private:
516 class Private;
517 Private *d;
500 518
501}; 519};
502 520
503 521
504/*====================================================================================== 522/*======================================================================================
505 * OWlanNGMonitoringInterface 523 * OWlanNGMonitoringInterface
506 *======================================================================================*/ 524 *======================================================================================*/
507 525
508 526
509class OWlanNGMonitoringInterface : public OMonitoringInterface 527class OWlanNGMonitoringInterface : public OMonitoringInterface
510{ 528{
511 public: 529 public:
512 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 530 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
513 virtual ~OWlanNGMonitoringInterface(); 531 virtual ~OWlanNGMonitoringInterface();
514 532
515 public: 533 public:
516 virtual void setEnabled( bool ); 534 virtual void setEnabled( bool );
517 virtual QString name() const; 535 virtual QString name() const;
518 virtual void setChannel( int ); 536 virtual void setChannel( int );
537 private:
538 class Private;
539 Private *d;
519 540
520}; 541};
521 542
522 543
523/*====================================================================================== 544/*======================================================================================
524 * OHostAPMonitoringInterface 545 * OHostAPMonitoringInterface
525 *======================================================================================*/ 546 *======================================================================================*/
526 547
527 548
528class OHostAPMonitoringInterface : public OMonitoringInterface 549class OHostAPMonitoringInterface : public OMonitoringInterface
529{ 550{
530 public: 551 public:
531 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 552 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
532 virtual ~OHostAPMonitoringInterface(); 553 virtual ~OHostAPMonitoringInterface();
533 554
534 public: 555 public:
535 virtual void setEnabled( bool ); 556 virtual void setEnabled( bool );
536 virtual QString name() const; 557 virtual QString name() const;
558
559 private:
560 class Private;
561 Private *d;
537 }; 562 };
538 563
539 564
540/*====================================================================================== 565/*======================================================================================
541 * OOrinocoMonitoringInterface 566 * OOrinocoMonitoringInterface
542 *======================================================================================*/ 567 *======================================================================================*/
543 568
544 569
545class OOrinocoMonitoringInterface : public OMonitoringInterface 570class OOrinocoMonitoringInterface : public OMonitoringInterface
546{ 571{
547 public: 572 public:
548 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 573 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
549 virtual ~OOrinocoMonitoringInterface(); 574 virtual ~OOrinocoMonitoringInterface();
550 575
551 public: 576 public:
552 virtual void setChannel( int ); 577 virtual void setChannel( int );
553 virtual void setEnabled( bool ); 578 virtual void setEnabled( bool );
554 virtual QString name() const; 579 virtual QString name() const;
555 580
581 private:
582 class Private;
583 Private *d;
556}; 584};
557 585
586}
587}
588
558#endif // ONETWORK_H 589#endif // ONETWORK_H
559 590