VirtualBox

source: vbox/trunk/src/libs/curl-8.11.1/lib/connect.h@ 108333

最後變更 在這個檔案從108333是 108048,由 vboxsync 提交於 7 週 前

curl-8.11.1: Applied and adjusted our curl changes to 8.7.1. jiraref:VBP-1535

  • 屬性 svn:eol-style 設為 native
檔案大小: 5.8 KB
 
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, <[email protected]>, 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 "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
29#include "sockaddr.h"
30#include "timeval.h"
31
32struct Curl_dns_entry;
33struct ip_quadruple;
34
35/* generic function that returns how much time there is left to run, according
36 to the timeouts set */
37timediff_t Curl_timeleft(struct Curl_easy *data,
38 struct curltime *nowp,
39 bool duringconnect);
40
41#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
42
43#define DEFAULT_SHUTDOWN_TIMEOUT_MS (2 * 1000)
44
45void Curl_shutdown_start(struct Curl_easy *data, int sockindex,
46 struct curltime *nowp);
47
48/* return how much time there is left to shutdown the connection at
49 * sockindex. Returns 0 if there is no limit or shutdown has not started. */
50timediff_t Curl_shutdown_timeleft(struct connectdata *conn, int sockindex,
51 struct curltime *nowp);
52
53/* return how much time there is left to shutdown the connection.
54 * Returns 0 if there is no limit or shutdown has not started. */
55timediff_t Curl_conn_shutdown_timeleft(struct connectdata *conn,
56 struct curltime *nowp);
57
58void Curl_shutdown_clear(struct Curl_easy *data, int sockindex);
59
60/* TRUE iff shutdown has been started */
61bool Curl_shutdown_started(struct Curl_easy *data, int sockindex);
62
63/*
64 * Used to extract socket and connectdata struct for the most recent
65 * transfer on the given Curl_easy.
66 *
67 * The returned socket will be CURL_SOCKET_BAD in case of failure!
68 */
69curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
70 struct connectdata **connp);
71
72bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
73 char *addr, int *port);
74
75/*
76 * Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
77 * argument specifies if it is the end of a connection or a stream.
78 *
79 * For stream-based protocols (such as HTTP/2), a stream close will not cause
80 * a connection close. Other protocols will close the connection for both
81 * cases.
82 *
83 * It sets the bit.close bit to TRUE (with an explanation for debug builds),
84 * when the connection will close.
85 */
86
87#define CONNCTRL_KEEP 0 /* undo a marked closure */
88#define CONNCTRL_CONNECTION 1
89#define CONNCTRL_STREAM 2
90
91void Curl_conncontrol(struct connectdata *conn,
92 int closeit
93#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
94 , const char *reason
95#endif
96 );
97
98#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
99#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
100#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
101#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
102#else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */
103#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM)
104#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
105#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP)
106#endif
107
108/**
109 * Create a cfilter for making an "ip" connection to the
110 * given address, using parameters from `conn`. The "ip" connection
111 * can be a TCP socket, a UDP socket or even a QUIC connection.
112 *
113 * It MUST use only the supplied `ai` for its connection attempt.
114 *
115 * Such a filter may be used in "happy eyeball" scenarios, and its
116 * `connect` implementation needs to support non-blocking. Once connected,
117 * it MAY be installed in the connection filter chain to serve transfers.
118 */
119typedef CURLcode cf_ip_connect_create(struct Curl_cfilter **pcf,
120 struct Curl_easy *data,
121 struct connectdata *conn,
122 const struct Curl_addrinfo *ai,
123 int transport);
124
125CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at,
126 struct Curl_easy *data,
127 const struct Curl_dns_entry *remotehost,
128 int transport,
129 int ssl_mode);
130
131/**
132 * Setup the cfilters at `sockindex` in connection `conn`.
133 * If no filter chain is installed yet, inspects the configuration
134 * in `data` and `conn? to install a suitable filter chain.
135 */
136CURLcode Curl_conn_setup(struct Curl_easy *data,
137 struct connectdata *conn,
138 int sockindex,
139 const struct Curl_dns_entry *remotehost,
140 int ssl_mode);
141
142extern struct Curl_cftype Curl_cft_happy_eyeballs;
143extern struct Curl_cftype Curl_cft_setup;
144
145#ifdef UNITTESTS
146void Curl_debug_set_transport_provider(int transport,
147 cf_ip_connect_create *cf_create);
148#endif
149
150#endif /* HEADER_CURL_CONNECT_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette