return result;
}
-void Curl_conn_cf_add(struct Curl_easy *data, int index,
+void Curl_conn_cf_add(struct Curl_easy *data,
+ struct connectdata *conn,
+ int index,
struct Curl_cfilter *cf)
{
(void)data;
- DEBUGF(infof(data, DMSGI(data, index, "cf_add(filter=%s)"),
- cf->cft->name));
-
- DEBUGASSERT(data->conn);
+ DEBUGASSERT(conn);
DEBUGASSERT(!cf->conn);
DEBUGASSERT(!cf->next);
- cf->next = data->conn->cfilter[index];
- cf->conn = data->conn;
+
+ DEBUGF(infof(data, CMSGI(conn, index, "cf_add(filter=%s)"),
+ cf->cft->name));
+ cf->next = conn->cfilter[index];
+ cf->conn = conn;
cf->sockindex = index;
- data->conn->cfilter[index] = cf;
+ conn->cfilter[index] = cf;
}
void Curl_conn_cf_discard(struct Curl_cfilter *cf, struct Curl_easy *data)
}
CURLcode Curl_conn_setup(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex,
const struct Curl_dns_entry *remotehost,
int ssl_mode)
{
- struct connectdata *conn = data->conn;
struct Curl_cfilter *cf;
CURLcode result;
*/
if(!conn->cfilter[sockindex]) {
DEBUGF(infof(data, DMSGI(data, sockindex, "setup, init filter chain")));
- result = Curl_conn_socket_set(data, sockindex);
+ result = Curl_conn_socket_set(data, conn, sockindex);
if(result)
goto out;
#ifndef CURL_DISABLE_PROXY
if(conn->bits.socksproxy) {
- result = Curl_conn_socks_proxy_add(data, sockindex);
+ result = Curl_conn_socks_proxy_add(data, conn, sockindex);
if(result)
goto out;
}
if(conn->bits.httpproxy) {
#ifdef USE_SSL
if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) {
- result = Curl_ssl_cfilter_proxy_add(data, sockindex);
+ result = Curl_ssl_cfilter_proxy_add(data, conn, sockindex);
if(result)
goto out;
}
#if !defined(CURL_DISABLE_HTTP)
if(conn->bits.tunnel_proxy) {
- result = Curl_conn_http_proxy_add(data, sockindex);
+ result = Curl_conn_http_proxy_add(data, conn, sockindex);
if(result)
goto out;
}
if(ssl_mode == CURL_CF_SSL_ENABLE
|| (ssl_mode != CURL_CF_SSL_DISABLE
&& conn->handler->flags & PROTOPT_SSL)) {
- result = Curl_ssl_cfilter_add(data, sockindex);
+ result = Curl_ssl_cfilter_add(data, conn, sockindex);
if(result)
goto out;
}
#if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP)
if(data->set.haproxyprotocol) {
- result = Curl_conn_haproxy_add(data, sockindex);
+ result = Curl_conn_haproxy_add(data, conn, sockindex);
if(result)
goto out;
}
* the start of the chain (top).
*/
void Curl_conn_cf_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex,
struct Curl_cfilter *cf);
* 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);
const struct Curl_dns_entry *remotehost)
{
struct socket_cf_ctx *ctx = cf->ctx;
- bool done;
+ (void)data;
DEBUGASSERT(ctx);
if(ctx->remotehost != remotehost) {
if(ctx->remotehost) {
}
ctx->remotehost = remotehost;
}
- /* we start connecting right on setup */
DEBUGF(infof(data, CFMSG(cf, "setup(remotehost=%s)"),
cf->conn->hostname_resolve));
- return socket_cf_connect(cf, data, FALSE, &done);
+ return CURLE_OK;
}
static void socket_cf_close(struct Curl_cfilter *cf,
};
CURLcode Curl_conn_socket_set(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex)
{
CURLcode result;
struct socket_cf_ctx *scf_ctx = NULL;
/* Need to be first */
- DEBUGASSERT(!data->conn->cfilter[sockindex]);
+ DEBUGASSERT(conn);
+ DEBUGASSERT(!conn->cfilter[sockindex]);
scf_ctx = calloc(sizeof(*scf_ctx), 1);
if(!scf_ctx) {
result = CURLE_OUT_OF_MEMORY;
result = Curl_cf_create(&cf, &cft_socket, scf_ctx);
if(result)
goto out;
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
out:
if(result) {
};
CURLcode Curl_conn_socket_accepted_set(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex, curl_socket_t *s)
{
- struct connectdata *conn = data->conn;
CURLcode result;
struct Curl_cfilter *cf = NULL;
struct socket_cf_ctx *scf_ctx = NULL;
result = Curl_cf_create(&cf, &cft_socket_accept, scf_ctx);
if(result)
goto out;
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
}
/* close any existing socket and replace */
#endif
CURLcode Curl_conn_socket_set(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex);
CURLcode Curl_conn_socket_accepted_set(struct Curl_easy *data,
- int sockindex, curl_socket_t *s);
+ struct connectdata *conn,
+ int sockindex,
+ curl_socket_t *s);
#endif /* HEADER_CURL_CONNECT_H */
(void)curlx_nonblock(s, TRUE); /* enable non-blocking */
/* Replace any filter on SECONDARY with one listeing on this socket */
- result = Curl_conn_socket_accepted_set(data, SECONDARYSOCKET, &s);
+ result = Curl_conn_socket_accepted_set(data, conn, SECONDARYSOCKET, &s);
if(result)
return result;
ftpc->count1 = fcmd;
/* Replace any filter on SECONDARY with one listeing on this socket */
- result = Curl_conn_socket_accepted_set(data, SECONDARYSOCKET, &portsock);
+ result = Curl_conn_socket_accepted_set(data, conn, SECONDARYSOCKET,
+ &portsock);
if(result)
goto out;
portsock = CURL_SOCKET_BAD; /* now held in filter */
}
}
- result = Curl_conn_setup(data, SECONDARYSOCKET, addr,
+ result = Curl_conn_setup(data, conn, SECONDARYSOCKET, addr,
conn->bits.ftp_use_data_ssl?
CURL_CF_SSL_ENABLE : CURL_CF_SSL_DISABLE);
/* this was BLOCKING, keep it so for now */
bool done;
if(!Curl_ssl_conn_is_ssl(data, FIRSTSOCKET)) {
- result = Curl_ssl_cfilter_add(data, FIRSTSOCKET);
+ result = Curl_ssl_cfilter_add(data, conn, FIRSTSOCKET);
if(result) {
/* we failed and bail out */
return CURLE_USE_SSL_FAILED;
#endif
static CURLcode h3_setup_conn(struct Curl_easy *data,
- struct connectdata *conn)
+ struct connectdata *conn)
{
#ifdef ENABLE_QUIC
/* We want HTTP/3 directly, setup the filter chain ourself,
DEBUGF(infof(data, "HTTP/3 direct conn setup(conn #%ld, index=%d)",
conn->connection_id, FIRSTSOCKET));
- return Curl_conn_socket_set(data, FIRSTSOCKET);
+ return Curl_conn_socket_set(data, conn, FIRSTSOCKET);
#else /* ENABLE_QUIC */
(void)conn;
};
CURLcode Curl_conn_http_proxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex)
{
struct Curl_cfilter *cf;
result = Curl_cf_create(&cf, &cft_http_proxy, NULL);
if(!result)
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
return result;
}
};
CURLcode Curl_conn_haproxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex)
{
struct Curl_cfilter *cf;
result = Curl_cf_create(&cf, &cft_haproxy, NULL);
if(!result)
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
return result;
}
#define PROXY_TIMEOUT (3600*1000)
CURLcode Curl_conn_http_proxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex);
CURLcode Curl_conn_haproxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex);
#endif /* !CURL_DISABLE_PROXY && !CURL_DISABLE_HTTP */
CURLcode result;
if(!Curl_ssl_conn_is_ssl(data, FIRSTSOCKET)) {
- result = Curl_ssl_cfilter_add(data, FIRSTSOCKET);
+ result = Curl_ssl_cfilter_add(data, conn, FIRSTSOCKET);
if(result)
goto out;
}
CURLcode result;
if(!Curl_ssl_conn_is_ssl(data, FIRSTSOCKET)) {
- result = Curl_ssl_cfilter_add(data, FIRSTSOCKET);
+ result = Curl_ssl_cfilter_add(data, conn, FIRSTSOCKET);
if(result)
goto out;
}
CURLcode result;
if(!Curl_ssl_conn_is_ssl(data, FIRSTSOCKET)) {
- result = Curl_ssl_cfilter_add(data, FIRSTSOCKET);
+ result = Curl_ssl_cfilter_add(data, conn, FIRSTSOCKET);
if(result)
goto out;
}
};
CURLcode Curl_conn_socks_proxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex)
{
struct Curl_cfilter *cf;
result = Curl_cf_create(&cf, &cft_socks_proxy, NULL);
if(!result)
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
return result;
}
#endif
CURLcode Curl_conn_socks_proxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex);
#endif /* CURL_DISABLE_PROXY */
is later set again for the progress meter purpose */
conn->now = Curl_now();
if(!conn->bits.reuse)
- result = Curl_conn_setup(data, FIRSTSOCKET, conn->dns_entry,
+ result = Curl_conn_setup(data, conn, FIRSTSOCKET, conn->dns_entry,
CURL_CF_SSL_DEFAULT);
/* not sure we need this flag to be passed around any more */
*protocol_done = FALSE;
connssl->port = (int)cf->conn->remote_port;
}
}
+ DEBUGASSERT(connssl->hostname);
}
static void ssl_cf_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
}
(void)connssl;
+ DEBUGASSERT(data->conn);
+ DEBUGASSERT(data->conn == cf->conn);
DEBUGASSERT(connssl);
- /* TODO: right now we do not fully control when hostname is set, but
- * copy it over again on each connect call. Esp. secondary chains seems
- * to set it after the filters have been added */
- reinit_hostname(cf);
+ DEBUGASSERT(cf->conn->host.name);
result = cf->next->cft->connect(cf->next, data, blocking, done);
if(result || !*done)
return result;
+ /* TODO: right now we do not fully control when hostname is set,
+ * assign it on each connect call. */
+ reinit_hostname(cf);
*done = FALSE;
+
if(blocking) {
result = ssl_connect(cf, data);
*done = (result == CURLE_OK);
};
CURLcode Curl_ssl_cfilter_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex)
{
struct Curl_cfilter *cf;
if(result)
goto out;
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
- reinit_hostname(cf);
result = CURLE_OK;
out:
#ifndef CURL_DISABLE_PROXY
CURLcode Curl_ssl_cfilter_proxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex)
{
struct Curl_cfilter *cf;
if(result)
goto out;
- Curl_conn_cf_add(data, sockindex, cf);
+ Curl_conn_cf_add(data, conn, sockindex, cf);
- reinit_hostname(cf);
result = CURLE_OK;
out:
(void)data;
DEBUGASSERT(data->conn);
cf = get_ssl_cf_engaged(data->conn, sockindex);
- return cf? Curl_ssl_cf_get_config(cf, data) : NULL;
+ return cf? Curl_ssl_cf_get_config(cf, data) : &data->set.ssl;
}
struct ssl_primary_config *
#define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
CURLcode Curl_ssl_cfilter_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex);
CURLcode Curl_ssl_cfilter_remove(struct Curl_easy *data,
#ifndef CURL_DISABLE_PROXY
CURLcode Curl_ssl_cfilter_proxy_add(struct Curl_easy *data,
+ struct connectdata *conn,
int sockindex);
#endif /* !CURL_DISABLE_PROXY */
#define Curl_ssl_get_backend_data_size(a) 0
#define Curl_ssl_use(a,b) FALSE
#define Curl_ssl_conn_is_ssl(a,b) FALSE
-#define Curl_ssl_cfilter_add(a,b) CURLE_NOT_BUILT_IN
-#define Curl_ssl_cfilter_proxy_add(a,b) CURLE_NOT_BUILT_IN
+#define Curl_ssl_cfilter_add(a,b,c) CURLE_NOT_BUILT_IN
+#define Curl_ssl_cfilter_proxy_add(a,b,c) CURLE_NOT_BUILT_IN
#define Curl_ssl_get_config(a,b) NULL
#define Curl_ssl_cfilter_remove(a,b) CURLE_OK
#endif