$OpenBSD: patch-common_ECChannel_cpp,v 1.7 2020/03/22 11:20:34 robert Exp $

Index: common/ECChannel.cpp
--- common/ECChannel.cpp.orig
+++ common/ECChannel.cpp
@@ -49,6 +49,8 @@
 #define hrSuccess 0
 #endif
 
+#include "config.h"
+
 using namespace std::string_literals;
 
 namespace KC {
@@ -762,9 +764,11 @@ static int ec_listen_generic(const struct ec_socket &s
 		}
 	}
 	int y = 1;
+#ifdef LINUX
 	if (sk.m_ai->ai_family == PF_INET6 &&
 	    setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, &y, sizeof(y)) < 0)
 		ec_log_warn("K-1556: Unable to set IPV6_V6ONLY: %s", strerror(errno));
+#endif
 	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<const char *>(&y), sizeof(y)) < 0)
 		ec_log_warn("K-1557: Unable to set reuseaddr socket option: %s", strerror(errno));
 #ifdef LINUX
@@ -979,6 +983,7 @@ static int ec_fdtable_socket_ai(const ec_socket &sk)
 		if (ret < 0)
 			continue;
 		char ifnam[24];
+#ifdef LINUX
 		arglen = sizeof(ifnam);
 		ret = getsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, ifnam, &arglen);
 		if (ret != 0)
@@ -987,6 +992,9 @@ static int ec_fdtable_socket_ai(const ec_socket &sk)
 			ifnam[arglen] = '\0';
 		else
 			ifnam[sizeof(ifnam)-1] = '\0';
+#else
+		ifnam[0] = '\0';
+#endif
 		struct sockaddr_storage addr{};
 		arglen = sizeof(addr);
 		ret = getsockname(fd, reinterpret_cast<struct sockaddr *>(&addr), &arglen);
