mirror of
https://github.com/curl/curl.git
synced 2024-12-15 06:40:09 +08:00
71b7e01610
Refactoring of connection setup and happy eyeballing. Move nghttp2. ngtcp2, quiche and msh3 into connection filters. - eyeballing cfilter that uses sub-filters for performing parallel connects - socket cfilter for all transport types, including QUIC - QUIC implementations in cfilter, can now participate in eyeballing - connection setup is more dynamic in order to adapt to what filter did really connect. Relevant to see if a SSL filter needs to be added or if SSL has already been provided - HTTP/3 test cases similar to HTTP/2 - multiuse of parallel transfers for HTTP/3, tested for ngtcp2 and quiche - Fix for data attach/detach in VTLS filters that could lead to crashes during parallel transfers. - Eliminating setup() methods in cfilters, no longer needed. - Improving Curl_conn_is_alive() to replace Curl_connalive() and integrated ssl alive checks into cfilter. - Adding CF_CNTRL_CONN_INFO_UPDATE to tell filters to update connection into and persist it at the easy handle. - Several more cfilter related cleanups and moves: - stream_weigth and dependency info is now wrapped in struct Curl_data_priority - Curl_data_priority members depend is available in HTTP2|HTTP3 - Curl_data_priority members depend on NGHTTP2 support - handling init/reset/cleanup of priority part of url.c - data->state.priority same struct, but shallow copy for compares only - PROTOPT_STREAM has been removed - Curl_conn_is_mulitplex() now available to check on capability - Adding query method to connection filters. - ngtcp2+quiche: implementing query for max concurrent transfers. - Adding is_alive and keep_alive cfilter methods. Adding DATA_SETUP event. - setting keepalive timestamp on connect - DATA_SETUP is called after the connection has been completely setup (but may not connected yet) to allow filters to initialize data members they use. - there is no socket to be had with msh3, it is unclear how select shall work - manual test via "curl --http3 https://curl.se" fail with "empty reply from server". - Various socket/conn related cleanups: - Curl_socket is now Curl_socket_open and in cf-socket.c - Curl_closesocket is now Curl_socket_close and in cf-socket.c - Curl_ssl_use has been replaced with Cur_conn_is_ssl - Curl_conn_tcp_accepted_set has been split into Curl_conn_tcp_listen_set and Curl_conn_tcp_accepted_set with a clearer purpose Closes #10141
137 lines
5.3 KiB
C
137 lines
5.3 KiB
C
#ifndef HEADER_CURL_CONNECT_H
|
|
#define HEADER_CURL_CONNECT_H
|
|
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) 1998 - 2022, 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.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.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
#include "curl_setup.h"
|
|
|
|
#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
|
|
#include "sockaddr.h"
|
|
#include "timeval.h"
|
|
|
|
struct Curl_dns_entry;
|
|
|
|
/* generic function that returns how much time there's left to run, according
|
|
to the timeouts set */
|
|
timediff_t Curl_timeleft(struct Curl_easy *data,
|
|
struct curltime *nowp,
|
|
bool duringconnect);
|
|
|
|
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
|
|
|
|
/*
|
|
* Used to extract socket and connectdata struct for the most recent
|
|
* transfer on the given Curl_easy.
|
|
*
|
|
* The returned socket will be CURL_SOCKET_BAD in case of failure!
|
|
*/
|
|
curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
|
|
struct connectdata **connp);
|
|
|
|
bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
|
|
char *addr, int *port);
|
|
|
|
void Curl_persistconninfo(struct Curl_easy *data, struct connectdata *conn,
|
|
char *local_ip, int local_port);
|
|
|
|
/*
|
|
* Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
|
|
* argument specifies if it is the end of a connection or a stream.
|
|
*
|
|
* For stream-based protocols (such as HTTP/2), a stream close will not cause
|
|
* a connection close. Other protocols will close the connection for both
|
|
* cases.
|
|
*
|
|
* It sets the bit.close bit to TRUE (with an explanation for debug builds),
|
|
* when the connection will close.
|
|
*/
|
|
|
|
#define CONNCTRL_KEEP 0 /* undo a marked closure */
|
|
#define CONNCTRL_CONNECTION 1
|
|
#define CONNCTRL_STREAM 2
|
|
|
|
void Curl_conncontrol(struct connectdata *conn,
|
|
int closeit
|
|
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
|
, const char *reason
|
|
#endif
|
|
);
|
|
|
|
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
|
#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
|
|
#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
|
|
#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
|
|
#else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */
|
|
#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM)
|
|
#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
|
|
#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP)
|
|
#endif
|
|
|
|
/**
|
|
* Create a cfilter for making an "ip" connection to the
|
|
* given address, using paramters from `conn`. The "ip" connection
|
|
* can be a TCP socket, a UDP socket or even a QUIC connection.
|
|
*
|
|
* It MUST use only the supplied `ai` for its connection attempt.
|
|
*
|
|
* Such a filter may be used in "happy eyeball" scenarios, and its
|
|
* `connect` implementation needs to support non-blocking. Once connected,
|
|
* it MAY be installed in the connection filter chain to serve transfers.
|
|
*/
|
|
typedef CURLcode cf_ip_connect_create(struct Curl_cfilter **pcf,
|
|
struct Curl_easy *data,
|
|
struct connectdata *conn,
|
|
const struct Curl_addrinfo *ai);
|
|
|
|
/**
|
|
* Create a happy eyeball connection filter that uses the, once resolved,
|
|
* address information to connect on ip families based on connection
|
|
* configuration.
|
|
* @param pcf output, the created cfilter
|
|
* @param data easy handle used in creation
|
|
* @param conn connection the filter is created for
|
|
* @param cf_create method to create the sub-filters performing the
|
|
* actual connects.
|
|
*/
|
|
CURLcode
|
|
Curl_cf_happy_eyeballs_create(struct Curl_cfilter **pcf,
|
|
struct Curl_easy *data,
|
|
struct connectdata *conn,
|
|
cf_ip_connect_create *cf_create,
|
|
const struct Curl_dns_entry *remotehost);
|
|
|
|
/**
|
|
* Setup the cfilters at `sockindex` in connection `conn`, invoking
|
|
* the instance `setup(remotehost)` methods. If no filter chain is
|
|
* installed yet, inspects the configuration in `data` to install a
|
|
* suitable filter chain.
|
|
*/
|
|
CURLcode Curl_conn_setup(struct Curl_easy *data,
|
|
struct connectdata *conn,
|
|
int sockindex,
|
|
const struct Curl_dns_entry *remotehost,
|
|
int ssl_mode);
|
|
|
|
|
|
#endif /* HEADER_CURL_CONNECT_H */
|