Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/contrib/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h> // OpenBSD
#include <netinet/tcp.h> // TCP_FASTOPEN
#include <netinet/in.h>
#include <poll.h>
#include <stdbool.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <unistd.h>

Expand All @@ -21,6 +21,10 @@
#include "contrib/sockaddr.h"
#include "contrib/time.h"

#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif

/*!
* \brief Enable socket option.
*/
Expand Down Expand Up @@ -238,7 +242,7 @@ static int tfo_connect(int sock, const struct sockaddr_storage *addr)
return KNOT_EOK;
#elif defined(__FreeBSD__)
return sockopt_enable(sock, IPPROTO_TCP, TCP_FASTOPEN);
#elif defined(__APPLE__)
#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
/* Connection is performed lazily when first data is sent. */
sa_endpoints_t ep = {
.sae_dstaddr = (const struct sockaddr *)addr,
Expand Down
4 changes: 4 additions & 0 deletions src/knot/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ static bool enable_pktinfo(int sock, int family)
break;
case AF_INET6:
level = IPPROTO_IPV6;
#if defined(IPV6_RECVPKTINFO)
option = IPV6_RECVPKTINFO; /* Multiplatform */
#else
option = IPV6_PKTINFO;
#endif
break;
default:
assert(0);
Expand Down
6 changes: 5 additions & 1 deletion src/utils/common/netio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include <sys/uio.h>
#endif

#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif

#include "utils/common/netio.h"
#include "utils/common/msg.h"
#include "utils/common/tls.h"
Expand Down Expand Up @@ -347,7 +351,7 @@ static int fastopen_connect(int sockfd, const struct addrinfo *srv)
#if defined( __FreeBSD__)
const int enable = 1;
return setsockopt(sockfd, IPPROTO_TCP, TCP_FASTOPEN, &enable, sizeof(enable));
#elif defined(__APPLE__)
#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
// connection is performed lazily when first data are sent
struct sa_endpoints ep = {0};
ep.sae_dstaddr = srv->ai_addr;
Expand Down