PcapPlusPlus
PcapDevice.h
Go to the documentation of this file.
1 #ifndef PCAPPP_DEVICE
2 #define PCAPPP_DEVICE
3 
4 #include "RawPacket.h"
5 #include "PcapFilter.h"
6 #include "PointerVector.h"
7 #include <pcap.h>
8 
10 
15 namespace pcpp
16 {
17 
20 
27  {
28  protected:
29  pcap_t* m_PcapDescriptor;
30  bool m_DeviceOpened;
31 
32  // c'tor should not be public
33  IPcapDevice() { m_DeviceOpened = false; m_PcapDescriptor = NULL; }
34 
35  public:
36  virtual ~IPcapDevice();
37 
42  virtual bool open() = 0;
43 
47  virtual void close() = 0;
48 
52  inline bool isOpened() { return m_DeviceOpened; }
53 
61  virtual void getStatistics(pcap_stat& stats) = 0;
62 
68  bool setFilter(GeneralFilter& filter);
69 
75  virtual bool setFilter(std::string filterAsString);
76 
80  void clearFilter();
81 
87  static bool verifyFilter(std::string filterAsString);
88 
96  static bool matchPakcetWithFilter(std::string filterAsString, RawPacket* rawPacket);
97  };
98 
99 } // namespace pcpp
100 
101 #endif
PointerVector< RawPacket > RawPacketVector
Definition: PcapDevice.h:19
Definition: PcapFilter.h:72
Definition: PcapDevice.h:26
bool isOpened()
Definition: PcapDevice.h:52
Definition: RawPacket.h:220
The main namespace for the PcapPlusPlus lib.
static bool matchPakcetWithFilter(std::string filterAsString, RawPacket *rawPacket)
virtual void close()=0
bool setFilter(GeneralFilter &filter)
virtual void getStatistics(pcap_stat &stats)=0
virtual bool open()=0
static bool verifyFilter(std::string filterAsString)
Definition: PointerVector.h:24