PcapPlusPlus  Next
PcapRemoteDevice.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <memory>
5 #include "PcapLiveDevice.h"
6 
8 
9 struct pcap_rmtauth;
10 
13 namespace pcpp
14 {
20  {
21  public:
25  PcapRemoteAuthentication(const std::string& username, const std::string& password) : userName(username)
26  {
27  this->password = password;
28  }
29 
33  : userName(other.userName), password(other.password)
34  {}
35 
37  std::string userName;
38 
40  std::string password;
41 
46  pcap_rmtauth getPcapRmAuth() const;
47  };
48 
68  {
69  friend class PcapRemoteDeviceList;
70 
71  private:
72  IPAddress m_RemoteMachineIpAddress;
73  uint16_t m_RemoteMachinePort;
74  std::shared_ptr<PcapRemoteAuthentication> m_RemoteAuthentication;
75 
76  // c'tor is private, as only PcapRemoteDeviceList should create instances of it, and it'll create only one for
77  // every remote interface
78  PcapRemoteDevice(pcap_if_t* iface, std::shared_ptr<PcapRemoteAuthentication> remoteAuthentication,
79  const IPAddress& remoteMachineIP, uint16_t remoteMachinePort)
80  : PcapRemoteDevice(DeviceInterfaceDetails(iface), std::move(remoteAuthentication), remoteMachineIP,
81  remoteMachinePort)
82  {}
84  std::shared_ptr<PcapRemoteAuthentication> remoteAuthentication,
85  const IPAddress& remoteMachineIP, uint16_t remoteMachinePort);
86 
87  public:
88  PcapRemoteDevice(const PcapRemoteDevice&) = delete;
89  PcapRemoteDevice(PcapRemoteDevice&&) noexcept = delete;
90  PcapRemoteDevice& operator=(const PcapRemoteDevice&) = delete;
91  PcapRemoteDevice& operator=(PcapRemoteDevice&&) noexcept = delete;
92 
93  ~PcapRemoteDevice() override = default;
94 
98  {
99  return m_RemoteMachineIpAddress;
100  }
101 
104  uint16_t getRemoteMachinePort() const
105  {
106  return m_RemoteMachinePort;
107  }
108 
110  LiveDeviceType getDeviceType() const override
111  {
112  return RemoteDevice;
113  }
114 
117  uint32_t getMtu() const override;
118 
121  MacAddress getMacAddress() const override;
122 
131  bool open() override;
132 
133  void getStatistics(IPcapDevice::PcapStats& stats) const override;
134 
135  PcapRemoteDevice* clone() const override;
136  };
137 } // namespace pcpp
Definition: IpAddress.h:276
Definition: MacAddress.h:21
Definition: PcapLiveDevice.h:68
LiveDeviceType
The type of the live device.
Definition: PcapLiveDevice.h:142
@ RemoteDevice
WinPcap/Npcap Remote Capture device.
Definition: PcapLiveDevice.h:148
Definition: PcapRemoteDevice.h:68
void getStatistics(IPcapDevice::PcapStats &stats) const override
bool open() override
PcapRemoteDevice * clone() const override
uint32_t getMtu() const override
IPAddress getRemoteMachineIpAddress() const
Definition: PcapRemoteDevice.h:97
uint16_t getRemoteMachinePort() const
Definition: PcapRemoteDevice.h:104
MacAddress getMacAddress() const override
LiveDeviceType getDeviceType() const override
Definition: PcapRemoteDevice.h:110
Definition: PcapRemoteDeviceList.h:25
The main namespace for the PcapPlusPlus lib.
Definition: PcapDevice.h:104
A struct that contains all details of a network interface.
Definition: PcapLiveDevice.h:75
Definition: PcapRemoteDevice.h:20
pcap_rmtauth getPcapRmAuth() const
std::string password
The password for authentication.
Definition: PcapRemoteDevice.h:40
PcapRemoteAuthentication(const PcapRemoteAuthentication &other)
Definition: PcapRemoteDevice.h:32
PcapRemoteAuthentication(const std::string &username, const std::string &password)
Definition: PcapRemoteDevice.h:25
std::string userName
The username for authentication.
Definition: PcapRemoteDevice.h:37