summaryrefslogtreecommitdiff
path: root/libopie2/opienet/opcap.h
Unidiff
Diffstat (limited to 'libopie2/opienet/opcap.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.h7
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 */
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 <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 */
58typedef struct timeval timevalstruct; 60typedef struct timeval timevalstruct;
59typedef struct pcap_pkthdr packetheaderstruct; 61typedef struct pcap_pkthdr packetheaderstruct;
60 62
61/* FORWARDS */ 63/* FORWARDS */
62class OPacketCapturer; 64class OPacketCapturer;
63class QSocketNotifier; 65class 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
93class OEthernetPacket : public QObject 97class 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