PcapPlusPlus  23.09
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 
58  virtual void getStatistics(PcapStats& stats) const = 0;
59 
65  static std::string getPcapLibVersionInfo();
66 
74  static bool matchPacketWithFilter(GeneralFilter& filter, RawPacket* rawPacket);
75 
76 
77  // implement abstract methods
78 
80 
88  virtual bool setFilter(std::string filterAsString);
89 
94  bool clearFilter();
95  };
96 
97 } // namespace pcpp
98 
99 #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:254
Definition: Device.h:24
uint64_t packetsDrop
Definition: PcapDevice.h:46
Definition: Device.h:60
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:76
Definition: PcapDevice.h:41