From 26cbd4f43f1f4dad878c02d0a095c2fe9731c44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Macia=C5=9B?= Date: Wed, 23 Dec 2020 12:32:16 +0100 Subject: [PATCH 1/2] if_nametoindex function is now used when available --- CMakeLists.txt | 2 ++ builds/cmake/platform.hpp.in | 1 + configure.ac | 19 +++++++++++++++++++ src/ip_resolver.cpp | 4 ++-- src/udp_address.cpp | 3 +-- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74dd99ae..8b548302 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/builds/cmake/platform.hpp.in b/builds/cmake/platform.hpp.in index ff75ecfb..4b69606d 100644 --- a/builds/cmake/platform.hpp.in +++ b/builds/cmake/platform.hpp.in @@ -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 diff --git a/configure.ac b/configure.ac index a7a1609a..c486615b 100644 --- a/configure.ac +++ b/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 + #else + #include + #include + #include + #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]])], diff --git a/src/ip_resolver.cpp b/src/ip_resolver.cpp index 535096d8..97d87b21 100644 --- a/src/ip_resolver.cpp +++ b/src/ip_resolver.cpp @@ -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_); diff --git a/src/udp_address.cpp b/src/udp_address.cpp index 76d4bac4..41e4770d 100644 --- a/src/udp_address.cpp +++ b/src/udp_address.cpp @@ -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. From bac5f69685fc70b6efa48f34f32cd4f801ba7862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Macia=C5=9B?= Date: Wed, 23 Dec 2020 15:04:08 +0100 Subject: [PATCH 2/2] Added missing relicense file --- RELICENSE/stanpl.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 RELICENSE/stanpl.md diff --git a/RELICENSE/stanpl.md b/RELICENSE/stanpl.md new file mode 100644 index 00000000..e74801a2 --- /dev/null +++ b/RELICENSE/stanpl.md @@ -0,0 +1,15 @@ +# Permission to Relicense under MPLv2 or any other OSI approved license chosen by the current ZeroMQ BDFL + +This is a statement by Stanisław Maciaś +that grants permission to relicense its copyrights in the libzmq C++ +library (ZeroMQ) under the Mozilla Public License v2 (MPLv2) or any other +Open Source Initiative approved license chosen by the current ZeroMQ +BDFL (Benevolent Dictator for Life). + +A portion of the commits made by the Github handle "stanpl", with +commit author "Stanisław Maciaś", are copyright of Stanisław Maciaś. +This document hereby grants the libzmq project team to relicense libzmq, +including all past, present and future contributions of the author listed above. + +Stanisław Maciaś +2020/12/23