1
0
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:
Matias Fontanini
2014-09-07 23:48:37 -03:00
parent e0b9e38587
commit b532753a16
5 changed files with 62 additions and 10 deletions

View File

@@ -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.
*/

View File

@@ -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);