Line | Count | Source |
1 | | #ifndef HEADER_CURL_CONNECT_H |
2 | | #define HEADER_CURL_CONNECT_H |
3 | | /*************************************************************************** |
4 | | * _ _ ____ _ |
5 | | * Project ___| | | | _ \| | |
6 | | * / __| | | | |_) | | |
7 | | * | (__| |_| | _ <| |___ |
8 | | * \___|\___/|_| \_\_____| |
9 | | * |
10 | | * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. |
11 | | * |
12 | | * This software is licensed as described in the file COPYING, which |
13 | | * you should have received as part of this distribution. The terms |
14 | | * are also available at https://curl.se/docs/copyright.html. |
15 | | * |
16 | | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
17 | | * copies of the Software, and permit persons to whom the Software is |
18 | | * furnished to do so, under the terms of the COPYING file. |
19 | | * |
20 | | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
21 | | * KIND, either express or implied. |
22 | | * |
23 | | * SPDX-License-Identifier: curl |
24 | | * |
25 | | ***************************************************************************/ |
26 | | #include "curl_setup.h" |
27 | | |
28 | | #include "curlx/timeval.h" |
29 | | |
30 | | struct Curl_dns_entry; |
31 | | struct ip_quadruple; |
32 | | struct Curl_str; |
33 | | |
34 | | enum alpnid Curl_alpn2alpnid(const unsigned char *name, size_t len); |
35 | | enum alpnid Curl_str2alpnid(const struct Curl_str *str); |
36 | | |
37 | | /* generic function that returns how much time there is left to run, according |
38 | | to the timeouts set */ |
39 | | timediff_t Curl_timeleft_ms(struct Curl_easy *data, |
40 | | bool duringconnect); |
41 | | timediff_t Curl_timeleft_now_ms(struct Curl_easy *data, |
42 | | const struct curltime *pnow, |
43 | | bool duringconnect); |
44 | | |
45 | 0 | #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ |
46 | | |
47 | 0 | #define DEFAULT_SHUTDOWN_TIMEOUT_MS (2 * 1000) |
48 | | |
49 | | void Curl_shutdown_start(struct Curl_easy *data, int sockindex, |
50 | | int timeout_ms); |
51 | | |
52 | | /* return how much time there is left to shutdown the connection at |
53 | | * sockindex. Returns 0 if there is no limit or shutdown has not started. */ |
54 | | timediff_t Curl_shutdown_timeleft(struct Curl_easy *data, |
55 | | struct connectdata *conn, |
56 | | int sockindex); |
57 | | |
58 | | /* return how much time there is left to shutdown the connection. |
59 | | * Returns 0 if there is no limit or shutdown has not started. */ |
60 | | timediff_t Curl_conn_shutdown_timeleft(struct Curl_easy *data, |
61 | | struct connectdata *conn); |
62 | | |
63 | | void Curl_shutdown_clear(struct Curl_easy *data, int sockindex); |
64 | | |
65 | | /* TRUE iff shutdown has been started */ |
66 | | bool Curl_shutdown_started(struct Curl_easy *data, int sockindex); |
67 | | |
68 | | /* |
69 | | * Used to extract socket and connectdata struct for the most recent |
70 | | * transfer on the given Curl_easy. |
71 | | * |
72 | | * The returned socket will be CURL_SOCKET_BAD in case of failure! |
73 | | */ |
74 | | curl_socket_t Curl_getconnectinfo(struct Curl_easy *data, |
75 | | struct connectdata **connp); |
76 | | |
77 | | bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen, |
78 | | char *addr, uint16_t *port); |
79 | | |
80 | | /* |
81 | | * Curl_conncontrol() marks the end of a connection/stream. The 'closeit' |
82 | | * argument specifies if it is the end of a connection or a stream. |
83 | | * |
84 | | * For stream-based protocols (such as HTTP/2), a stream close will not cause |
85 | | * a connection close. Other protocols will close the connection for both |
86 | | * cases. |
87 | | * |
88 | | * It sets the bit.close bit to TRUE (with an explanation for debug builds), |
89 | | * when the connection will close. |
90 | | */ |
91 | | |
92 | 0 | #define CONNCTRL_KEEP 0 /* undo a marked closure */ |
93 | 0 | #define CONNCTRL_CONNECTION 1 |
94 | 0 | #define CONNCTRL_STREAM 2 |
95 | | |
96 | | void Curl_conncontrol(struct connectdata *conn, |
97 | | int closeit |
98 | | #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) |
99 | | , const char *reason |
100 | | #endif |
101 | | ); |
102 | | |
103 | | #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) |
104 | 0 | #define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM, y) |
105 | 0 | #define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y) |
106 | 0 | #define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP, y) |
107 | | #else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */ |
108 | | #define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM) |
109 | | #define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION) |
110 | | #define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP) |
111 | | #endif |
112 | | |
113 | | CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at, |
114 | | struct Curl_easy *data, |
115 | | uint8_t transport, |
116 | | int ssl_mode); |
117 | | |
118 | | /** |
119 | | * Setup the cfilters at `sockindex` in connection `conn`. |
120 | | * If no filter chain is installed yet, inspects the configuration |
121 | | * in `data` and `conn? to install a suitable filter chain. |
122 | | */ |
123 | | CURLcode Curl_conn_setup(struct Curl_easy *data, |
124 | | struct connectdata *conn, |
125 | | int sockindex, |
126 | | struct Curl_dns_entry *dns, |
127 | | int ssl_mode); |
128 | | |
129 | | /* Set conn to allow multiplexing. */ |
130 | | void Curl_conn_set_multiplex(struct connectdata *conn); |
131 | | |
132 | | extern struct Curl_cftype Curl_cft_setup; |
133 | | |
134 | | #endif /* HEADER_CURL_CONNECT_H */ |