PcapPlusPlus  Next
Device.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include "PointerVector.h"
6 #include "RawPacket.h"
7 #include "PcapFilter.h"
8 
11 namespace pcpp
12 {
15 
19  class IDevice
20  {
21  protected:
22  bool m_DeviceOpened;
23 
24  // c'tor should not be public
25  IDevice() : m_DeviceOpened(false)
26  {}
27 
28  public:
29  virtual ~IDevice()
30  {}
31 
34  virtual bool open() = 0;
35 
37  virtual void close() = 0;
38 
40  inline bool isOpened()
41  {
42  return m_DeviceOpened;
43  }
44  };
45 
51  {
52  protected:
53  // c'tor should not be public
54  IFilterableDevice() = default;
55 
56  public:
57  virtual ~IFilterableDevice() = default;
58 
63  virtual bool setFilter(GeneralFilter& filter)
64  {
65  std::string filterAsString;
66  filter.parseToString(filterAsString);
67  return setFilter(filterAsString);
68  }
69 
75  virtual bool setFilter(std::string filterAsString) = 0;
76 
79  virtual bool clearFilter() = 0;
80  };
81 } // namespace pcpp
Definition: PcapFilter.h:134
virtual void parseToString(std::string &result)=0
Definition: Device.h:20
bool isOpened()
Definition: Device.h:40
virtual void close()=0
Close the device.
virtual bool open()=0
Definition: Device.h:51
virtual bool clearFilter()=0
virtual bool setFilter(std::string filterAsString)=0
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:63
Definition: PointerVector.h:50
The main namespace for the PcapPlusPlus lib.
PointerVector< RawPacket > RawPacketVector
A vector of pointers to RawPacket.
Definition: Device.h:14