PcapPlusPlus  Next
PcapLiveDeviceList.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "IpAddress.h"
4 #include "PcapLiveDevice.h"
5 #include <vector>
6 #include <memory>
7 
9 
12 namespace pcpp
13 {
20  {
21  private:
22  std::vector<std::unique_ptr<PcapLiveDevice>> m_LiveDeviceList;
23  // Vector of raw device pointers to keep the signature of getPcapLiveDevicesList, as it returns a reference.
24  std::vector<PcapLiveDevice*> m_LiveDeviceListView;
25 
26  std::vector<IPv4Address> m_DnsServers;
27 
28  // private c'tor
30 
31  static std::vector<std::unique_ptr<PcapLiveDevice>> fetchAllLocalDevices();
32  static std::vector<IPv4Address> fetchDnsServers();
33 
34  public:
35  PcapLiveDeviceList(const PcapLiveDeviceList&) = delete;
36  PcapLiveDeviceList(PcapLiveDeviceList&&) noexcept = delete;
37  PcapLiveDeviceList& operator=(const PcapLiveDeviceList&) = delete;
38  PcapLiveDeviceList& operator=(PcapLiveDeviceList&&) noexcept = delete;
39 
43  {
44  static PcapLiveDeviceList instance;
45  return instance;
46  }
47 
49  const std::vector<PcapLiveDevice*>& getPcapLiveDevicesList() const
50  {
51  return m_LiveDeviceListView;
52  };
53 
58 
63 
68 
73  PcapLiveDevice* getPcapLiveDeviceByIp(const std::string& ipAddrAsString) const;
74 
78  PcapLiveDevice* getPcapLiveDeviceByName(const std::string& name) const;
79 
83  PcapLiveDevice* getPcapLiveDeviceByIpOrName(const std::string& ipOrName) const;
84 
87  const std::vector<IPv4Address>& getDnsServers() const
88  {
89  return m_DnsServers;
90  }
91 
95 
97  void reset();
98  };
99 } // namespace pcpp
Definition: IpAddress.h:276
Definition: IpAddress.h:28
Definition: IpAddress.h:156
Definition: PcapLiveDevice.h:68
Definition: PcapLiveDeviceList.h:20
const std::vector< IPv4Address > & getDnsServers() const
Definition: PcapLiveDeviceList.h:87
PcapLiveDevice * getPcapLiveDeviceByIp(const IPAddress &ipAddr) const
PcapLiveDevice * getPcapLiveDeviceByIp(const IPv4Address &ipAddr) const
PcapLiveDeviceList * clone()
PcapLiveDevice * getPcapLiveDeviceByIp(const std::string &ipAddrAsString) const
PcapLiveDevice * getPcapLiveDeviceByName(const std::string &name) const
static PcapLiveDeviceList & getInstance()
Definition: PcapLiveDeviceList.h:42
PcapLiveDevice * getPcapLiveDeviceByIp(const IPv6Address &ip6Addr) const
PcapLiveDevice * getPcapLiveDeviceByIpOrName(const std::string &ipOrName) const
const std::vector< PcapLiveDevice * > & getPcapLiveDevicesList() const
Definition: PcapLiveDeviceList.h:49
void reset()
Reset the live device list and DNS server list, meaning clear and refetch them.
The main namespace for the PcapPlusPlus lib.