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 
16 #if defined(PCAPPP_MINGW_ENV) && !defined(WIN32)
17 # define WIN32
18 #endif
19 #include <pcap.h>
20 
22 
27 namespace pcpp
28 {
29 
32 
39  {
40  protected:
41  pcap_t* m_PcapDescriptor;
42  bool m_DeviceOpened;
43 
44  // c'tor should not be public
45  IPcapDevice() { m_DeviceOpened = false; m_PcapDescriptor = NULL; }
46 
47  public:
48  virtual ~IPcapDevice();
49 
54  virtual bool open() = 0;
55 
59  virtual void close() = 0;
60 
64  inline bool isOpened() { return m_DeviceOpened; }
65 
73  virtual void getStatistics(pcap_stat& stats) = 0;
74 
80  bool setFilter(GeneralFilter& filter);
81 
87  virtual bool setFilter(std::string filterAsString);
88 
92  void clearFilter();
93 
99  static bool verifyFilter(std::string filterAsString);
100 
108  static bool matchPakcetWithFilter(std::string filterAsString, RawPacket* rawPacket);
109  };
110 
111 } // namespace pcpp
112 
113 #endif
static bool verifyFilter(std::string filterAsString)
Definition: RawPacket.h:220
Definition: PcapDevice.h:38
The main namespace for the PcapPlusPlus lib.
Definition: PcapFilter.h:72
PointerVector< RawPacket > RawPacketVector
Definition: PcapDevice.h:31
Definition: PointerVector.h:24
bool isOpened()
Definition: PcapDevice.h:64
virtual void getStatistics(pcap_stat &stats)=0
virtual bool open()=0
virtual void close()=0
static bool matchPakcetWithFilter(std::string filterAsString, RawPacket *rawPacket)
bool setFilter(GeneralFilter &filter)