From 53e930db105df0e1103d8b6de9d5cb223c744d49 Mon Sep 17 00:00:00 2001 From: Alfredo Cardigliano Date: Mon, 29 Mar 2021 09:28:13 +0200 Subject: [PATCH] Fix compilation on MacOS --- include/n2n.h | 10 ++++++++-- src/edge_utils.c | 4 ++-- src/sn_utils.c | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/n2n.h b/include/n2n.h index 7a38da3..8f850e2 100644 --- a/include/n2n.h +++ b/include/n2n.h @@ -155,11 +155,17 @@ #include "sn_selection.h" #include "network_traffic_filter.h" -/* ************************************** */ - #include "header_encryption.h" #include "tf.h" +/* ************************************** */ + +#if !defined(SOL_TCP) && defined(IPPROTO_TCP) +#define SOL_TCP IPPROTO_TCP +#endif + +/* ************************************** */ + #ifndef TRACE_ERROR #define TRACE_ERROR 0, __FILE__, __LINE__ #define TRACE_WARNING 1, __FILE__, __LINE__ diff --git a/src/edge_utils.c b/src/edge_utils.c index aecc38f..46f04fb 100644 --- a/src/edge_utils.c +++ b/src/edge_utils.c @@ -890,7 +890,7 @@ static ssize_t sendto_sock (n2n_edge_t *eee, const void * buf, setsockopt(eee->sock, SOL_TCP, TCP_NODELAY, &value, sizeof(value)); value = 1; -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) setsockopt(eee->sock, SOL_TCP, TCP_CORK, &value, sizeof(value)); #endif @@ -908,7 +908,7 @@ static ssize_t sendto_sock (n2n_edge_t *eee, const void * buf, if(eee->conf.connect_tcp) { value = 1; /* value should still be set to 1 */ setsockopt(eee->sock, SOL_TCP, TCP_NODELAY, &value, sizeof(value)); -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) value = 0; setsockopt(eee->sock, SOL_TCP, TCP_CORK, &value, sizeof(value)); #endif diff --git a/src/sn_utils.c b/src/sn_utils.c index 3f9ec98..7ee8746 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -151,7 +151,7 @@ static ssize_t sendto_sock(n2n_sn_t *sss, setsockopt(socket_fd, SOL_TCP, TCP_NODELAY, &value, sizeof(value)); value = 1; -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) setsockopt(socket_fd, SOL_TCP, TCP_CORK, &value, sizeof(value)); #endif @@ -170,7 +170,7 @@ static ssize_t sendto_sock(n2n_sn_t *sss, if((socket_fd >= 0) && (socket_fd != sss->sock)) { value = 1; /* value should still be set to 1 */ setsockopt(socket_fd, SOL_TCP, TCP_NODELAY, &value, sizeof(value)); -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) value = 0; setsockopt(socket_fd, SOL_TCP, TCP_CORK, &value, sizeof(value)); #endif