Skip to content

Commit 20b8acd

Browse files
committed
Replace the link-time pragma from r1839494 with APR_DECLARE_LATE_DLL_FUNC
resolution of if_indextoname and if_nametoindex. Backports: r1855855 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1855857 13f79535-47bb-0310-9956-ffa450edef68
1 parent 29fddf0 commit 20b8acd

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

include/arch/win32/apr_arch_misc.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#include <tlhelp32.h>
4848
#endif
4949

50+
#if defined(HAVE_IF_INDEXTONAME) && defined(_MSC_VER)
51+
#include <Iphlpapi.h>
52+
#endif
53+
5054
struct apr_other_child_rec_t {
5155
apr_pool_t *p;
5256
struct apr_other_child_rec_t *next;
@@ -178,8 +182,9 @@ typedef enum {
178182
DLL_WINSOCKAPI = 2, /* mswsock From WinSock.h */
179183
DLL_WINSOCK2API = 3, /* ws2_32 From WinSock2.h */
180184
DLL_SHSTDAPI = 4, /* shell32 From ShellAPI.h */
181-
DLL_NTDLL = 5, /* shell32 From our real kernel */
182-
DLL_defined = 6 /* must define as last idx_ + 1 */
185+
DLL_NTDLL = 5, /* ntdll From our real kernel */
186+
DLL_IPHLPAPI = 6, /* Iphlpapi From Iphlpapi.h */
187+
DLL_defined = 7 /* must define as last idx_ + 1 */
183188
} apr_dlltoken_e;
184189

185190
FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal);
@@ -481,6 +486,23 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SetDllDirectoryW, 0, (
481486
(lpPathName));
482487
#define SetDllDirectoryW apr_winapi_SetDllDirectoryW
483488

489+
#ifdef if_nametoindex
490+
#undef if_nametoindex
491+
#endif
492+
APR_DECLARE_LATE_DLL_FUNC(DLL_IPHLPAPI, NET_IFINDEX, WINAPI, if_nametoindex, 0, (
493+
IN PCSTR InterfaceName),
494+
(InterfaceName));
495+
#define if_nametoindex apr_winapi_if_nametoindex
496+
497+
#ifdef if_indextoname
498+
#undef if_indextoname
499+
#endif
500+
APR_DECLARE_LATE_DLL_FUNC(DLL_IPHLPAPI, PCHAR, NETIOAPI_API_, if_indextoname, 0, (
501+
NET_IFINDEX InterfaceIndex
502+
PCHAR InterfaceName),
503+
(InterfaceIndex, InterfaceName));
504+
#define if_indextoname apr_winapi_if_indextoname
505+
484506
#endif /* !defined(_WIN32_WCE) */
485507

486508
#endif /* ! MISC_H */

misc/win32/misc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level)
164164
*/
165165

166166
static const char* const lateDllName[DLL_defined] = {
167-
"kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll" };
167+
"kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll",
168+
"Iphplapi" };
168169
static HMODULE lateDllHandle[DLL_defined] = {
169-
NULL, NULL, NULL, NULL, NULL, NULL };
170+
NULL, NULL, NULL, NULL, NULL, NULL,
171+
NULL };
170172

171173
FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal)
172174
{

network_io/unix/sockaddr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
#if defined(HAVE_IF_INDEXTONAME) && defined(_MSC_VER)
3333
#include <Iphlpapi.h>
34-
#pragma comment(lib, "Iphlpapi.lib")
3534
#endif
3635

3736
#define APR_WANT_STRFUNC

0 commit comments

Comments
 (0)