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
Definition: PcapFilter.h:72
bool setFilter(GeneralFilter &filter)
Definition: RawPacket.h:220
bool isOpened()
Definition: PcapDevice.h:52
static bool matchPakcetWithFilter(std::string filterAsString, RawPacket *rawPacket)
virtual bool open()=0
virtual void close()=0
Definition: PcapDevice.h:26
static bool verifyFilter(std::string filterAsString)
PointerVector< RawPacket > RawPacketVector
Definition: PcapDevice.h:19
virtual void getStatistics(pcap_stat &stats)=0
The main namespace for the PcapPlusPlus lib.
Definition: PointerVector.h:24