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 
15 namespace pcpp
16 {
17 
25  {
26  public:
32  PcapRemoteAuthentication(const std::string& username, const std::string& password) : userName(username)
33  {
34  this->password = password;
35  }
36 
42  : userName(other.userName), password(other.password)
43  {}
44 
48  std::string userName;
49 
53  std::string password;
54 
61  pcap_rmtauth getPcapRmAuth() const;
62  };
63 
85  {
86  friend class PcapRemoteDeviceList;
87 
88  private:
89  IPAddress m_RemoteMachineIpAddress;
90  uint16_t m_RemoteMachinePort;
91  std::shared_ptr<PcapRemoteAuthentication> m_RemoteAuthentication;
92 
93  // c'tor is private, as only PcapRemoteDeviceList should create instances of it, and it'll create only one for
94  // every remote interface
95  PcapRemoteDevice(pcap_if_t* iface, std::shared_ptr<PcapRemoteAuthentication> remoteAuthentication,
96  const IPAddress& remoteMachineIP, uint16_t remoteMachinePort)
97  : PcapRemoteDevice(DeviceInterfaceDetails(iface), std::move(remoteAuthentication), remoteMachineIP,
98  remoteMachinePort)
99  {}
101  std::shared_ptr<PcapRemoteAuthentication> remoteAuthentication,
102  const IPAddress& remoteMachineIP, uint16_t remoteMachinePort);
103 
104  public:
105  PcapRemoteDevice(const PcapRemoteDevice&) = delete;
106  PcapRemoteDevice(PcapRemoteDevice&&) noexcept = delete;
107  PcapRemoteDevice& operator=(const PcapRemoteDevice&) = delete;
108  PcapRemoteDevice& operator=(PcapRemoteDevice&&) noexcept = delete;
109 
110  ~PcapRemoteDevice() override
111  {}
112 
118  {
119  return m_RemoteMachineIpAddress;
120  }
121 
126  uint16_t getRemoteMachinePort() const
127  {
128  return m_RemoteMachinePort;
129  }
130 
134  LiveDeviceType getDeviceType() const override
135  {
136  return RemoteDevice;
137  }
138 
143  uint32_t getMtu() const override;
144 
149  MacAddress getMacAddress() const override;
150 
161  bool open() override;
162 
163  void getStatistics(IPcapDevice::PcapStats& stats) const override;
164 
165  PcapRemoteDevice* clone() const override;
166  };
167 
168 } // namespace pcpp
Definition: IpAddress.h:358
Definition: MacAddress.h:25
Definition: PcapLiveDevice.h:79
LiveDeviceType
Definition: PcapLiveDevice.h:155
@ RemoteDevice
Definition: PcapLiveDevice.h:161
Definition: PcapRemoteDevice.h:85
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:117
uint16_t getRemoteMachinePort() const
Definition: PcapRemoteDevice.h:126
MacAddress getMacAddress() const override
LiveDeviceType getDeviceType() const override
Definition: PcapRemoteDevice.h:134
Definition: PcapRemoteDeviceList.h:30
The main namespace for the PcapPlusPlus lib.
Definition: PcapDevice.h:128
A struct that contains all details of a network interface.
Definition: PcapLiveDevice.h:86
Definition: PcapRemoteDevice.h:25
pcap_rmtauth getPcapRmAuth() const
std::string password
Definition: PcapRemoteDevice.h:53
PcapRemoteAuthentication(const PcapRemoteAuthentication &other)
Definition: PcapRemoteDevice.h:41
PcapRemoteAuthentication(const std::string &username, const std::string &password)
Definition: PcapRemoteDevice.h:32
std::string userName
Definition: PcapRemoteDevice.h:48