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 
14 namespace pcpp
15 {
16 
25  {
26  private:
27  std::vector<std::unique_ptr<PcapLiveDevice>> m_LiveDeviceList;
28  // Vector of raw device pointers to keep the signature of getPcapLiveDevicesList, as it returns a reference.
29  std::vector<PcapLiveDevice*> m_LiveDeviceListView;
30 
31  std::vector<IPv4Address> m_DnsServers;
32 
33  // private c'tor
35 
36  static std::vector<std::unique_ptr<PcapLiveDevice>> fetchAllLocalDevices();
37  static std::vector<IPv4Address> fetchDnsServers();
38 
39  public:
40  PcapLiveDeviceList(const PcapLiveDeviceList&) = delete;
41  PcapLiveDeviceList(PcapLiveDeviceList&&) noexcept = delete;
42  PcapLiveDeviceList& operator=(const PcapLiveDeviceList&) = delete;
43  PcapLiveDeviceList& operator=(PcapLiveDeviceList&&) noexcept = delete;
44 
50  {
51  static PcapLiveDeviceList instance;
52  return instance;
53  }
54 
58  const std::vector<PcapLiveDevice*>& getPcapLiveDevicesList() const
59  {
60  return m_LiveDeviceListView;
61  };
62 
69 
76 
83 
89  PcapLiveDevice* getPcapLiveDeviceByIp(const std::string& ipAddrAsString) const;
90 
96  PcapLiveDevice* getPcapLiveDeviceByName(const std::string& name) const;
97 
103  PcapLiveDevice* getPcapLiveDeviceByIpOrName(const std::string& ipOrName) const;
104 
109  const std::vector<IPv4Address>& getDnsServers() const
110  {
111  return m_DnsServers;
112  }
113 
119 
123  void reset();
124  };
125 
126 } // namespace pcpp
Definition: IpAddress.h:358
Definition: IpAddress.h:32
Definition: IpAddress.h:199
Definition: PcapLiveDevice.h:79
Definition: PcapLiveDeviceList.h:25
const std::vector< IPv4Address > & getDnsServers() const
Definition: PcapLiveDeviceList.h:109
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:49
PcapLiveDevice * getPcapLiveDeviceByIp(const IPv6Address &ip6Addr) const
PcapLiveDevice * getPcapLiveDeviceByIpOrName(const std::string &ipOrName) const
const std::vector< PcapLiveDevice * > & getPcapLiveDevicesList() const
Definition: PcapLiveDeviceList.h:58
The main namespace for the PcapPlusPlus lib.