mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Fixed network naming on Windows.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#define TINS_NETWORK_INTERFACE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "hw_address.h"
|
||||
#include "ip_address.h"
|
||||
@@ -66,6 +67,16 @@ public:
|
||||
*/
|
||||
static NetworkInterface default_interface();
|
||||
|
||||
/**
|
||||
* Returns all available network interfaces.
|
||||
*/
|
||||
static std::vector<NetworkInterface> all();
|
||||
|
||||
/**
|
||||
* Returns a network interface for the given index.
|
||||
*/
|
||||
static NetworkInterface from_index(id_type identifier);
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <winsock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#undef interface
|
||||
#include "network_interface.h"
|
||||
#endif
|
||||
#include "macros.h"
|
||||
#if defined(BSD) || defined(__FreeBSD_kernel__)
|
||||
@@ -389,9 +390,8 @@ void Tins::Utils::route_entries(ForwardIterator output) {
|
||||
for (DWORD i = 0; i < table->dwNumEntries; i++) {
|
||||
MIB_IPFORWARDROW *row = &table->table[i];
|
||||
if(row->dwForwardType == MIB_IPROUTE_TYPE_INDIRECT) {
|
||||
if_indextoname(row->dwForwardIfIndex, iface_name);
|
||||
RouteEntry entry;
|
||||
entry.interface = iface_name;
|
||||
entry.interface = NetworkInterface::from_index(row->dwForwardIfIndex).name();
|
||||
entry.destination = IPv4Address(row->dwForwardDest);
|
||||
entry.mask = IPv4Address(row->dwForwardMask);
|
||||
entry.gateway = IPv4Address(row->dwForwardNextHop);
|
||||
|
||||
Reference in New Issue
Block a user