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 
13 namespace pcpp
14 {
17 
23  class IDevice
24  {
25  protected:
26  bool m_DeviceOpened;
27 
28  // c'tor should not be public
29  IDevice() : m_DeviceOpened(false)
30  {}
31 
32  public:
33  virtual ~IDevice()
34  {}
35 
40  virtual bool open() = 0;
41 
45  virtual void close() = 0;
46 
50  inline bool isOpened()
51  {
52  return m_DeviceOpened;
53  }
54  };
55 
63  {
64  protected:
65  // c'tor should not be public
67  {}
68 
69  public:
70  virtual ~IFilterableDevice()
71  {}
72 
79  virtual bool setFilter(GeneralFilter& filter)
80  {
81  std::string filterAsString;
82  filter.parseToString(filterAsString);
83  return setFilter(filterAsString);
84  }
85 
93  virtual bool setFilter(std::string filterAsString) = 0;
94 
99  virtual bool clearFilter() = 0;
100  };
101 } // namespace pcpp
Definition: PcapFilter.h:160
virtual void parseToString(std::string &result)=0
Definition: Device.h:24
bool isOpened()
Definition: Device.h:50
virtual void close()=0
virtual bool open()=0
Definition: Device.h:63
virtual bool clearFilter()=0
virtual bool setFilter(std::string filterAsString)=0
virtual bool setFilter(GeneralFilter &filter)
Definition: Device.h:79
Definition: PointerVector.h:58
The main namespace for the PcapPlusPlus lib.
PointerVector< RawPacket > RawPacketVector
Definition: Device.h:16