mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-14 01:37:56 +08: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")
|
set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib")
|
||||||
check_cxx_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI)
|
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 "")
|
set(CMAKE_REQUIRED_LIBRARIES "")
|
||||||
# TODO: This not the symbol we're looking for. What is the symbol?
|
# TODO: This not the symbol we're looking for. What is the symbol?
|
||||||
check_library_exists(ws2 fopen "" HAVE_WS2)
|
check_library_exists(ws2 fopen "" HAVE_WS2)
|
||||||
else()
|
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(SO_PEERCRED sys/socket.h ZMQ_HAVE_SO_PEERCRED)
|
||||||
check_cxx_symbol_exists(LOCAL_PEERCRED sys/socket.h ZMQ_HAVE_LOCAL_PEERCRED)
|
check_cxx_symbol_exists(LOCAL_PEERCRED sys/socket.h ZMQ_HAVE_LOCAL_PEERCRED)
|
||||||
endif()
|
endif()
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
#cmakedefine SODIUM_STATIC
|
#cmakedefine SODIUM_STATIC
|
||||||
#cmakedefine ZMQ_USE_GNUTLS
|
#cmakedefine ZMQ_USE_GNUTLS
|
||||||
#cmakedefine ZMQ_USE_RADIX_TREE
|
#cmakedefine ZMQ_USE_RADIX_TREE
|
||||||
|
#cmakedefine HAVE_IF_NAMETOINDEX
|
||||||
|
|
||||||
#ifdef _AIX
|
#ifdef _AIX
|
||||||
#define ZMQ_HAVE_AIX
|
#define ZMQ_HAVE_AIX
|
||||||
|
19
configure.ac
19
configure.ac
@ -788,6 +788,25 @@ AC_COMPILE_IFELSE(
|
|||||||
AC_MSG_RESULT([no])
|
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],
|
AC_ARG_ENABLE([libbsd],
|
||||||
[AS_HELP_STRING([--enable-libbsd],
|
[AS_HELP_STRING([--enable-libbsd],
|
||||||
[enable libbsd [default=auto]])],
|
[enable libbsd [default=auto]])],
|
||||||
|
@ -726,10 +726,10 @@ void zmq::ip_resolver_t::do_freeaddrinfo (struct addrinfo *res_)
|
|||||||
freeaddrinfo (res_);
|
freeaddrinfo (res_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int zmq::ip_resolver_t::do_if_nametoindex (const char *ifname_)
|
unsigned int zmq::ip_resolver_t::do_if_nametoindex (const char *ifname_)
|
||||||
{
|
{
|
||||||
#if _WIN32_WINNT > _WIN32_WINNT_WINXP && !defined ZMQ_HAVE_WINDOWS_UWP \
|
#ifdef HAVE_IF_NAMETOINDEX
|
||||||
&& !defined ZMQ_HAVE_VXWORKS
|
|
||||||
return if_nametoindex (ifname_);
|
return if_nametoindex (ifname_);
|
||||||
#else
|
#else
|
||||||
LIBZMQ_UNUSED (ifname_);
|
LIBZMQ_UNUSED (ifname_);
|
||||||
|
@ -104,8 +104,7 @@ int zmq::udp_address_t::resolve (const char *name_, bool bind_, bool ipv6_)
|
|||||||
if (src_name == "*") {
|
if (src_name == "*") {
|
||||||
_bind_interface = 0;
|
_bind_interface = 0;
|
||||||
} else {
|
} else {
|
||||||
#if _WIN32_WINNT > _WIN32_WINNT_WINXP && !defined ZMQ_HAVE_WINDOWS_UWP \
|
#ifdef HAVE_IF_NAMETOINDEX
|
||||||
&& !defined ZMQ_HAVE_VXWORKS
|
|
||||||
_bind_interface = if_nametoindex (src_name.c_str ());
|
_bind_interface = if_nametoindex (src_name.c_str ());
|
||||||
if (_bind_interface == 0) {
|
if (_bind_interface == 0) {
|
||||||
// Error, probably not an interface name.
|
// Error, probably not an interface name.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user