From 007b2f072b0211214a5c1d307dac420e9ebdd97a Mon Sep 17 00:00:00 2001 From: "robert.gomulka" Date: Sun, 7 Jun 2015 21:13:25 +0200 Subject: [PATCH] Add missing get_dst implementation Add intf_get_dst() implementation on win32. The implementation has been removed by some of the previous refactoring commits. --- src/intf-win32.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/intf-win32.c b/src/intf-win32.c index 59252e2..a4a962b 100644 --- a/src/intf-win32.c +++ b/src/intf-win32.c @@ -377,8 +377,27 @@ intf_get_src(intf_t *intf, struct intf_entry *entry, struct addr *src) int intf_get_dst(intf_t *intf, struct intf_entry *entry, struct addr *dst) { - errno = ENOSYS; - SetLastError(ERROR_NOT_SUPPORTED); + IP_ADAPTER_ADDRESSES *a; + DWORD intfIdx; + + if (dst->addr_type != ADDR_TYPE_IP) { + errno = EINVAL; + return (-1); + } + + if (_refresh_tables(intf) < 0) + return (-1); + + if (GetBestInterface(dst->addr_ip, &intfIdx) != NO_ERROR) + return (-1); + + for (a = intf->iftable; a != NULL; a = a->Next) { + if (a->IfIndex == intfIdx) { + _adapter_address_to_entry(intf, a, entry); + return (0); + } + } + return (-1); }