PcapPlusPlus  24.09
PcapRemoteDevice.h
Go to the documentation of this file.
1 #pragma once
2 
3 #if defined(_WIN32)
4 
5 # include <vector>
6 # include <memory>
7 # include "PcapLiveDevice.h"
8 
10 
11 struct pcap_rmtauth;
12 
17 namespace pcpp
18 {
19 
27  {
28  public:
34  PcapRemoteAuthentication(const std::string& username, const std::string& password) : userName(username)
35  {
36  this->password = password;
37  }
38 
44  : userName(other.userName), password(other.password)
45  {}
46 
50  std::string userName;
51 
55  std::string password;
56 
63  pcap_rmtauth getPcapRmAuth() const;
64  };
65 
87  {
88  friend class PcapRemoteDeviceList;
89 
90  private:
91  IPAddress m_RemoteMachineIpAddress;
92  uint16_t m_RemoteMachinePort;
93  std::shared_ptr<PcapRemoteAuthentication> m_RemoteAuthentication;
94 
95  // c'tor is private, as only PcapRemoteDeviceList should create instances of it, and it'll create only one for
96  // every remote interface
97  PcapRemoteDevice(pcap_if_t* iface, std::shared_ptr<PcapRemoteAuthentication> remoteAuthentication,
98  const IPAddress& remoteMachineIP, uint16_t remoteMachinePort);
99 
100  public:
101  PcapRemoteDevice(const PcapRemoteDevice&) = delete;
102  PcapRemoteDevice(PcapRemoteDevice&&) noexcept = delete;
103  PcapRemoteDevice& operator=(const PcapRemoteDevice&) = delete;
104  PcapRemoteDevice& operator=(PcapRemoteDevice&&) noexcept = delete;
105 
106  ~PcapRemoteDevice() override
107  {}
108 
114  {
115  return m_RemoteMachineIpAddress;
116  }
117 
122  uint16_t getRemoteMachinePort() const
123  {
124  return m_RemoteMachinePort;
125  }
126 
130  LiveDeviceType getDeviceType() const override
131  {
132  return RemoteDevice;
133  }
134 
139  uint32_t getMtu() const override;
140 
145  MacAddress getMacAddress() const override;
146 
157  bool open() override;
158 
159  void getStatistics(IPcapDevice::PcapStats& stats) const override;
160  };
161 
162 } // namespace pcpp
163 
164 #endif // _WIN32
Definition: IpAddress.h:358
Definition: MacAddress.h:25
Definition: PcapLiveDevice.h:79
LiveDeviceType
Definition: PcapLiveDevice.h:140
@ RemoteDevice
Definition: PcapLiveDevice.h:146
Definition: PcapRemoteDevice.h:87
void getStatistics(IPcapDevice::PcapStats &stats) const override
bool open() override
uint32_t getMtu() const override
IPAddress getRemoteMachineIpAddress() const
Definition: PcapRemoteDevice.h:113
uint16_t getRemoteMachinePort() const
Definition: PcapRemoteDevice.h:122
MacAddress getMacAddress() const override
LiveDeviceType getDeviceType() const override
Definition: PcapRemoteDevice.h:130
Definition: PcapRemoteDeviceList.h:32
The main namespace for the PcapPlusPlus lib.
Definition: PcapDevice.h:128
Definition: PcapRemoteDevice.h:27
pcap_rmtauth getPcapRmAuth() const
std::string password
Definition: PcapRemoteDevice.h:55
PcapRemoteAuthentication(const PcapRemoteAuthentication &other)
Definition: PcapRemoteDevice.h:43
PcapRemoteAuthentication(const std::string &username, const std::string &password)
Definition: PcapRemoteDevice.h:34
std::string userName
Definition: PcapRemoteDevice.h:50