mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 10:33:52 +01:00
if_nametoindex function is now used when available
This commit is contained in:
parent
10140050c7
commit
26cbd4f43f
@ -546,11 +546,13 @@ if(ZMQ_HAVE_WINDOWS)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib")
|
||||
check_cxx_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI)
|
||||
check_cxx_symbol_exists(if_nametoindex "iphlpapi.h" HAVE_IF_NAMETOINDEX)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES "")
|
||||
# TODO: This not the symbol we're looking for. What is the symbol?
|
||||
check_library_exists(ws2 fopen "" HAVE_WS2)
|
||||
else()
|
||||
check_cxx_symbol_exists(if_nametoindex net/if.h HAVE_IF_NAMETOINDEX)
|
||||
check_cxx_symbol_exists(SO_PEERCRED sys/socket.h ZMQ_HAVE_SO_PEERCRED)
|
||||
check_cxx_symbol_exists(LOCAL_PEERCRED sys/socket.h ZMQ_HAVE_LOCAL_PEERCRED)
|
||||
endif()
|
||||
|
@ -73,6 +73,7 @@
|
||||
#cmakedefine SODIUM_STATIC
|
||||
#cmakedefine ZMQ_USE_GNUTLS
|
||||
#cmakedefine ZMQ_USE_RADIX_TREE
|
||||
#cmakedefine HAVE_IF_NAMETOINDEX
|
||||
|
||||
#ifdef _AIX
|
||||
#define ZMQ_HAVE_AIX
|
||||
|
19
configure.ac
19
configure.ac
@ -788,6 +788,25 @@ AC_COMPILE_IFELSE(
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([whether if_nametoindex is available])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#ifdef _WIN32
|
||||
#include <iphlpapi.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#endif]], [[
|
||||
if_nametoindex("");
|
||||
]])],[
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(HAVE_IF_NAMETOINDEX, [1],
|
||||
[if_nametoindex is available])
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE([libbsd],
|
||||
[AS_HELP_STRING([--enable-libbsd],
|
||||
[enable libbsd [default=auto]])],
|
||||
|
@ -726,10 +726,10 @@ void zmq::ip_resolver_t::do_freeaddrinfo (struct addrinfo *res_)
|
||||
freeaddrinfo (res_);
|
||||
}
|
||||
|
||||
|
||||
unsigned int zmq::ip_resolver_t::do_if_nametoindex (const char *ifname_)
|
||||
{
|
||||
#if _WIN32_WINNT > _WIN32_WINNT_WINXP && !defined ZMQ_HAVE_WINDOWS_UWP \
|
||||
&& !defined ZMQ_HAVE_VXWORKS
|
||||
#ifdef HAVE_IF_NAMETOINDEX
|
||||
return if_nametoindex (ifname_);
|
||||
#else
|
||||
LIBZMQ_UNUSED (ifname_);
|
||||
|
@ -104,8 +104,7 @@ int zmq::udp_address_t::resolve (const char *name_, bool bind_, bool ipv6_)
|
||||
if (src_name == "*") {
|
||||
_bind_interface = 0;
|
||||
} else {
|
||||
#if _WIN32_WINNT > _WIN32_WINNT_WINXP && !defined ZMQ_HAVE_WINDOWS_UWP \
|
||||
&& !defined ZMQ_HAVE_VXWORKS
|
||||
#ifdef HAVE_IF_NAMETOINDEX
|
||||
_bind_interface = if_nametoindex (src_name.c_str ());
|
||||
if (_bind_interface == 0) {
|
||||
// Error, probably not an interface name.
|
||||
|
Loading…
Reference in New Issue
Block a user