Skip to content

Commit

Permalink
add $PVXS_ENABLE_IPV6
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Aug 26, 2023
1 parent 9aa3755 commit 058b3c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/evhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <errlog.h>
#include <epicsEvent.h>
#include <epicsString.h>
#include <epicsThread.h>
#include <epicsExit.h>
#include <epicsMutex.h>
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/evhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ struct PVXS_API evsocket
static
bool canIPv6;

static bool init_canIPv6();
static bool init_canIPv6() noexcept;

enum ipstack_t {
Linsock,
Expand Down Expand Up @@ -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<uint64_t, Iface> byIndex;
std::map<std::string, Iface*> byName;
Expand Down

0 comments on commit 058b3c9

Please sign in to comment.