PcapPlusPlus  22.11
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 
6 // forward declaration for the pcap descriptor defined in pcap.h
7 struct pcap;
8 typedef pcap pcap_t;
9 struct pcap_pkthdr;
10 
12 
17 namespace pcpp
18 {
19  //Forward Declaration - required for IPcapDevice::matchPacketWithFilter
20  class GeneralFilter;
21 
27  class IPcapDevice : public IDevice, public IFilterableDevice
28  {
29  protected:
30  pcap_t* m_PcapDescriptor;
31 
32  // c'tor should not be public
33  IPcapDevice() : IDevice() { m_PcapDescriptor = NULL; }
34 
35  public:
36 
41  struct PcapStats
42  {
44  uint64_t packetsRecv;
46  uint64_t packetsDrop;
49  };
50 
51 
52  virtual ~IPcapDevice();
53 
59  virtual void getStatistics(PcapStats& stats) const = 0;
60 
66  static std::string getPcapLibVersionInfo();
67 
75  static bool matchPacketWithFilter(GeneralFilter& filter, RawPacket* rawPacket);
76 
77 
78  // implement abstract methods
79 
81 
89  virtual bool setFilter(std::string filterAsString);
90 
95  bool clearFilter();
96  };
97 
98 } // namespace pcpp
99 
100 #endif // PCAPPP_PCAP_DEVICE
The main namespace for the PcapPlusPlus lib.
uint64_t packetsDropByInterface
Definition: PcapDevice.h:48
Definition: PcapDevice.h:27
Definition: PcapFilter.h:136
Definition: RawPacket.h:252
Definition: Device.h:24
uint64_t packetsDrop
Definition: PcapDevice.h:46
Definition: Device.h:61
uint64_t packetsRecv
Definition: PcapDevice.h:44
static std::string getPcapLibVersionInfo()
virtual void getStatistics(PcapStats &stats) const =0
static bool matchPacketWithFilter(GeneralFilter &filter, RawPacket *rawPacket)
virtual bool setFilter(std::string filterAsString)
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:77
Definition: PcapDevice.h:41