PcapPlusPlus  19.12
PcapDevice.h
Go to the documentation of this file.
1 #ifndef PCAPPP_PCAP_DEVICE
2 #define PCAPPP_PCAP_DEVICE
3 
4 #include "Device.h"
5 
14 #if defined(PCAPPP_MINGW_ENV) && !defined(WIN32)
15 # define WIN32
16 #endif
17 #include <pcap.h>
18 
20 
25 namespace pcpp
26 {
27  //Forward Declaration - required for IPcapDevice::matchPacketWithFilter
28  class GeneralFilter;
29 
35  class IPcapDevice : public IDevice, public IFilterableDevice
36  {
37  protected:
38  pcap_t* m_PcapDescriptor;
39 
40  // c'tor should not be public
41  IPcapDevice() : IDevice() { m_PcapDescriptor = NULL; }
42 
43  public:
44  virtual ~IPcapDevice();
45 
53  virtual void getStatistics(pcap_stat& stats) const = 0;
54 
60  static std::string getPcapLibVersionInfo();
61 
67 #if __cplusplus > 201402L || _MSC_VER >= 1900
68  [[deprecated("Prefer building a BPFStringFilter class and calling verifyFilter on it to check if a filter string is valid see PcapFilter.h")]]
69 #endif
70  static bool verifyFilter(std::string filterAsString);
71 
79 #if __cplusplus > 201402L || _MSC_VER >= 1900
80  [[deprecated("Prefer building a GeneralFilter class and calling matchPacketWithFilter using the constructed filter. See PcapFilter.h")]]
81 #endif
82  static bool matchPacketWithFilter(std::string filterAsString, RawPacket* rawPacket);
83 
91  static bool matchPacketWithFilter(GeneralFilter& filter, RawPacket* rawPacket);
92 
93 
94  // implement abstract methods
95 
97 
103  virtual bool setFilter(std::string filterAsString);
104 
109  bool clearFilter();
110  };
111 
112 } // namespace pcpp
113 
114 #endif // PCAPPP_PCAP_DEVICE
pcpp::IPcapDevice::getPcapLibVersionInfo
static std::string getPcapLibVersionInfo()
pcpp::IPcapDevice::getStatistics
virtual void getStatistics(pcap_stat &stats) const =0
pcpp::IFilterableDevice::setFilter
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:76
pcpp::IFilterableDevice
Definition: Device.h:60
pcpp::IPcapDevice::setFilter
virtual bool setFilter(std::string filterAsString)
Device.h
pcpp::IPcapDevice::matchPacketWithFilter
static bool matchPacketWithFilter(std::string filterAsString, RawPacket *rawPacket)
pcpp::IPcapDevice
Definition: PcapDevice.h:35
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::IPcapDevice::clearFilter
bool clearFilter()
pcpp::GeneralFilter
Definition: PcapFilter.h:78
pcpp::IDevice
Definition: Device.h:24
pcpp::RawPacket
Definition: RawPacket.h:219
pcpp::IPcapDevice::verifyFilter
static bool verifyFilter(std::string filterAsString)