]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
url: add CURLOPT_TCP_FASTOPEN option
authorAlessandro Ghedini <alessandro@cloudflare.com>
Tue, 16 Feb 2016 12:21:03 +0000 (12:21 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 18 Apr 2016 21:17:19 +0000 (23:17 +0200)
docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3 [new file with mode: 0644]
docs/libcurl/opts/Makefile.am
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/url.c
lib/urldata.h

diff --git a/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3 b/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3
new file mode 100644 (file)
index 0000000..6f6ddba
--- /dev/null
@@ -0,0 +1,46 @@
+.\" **************************************************************************
+.\" *                                  _   _ ____  _
+.\" *  Project                     ___| | | |  _ \| |
+.\" *                             / __| | | | |_) | |
+.\" *                            | (__| |_| |  _ <| |___
+.\" *                             \___|\___/|_| \_\_____|
+.\" *
+.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" *
+.\" * This software is licensed as described in the file COPYING, which
+.\" * you should have received as part of this distribution. The terms
+.\" * are also available at https://curl.haxx.se/docs/copyright.html.
+.\" *
+.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+.\" * copies of the Software, and permit persons to whom the Software is
+.\" * furnished to do so, under the terms of the COPYING file.
+.\" *
+.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+.\" * KIND, either express or implied.
+.\" *
+.\" **************************************************************************
+.\"
+.TH CURLOPT_TCP_FASTOPEN 3 "16 Feb 2016" "libcurl 7.49.0" "curl_easy_setopt options"
+.SH NAME
+CURLOPT_TCP_FASTOPEN \- enable TCP Fast Open
+.SH SYNOPSIS
+#include <curl/curl.h>
+
+CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_FASTOPEN, long enable);
+.SH DESCRIPTION
+Pass a long as parameter set to 1 to enable or 0 to disable.
+
+TCP Fast Open (RFC7413) is a mechanism that allows data to be carried in the
+SYN and SYN-ACK packets and consumed by the receiving end during the initial
+connection handshake, saving up to one full round-trip time (RTT).
+.SH DEFAULT
+0
+.SH PROTOCOLS
+All
+.SH EXAMPLE
+TODO
+.SH AVAILABILITY
+Added in 7.49.0. This option is currently only supported on OS X El Capitan.
+.SH RETURN VALUE
+Returns CURLE_OK if fast open is supported by the operating system, otherwise
+returns CURLE_NOT_BUILT_IN.
index c8c6657c05343ec720093f1aaadb9ed0e5f696f5..f9d98425c225d8a07c211bdf51c443bd01d2e93d 100644 (file)
@@ -103,6 +103,7 @@ man_MANS = CURLOPT_ACCEPT_ENCODING.3 CURLOPT_ACCEPTTIMEOUT_MS.3             \
  CURLOPT_TLSAUTH_TYPE.3 CURLOPT_TLSAUTH_USERNAME.3                     \
  CURLOPT_TRANSFER_ENCODING.3 CURLOPT_TRANSFERTEXT.3                    \
  CURLOPT_UNRESTRICTED_AUTH.3 CURLOPT_UPLOAD.3                          \
+ CURLOPT_TCP_FASTOPEN.3                                                                                \
  CURLOPT_URL.3 CURLOPT_USERAGENT.3 CURLOPT_USERNAME.3 CURLOPT_USERPWD.3        \
  CURLOPT_USE_SSL.3 CURLOPT_VERBOSE.3 CURLOPT_WILDCARDMATCH.3           \
  CURLOPT_WRITEDATA.3 CURLOPT_WRITEFUNCTION.3 CURLOPT_XFERINFODATA.3    \
@@ -229,6 +230,7 @@ HTMLPAGES = CURLOPT_ACCEPT_ENCODING.html CURLOPT_ACCEPTTIMEOUT_MS.html      \
  CURLOPT_TFTP_BLKSIZE.html CURLOPT_TFTP_NO_OPTIONS.html                        \
  CURLOPT_TIMECONDITION.html CURLOPT_TIMEOUT.html                       \
  CURLOPT_TIMEOUT_MS.html CURLOPT_TIMEVALUE.html                                \
+ CURLOPT_TCP_FASTOPEN.html                                                                     \
  CURLOPT_TLSAUTH_PASSWORD.html CURLOPT_TLSAUTH_TYPE.html               \
  CURLOPT_TLSAUTH_USERNAME.html CURLOPT_TRANSFER_ENCODING.html          \
  CURLOPT_TRANSFERTEXT.html CURLOPT_UNRESTRICTED_AUTH.html              \
