From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 31FA23857007; Wed, 1 Jul 2020 18:32:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31FA23857007 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: tcp: fix IPPROTO_TCP option handling X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: c11b0343c069c6d69b3bdf329bcaeb550a18d9e9 X-Git-Newrev: e037192b505b4f233fca9a6deafc9797210f6693 Message-Id: <20200701183223.31FA23857007@sourceware.org> Date: Wed, 1 Jul 2020 18:32:23 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jul 2020 18:32:23 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e037192b505b4f233fca9a6deafc9797210f6693 commit e037192b505b4f233fca9a6deafc9797210f6693 Author: Corinna Vinschen Date: Tue Jun 30 13:33:57 2020 +0200 Cygwin: tcp: fix IPPROTO_TCP option handling - Drop definitions from - Drop options only available on BSD - Fix value of TCP_MAXSEG. It was still defined as the BSD value while WinSock uses another value - Handle the fact that TCP_MAXSEG is a R/O value in WinSock Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler_socket_inet.cc | 15 +++++++++++++++ winsup/cygwin/include/cygwin/socket.h | 6 ------ winsup/cygwin/include/netinet/tcp.h | 6 +----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc index 18ee42260..ad17f48f1 100644 --- a/winsup/cygwin/fhandler_socket_inet.cc +++ b/winsup/cygwin/fhandler_socket_inet.cc @@ -23,6 +23,7 @@ #endif #include #include +#include #include #include #include @@ -1682,6 +1683,20 @@ fhandler_socket_inet::setsockopt (int level, int optname, const void *optval, } default: break; + + case IPPROTO_TCP: + switch (optname) + { + case TCP_MAXSEG: + /* Winsock doesn't support setting TCP_MAXSEG, only requesting it + via getsockopt. Make this a no-op. */ + ignore = true; + break; + + default: + break; + } + break; } /* Call Winsock setsockopt (or not) */ diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h index 721dafcfa..0ca8300d9 100644 --- a/winsup/cygwin/include/cygwin/socket.h +++ b/winsup/cygwin/include/cygwin/socket.h @@ -300,12 +300,6 @@ struct OLD_msghdr /* IPX options */ #define IPX_TYPE 1 -/* TCP options - this way around because someone left a set in the c library includes */ -#ifndef TCP_NODELAY -#define TCP_NODELAY 0x0001 -#define TCP_MAXSEG 2 -#endif - /* SUS symbolic values for the second parm to shutdown(2) */ #define SHUT_RD 0 /* == Win32 SD_RECEIVE */ #define SHUT_WR 1 /* == Win32 SD_SEND */ diff --git a/winsup/cygwin/include/netinet/tcp.h b/winsup/cygwin/include/netinet/tcp.h index c9d534dda..5503a3fd6 100644 --- a/winsup/cygwin/include/netinet/tcp.h +++ b/winsup/cygwin/include/netinet/tcp.h @@ -123,11 +123,7 @@ struct tcphdr { /* * User-settable options (used with setsockopt). */ -#ifndef TCP_NODELAY #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ -#define TCP_MAXSEG 0x02 /* set maximum segment size */ -#endif -#define TCP_NOPUSH 0x04 /* don't push last block of write */ -#define TCP_NOOPT 0x08 /* don't use TCP options */ +#define TCP_MAXSEG 0x04 /* get maximum segment size (r/o on windows) */ #endif