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 
61  PCPP_DEPRECATED("Use `getDeviceByIp`")
63 
67  PcapLiveDevice* getDeviceByIp(const IPAddress& ipAddr) const;
68 
73  PCPP_DEPRECATED("Use `getDeviceByIp`")
75 
79  PcapLiveDevice* getDeviceByIp(const IPv4Address& ipAddr) const;
80 
85  PCPP_DEPRECATED("Use `getDeviceByIp`")
87 
91  PcapLiveDevice* getDeviceByIp(const IPv6Address& ip6Addr) const;
92 
98  PCPP_DEPRECATED("Use `getDeviceByIp`")
99  PcapLiveDevice* getPcapLiveDeviceByIp(const std::string& ipAddrAsString) const;
100 
105  PcapLiveDevice* getDeviceByIp(const std::string& ipAddrAsString) const;
106 
111  PCPP_DEPRECATED("Use `getDeviceByName`")
112  PcapLiveDevice* getPcapLiveDeviceByName(const std::string& name) const;
113 
117  PcapLiveDevice* getDeviceByName(const std::string& name) const;
118 
123  PCPP_DEPRECATED("Use `getDeviceByIpOrName`")
124  PcapLiveDevice* getPcapLiveDeviceByIpOrName(const std::string& ipOrName) const;
125 
129  PcapLiveDevice* getDeviceByIpOrName(const std::string& ipOrName) const;
130 
133  const std::vector<IPv4Address>& getDnsServers() const
134  {
135  return m_DnsServers;
136  }
137 
141 
143  void reset();
144  };
145 } // namespace pcpp
Definition: IpAddress.h:318
Definition: IpAddress.h:30
Definition: IpAddress.h:165
Definition: PcapLiveDevice.h:66
Definition: PcapLiveDeviceList.h:22
const std::vector< IPv4Address > & getDnsServers() const
Definition: PcapLiveDeviceList.h:133
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.