From 09eef8af18c7cc1a20f132843880f60f692d76c8 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Tue, 28 May 2019 22:07:33 +0100 Subject: url: Load if_nametoindex() dynamically from iphlpapi.dll on Windows This fixes the static dependency on iphlpapi.lib and allows curl to build for targets prior to Windows Vista. This partially reverts 170bd047. Fixes #3960 Closes #3958 --- lib/url.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/url.c') diff --git a/lib/url.c b/lib/url.c index 086e214e4..eb22dcc37 100644 --- a/lib/url.c +++ b/lib/url.c @@ -95,6 +95,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out); #include "inet_pton.h" #include "getinfo.h" #include "urlapi-int.h" +#include "system_win32.h" /* And now for the protocols */ #include "ftp.h" @@ -1903,18 +1904,28 @@ static void zonefrom_url(CURLU *uh, struct connectdata *conn) if(!*endp && (scope < UINT_MAX)) /* A plain number, use it directly as a scope id. */ conn->scope_id = (unsigned int)scope; -#ifdef HAVE_IF_NAMETOINDEX +#if defined(HAVE_IF_NAMETOINDEX) else { +#elif defined(WIN32) + else if(Curl_if_nametoindex) { +#endif + +#if defined(HAVE_IF_NAMETOINDEX) || defined(WIN32) /* Zone identifier is not numeric */ unsigned int scopeidx = 0; +#if defined(WIN32) + scopeidx = Curl_if_nametoindex(zoneid); +#else scopeidx = if_nametoindex(zoneid); +#endif if(!scopeidx) infof(conn->data, "Invalid zoneid: %s; %s\n", zoneid, strerror(errno)); else conn->scope_id = scopeidx; } -#endif /* HAVE_IF_NAMETOINDEX */ +#endif /* HAVE_IF_NAMETOINDEX || WIN32 */ + free(zoneid); } } -- cgit v1.2.3