-rw-r--r-- | libopie2/opienet/opcap.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index ddef278..c9b0624 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -25,82 +25,86 @@ | |||
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 */ |
38 | extern "C" // work around a bpf/pcap conflict in recent headers | 38 | extern "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 <qhostaddress.h> | 50 | #include <qhostaddress.h> |
50 | #include <qobject.h> | 51 | #include <qobject.h> |
51 | #include <qstring.h> | 52 | #include <qstring.h> |
53 | #include <qmap.h> | ||
52 | 54 | ||
53 | /* OPIE */ | 55 | /* OPIE */ |
54 | #include <opie2/onetutils.h> | 56 | #include <opie2/onetutils.h> |
55 | #include "802_11_user.h" | 57 | #include "802_11_user.h" |
56 | 58 | ||
57 | /* TYPEDEFS */ | 59 | /* TYPEDEFS */ |
58 | typedef struct timeval timevalstruct; | 60 | typedef struct timeval timevalstruct; |
59 | typedef struct pcap_pkthdr packetheaderstruct; | 61 | typedef struct pcap_pkthdr packetheaderstruct; |
60 | 62 | ||
61 | /* FORWARDS */ | 63 | /* FORWARDS */ |
62 | class OPacketCapturer; | 64 | class OPacketCapturer; |
63 | class QSocketNotifier; | 65 | class QSocketNotifier; |
64 | 66 | ||
65 | /*====================================================================================== | 67 | /*====================================================================================== |
66 | * OPacket - A frame on the wire | 68 | * OPacket - A frame on the wire |
67 | *======================================================================================*/ | 69 | *======================================================================================*/ |
68 | 70 | ||
69 | class OPacket : public QObject | 71 | class OPacket : public QObject |
70 | { | 72 | { |
71 | Q_OBJECT | 73 | Q_OBJECT |
72 | 74 | ||
73 | public: | 75 | public: |
74 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 76 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
75 | virtual ~OPacket(); | 77 | virtual ~OPacket(); |
76 | 78 | ||
77 | timevalstruct timeval() const; | 79 | timevalstruct timeval() const; |
78 | 80 | ||
79 | int caplen() const; | 81 | int caplen() const; |
80 | int len() const; | 82 | int len() const; |
81 | QString dump( int = 32 ) const; | 83 | QString dump( int = 32 ) const; |
82 | 84 | ||
85 | void updateStats( QMap<QString,int>&, QObjectList* ); | ||
86 | |||
83 | private: | 87 | private: |
84 | const packetheaderstruct _hdr; // pcap packet header | 88 | const packetheaderstruct _hdr; // pcap packet header |
85 | const unsigned char* _data; // pcap packet data | 89 | const unsigned char* _data; // pcap packet data |
86 | const unsigned char* _end; // end of pcap packet data | 90 | const unsigned char* _end; // end of pcap packet data |
87 | }; | 91 | }; |
88 | 92 | ||
89 | /*====================================================================================== | 93 | /*====================================================================================== |
90 | * OEthernetPacket - DLT_EN10MB frame | 94 | * OEthernetPacket - DLT_EN10MB frame |
91 | *======================================================================================*/ | 95 | *======================================================================================*/ |
92 | 96 | ||
93 | class OEthernetPacket : public QObject | 97 | class OEthernetPacket : public QObject |
94 | { | 98 | { |
95 | Q_OBJECT | 99 | Q_OBJECT |
96 | 100 | ||
97 | public: | 101 | public: |
98 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 102 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
99 | virtual ~OEthernetPacket(); | 103 | virtual ~OEthernetPacket(); |
100 | 104 | ||
101 | OMacAddress sourceAddress() const; | 105 | OMacAddress sourceAddress() const; |
102 | OMacAddress destinationAddress() const; | 106 | OMacAddress destinationAddress() const; |
103 | int type() const; | 107 | int type() const; |
104 | 108 | ||
105 | private: | 109 | private: |
106 | const struct ether_header* _ether; | 110 | const struct ether_header* _ether; |
@@ -413,40 +417,43 @@ class OTCPPacket : public QObject | |||
413 | 417 | ||
414 | 418 | ||
415 | /*====================================================================================== | 419 | /*====================================================================================== |
416 | * OPacketCapturer | 420 | * OPacketCapturer |
417 | *======================================================================================*/ | 421 | *======================================================================================*/ |
418 | 422 | ||
419 | class OPacketCapturer : public QObject | 423 | class OPacketCapturer : public QObject |
420 | { | 424 | { |
421 | Q_OBJECT | 425 | Q_OBJECT |
422 | 426 | ||
423 | public: | 427 | public: |
424 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); | 428 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); |
425 | ~OPacketCapturer(); | 429 | ~OPacketCapturer(); |
426 | 430 | ||
427 | void setBlocking( bool ); | 431 | void setBlocking( bool ); |
428 | bool blocking() const; | 432 | bool blocking() const; |
429 | 433 | ||
430 | void close(); | 434 | void close(); |
431 | int dataLink() const; | 435 | int dataLink() const; |
432 | int fileno() const; | 436 | int fileno() const; |
433 | OPacket* next(); | 437 | OPacket* next(); |
434 | bool open( const QString& name ); | 438 | bool open( const QString& name ); |
435 | bool isOpen() const; | 439 | bool isOpen() const; |
436 | 440 | ||
441 | const QMap<QString,int>& statistics() const; | ||
442 | |||
437 | signals: | 443 | signals: |
438 | void receivedPacket( OPacket* ); | 444 | void receivedPacket( OPacket* ); |
439 | 445 | ||
440 | protected slots: | 446 | protected slots: |
441 | void readyToReceive(); | 447 | void readyToReceive(); |
442 | 448 | ||
443 | protected: | 449 | protected: |
444 | QString _name; // devicename | 450 | QString _name; // devicename |
445 | bool _open; // check this before doing pcap calls | 451 | bool _open; // check this before doing pcap calls |
446 | pcap_t* _pch; // pcap library handle | 452 | pcap_t* _pch; // pcap library handle |
447 | QSocketNotifier* _sn; // socket notifier for main loop | 453 | QSocketNotifier* _sn; // socket notifier for main loop |
448 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; | 454 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; |
455 | QMap<QString, int> _stats; // statistics; | ||
449 | }; | 456 | }; |
450 | 457 | ||
451 | #endif // OPCAP_H | 458 | #endif // OPCAP_H |
452 | 459 | ||