From 3af0e76d1e71995b7790c74e79b76af86ee7c681 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 21 Jul 2019 23:48:58 +0200 Subject: HTTP3: initial (experimental) support USe configure --with-ngtcp2 or --with-quiche Using either option will enable a HTTP3 build. Co-authored-by: Alessandro Ghedini Closes #3500 --- lib/connect.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/connect.c') diff --git a/lib/connect.c b/lib/connect.c index 4a1f2c640..59084f251 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -75,6 +75,7 @@ #include "conncache.h" #include "multihandle.h" #include "system_win32.h" +#include "quic.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -683,8 +684,8 @@ UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr, connection */ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) { - if(conn->socktype == SOCK_DGRAM) - /* there's no connection! */ + if(conn->transport != TRNSPRT_TCP) + /* there's no TCP connection! */ return; #if defined(HAVE_GETPEERNAME) || defined(HAVE_GETSOCKNAME) @@ -1099,8 +1100,8 @@ static CURLcode singleipconnect(struct connectdata *conn, if(conn->num_addr > 1) Curl_expire(data, conn->timeoutms_per_addr, EXPIRE_DNS_PER_NAME); - /* Connect TCP sockets, bind UDP */ - if(!isconnected && (conn->socktype == SOCK_STREAM)) { + /* Connect TCP and QUIC sockets */ + if(!isconnected && (conn->transport != TRNSPRT_UDP)) { if(conn->bits.tcp_fastopen) { #if defined(CONNECT_DATA_IDEMPOTENT) /* Darwin */ # if defined(HAVE_BUILTIN_AVAILABLE) @@ -1152,6 +1153,15 @@ static CURLcode singleipconnect(struct connectdata *conn, return CURLE_OK; } +#ifdef ENABLE_QUIC + if(!isconnected && (conn->transport == TRNSPRT_QUIC)) { + result = Curl_quic_connect(conn, sockfd, &addr.sa_addr, addr.addrlen); + if(result) + return result; + rc = 0; /* connect success */ + } +#endif + if(-1 == rc) { switch(error) { case EINPROGRESS: @@ -1386,8 +1396,9 @@ CURLcode Curl_socket(struct connectdata *conn, */ addr->family = ai->ai_family; - addr->socktype = conn->socktype; - addr->protocol = conn->socktype == SOCK_DGRAM?IPPROTO_UDP:ai->ai_protocol; + addr->socktype = (conn->transport == TRNSPRT_TCP) ? SOCK_STREAM : SOCK_DGRAM; + addr->protocol = conn->transport != TRNSPRT_TCP ? IPPROTO_UDP : + ai->ai_protocol; addr->addrlen = ai->ai_addrlen; if(addr->addrlen > sizeof(struct Curl_sockaddr_storage)) -- cgit v1.2.3