author | mickeyl <mickeyl> | 2003-04-09 21:37:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-09 21:37:05 (UTC) |
commit | b055856776807f0a459a86b1e1f62902d2d3a9c3 (patch) (unidiff) | |
tree | 46bee28833c363607d20f4db93eef0166a45852d /libopie2/opienet/opcap.h | |
parent | c8401f7ebb9e9314ed48517da38b949c24800c50 (diff) | |
download | opie-b055856776807f0a459a86b1e1f62902d2d3a9c3.zip opie-b055856776807f0a459a86b1e1f62902d2d3a9c3.tar.gz opie-b055856776807f0a459a86b1e1f62902d2d3a9c3.tar.bz2 |
implements a statistic interface for OPacketCapturer
-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 | |||
@@ -37,27 +37,29 @@ | |||
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; |
@@ -71,24 +73,26 @@ class OPacket : public QObject | |||
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 | { |
@@ -425,28 +429,31 @@ class OPacketCapturer : public QObject | |||
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 | ||