From 4a578b145000800e76211aa390897d05bb593a98 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Mon, 28 May 2018 14:07:34 -0700 Subject: [PATCH] fix scope_id in enum_routes on Windows --- src/enum_net.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/enum_net.cpp b/src/enum_net.cpp index c110ac665..5514e0350 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -1114,6 +1114,16 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl { ip_route r; r.gateway = sockaddr_to_address((const sockaddr*)&routes->Table[i].NextHop); +#if TORRENT_USE_IPV6 + // The scope_id in NextHop is always zero because that would make + // things too easy apparently + if (r.gateway.is_v6() && r.gateway.to_v6().is_link_local()) + { + address_v6 gateway6 = r.gateway.to_v6(); + gateway6.scope_id(routes->Table[i].InterfaceIndex); + r.gateway = gateway6; + } +#endif r.destination = sockaddr_to_address( (const sockaddr*)&routes->Table[i].DestinationPrefix.Prefix); r.netmask = build_netmask(routes->Table[i].DestinationPrefix.PrefixLength