#define HAVE_WS2TCPIP_H 1
#endif
-/* Define if you have the <Iphlpapi.h> header file. */
-#ifndef __SALFORDC__
-#define HAVE_IPHLPAPI_H 1
-#endif
-
/* ---------------------------------------------------------------- */
/* OTHER HEADER INFO */
/* ---------------------------------------------------------------- */
# define HAVE_GETNAMEINFO 1
# endif
#endif
-#if defined(HAVE_IPHLPAPI_H)
- #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
- #define HAVE_IF_NAMETOINDEX 1
- #endif
-#endif
#if defined(__POCC__)
# ifndef _MSC_VER
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2016 - 2017, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2016 - 2019, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
LARGE_INTEGER Curl_freq;
bool Curl_isVistaOrGreater;
+/* Handle of iphlpapp.dll */
+static HMODULE s_hIpHlpApiDll = NULL;
+
+/* Pointer to the if_nametoindex function */
+IF_NAMETOINDEX_FN Curl_if_nametoindex = NULL;
+
/* Curl_win32_init() performs win32 global initialization */
CURLcode Curl_win32_init(long flags)
{
}
#endif
+ s_hIpHlpApiDll = Curl_load_library(TEXT("iphlpapi.dll"));
+ if(s_hIpHlpApiDll) {
+ /* Get the address of the if_nametoindex function */
+ IF_NAMETOINDEX_FN pIfNameToIndex =
+ CURLX_FUNCTION_CAST(IF_NAMETOINDEX_FN,
+ (GetProcAddress(s_hIpHlpApiDll, "if_nametoindex")));
+
+ if(pIfNameToIndex)
+ Curl_if_nametoindex = pIfNameToIndex;
+ }
+
if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL)) {
Curl_isVistaOrGreater = TRUE;
/* Curl_win32_cleanup() is the opposite of Curl_win32_init() */
void Curl_win32_cleanup(long init_flags)
{
+ if(s_hIpHlpApiDll) {
+ FreeLibrary(s_hIpHlpApiDll);
+ s_hIpHlpApiDll = NULL;
+ Curl_if_nametoindex = NULL;
+ }
+
#ifdef USE_WINDOWS_SSPI
Curl_sspi_global_cleanup();
#endif
}
}
-#if defined(USE_WINDOWS_SSPI) || (!defined(CURL_DISABLE_TELNET) && \
- defined(USE_WINSOCK))
-
-
#if !defined(LOAD_WITH_ALTERED_SEARCH_PATH)
#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
#endif
# define LOADLIBARYEX "LoadLibraryExA"
#endif
-#endif /* USE_WINDOWS_SSPI || (!CURL_DISABLE_TELNET && USE_WINSOCK) */
-
/*
* Curl_verify_windows_version()
*
return matched;
}
-#if defined(USE_WINDOWS_SSPI) || (!defined(CURL_DISABLE_TELNET) && \
- defined(USE_WINSOCK))
-
/*
* Curl_load_library()
*
return hModule;
}
-#endif /* USE_WINDOWS_SSPI || (!CURL_DISABLE_TELNET && USE_WINSOCK) */
-
#endif /* WIN32 */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2016 - 2019, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
PLATFORM_WINNT
} PlatformIdentifier;
+/* We use our own typedef here since some headers might lack this */
+typedef unsigned int(WINAPI *IF_NAMETOINDEX_FN)(char *);
+
+/* This is used instread of if_nametoindex if available on Windows */
+IF_NAMETOINDEX_FN Curl_if_nametoindex;
+
/* This is used to verify if we are running on a specific windows version */
bool Curl_verify_windows_version(const unsigned int majorVersion,
const unsigned int minorVersion,
const PlatformIdentifier platform,
const VersionCondition condition);
-#if defined(USE_WINDOWS_SSPI) || (!defined(CURL_DISABLE_TELNET) && \
- defined(USE_WINSOCK))
-
/* This is used to dynamically load DLLs */
HMODULE Curl_load_library(LPCTSTR filename);
-#endif /* USE_WINDOWS_SSPI || (!CURL_DISABLE_TELNET && USE_WINSOCK) */
-
#endif /* WIN32 */
#endif /* HEADER_CURL_SYSTEM_WIN32_H */
#include "inet_pton.h"
#include "getinfo.h"
#include "urlapi-int.h"
+#include "system_win32.h"
/* And now for the protocols */
#include "ftp.h"
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);
}
}