@@ -360,6 +362,7 @@ PDFPAGES = CURLOPT_ACCEPT_ENCODING.pdf CURLOPT_ACCEPTTIMEOUT_MS.pdf \
  CURLOPT_TCP_NODELAY.pdf CURLOPT_TELNETOPTIONS.pdf                     \
  CURLOPT_TFTP_BLKSIZE.pdf CURLOPT_TFTP_NO_OPTIONS.pdf                  \
  CURLOPT_TIMECONDITION.pdf CURLOPT_TIMEOUT.pdf                         \
+ CURLOPT_TCP_FASTOPEN.pdf                                                                      \
  CURLOPT_TIMEOUT_MS.pdf CURLOPT_TIMEVALUE.pdf                          \
  CURLOPT_TLSAUTH_PASSWORD.pdf CURLOPT_TLSAUTH_TYPE.pdf                 \
  CURLOPT_TLSAUTH_USERNAME.pdf CURLOPT_TRANSFER_ENCODING.pdf            \
index ba144ec4531f6a2a6d3b1689232c89e76c85c1d1..9d61f445d770d8804120e68852ad80788170a47e 100644 (file)
@@ -538,6 +538,7 @@ CURLOPT_TCP_KEEPALIVE           7.25.0
 CURLOPT_TCP_KEEPIDLE            7.25.0
 CURLOPT_TCP_KEEPINTVL           7.25.0
 CURLOPT_TCP_NODELAY             7.11.2
+CURLOPT_TCP_FASTOPEN            7.49.0
 CURLOPT_TELNETOPTIONS           7.7
 CURLOPT_TFTP_BLKSIZE            7.19.4
 CURLOPT_TFTP_NO_OPTIONS         7.48.0
index 20dd250e8ad4905c045bd2bcf9c2d3fe45bae84a..639810a854f3de37e612da23650c486f9c52b591 100644 (file)
@@ -1686,6 +1686,9 @@ typedef enum {
      overrides the URL's host:port (only for the network layer) */
   CINIT(CONNECT_TO, STRINGPOINT, 243),
 
+  /* Set TCP Fast Open */
+  CINIT(TCP_FASTOPEN, LONG, 244),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;
 
index c93491582c85750b93bdc5297b84dad648fecc89..e76d4e8e0990b6d0b55471ee4e02854ea507c7c3 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -595,6 +595,7 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
   set->tcp_keepalive = FALSE;
   set->tcp_keepintvl = 60;
   set->tcp_keepidle = 60;
+  set->tcp_fastopen = FALSE;
 
   set->ssl_enable_npn = TRUE;
   set->ssl_enable_alpn = TRUE;
@@ -2631,6 +2632,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
   case CURLOPT_TCP_KEEPINTVL:
     data->set.tcp_keepintvl = va_arg(param, long);
     break;
+  case CURLOPT_TCP_FASTOPEN:
+#if defined(CONNECT_DATA_IDEMPOTENT)
+    data->set.tcp_fastopen = (0 != va_arg(param, long))?TRUE:FALSE;
+#else
+    result = CURLE_NOT_BUILT_IN;
+#endif
+    break;
   case CURLOPT_SSL_ENABLE_NPN:
     data->set.ssl_enable_npn = (0 != va_arg(param, long)) ? TRUE : FALSE;
     break;
@@ -5975,6 +5983,8 @@ static CURLcode create_conn(struct SessionHandle *data,
   conn->recv[SECONDARYSOCKET] = Curl_recv_plain;
   conn->send[SECONDARYSOCKET] = Curl_send_plain;
 
+  conn->bits.tcp_fastopen = data->set.tcp_fastopen;
+
   /***********************************************************************
    * file: is a special case in that it doesn't need a network connection
    ***********************************************************************/
index aea688ced546a5a9e62bf9473744756e4cf4adb4..0167619292a9ff318a8c22416a5afa543cd4062b 100644 (file)
@@ -544,6 +544,8 @@ struct ConnectBits {
                  connection */
   bool type_set;  /* type= was used in the URL */
   bool multiplex; /* connection is multiplexed */
+
+  bool tcp_fastopen; /* use TCP Fast Open */
 };
 
 struct hostname {
@@ -1650,6 +1652,7 @@ struct UserDefined {
   bool tcp_keepalive;    /* use TCP keepalives */
   long tcp_keepidle;     /* seconds in idle before sending keepalive probe */
   long tcp_keepintvl;    /* seconds between TCP keepalive probes */
+  bool tcp_fastopen;     /* use TCP Fast Open */
 
   size_t maxconnects;  /* Max idle connections in the connection cache */