PcapPlusPlus  Next
PcapLiveDeviceList.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "DeprecationUtils.h"
4 #include "IpAddress.h"
5 #include "DeviceListBase.h"
6 #include "PcapLiveDevice.h"
7 #include <vector>
8 #include <memory>
9 
11 
14 namespace pcpp
15 {
21  class PcapLiveDeviceList : public internal::DeviceListBase<PcapLiveDevice>
22  {
23  private:
25 
26  // Vector of raw device pointers to keep the signature of getPcapLiveDevicesList, as it returns a reference.
27  std::vector<PcapLiveDevice*> m_LiveDeviceListView;
28 
29  std::vector<IPv4Address> m_DnsServers;
30 
31  // private c'tor
33 
34  static PointerVector<PcapLiveDevice> fetchAllLocalDevices();
35  static std::vector<IPv4Address> fetchDnsServers();
36 
37  public:
38  PcapLiveDeviceList(const PcapLiveDeviceList&) = delete;
39  PcapLiveDeviceList(PcapLiveDeviceList&&) noexcept = delete;
40  PcapLiveDeviceList& operator=(const PcapLiveDeviceList&) = delete;
41  PcapLiveDeviceList& operator=(PcapLiveDeviceList&&) noexcept = delete;
42 
46  {
47  static PcapLiveDeviceList instance;
48  return instance;
49  }
50 
52  const std::vector<PcapLiveDevice*>& getPcapLiveDevicesList() const
53  {
54  return m_LiveDeviceListView;
55  };
56 
60  PCPP_DEPRECATED("Use `getDeviceByIp`")
62 
66  PcapLiveDevice* getDeviceByIp(const IPAddress& ipAddr) const;
67 
71  PCPP_DEPRECATED("Use `getDeviceByIp`")
73 
77  PcapLiveDevice* getDeviceByIp(const IPv4Address& ipAddr) const;
78 
82  PCPP_DEPRECATED("Use `getDeviceByIp`")
84 
88  PcapLiveDevice* getDeviceByIp(const IPv6Address& ip6Addr) const;
89 
94  PCPP_DEPRECATED("Use `getDeviceByIp`")
95  PcapLiveDevice* getPcapLiveDeviceByIp(const std::string& ipAddrAsString) const;
96 
101  PcapLiveDevice* getDeviceByIp(const std::string& ipAddrAsString) const;
102 
106  PCPP_DEPRECATED("Use `getDeviceByName`")
107  PcapLiveDevice* getPcapLiveDeviceByName(const std::string& name) const;
108 
112  PcapLiveDevice* getDeviceByName(const std::string& name) const;
113 
117  PCPP_DEPRECATED("Use `getDeviceByIpOrName`")
118  PcapLiveDevice* getPcapLiveDeviceByIpOrName(const std::string& ipOrName) const;
119 
123  PcapLiveDevice* getDeviceByIpOrName(const std::string& ipOrName) const;
124 
127  const std::vector<IPv4Address>& getDnsServers() const
128  {
129  return m_DnsServers;
130  }
131 
135 
137  void reset();
138  };
139 } // namespace pcpp
Definition: IpAddress.h:276
Definition: IpAddress.h:28
Definition: IpAddress.h:156
Definition: PcapLiveDevice.h:66
Definition: PcapLiveDeviceList.h:22
const std::vector< IPv4Address > & getDnsServers() const
Definition: PcapLiveDeviceList.h:127
PcapLiveDevice * getPcapLiveDeviceByIp(const IPAddress &ipAddr) const
PcapLiveDeviceList * clone()
PcapLiveDevice * getDeviceByIp(const IPAddress &ipAddr) const
PcapLiveDevice * getDeviceByName(const std::string &name) const
PcapLiveDevice * getPcapLiveDeviceByName(const std::string &name) const
static PcapLiveDeviceList & getInstance()
Definition: PcapLiveDeviceList.h:45
PcapLiveDevice * getPcapLiveDeviceByIpOrName(const std::string &ipOrName) const
PcapLiveDevice * getDeviceByIpOrName(const std::string &ipOrName) const
const std::vector< PcapLiveDevice * > & getPcapLiveDevicesList() const
Definition: PcapLiveDeviceList.h:52
void reset()
Reset the live device list and DNS server list, meaning clear and refetch them.
Definition: PointerVector.h:50
A base class for device lists, providing common functionality for managing a list of devices.
Definition: DeviceListBase.h:10
The main namespace for the PcapPlusPlus lib.