PcapPlusPlus  21.11
Device.h
Go to the documentation of this file.
1 #ifndef PCAPPP_DEVICE
2 #define PCAPPP_DEVICE
3 
5 
6 #include "PointerVector.h"
7 #include "RawPacket.h"
8 #include "PcapFilter.h"
9 
14 namespace pcpp
15 {
18 
24  class IDevice
25  {
26  protected:
27  bool m_DeviceOpened;
28 
29  // c'tor should not be public
30  IDevice() : m_DeviceOpened(false) {}
31 
32  public:
33 
34  virtual ~IDevice() {}
35 
40  virtual bool open() = 0;
41 
46  virtual void close() = 0;
47 
51  inline bool isOpened() { return m_DeviceOpened; }
52  };
53 
54 
62  {
63  protected:
64 
65  // c'tor should not be public
67 
68  public:
69 
70  virtual ~IFilterableDevice() {}
71 
77  virtual bool setFilter(GeneralFilter& filter)
78  {
79  std::string filterAsString;
80  filter.parseToString(filterAsString);
81  return setFilter(filterAsString);
82  }
83 
89  virtual bool setFilter(std::string filterAsString) = 0;
90 
95  virtual bool clearFilter() = 0;
96  };
97 }
98 
99 #endif // PCAPPP_DEVICE
The main namespace for the PcapPlusPlus lib.
Definition: PointerVector.h:24
Definition: PcapFilter.h:136
Definition: Device.h:24
virtual bool open()=0
Definition: Device.h:61
virtual void close()=0
bool isOpened()
Definition: Device.h:51
virtual void parseToString(std::string &result)=0
PointerVector< RawPacket > RawPacketVector
Definition: Device.h:17
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:77