From 058b3c914b59a3915dc57c416e28e4c54fd467fc Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 26 Aug 2023 10:52:40 +0200 Subject: [PATCH] add $PVXS_ENABLE_IPV6 --- src/evhelper.cpp | 13 ++++++++++++- src/evhelper.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/evhelper.cpp b/src/evhelper.cpp index 43d233a33..da253daf3 100644 --- a/src/evhelper.cpp +++ b/src/evhelper.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -661,9 +662,19 @@ size_t evsocket::get_buffer_size(evutil_socket_t sock, bool tx) # define EAFNOSUPPORT WSAESOCKTNOSUPPORT #endif -bool evsocket::init_canIPv6() +bool evsocket::init_canIPv6() noexcept { try { + if(auto ena6 = getenv("PVXS_ENABLE_IPV6")) { + if(epicsStrCaseCmp(ena6, "NO")==0) { + log_info_printf(logsock, "IPv6 support disabled%s", "\n"); + return false; + } else if(epicsStrCaseCmp(ena6, "YES")!=0) { + log_warn_printf(logsock, "PVXS_ENABLE_IPV6=%s ignoring unrecognized\n", + ena6); + } + } + evsocket sock(AF_INET6, SOCK_DGRAM, 0); auto addr(SockAddr::loopback(AF_INET6)); sock.bind(addr); diff --git a/src/evhelper.h b/src/evhelper.h index d2cea97c1..ab0f552a9 100644 --- a/src/evhelper.h +++ b/src/evhelper.h @@ -255,7 +255,7 @@ struct PVXS_API evsocket static bool canIPv6; - static bool init_canIPv6(); + static bool init_canIPv6() noexcept; enum ipstack_t { Linsock, @@ -302,6 +302,7 @@ struct PVXS_API IfaceMap { Iface(const std::string& name, uint64_t index, bool isLO) :name(name), index(index), isLO(isLO) {} }; + SockAttach attach; epicsMutex lock; std::map byIndex; std::map byName;