Skip to content

Commit

Permalink
Fixed remote device fetch being windows only.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimi1010 committed May 27, 2024
1 parent 87c4855 commit fd595c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Pcap++/header/DeviceUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ namespace pcpp
* @throws std::runtime_error The system encountered an error fetching the devices.
*/
std::unique_ptr<pcap_if_t, PcapFreeAllDevsDeleter> getAllLocalPcapDevices();
#ifdef _WIN32
/**
* Fetches a list of all network devices on a remote machine that LibPcap/WinPcap/NPcap can find.
* Fetches a list of all network devices on a remote machine that WinPcap/NPcap can find.
* @param[in] ipAddress IP address of the remote machine.
* @param[in] port Port to use when connecting to the remote machine.
* @param[in] pRmAuth Pointer to an authentication structure to use when connecting to the remote machine. Nullptr if no authentication is required.
* @return A smart pointer to an interface list structure.
* @throws std::runtime_error The system encountered an error fetching the devices.
*/
std::unique_ptr<pcap_if_t, PcapFreeAllDevsDeleter> getAllRemotePcapDevices(const IPAddress& ipAddress, uint16_t port, pcap_rmtauth* pRmAuth = nullptr);
#endif // _WIN32
}
}
3 changes: 3 additions & 0 deletions Pcap++/src/DeviceUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace pcpp
// Assigns the raw pointer to the smart pointer with specialized deleter.
return std::unique_ptr<pcap_if_t, internal::PcapFreeAllDevsDeleter>(interfaceListRaw);
}

#ifdef _WIN32
std::unique_ptr<pcap_if_t, PcapFreeAllDevsDeleter> getAllRemotePcapDevices(const IPAddress& ipAddress, uint16_t port, pcap_rmtauth* pRmAuth)
{
PCPP_LOG_DEBUG("Searching remote devices on IP: " << ipAddress << " and port: " << port);
Expand All @@ -43,5 +45,6 @@ namespace pcpp
}
return std::unique_ptr<pcap_if_t, internal::PcapFreeAllDevsDeleter>(interfaceListRaw);
}
#endif // _WIN32
}
}

0 comments on commit fd595c6

Please sign in to comment.