mirror of
https://github.com/mfontanini/libtins
synced 2026-01-27 04:11:35 +01:00
Make Utils::resolve_hwaddress work on Windows
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include "utils_tests.h"
|
||||
#include "tins/ethernetII.h"
|
||||
#include "tins/arp.h"
|
||||
@@ -38,6 +39,7 @@ using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::numeric_limits;
|
||||
using std::ostringstream;
|
||||
|
||||
using Tins::PDU;
|
||||
@@ -52,9 +54,11 @@ ResolveHWAddressTest::ResolveHWAddressTest(const PacketSenderPtr& packet_sender,
|
||||
: ActiveTest(packet_sender, configuration) {
|
||||
vector<RouteEntry> entries = Tins::Utils::route_entries();
|
||||
string interface_name = configuration->interface().name();
|
||||
int current_metric = numeric_limits<int>::max();
|
||||
for (const auto& entry : entries) {
|
||||
if (entry.interface == interface_name && entry.gateway != "0.0.0.0") {
|
||||
if (entry.interface == interface_name && entry.gateway != "0.0.0.0" && entry.metric < current_metric) {
|
||||
target_address_ = entry.gateway;
|
||||
current_metric = entry.metric;
|
||||
}
|
||||
}
|
||||
disable_on_platform(Configuration::WINDOWS);
|
||||
@@ -74,6 +78,7 @@ void ResolveHWAddressTest::execute_test() {
|
||||
resolved_address_ = Tins::Utils::resolve_hwaddr(configuration()->interface(),
|
||||
target_address_,
|
||||
*packet_sender());
|
||||
cout << log_prefix() << "address resolved to " << resolved_address_ << endl;
|
||||
auto local_ip_address = configuration()->interface().ipv4_address();
|
||||
auto local_hw_address = configuration()->interface().hw_address();
|
||||
auto packet = ARP::make_arp_request(target_address_, local_ip_address, local_hw_address);
|
||||
|
||||
Reference in New Issue
Block a user