Browse Source

drop non portable SOL_TCP / fix MacOS v2 (#680)

* Revert "Fix compilation on MacOS"

in order to another solution

* src: use IPPROTO_TCP in place of SOL_TCP

* use the more specific IPPROTO_TCP type for setsockopt
* fixes build on MacOS

src/edge_utils.c:891:31: error: use of undeclared identifier 'SOL_TCP'; did you mean 'FPP_TCP'?
        setsockopt(eee->sock, SOL_TCP, TCP_NODELAY, &value, sizeof(value));

src/edge_utils.c:894:31: error: use of undeclared identifier 'SOL_TCP'
        setsockopt(eee->sock, SOL_TCP, TCP_CORK, &value, sizeof(value));
                              ^
src/edge_utils.c:894:40: error: use of undeclared identifier 'TCP_CORK'
        setsockopt(eee->sock, SOL_TCP, TCP_CORK, &value, sizeof(value));

* include/n2n.h: drop redefiniton of SOL_TCP for WIN32, as we don't use it anywhere now

* src: only use TCP_CORK on LINUX

* it's LINUX only and fails on Win32 and MacOS (man 7 tcp)
pull/682/head
Sven Roederer 4 years ago
committed by GitHub
parent
commit
23c18e349f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      include/n2n.h
  2. 12
      src/edge_utils.c
  3. 12
      src/sn_utils.c

11
include/n2n.h

@ -137,7 +137,6 @@
#ifdef WIN32
#include <winsock2.h> /* for tcp */
#define SHUT_RDWR SD_BOTH /* for tcp */
#define SOL_TCP IPPROTO_TCP /* for tcp */
#include "win32/wintap.h"
#include <sys/stat.h>
#else
@ -155,16 +154,10 @@
#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
/* ************************************** */
#include "header_encryption.h"
#include "tf.h"
#ifndef TRACE_ERROR
#define TRACE_ERROR 0, __FILE__, __LINE__

12
src/edge_utils.c

@ -888,10 +888,10 @@ static ssize_t sendto_sock (n2n_edge_t *eee, const void * buf,
// if the connection is tcp, i.e. not the regular sock...
if(eee->conf.connect_tcp) {
setsockopt(eee->sock, SOL_TCP, TCP_NODELAY, &value, sizeof(value));
setsockopt(eee->sock, IPPROTO_TCP, TCP_NODELAY, &value, sizeof(value));
value = 1;
#if !defined(WIN32) && !defined(__APPLE__)
setsockopt(eee->sock, SOL_TCP, TCP_CORK, &value, sizeof(value));
#ifdef LINUX
setsockopt(eee->sock, IPPROTO_TCP, TCP_CORK, &value, sizeof(value));
#endif
// prepend packet length...
@ -907,10 +907,10 @@ static ssize_t sendto_sock (n2n_edge_t *eee, const void * buf,
// if the connection is tcp, i.e. not the regular sock...
if(eee->conf.connect_tcp) {
value = 1; /* value should still be set to 1 */
setsockopt(eee->sock, SOL_TCP, TCP_NODELAY, &value, sizeof(value));
#if !defined(WIN32) && !defined(__APPLE__)
setsockopt(eee->sock, IPPROTO_TCP, TCP_NODELAY, &value, sizeof(value));
#ifdef LINUX
value = 0;
setsockopt(eee->sock, SOL_TCP, TCP_CORK, &value, sizeof(value));
setsockopt(eee->sock, IPPROTO_TCP, TCP_CORK, &value, sizeof(value));
#endif
}

12
src/sn_utils.c

@ -149,10 +149,10 @@ static ssize_t sendto_sock(n2n_sn_t *sss,
// if the connection is tcp, i.e. not the regular sock...
if((socket_fd >= 0) && (socket_fd != sss->sock)) {
setsockopt(socket_fd, SOL_TCP, TCP_NODELAY, &value, sizeof(value));
setsockopt(socket_fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof(value));
value = 1;
#if !defined(WIN32) && !defined(__APPLE__)
setsockopt(socket_fd, SOL_TCP, TCP_CORK, &value, sizeof(value));
#ifdef LINUX
setsockopt(socket_fd, IPPROTO_TCP, TCP_CORK, &value, sizeof(value));
#endif
// prepend packet length...
@ -169,10 +169,10 @@ static ssize_t sendto_sock(n2n_sn_t *sss,
// if the connection is tcp, i.e. not the regular sock...
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));
#if !defined(WIN32) && !defined(__APPLE__)
setsockopt(socket_fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof(value));
#ifdef LINUX
value = 0;
setsockopt(socket_fd, SOL_TCP, TCP_CORK, &value, sizeof(value));
setsockopt(socket_fd, IPPROTO_TCP, TCP_CORK, &value, sizeof(value));
#endif
}

Loading…
Cancel
Save