summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/asyn-ares.c2
-rw-r--r--lib/c-hyper.c4
-rw-r--r--lib/conncache.c36
-rw-r--r--lib/conncache.h6
-rw-r--r--lib/connect.c4
-rw-r--r--lib/file.c8
-rw-r--r--lib/ftp.c4
-rw-r--r--lib/http.c6
-rw-r--r--lib/http_ntlm.c34
-rw-r--r--lib/http_ntlm.h6
-rw-r--r--lib/http_proxy.c4
-rw-r--r--lib/imap.c2
-rw-r--r--lib/multi.c6
-rw-r--r--lib/pingpong.c7
-rw-r--r--lib/pingpong.h3
-rw-r--r--lib/pop3.c2
-rw-r--r--lib/progress.c20
-rw-r--r--lib/progress.h6
-rw-r--r--lib/rtsp.c2
-rw-r--r--lib/smtp.c2
-rw-r--r--lib/socks.c75
-rw-r--r--lib/socks.h10
-rw-r--r--lib/socks_gssapi.c12
-rw-r--r--lib/socks_sspi.c30
-rw-r--r--lib/telnet.c167
-rw-r--r--lib/tftp.c6
-rw-r--r--lib/transfer.c4
-rw-r--r--lib/url.c29
-rw-r--r--lib/vssh/libssh.c285
-rw-r--r--lib/vssh/libssh2.c364
30 files changed, 572 insertions, 574 deletions
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
index c8e8e14ea..c17cd265b 100644
--- a/lib/asyn-ares.c
+++ b/lib/asyn-ares.c
@@ -463,7 +463,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
if(result || conn->async.done)
break;
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else {
struct curltime now2 = Curl_now();
diff --git a/lib/c-hyper.c b/lib/c-hyper.c
index 51c6cdebe..5e7a76f80 100644
--- a/lib/c-hyper.c
+++ b/lib/c-hyper.c
@@ -144,7 +144,7 @@ static int hyper_each_header(void *userdata,
Curl_debug(data, CURLINFO_HEADER_IN, headp, len);
- result = Curl_client_write(data->conn, CLIENTWRITE_HEADER, headp, len);
+ result = Curl_client_write(data, CLIENTWRITE_HEADER, headp, len);
if(result) {
data->state.hresult = CURLE_ABORTED_BY_CALLBACK;
return HYPER_ITER_BREAK;
@@ -175,7 +175,7 @@ static int hyper_body_chunk(void *userdata, const hyper_buf *chunk)
if(k->ignorebody)
return HYPER_ITER_CONTINUE;
Curl_debug(data, CURLINFO_DATA_IN, buf, len);
- result = Curl_client_write(data->conn, CLIENTWRITE_BODY, buf, len);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len);
if(result) {
data->state.hresult = result;
diff --git a/lib/conncache.c b/lib/conncache.c
index ecdbaf461..8dfdc0ac8 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -179,12 +179,14 @@ size_t Curl_conncache_size(struct Curl_easy *data)
connectdata struct is setup to use.
**NOTE**: When it returns, it holds the connection cache lock! */
-struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
- struct conncache *connc,
- const char **hostp)
+struct connectbundle *
+Curl_conncache_find_bundle(struct Curl_easy *data,
+ struct connectdata *conn,
+ struct conncache *connc,
+ const char **hostp)
{
struct connectbundle *bundle = NULL;
- CONNCACHE_LOCK(conn->data);
+ CONNCACHE_LOCK(data);
if(connc) {
char key[HASHKEY_SIZE];
hashkey(conn, key, sizeof(key), hostp);
@@ -227,15 +229,17 @@ static void conncache_remove_bundle(struct conncache *connc,
}
}
-CURLcode Curl_conncache_add_conn(struct conncache *connc,
- struct connectdata *conn)
+CURLcode Curl_conncache_add_conn(struct Curl_easy *data)
{
CURLcode result = CURLE_OK;
struct connectbundle *bundle = NULL;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
+ struct conncache *connc = data->state.conn_cache;
+ DEBUGASSERT(conn);
/* *find_bundle() locks the connection cache */
- bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache, NULL);
+ bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache,
+ NULL);
if(!bundle) {
int rc;
char key[HASHKEY_SIZE];
@@ -259,7 +263,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
conn->connection_id = connc->next_connection_id++;
connc->num_conn++;
- DEBUGF(infof(conn->data, "Added connection %ld. "
+ DEBUGF(infof(data, "Added connection %ld. "
"The cache now contains %zu members\n",
conn->connection_id, connc->num_conn));
@@ -270,8 +274,8 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
}
/*
- * Removes the connectdata object from the connection cache, but does *not*
- * clear the conn->data association. The transfer still owns this connection.
+ * Removes the connectdata object from the connection cache, but the transfer
+ * still owns this connection.
*
* Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
* already holds the lock or not.
@@ -445,7 +449,7 @@ Curl_conncache_extract_bundle(struct Curl_easy *data,
while(curr) {
conn = curr->ptr;
- if(!CONN_INUSE(conn) && !conn->data) {
+ if(!CONN_INUSE(conn)) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
@@ -503,7 +507,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
while(curr) {
conn = curr->ptr;
- if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close &&
+ if(!CONN_INUSE(conn) && !conn->bits.close &&
!conn->bits.connect_only) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
@@ -544,12 +548,10 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
conn = conncache_find_first_connection(connc);
while(conn) {
SIGPIPE_VARIABLE(pipe_st);
- conn->data = connc->closure_handle;
-
- sigpipe_ignore(conn->data, &pipe_st);
+ sigpipe_ignore(connc->closure_handle, &pipe_st);
/* This will remove the connection from the cache */
connclose(conn, "kill all");
- Curl_conncache_remove_conn(conn->data, conn, TRUE);
+ Curl_conncache_remove_conn(connc->closure_handle, conn, TRUE);
(void)Curl_disconnect(connc->closure_handle, conn, FALSE);
sigpipe_restore(&pipe_st);
diff --git a/lib/conncache.h b/lib/conncache.h
index ab878caf3..e9c1e32f8 100644
--- a/lib/conncache.h
+++ b/lib/conncache.h
@@ -85,7 +85,8 @@ int Curl_conncache_init(struct conncache *, int size);
void Curl_conncache_destroy(struct conncache *connc);
/* return the correct bundle, to a host or a proxy */
-struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
+struct connectbundle *Curl_conncache_find_bundle(struct Curl_easy *data,
+ struct connectdata *conn,
struct conncache *connc,
const char **hostp);
/* returns number of connections currently held in the connection cache */
@@ -93,8 +94,7 @@ size_t Curl_conncache_size(struct Curl_easy *data);
bool Curl_conncache_return_conn(struct Curl_easy *data,
struct connectdata *conn);
-CURLcode Curl_conncache_add_conn(struct conncache *connc,
- struct connectdata *conn) WARN_UNUSED_RESULT;
+CURLcode Curl_conncache_add_conn(struct Curl_easy *data) WARN_UNUSED_RESULT;
void Curl_conncache_remove_conn(struct Curl_easy *data,
struct connectdata *conn,
bool lock);
diff --git a/lib/connect.c b/lib/connect.c
index b0af08445..712fc8a0d 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -788,13 +788,13 @@ static CURLcode connect_SOCKS(struct Curl_easy *data, int sockindex,
case CURLPROXY_SOCKS5:
case CURLPROXY_SOCKS5_HOSTNAME:
pxresult = Curl_SOCKS5(conn->socks_proxy.user, conn->socks_proxy.passwd,
- host, port, sockindex, conn, done);
+ host, port, sockindex, data, done);
break;
case CURLPROXY_SOCKS4:
case CURLPROXY_SOCKS4A:
pxresult = Curl_SOCKS4(conn->socks_proxy.user, host, port, sockindex,
- conn, done);
+ data, done);
break;
default:
diff --git a/lib/file.c b/lib/file.c
index 5156c7add..509e4836f 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -338,12 +338,12 @@ static CURLcode file_upload(struct Curl_easy *data)
Curl_pgrsSetUploadCounter(data, bytecount);
- if(Curl_pgrsUpdate(data->conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, Curl_now());
}
- if(!result && Curl_pgrsUpdate(data->conn))
+ if(!result && Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
close(fd);
@@ -527,12 +527,12 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
Curl_pgrsSetDownloadCounter(data, bytecount);
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, Curl_now());
}
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
return result;
diff --git a/lib/ftp.c b/lib/ftp.c
index 9e9830e26..63bf3f30a 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -678,7 +678,7 @@ CURLcode Curl_GetFTPResponse(struct Curl_easy *data,
return CURLE_RECV_ERROR;
case 0: /* timeout */
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
continue; /* just continue in our loop for the timeout duration */
@@ -2656,7 +2656,7 @@ static CURLcode ftp_statemachine(struct Curl_easy *data,
size_t nread = 0;
if(pp->sendleft)
- return Curl_pp_flushsend(pp);
+ return Curl_pp_flushsend(data, pp);
result = ftp_readresp(data, sock, pp, &ftpcode, &nread);
if(result)
diff --git a/lib/http.c b/lib/http.c
index 89e5da975..993dc61af 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -690,7 +690,7 @@ output_auth_headers(struct Curl_easy *data,
#ifdef USE_NTLM
if(authstatus->picked == CURLAUTH_NTLM) {
auth = "NTLM";
- result = Curl_output_ntlm(conn, proxy);
+ result = Curl_output_ntlm(data, proxy);
if(result)
return result;
}
@@ -966,7 +966,7 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
if(authp->picked == CURLAUTH_NTLM ||
authp->picked == CURLAUTH_NTLM_WB) {
/* NTLM authentication is picked and activated */
- CURLcode result = Curl_input_ntlm(conn, proxy, auth);
+ CURLcode result = Curl_input_ntlm(data, proxy, auth);
if(!result) {
data->state.authproblem = FALSE;
#ifdef NTLM_WB_ENABLED
@@ -3184,7 +3184,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
/* if a request-body has been sent off, we make sure this progress is noted
properly */
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
if(!http->postsize) {
diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c
index 91e1d1f71..6cb829edf 100644
--- a/lib/http_ntlm.c
+++ b/lib/http_ntlm.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, 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
@@ -59,7 +59,7 @@
# define DEBUG_OUT(x) Curl_nop_stmt
#endif
-CURLcode Curl_input_ntlm(struct connectdata *conn,
+CURLcode Curl_input_ntlm(struct Curl_easy *data,
bool proxy, /* if proxy or not */
const char *header) /* rest of the www-authenticate:
header */
@@ -68,6 +68,7 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
struct ntlmdata *ntlm;
curlntlm *state;
CURLcode result = CURLE_OK;
+ struct connectdata *conn = data->conn;
ntlm = proxy ? &conn->proxyntlm : &conn->ntlm;
state = proxy ? &conn->proxy_ntlm_state : &conn->http_ntlm_state;
@@ -79,7 +80,7 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
header++;
if(*header) {
- result = Curl_auth_decode_ntlm_type2_message(conn->data, header, ntlm);
+ result = Curl_auth_decode_ntlm_type2_message(data, header, ntlm);
if(result)
return result;
@@ -87,17 +88,17 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
}
else {
if(*state == NTLMSTATE_LAST) {
- infof(conn->data, "NTLM auth restarted\n");
+ infof(data, "NTLM auth restarted\n");
Curl_http_auth_cleanup_ntlm(conn);
}
else if(*state == NTLMSTATE_TYPE3) {
- infof(conn->data, "NTLM handshake rejected\n");
+ infof(data, "NTLM handshake rejected\n");
Curl_http_auth_cleanup_ntlm(conn);
*state = NTLMSTATE_NONE;
return CURLE_REMOTE_ACCESS_DENIED;
}
else if(*state >= NTLMSTATE_TYPE1) {
- infof(conn->data, "NTLM handshake failure (internal error)\n");
+ infof(data, "NTLM handshake failure (internal error)\n");
return CURLE_REMOTE_ACCESS_DENIED;
}
@@ -111,7 +112,7 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
/*
* This is for creating ntlm header output
*/
-CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
+CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
{
char *base64 = NULL;
size_t len = 0;
@@ -131,8 +132,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
struct ntlmdata *ntlm;
curlntlm *state;
struct auth *authp;
- struct Curl_easy *data = conn->data;
-
+ struct connectdata *conn = data->conn;
DEBUGASSERT(conn);
DEBUGASSERT(data);
@@ -142,12 +142,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
allocuserpwd = &data->state.aptr.proxyuserpwd;
userp = conn->http_proxy.user;
passwdp = conn->http_proxy.passwd;
- service = conn->data->set.str[STRING_PROXY_SERVICE_NAME] ?
- conn->data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
+ service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
+ data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
hostname = conn->http_proxy.host.name;
ntlm = &conn->proxyntlm;
state = &conn->proxy_ntlm_state;
- authp = &conn->data->state.authproxy;
+ authp = &data->state.authproxy;
#else
return CURLE_NOT_BUILT_IN;
#endif
@@ -156,12 +156,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
allocuserpwd = &data->state.aptr.userpwd;
userp = conn->user;
passwdp = conn->passwd;
- service = conn->data->set.str[STRING_SERVICE_NAME] ?
- conn->data->set.str[STRING_SERVICE_NAME] : "HTTP";
+ service = data->set.str[STRING_SERVICE_NAME] ?
+ data->set.str[STRING_SERVICE_NAME] : "HTTP";
hostname = conn->host.name;
ntlm = &conn->ntlm;
state = &conn->http_ntlm_state;
- authp = &conn->data->state.authhost;
+ authp = &data->state.authhost;
}
authp->done = FALSE;
@@ -188,7 +188,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
case NTLMSTATE_TYPE1:
default: /* for the weird cases we (re)start here */
/* Create a type-1 message */
- result = Curl_auth_create_ntlm_type1_message(conn->data, userp, passwdp,
+ result = Curl_auth_create_ntlm_type1_message(data, userp, passwdp,
service, hostname,
ntlm, &base64,
&len);
@@ -210,7 +210,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
case NTLMSTATE_TYPE2:
/* We already received the type-2 message, create a type-3 message */
- result = Curl_auth_create_ntlm_type3_message(conn->data, userp, passwdp,
+ result = Curl_auth_create_ntlm_type3_message(data, userp, passwdp,
ntlm, &base64, &len);
if(result)
return result;
diff --git a/lib/http_ntlm.h b/lib/http_ntlm.h
index 5ddf53872..5b4fa00ba 100644
--- a/lib/http_ntlm.h
+++ b/lib/http_ntlm.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, 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
@@ -27,11 +27,11 @@
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM)
/* this is for ntlm header input */
-CURLcode Curl_input_ntlm(struct connectdata *conn, bool proxy,
+CURLcode Curl_input_ntlm(struct Curl_easy *data, bool proxy,
const char *header);
/* this is for creating ntlm header output */
-CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
+CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy);
void Curl_http_auth_cleanup_ntlm(struct connectdata *conn);
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 3e38ab0cd..37f787ba5 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -347,7 +347,7 @@ static CURLcode CONNECT(struct connectdata *conn,
/* socket buffer drained, return */
return CURLE_OK;
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
if(result) {
@@ -560,7 +560,7 @@ static CURLcode CONNECT(struct connectdata *conn,
Curl_dyn_reset(&s->rcvbuf);
} /* while there's buffer left and loop is requested */
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
if(error)
diff --git a/lib/imap.c b/lib/imap.c
index bab531239..754b4d31e 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -1284,7 +1284,7 @@ static CURLcode imap_statemachine(struct Curl_easy *data,
/* Flush any data that needs to be sent */
if(pp->sendleft)
- return Curl_pp_flushsend(pp);
+ return Curl_pp_flushsend(data, pp);
do {
/* Read the response from the server */
diff --git a/lib/multi.c b/lib/multi.c
index 8d6d2cee1..5d4d45073 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -593,7 +593,7 @@ static CURLcode multi_done(struct Curl_easy *data,
if(CURLE_ABORTED_BY_CALLBACK != result) {
/* avoid this if we already aborted by callback to avoid this calling
another callback */
- CURLcode rc = Curl_pgrsDone(conn);
+ CURLcode rc = Curl_pgrsDone(data);
if(!result && rc)
result = CURLE_ABORTED_BY_CALLBACK;
}
@@ -2069,7 +2069,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
DEBUGASSERT(data->conn);
/* if both rates are within spec, resume transfer */
- if(Curl_pgrsUpdate(data->conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, *nowp);
@@ -2352,7 +2352,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
rc = CURLM_CALL_MULTI_PERFORM;
}
/* if there's still a connection to use, call the progress function */
- else if(data->conn && Curl_pgrsUpdate(data->conn)) {
+ else if(data->conn && Curl_pgrsUpdate(data)) {
/* aborted due to progress callback return code must close the
connection */
result = CURLE_ABORTED_BY_CALLBACK;
diff --git a/lib/pingpong.c b/lib/pingpong.c
index 8ff394866..11d219125 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -117,7 +117,7 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data,
if(block) {
/* if we didn't wait, we don't have to spend time on this now */
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, Curl_now());
@@ -469,13 +469,14 @@ int Curl_pp_getsock(struct pingpong *pp, curl_socket_t *socks)
return GETSOCK_READSOCK(0);
}
-CURLcode Curl_pp_flushsend(struct pingpong *pp)
+CURLcode Curl_pp_flushsend(struct Curl_easy *data,
+ struct pingpong *pp)
{
/* we have a piece of a command still left to send */
struct connectdata *conn = pp->conn;
ssize_t written;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
- CURLcode result = Curl_write(conn->data, sock, pp->sendthis + pp->sendsize -
+ CURLcode result = Curl_write(data, sock, pp->sendthis + pp->sendsize -
pp->sendleft, pp->sendleft, &written);
if(result)
return result;
diff --git a/lib/pingpong.h b/lib/pingpong.h
index 3685a99a7..9a0431b42 100644
--- a/lib/pingpong.h
+++ b/lib/pingpong.h
@@ -143,7 +143,8 @@ CURLcode Curl_pp_readresp(struct Curl_easy *data,
size_t *size); /* size of the response */
-CURLcode Curl_pp_flushsend(struct pingpong *pp);
+CURLcode Curl_pp_flushsend(struct Curl_easy *data,
+ struct pingpong *pp);
/* call this when a pingpong connection is disconnected */
CURLcode Curl_pp_disconnect(struct pingpong *pp);
diff --git a/lib/pop3.c b/lib/pop3.c
index 551d0da9c..8683f895a 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -962,7 +962,7 @@ static CURLcode pop3_statemachine(struct Curl_easy *data,
/* Flush any data that needs to be sent */
if(pp->sendleft)
- return Curl_pp_flushsend(pp);
+ return Curl_pp_flushsend(data, pp);
do {
/* Read the response from the server */
diff --git a/lib/progress.c b/lib/progress.c
index 658d05ab8..55e8ded04 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, 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
@@ -137,12 +137,11 @@ static char *max5data(curl_off_t bytes, char *max5)
*/
-int Curl_pgrsDone(struct connectdata *conn)
+int Curl_pgrsDone(struct Curl_easy *data)
{
int rc;
- struct Curl_easy *data = conn->data;
data->progress.lastshow = 0;
- rc = Curl_pgrsUpdate(conn); /* the final (forced) update */
+ rc = Curl_pgrsUpdate(data); /* the final (forced) update */
if(rc)
return rc;
@@ -371,11 +370,10 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
}
/* returns TRUE if it's time to show the progress meter */
-static bool progress_calc(struct connectdata *conn, struct curltime now)
+static bool progress_calc(struct Curl_easy *data, struct curltime now)
{
curl_off_t timespent;
curl_off_t timespent_ms; /* milliseconds */
- struct Curl_easy *data = conn->data;
curl_off_t dl = data->progress.downloaded;
curl_off_t ul = data->progress.uploaded;
bool timetoshow = FALSE;
@@ -465,9 +463,8 @@ static bool progress_calc(struct connectdata *conn, struct curltime now)
}
#ifndef CURL_DISABLE_PROGRESS_METER
-static void progress_meter(struct connectdata *conn)
+static void progress_meter(struct Curl_easy *data)
{
- struct Curl_easy *data = conn->data;
char max5[6][10];
curl_off_t dlpercen = 0;
curl_off_t ulpercen = 0;
@@ -581,11 +578,10 @@ static void progress_meter(struct connectdata *conn)
* Curl_pgrsUpdate() returns 0 for success or the value returned by the
* progress callback!
*/
-int Curl_pgrsUpdate(struct connectdata *conn)
+int Curl_pgrsUpdate(struct Curl_easy *data)
{
- struct Curl_easy *data = conn->data;
struct curltime now = Curl_now(); /* what time is it */
- bool showprogress = progress_calc(conn, now);
+ bool showprogress = progress_calc(data, now);
if(!(data->progress.flags & PGRS_HIDE)) {
if(data->set.fxferinfo) {
int result;
@@ -621,7 +617,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
}
if(showprogress)
- progress_meter(conn);
+ progress_meter(data);
}
return 0;
diff --git a/lib/progress.h b/lib/progress.h
index 74680099f..ac4ebc098 100644
--- a/lib/progress.h
+++ b/lib/progress.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, 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
@@ -40,14 +40,14 @@ typedef enum {
TIMER_LAST /* must be last */
} timerid;
-int Curl_pgrsDone(struct connectdata *);
+int Curl_pgrsDone(struct Curl_easy *data);
void Curl_pgrsStartNow(struct Curl_easy *data);
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
-int Curl_pgrsUpdate(struct connectdata *);
+int Curl_pgrsUpdate(struct Curl_easy *data);
void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer);
timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
diff --git a/lib/rtsp.c b/lib/rtsp.c
index 46d0090e2..e40832513 100644
--- a/lib/rtsp.c
+++ b/lib/rtsp.c
@@ -590,7 +590,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
/* if a request-body has been sent off, we make sure this progress is
noted properly */
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
}
diff --git a/lib/smtp.c b/lib/smtp.c
index d408a6dbe..39351b463 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -1179,7 +1179,7 @@ static CURLcode smtp_statemachine(struct Curl_easy *data,
/* Flush any data that needs to be sent */
if(pp->sendleft)
- return Curl_pp_flushsend(pp);
+ return Curl_pp_flushsend(data, pp);
do {
/* Read the response from the server */
diff --git a/lib/socks.c b/lib/socks.c
index a3186a6ff..64b04dd68 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -51,7 +51,7 @@
*
* This is STUPID BLOCKING behavior. Only used by the SOCKS GSSAPI functions.
*/
-int Curl_blockread_all(struct connectdata *conn, /* connection data */
+int Curl_blockread_all(struct Curl_easy *data, /* transfer */
curl_socket_t sockfd, /* read from this socket */
char *buf, /* store read data here */
ssize_t buffersize, /* max amount to read */
@@ -62,7 +62,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
int result;
*n = 0;
for(;;) {
- timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, TRUE);
+ timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* we already got the timeout */
result = CURLE_OPERATION_TIMEDOUT;
@@ -107,13 +107,14 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
/* always use this function to change state, to make debugging easier */
-static void socksstate(struct connectdata *conn,
+static void socksstate(struct Curl_easy *data,
enum connect_t state
#ifdef DEBUGBUILD
, int lineno
#endif
)
{
+ struct connectdata *conn = data->conn;
enum connect_t oldstate = conn->cnnct.state;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* synced with the state list in urldata.h */
@@ -146,7 +147,7 @@ static void socksstate(struct connectdata *conn,
conn->cnnct.state = state;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- infof(conn->data,
+ infof(data,
"SXSTATE: %s => %s conn %p; line %d\n",
statename[oldstate], statename[conn->cnnct.state], conn,
lineno);
@@ -188,29 +189,29 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
const char *hostname,
int remote_port,
int sockindex,
- struct connectdata *conn,
+ struct Curl_easy *data,
bool *done)
{
+ struct connectdata *conn = data->conn;
const bool protocol4a =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE;
unsigned char *socksreq = &conn->cnnct.socksreq[0];
CURLcode result;
curl_socket_t sockfd = conn->sock[sockindex];
- struct Curl_easy *data = conn->data;
struct connstate *sx = &conn->cnnct;
struct Curl_dns_entry *dns = NULL;
ssize_t actualread;
ssize_t written;
if(!SOCKS_STATE(sx->state) && !*done)
- sxstate(conn, CONNECT_SOCKS_INIT);
+ sxstate(data, CONNECT_SOCKS_INIT);
switch(sx->state) {
case CONNECT_SOCKS_INIT:
/* SOCKS4 can only do IPv4, insist! */
conn->ip_version = CURL_IPRESOLVE_V4;
if(conn->bits.httpproxy)
- infof(conn->data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
+ infof(data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
protocol4a ? "a" : "", hostname, remote_port);
infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
@@ -239,16 +240,16 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
if(rc == CURLRESOLV_ERROR)
return CURLPX_RESOLVE_HOST;
else if(rc == CURLRESOLV_PENDING) {
- sxstate(conn, CONNECT_RESOLVING);
+ sxstate(data, CONNECT_RESOLVING);
infof(data, "SOCKS4 non-blocking resolve of %s\n", hostname);
return CURLPX_OK;
}
- sxstate(conn, CONNECT_RESOLVED);
+ sxstate(data, CONNECT_RESOLVED);
goto CONNECT_RESOLVED;
}
/* socks4a doesn't resolve anything locally */
- sxstate(conn, CONNECT_REQ_INIT);
+ sxstate(data, CONNECT_REQ_INIT);
goto CONNECT_REQ_INIT;
case CONNECT_RESOLVING:
@@ -261,7 +262,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
conn->async.done = TRUE;
#endif
infof(data, "Hostname '%s' was found\n", hostname);
- sxstate(conn, CONNECT_RESOLVED);
+ sxstate(data, CONNECT_RESOLVED);
}
else {
result = Curl_resolv_check(data->conn, &dns);
@@ -352,7 +353,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
}
sx->outp = socksreq;
sx->outstanding = packetsize;
- sxstate(conn, CONNECT_REQ_SENDING);
+ sxstate(data, CONNECT_REQ_SENDING);
}
/* FALLTHROUGH */
case CONNECT_REQ_SENDING:
@@ -373,7 +374,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
/* done sending! */
sx->outstanding = 8; /* receive data size */
sx->outp = socksreq;
- sxstate(conn, CONNECT_SOCKS_READ);
+ sxstate(data, CONNECT_SOCKS_READ);
/* FALLTHROUGH */
case CONNECT_SOCKS_READ:
@@ -396,7 +397,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
sx->outp += actualread;
return CURLPX_OK;
}
- sxstate(conn, CONNECT_DONE);
+ sxstate(data, CONNECT_DONE);
break;
default: /* lots of unused states in SOCKS4 */
break;
@@ -486,7 +487,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
const char *hostname,
int remote_port,
int sockindex,
- struct connectdata *conn,
+ struct Curl_easy *data,
bool *done)
{
/*
@@ -505,6 +506,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
o REP Reply field:
o X'00' succeeded
*/
+ struct connectdata *conn = data->conn;
unsigned char *socksreq = &conn->cnnct.socksreq[0];
char dest[256] = "unknown"; /* printable hostname:port */
int idx;
@@ -512,7 +514,6 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
ssize_t written;
CURLcode result;
curl_socket_t sockfd = conn->sock[sockindex];
- struct Curl_easy *data = conn->data;
bool socks5_resolve_local =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
const size_t hostname_len = strlen(hostname);
@@ -523,23 +524,23 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
struct Curl_dns_entry *dns = NULL;
if(!SOCKS_STATE(sx->state) && !*done)
- sxstate(conn, CONNECT_SOCKS_INIT);
+ sxstate(data, CONNECT_SOCKS_INIT);
switch(sx->state) {
case CONNECT_SOCKS_INIT:
if(conn->bits.httpproxy)
- infof(conn->data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
+ infof(data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
hostname, remote_port);
/* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
if(!socks5_resolve_local && hostname_len > 255) {
- infof(conn->data, "SOCKS5: server resolving disabled for hostnames of "
+ infof(data, "SOCKS5: server resolving disabled for hostnames of "
"length > 255 [actual len=%zu]\n", hostname_len);
socks5_resolve_local = TRUE;
}
if(auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
- infof(conn->data,
+ infof(data,
"warning: unsupported value passed to CURLOPT_SOCKS5_AUTH: %lu\n",
auth);
if(!(auth & CURLAUTH_BASIC))
@@ -567,12 +568,12 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
return CURLPX_SEND_CONNECT;
}
if(written != idx) {
- sxstate(conn, CONNECT_SOCKS_SEND);
+ sxstate(data, CONNECT_SOCKS_SEND);
sx->outstanding = idx - written;
sx->outp = &socksreq[written];
return CURLPX_OK;
}
- sxstate(conn, CONNECT_SOCKS_READ);
+ sxstate(data, CONNECT_SOCKS_READ);
goto CONNECT_SOCKS_READ_INIT;
case CONNECT_SOCKS_SEND:
result = Curl_write_plain(data, sockfd, (char *)sx->outp,
@@ -617,18 +618,18 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
}
else if(socksreq[1] == 0) {
/* DONE! No authentication needed. Send request. */
- sxstate(conn, CONNECT_REQ_INIT);
+ sxstate(data, CONNECT_REQ_INIT);
goto CONNECT_REQ_INIT;
}
else if(socksreq[1] == 2) {
/* regular name + password authentication */
- sxstate(conn, CONNECT_AUTH_INIT);
+ sxstate(data, CONNECT_AUTH_INIT);
goto CONNECT_AUTH_INIT;
}
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
else if(allow_gssapi && (socksreq[1] == 1)) {
- sxstate(conn, CONNECT_GSSAPI_INIT);
- result = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
+ sxstate(data, CONNECT_GSSAPI_INIT);
+ result = Curl_SOCKS5_gssapi_negotiate(sockindex, data);
if(result) {
failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
return CURLPX_GSSAPI;
@@ -701,7 +702,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
memcpy(socksreq + len, proxy_password, proxy_password_len);
}
len += proxy_password_len;
- sxstate(conn, CONNECT_AUTH_SEND);
+ sxstate(data, CONNECT_AUTH_SEND);
sx->outstanding = len;
sx->outp = socksreq;
}
@@ -721,7 +722,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
}
sx->outp = socksreq;
sx->outstanding = 2;
- sxstate(conn, CONNECT_AUTH_READ);
+ sxstate(data, CONNECT_AUTH_READ);
/* FALLTHROUGH */
case CONNECT_AUTH_READ:
result = Curl_read_plain(sockfd, (char *)sx->outp,
@@ -749,7 +750,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
}
/* Everything is good so far, user was authenticated! */
- sxstate(conn, CONNECT_REQ_INIT);
+ sxstate(data, CONNECT_REQ_INIT);
/* FALLTHROUGH */
CONNECT_REQ_INIT:
case CONNECT_REQ_INIT:
@@ -761,10 +762,10 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
return CURLPX_RESOLVE_HOST;
if(rc == CURLRESOLV_PENDING) {
- sxstate(conn, CONNECT_RESOLVING);
+ sxstate(data, CONNECT_RESOLVING);
return CURLPX_OK;
}
- sxstate(conn, CONNECT_RESOLVED);
+ sxstate(data, CONNECT_RESOLVED);
goto CONNECT_RESOLVED;
}
goto CONNECT_RESOLVE_REMOTE;
@@ -878,7 +879,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
#endif
sx->outp = socksreq;
sx->outstanding = len;
- sxstate(conn, CONNECT_REQ_SENDING);
+ sxstate(data, CONNECT_REQ_SENDING);
/* FALLTHROUGH */
case CONNECT_REQ_SENDING:
result = Curl_write_plain(data, sockfd, (char *)sx->outp,
@@ -901,7 +902,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
#endif
sx->outstanding = 10; /* minimum packet size is 10 */
sx->outp = socksreq;
- sxstate(conn, CONNECT_REQ_READ);
+ sxstate(data, CONNECT_REQ_READ);
/* FALLTHROUGH */
case CONNECT_REQ_READ:
result = Curl_read_plain(sockfd, (char *)sx->outp,
@@ -992,10 +993,10 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
if(len > 10) {
sx->outstanding = len - 10; /* get the rest */
sx->outp = &socksreq[10];
- sxstate(conn, CONNECT_REQ_READ_MORE);
+ sxstate(data, CONNECT_REQ_READ_MORE);
}
else {
- sxstate(conn, CONNECT_DONE);
+ sxstate(data, CONNECT_DONE);
break;
}
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
@@ -1020,7 +1021,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
sx->outp += actualread;
return CURLPX_OK;
}
- sxstate(conn, CONNECT_DONE);
+ sxstate(data, CONNECT_DONE);
}
infof(data, "SOCKS5 request granted.\n");
diff --git a/lib/socks.h b/lib/socks.h
index 1fae58b6f..b0c7f9b26 100644
--- a/lib/socks.h
+++ b/lib/socks.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, 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
@@ -35,7 +35,7 @@
*
* This is STUPID BLOCKING behavior
*/
-int Curl_blockread_all(struct connectdata *conn,
+int Curl_blockread_all(struct Curl_easy *data,
curl_socket_t sockfd,
char *buf,
ssize_t buffersize,
@@ -52,7 +52,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_name,
const char *hostname,
int remote_port,
int sockindex,
- struct connectdata *conn,
+ struct Curl_easy *data,
bool *done);
/*
@@ -64,7 +64,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_name,
const char *hostname,
int remote_port,
int sockindex,
- struct connectdata *conn,
+ struct Curl_easy *data,
bool *done);
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
@@ -72,7 +72,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_name,
* This function handles the SOCKS5 GSS-API negotiation and initialisation
*/
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
- struct connectdata *conn);
+ struct Curl_easy *data);
#endif
#endif /* CURL_DISABLE_PROXY */
diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c
index 467433828..3ab786d0b 100644
--- a/lib/socks_gssapi.c
+++ b/lib/socks_gssapi.c
@@ -100,9 +100,9 @@ static int check_gss_err(struct Curl_easy *data,
}
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
- struct connectdata *conn)
+ struct Curl_easy *data)
{
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
curl_socket_t sock = conn->sock[sockindex];
CURLcode code;
ssize_t actualread;
@@ -240,7 +240,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
* +----+------+-----+----------------+
*/
- result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
+ result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) {
failf(data, "Failed to receive GSS-API authentication response.");
gss_release_name(&gss_status, &server);
@@ -279,7 +279,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_OUT_OF_MEMORY;
}
- result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
+ result = Curl_blockread_all(data, sock, (char *)gss_recv_token.value,
gss_recv_token.length, &actualread);
if(result || (actualread != us_length)) {
@@ -437,7 +437,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_w_token);
}
- result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
+ result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) {
failf(data, "Failed to receive GSS-API encryption response.");
gss_delete_sec_context(&gss_status, &gss_context, NULL);
@@ -468,7 +468,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_delete_sec_context(&gss_status, &gss_context, NULL);
return CURLE_OUT_OF_MEMORY;
}
- result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
+ result = Curl_blockread_all(data, sock, (char *)gss_recv_token.value,
gss_recv_token.length, &actualread);
if(result || (actualread != us_length)) {
diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c
index 516a5bcd6..b343538f0 100644
--- a/lib/socks_sspi.c
+++ b/lib/socks_sspi.c
@@ -43,7 +43,7 @@
/*
* Helper sspi error functions.
*/
-static int check_sspi_err(struct connectdata *conn,
+static int check_sspi_err(struct Curl_easy *data,
SECURITY_STATUS status,
const char *function)
{
@@ -52,7 +52,7 @@ static int check_sspi_err(struct connectdata *conn,
status != SEC_I_COMPLETE_NEEDED &&
status != SEC_I_CONTINUE_NEEDED) {
char buffer[STRERROR_LEN];
- failf(conn->data, "SSPI error: %s failed: %s", function,
+ failf(data, "SSPI error: %s failed: %s", function,
Curl_sspi_strerror(status, buffer, sizeof(buffer)));
return 1;
}
@@ -61,9 +61,9 @@ static int check_sspi_err(struct connectdata *conn,
/* This is the SSPI-using version of this function */
CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
- struct connectdata *conn)
+ struct Curl_easy *data)
{
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
curl_socket_t sock = conn->sock[sockindex];
CURLcode code;
ssize_t actualread;
@@ -86,7 +86,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
unsigned long qop;
unsigned char socksreq[4]; /* room for GSS-API exchange header only */
const char *service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
- data->set.str[STRING_PROXY_SERVICE_NAME] : "rcmd";
+ data->set.str[STRING_PROXY_SERVICE_NAME] : "rcmd";
const size_t service_length = strlen(service);
/* GSS-API request looks like
@@ -146,7 +146,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
&cred_handle,
&expiry);
- if(check_sspi_err(conn, status, "AcquireCredentialsHandle")) {
+ if(check_sspi_err(data, status, "AcquireCredentialsHandle")) {
failf(data, "Failed to acquire credentials.");
free(service_name);
s_pSecFn->FreeCredentialsHandle(&cred_handle);
@@ -188,7 +188,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
sspi_recv_token.cbBuffer = 0;
}
- if(check_sspi_err(conn, status, "InitializeSecurityContext")) {
+ if(check_sspi_err(data, status, "InitializeSecurityContext")) {
free(service_name);
s_pSecFn->FreeCredentialsHandle(&cred_handle);
s_pSecFn->DeleteSecurityContext(&sspi_context);
@@ -258,7 +258,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
* +----+------+-----+----------------+
*/
- result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
+ result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) {
failf(data, "Failed to receive SSPI authentication response.");
free(service_name);
@@ -298,7 +298,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
s_pSecFn->DeleteSecurityContext(&sspi_context);
return CURLE_OUT_OF_MEMORY;
}
- result = Curl_blockread_all(conn, sock, (char *)sspi_recv_token.pvBuffer,
+ result = Curl_blockread_all(data, sock, (char *)sspi_recv_token.pvBuffer,
sspi_recv_token.cbBuffer, &actualread);
if(result || (actualread != us_length)) {
@@ -321,7 +321,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
SECPKG_CRED_ATTR_NAMES,
&names);
s_pSecFn->FreeCredentialsHandle(&cred_handle);
- if(check_sspi_err(conn, status, "QueryCredentialAttributes")) {
+ if(check_sspi_err(data, status, "QueryCredentialAttributes")) {
s_pSecFn->DeleteSecurityContext(&sspi_context);
s_pSecFn->FreeContextBuffer(names.sUserName);
failf(data, "Failed to determine user name.");
@@ -386,7 +386,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
status = s_pSecFn->QueryContextAttributes(&sspi_context,
SECPKG_ATTR_SIZES,
&sspi_sizes);
- if(check_sspi_err(conn, status, "QueryContextAttributes")) {
+ if(check_sspi_err(data, status, "QueryContextAttributes")) {
s_pSecFn->DeleteSecurityContext(&sspi_context);
failf(data, "Failed to query security context attributes.");
return CURLE_COULDNT_CONNECT;
@@ -423,7 +423,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
KERB_WRAP_NO_ENCRYPT,
&wrap_desc,
0);
- if(check_sspi_err(conn, status, "EncryptMessage")) {
+ if(check_sspi_err(data, status, "EncryptMessage")) {
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
s_pSecFn->FreeContextBuffer(sspi_w_token[1].pvBuffer);
s_pSecFn->FreeContextBuffer(sspi_w_token[2].pvBuffer);
@@ -498,7 +498,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
}
- result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
+ result = Curl_blockread_all(data, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) {
failf(data, "Failed to receive SSPI encryption response.");
s_pSecFn->DeleteSecurityContext(&sspi_context);
@@ -530,7 +530,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_OUT_OF_MEMORY;
}
- result = Curl_blockread_all(conn, sock, (char *)sspi_w_token[0].pvBuffer,
+ result = Curl_blockread_all(data, sock, (char *)sspi_w_token[0].pvBuffer,
sspi_w_token[0].cbBuffer, &actualread);
if(result || (actualread != us_length)) {
@@ -553,7 +553,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
0,
&qop);
- if(check_sspi_err(conn, status, "DecryptMessage")) {
+ if(check_sspi_err(data, status, "DecryptMessage")) {
if(sspi_w_token[0].pvBuffer)
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
if(sspi_w_token[1].pvBuffer)
diff --git a/lib/telnet.c b/lib/telnet.c
index ef99920b1..63b11605a 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -88,7 +88,7 @@
#endif
static
-CURLcode telrcv(struct connectdata *,
+CURLcode telrcv(struct Curl_easy *data,
const unsigned char *inbuf, /* Data received from socket */
ssize_t count); /* Number of bytes received */
@@ -98,18 +98,18 @@ static void printoption(struct Curl_easy *data,
int cmd, int option);
#endif
-static void negotiate(struct connectdata *);
-static void send_negotiation(struct connectdata *, int cmd, int option);
-static void set_local_option(struct connectdata *conn,
+static void negotiate(struct Curl_easy *data);
+static void send_negotiation(struct Curl_easy *data, int cmd, int option);
+static void set_local_option(struct Curl_easy *data,
int option, int newstate);
-static void set_remote_option(struct connectdata *conn,
+static void set_remote_option(struct Curl_easy *data,
int option, int newstate);
static void printsub(struct Curl_easy *data,
int direction, unsigned char *pointer,
size_t length);
-static void suboption(struct connectdata *);
-static void sendsuboption(struct connectdata *conn, int option);
+static void suboption(struct Curl_easy *data);
+static void sendsuboption(struct Curl_easy *data, int option);
static CURLcode telnet_do(struct Curl_easy *data, bool *done);
static CURLcode telnet_done(struct Curl_easy *data,
@@ -194,7 +194,7 @@ const struct Curl_handler Curl_handler_telnet = {
static
-CURLcode init_telnet(struct connectdata *conn)
+CURLcode init_telnet(struct Curl_easy *data)
{
struct TELNET *tn;
@@ -202,7 +202,7 @@ CURLcode init_telnet(struct connectdata *conn)
if(!tn)
return CURLE_OUT_OF_MEMORY;
- conn->data->req.p.telnet = tn; /* make us known */
+ data->req.p.telnet = tn; /* make us known */
tn->telrcv_state = CURL_TS_DATA;
@@ -244,20 +244,20 @@ CURLcode init_telnet(struct connectdata *conn)
return CURLE_OK;
}
-static void negotiate(struct connectdata *conn)
+static void negotiate(struct Curl_easy *data)
{
int i;
- struct TELNET *tn = (struct TELNET *) conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
for(i = 0; i < CURL_NTELOPTS; i++) {
if(i == CURL_TELOPT_ECHO)
continue;
if(tn->us_preferred[i] == CURL_YES)
- set_local_option(conn, i, CURL_YES);
+ set_local_option(data, i, CURL_YES);
if(tn->him_preferred[i] == CURL_YES)
- set_remote_option(conn, i, CURL_YES);
+ set_remote_option(data, i, CURL_YES);
}
}
@@ -298,34 +298,34 @@ static void printoption(struct Curl_easy *data,
}
#endif
-static void send_negotiation(struct connectdata *conn, int cmd, int option)
+static void send_negotiation(struct Curl_easy *data, int cmd, int option)
{
- unsigned char buf[3];
- ssize_t bytes_written;
- struct Curl_easy *data = conn->data;
+ unsigned char buf[3];
+ ssize_t bytes_written;
+ struct connectdata *conn = data->conn;
- buf[0] = CURL_IAC;
- buf[1] = (unsigned char)cmd;
- buf[2] = (unsigned char)option;
+ buf[0] = CURL_IAC;
+ buf[1] = (unsigned char)cmd;
+ buf[2] = (unsigned char)option;
- bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
- if(bytes_written < 0) {
- int err = SOCKERRNO;
- failf(data,"Sending data failed (%d)",err);
- }
+ bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
+ if(bytes_written < 0) {
+ int err = SOCKERRNO;
+ failf(data,"Sending data failed (%d)",err);
+ }
- printoption(conn->data, "SENT", cmd, option);
+ printoption(data, "SENT", cmd, option);
}
static
-void set_remote_option(struct connectdata *conn, int option, int newstate)
+void set_remote_option(struct Curl_easy *data, int option, int newstate)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
if(newstate == CURL_YES) {
switch(tn->him[option]) {
case CURL_NO:
tn->him[option] = CURL_WANTYES;
- send_negotiation(conn, CURL_DO, option);
+ send_negotiation(data, CURL_DO, option);
break;
case CURL_YES:
@@ -364,7 +364,7 @@ void set_remote_option(struct connectdata *conn, int option, int newstate)
case CURL_YES:
tn->him[option] = CURL_WANTNO;
- send_negotiation(conn, CURL_DONT, option);
+ send_negotiation(data, CURL_DONT, option);
break;
case CURL_WANTNO:
@@ -392,17 +392,17 @@ void set_remote_option(struct connectdata *conn, int option, int newstate)
}
static
-void rec_will(struct connectdata *conn, int option)
+void rec_will(struct Curl_easy *data, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
switch(tn->him[option]) {
case CURL_NO:
if(tn->him_preferred[option] == CURL_YES) {
tn->him[option] = CURL_YES;
- send_negotiation(conn, CURL_DO, option);
+ send_negotiation(data, CURL_DO, option);
}
else
- send_negotiation(conn, CURL_DONT, option);
+ send_negotiation(data, CURL_DONT, option);
break;
@@ -432,7 +432,7 @@ void rec_will(struct connectdata *conn, int option)
case CURL_OPPOSITE:
tn->him[option] = CURL_WANTNO;
tn->himq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_DONT, option);
+ send_negotiation(data, CURL_DONT, option);
break;
}
break;
@@ -440,9 +440,9 @@ void rec_will(struct connectdata *conn, int option)
}
static
-void rec_wont(struct connectdata *conn, int option)
+void rec_wont(struct Curl_easy *data, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
switch(tn->him[option]) {
case CURL_NO:
/* Already disabled */
@@ -450,7 +450,7 @@ void rec_wont(struct connectdata *conn, int option)
case CURL_YES:
tn->him[option] = CURL_NO;
- send_negotiation(conn, CURL_DONT, option);
+ send_negotiation(data, CURL_DONT, option);
break;
case CURL_WANTNO:
@@ -462,7 +462,7 @@ void rec_wont(struct connectdata *conn, int option)
case CURL_OPPOSITE:
tn->him[option] = CURL_WANTYES;
tn->himq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_DO, option);
+ send_negotiation(data, CURL_DO, option);
break;
}
break;
@@ -482,14 +482,14 @@ void rec_wont(struct connectdata *conn, int option)
}
static void
-set_local_option(struct connectdata *conn, int option, int newstate)
+set_local_option(struct Curl_easy *data, int option, int newstate)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
if(newstate == CURL_YES) {
switch(tn->us[option]) {
case CURL_NO:
tn->us[option] = CURL_WANTYES;
- send_negotiation(conn, CURL_WILL, option);
+ send_negotiation(data, CURL_WILL, option);
break;
case CURL_YES:
@@ -528,7 +528,7 @@ set_local_option(struct connectdata *conn, int option, int newstate)
case CURL_YES:
tn->us[option] = CURL_WANTNO;
- send_negotiation(conn, CURL_WONT, option);
+ send_negotiation(data, CURL_WONT, option);
break;
case CURL_WANTNO:
@@ -556,26 +556,26 @@ set_local_option(struct connectdata *conn, int option, int newstate)
}
static
-void rec_do(struct connectdata *conn, int option)
+void rec_do(struct Curl_easy *data, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
switch(tn->us[option]) {
case CURL_NO:
if(tn->us_preferred[option] == CURL_YES) {
tn->us[option] = CURL_YES;
- send_negotiation(conn, CURL_WILL, option);
+ send_negotiation(data, CURL_WILL, option);
if(tn->subnegotiation[option] == CURL_YES)
/* transmission of data option */
- sendsuboption(conn, option);
+ sendsuboption(data, option);
}
else if(tn->subnegotiation[option] == CURL_YES) {
/* send information to achieve this option*/
tn->us[option] = CURL_YES;
- send_negotiation(conn, CURL_WILL, option);
- sendsuboption(conn, option);
+ send_negotiation(data, CURL_WILL, option);
+ sendsuboption(data, option);
}
else
- send_negotiation(conn, CURL_WONT, option);
+ send_negotiation(data, CURL_WONT, option);
break;
case CURL_YES:
@@ -602,13 +602,13 @@ void rec_do(struct connectdata *conn, int option)
tn->us[option] = CURL_YES;
if(tn->subnegotiation[option] == CURL_YES) {
/* transmission of data option */
- sendsuboption(conn, option);
+ sendsuboption(data, option);
}
break;
case CURL_OPPOSITE:
tn->us[option] = CURL_WANTNO;
tn->himq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_WONT, option);
+ send_negotiation(data, CURL_WONT, option);
break;
}
break;
@@ -616,9 +616,9 @@ void rec_do(struct connectdata *conn, int option)
}
static
-void rec_dont(struct connectdata *conn, int option)
+void rec_dont(struct Curl_easy *data, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
switch(tn->us[option]) {
case CURL_NO:
/* Already disabled */
@@ -626,7 +626,7 @@ void rec_dont(struct connectdata *conn, int option)
case CURL_YES:
tn->us[option] = CURL_NO;
- send_negotiation(conn, CURL_WONT, option);
+ send_negotiation(data, CURL_WONT, option);
break;
case CURL_WANTNO:
@@ -638,7 +638,7 @@ void rec_dont(struct connectdata *conn, int option)
case CURL_OPPOSITE:
tn->us[option] = CURL_WANTYES;
tn->usq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_WILL, option);
+ send_negotiation(data, CURL_WILL, option);
break;
}
break;
@@ -770,14 +770,14 @@ static void printsub(struct Curl_easy *data,
}
}
-static CURLcode check_telnet_options(struct connectdata *conn)
+static CURLcode check_telnet_options(struct Curl_easy *data)
{
struct curl_slist *head;
struct curl_slist *beg;
char option_keyword[128] = "";
char option_arg[256] = "";
- struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
+ struct connectdata *conn = data->conn;
CURLcode result = CURLE_OK;
int binary_option;
@@ -874,7 +874,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
* side.
*/
-static void suboption(struct connectdata *conn)
+static void suboption(struct Curl_easy *data)
{
struct curl_slist *v;
unsigned char temp[2048];
@@ -883,8 +883,8 @@ static void suboption(struct connectdata *conn)
int err;
char varname[128] = "";
char varval[128] = "";
- struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
+ struct connectdata *conn = data->conn;
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
switch(CURL_SB_GET(tn)) {
@@ -951,15 +951,14 @@ static void suboption(struct connectdata *conn)
* Send suboption information to the server side.
*/
-static void sendsuboption(struct connectdata *conn, int option)
+static void sendsuboption(struct Curl_easy *data, int option)
{
ssize_t bytes_written;
int err;
unsigned short x, y;
unsigned char *uc1, *uc2;
-
- struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
+ struct connectdata *conn = data->conn;
switch(option) {
case CURL_TELOPT_NAWS:
@@ -1008,7 +1007,7 @@ static void sendsuboption(struct connectdata *conn, int option)
static
-CURLcode telrcv(struct connectdata *conn,
+CURLcode telrcv(struct Curl_easy *data,
const unsigned char *inbuf, /* Data received from socket */
ssize_t count) /* Number of bytes received */
{
@@ -1016,8 +1015,7 @@ CURLcode telrcv(struct connectdata *conn,
CURLcode result;
int in = 0;
int startwrite = -1;
- struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
#define startskipping() \
if(startwrite >= 0) { \
@@ -1097,28 +1095,28 @@ CURLcode telrcv(struct connectdata *conn,
case CURL_TS_WILL:
printoption(data, "RCVD", CURL_WILL, c);
tn->please_negotiate = 1;
- rec_will(conn, c);
+ rec_will(data, c);
tn->telrcv_state = CURL_TS_DATA;
break;
case CURL_TS_WONT:
printoption(data, "RCVD", CURL_WONT, c);
tn->please_negotiate = 1;
- rec_wont(conn, c);
+ rec_wont(data, c);
tn->telrcv_state = CURL_TS_DATA;
break;
case CURL_TS_DO:
printoption(data, "RCVD", CURL_DO, c);
tn->please_negotiate = 1;
- rec_do(conn, c);
+ rec_do(data, c);
tn->telrcv_state = CURL_TS_DATA;
break;
case CURL_TS_DONT:
printoption(data, "RCVD", CURL_DONT, c);
tn->please_negotiate = 1;
- rec_dont(conn, c);
+ rec_dont(data, c);
tn->telrcv_state = CURL_TS_DATA;
break;
@@ -1147,7 +1145,7 @@ CURLcode telrcv(struct connectdata *conn,
CURL_SB_TERM(tn);
printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
- suboption(conn); /* handle sub-option */
+ suboption(data); /* handle sub-option */
tn->telrcv_state = CURL_TS_IAC;
goto process_iac;
}
@@ -1159,7 +1157,7 @@ CURLcode telrcv(struct connectdata *conn,
CURL_SB_ACCUM(tn, CURL_SE);
tn->subpointer -= 2;
CURL_SB_TERM(tn);
- suboption(conn); /* handle sub-option */
+ suboption(data); /* handle sub-option */
tn->telrcv_state = CURL_TS_DATA;
}
break;
@@ -1236,8 +1234,7 @@ static CURLcode send_telnet_data(struct Curl_easy *data,
static CURLcode telnet_done(struct Curl_easy *data,
CURLcode status, bool premature)
{
- struct connectdata *conn = data->conn;
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = data->req.p.telnet;
(void)status; /* unused */
(void)premature; /* not used */
@@ -1247,7 +1244,7 @@ static CURLcode telnet_done(struct Curl_easy *data,
curl_slist_free_all(tn->telnet_vars);
tn->telnet_vars = NULL;
- Curl_safefree(conn->data->req.p.telnet);
+ Curl_safefree(data->req.p.telnet);
return CURLE_OK;
}
@@ -1281,13 +1278,13 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
*done = TRUE; /* unconditionally */
- result = init_telnet(conn);
+ result = init_telnet(data);
if(result)
return result;
tn = data->req.p.telnet;
- result = check_telnet_options(conn);
+ result = check_telnet_options(data);
if(result)
return result;
@@ -1436,7 +1433,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
break;
}
- result = telrcv(conn, (unsigned char *) buf, nread);
+ result = telrcv(data, (unsigned char *) buf, nread);
if(result) {
keepon = FALSE;
break;
@@ -1446,7 +1443,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
otherwise don't. We don't want to speak telnet with
non-telnet servers, like POP or SMTP. */
if(tn->please_negotiate && !tn->already_negotiated) {
- negotiate(conn);
+ negotiate(data);
tn->already_negotiated = 1;
}
}
@@ -1518,7 +1515,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
total_dl += nread;
Curl_pgrsSetDownloadCounter(data, total_dl);
- result = telrcv(conn, (unsigned char *)buf, nread);
+ result = telrcv(data, (unsigned char *)buf, nread);
if(result) {
keepon = FALSE;
break;
@@ -1528,7 +1525,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
otherwise don't. We don't want to speak telnet with
non-telnet servers, like POP or SMTP. */
if(tn->please_negotiate && !tn->already_negotiated) {
- negotiate(conn);
+ negotiate(data);
tn->already_negotiated = 1;
}
}
@@ -1575,7 +1572,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
}
}
- if(Curl_pgrsUpdate(conn)) {
+ if(Curl_pgrsUpdate(data)) {
result = CURLE_ABORTED_BY_CALLBACK;
break;
}
diff --git a/lib/tftp.c b/lib/tftp.c
index c6af20e59..0eee4ef88 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -1093,7 +1093,7 @@ static CURLcode tftp_done(struct Curl_easy *data, CURLcode status,
(void)status; /* unused */
(void)premature; /* not used */
- if(Curl_pgrsDone(conn))
+ if(Curl_pgrsDone(data))
return CURLE_ABORTED_BY_CALLBACK;
/* If we have encountered an error */
@@ -1201,7 +1201,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data)
}
/* Update the progress meter */
- if(Curl_pgrsUpdate(conn)) {
+ if(Curl_pgrsUpdate(data)) {
tftp_state_machine(state, TFTP_EVENT_ERROR);
return CURLE_ABORTED_BY_CALLBACK;
}
@@ -1323,7 +1323,7 @@ static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done)
/* The multi code doesn't have this logic for the DOING state so we
provide it for TFTP since it may do the entire transfer in this
state. */
- if(Curl_pgrsUpdate(data->conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, Curl_now());
diff --git a/lib/transfer.c b/lib/transfer.c
index 0a65c99b5..59b351519 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1259,7 +1259,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, k->now);
@@ -1318,7 +1318,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
failf(data, "transfer closed with outstanding read data remaining");
return CURLE_PARTIAL_FILE;
}
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
}
diff --git a/lib/url.c b/lib/url.c
index f8a7876b4..4a145b028 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -829,26 +829,23 @@ CURLcode Curl_disconnect(struct Curl_easy *data,
/* Cleanup NEGOTIATE connection-related data */
Curl_http_auth_cleanup_negotiate(conn);
- /* the protocol specific disconnect handler and conn_shutdown need a transfer
- for the connection! */
- conn->data = data;
-
if(conn->bits.connect_only)
/* treat the connection as dead in CONNECT_ONLY situations */
dead_connection = TRUE;
- if(conn->handler->disconnect) {
- /* During disconnect, the connection and the transfer is already
- disassociated, but the SSH backends (and more?) still need the
- transfer's connection pointer to identify the used connection */
- data->conn = conn;
+ /* temporarily attach the connection to this transfer handle for the
+ disonnect and shutdown */
+ Curl_attach_connnection(data, conn);
+ if(conn->handler->disconnect)
/* This is set if protocol-specific cleanups should be made */
conn->handler->disconnect(data, conn, dead_connection);
- data->conn = NULL; /* forget it again */
- }
conn_shutdown(data, conn);
+
+ /* detach it again */
+ Curl_detach_connnection(data);
+
conn_free(conn);
return CURLE_OK;
}
@@ -1111,7 +1108,7 @@ ConnectionExists(struct Curl_easy *data,
/* Look up the bundle with all the connections to this particular host.
Locks the connection cache, beware of early returns! */
- bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache,
+ bundle = Curl_conncache_find_bundle(data, needle, data->state.conn_cache,
&hostbundle);
if(bundle) {
/* Max pipe length is zero (unlimited) for multiplexed connections */
@@ -3650,7 +3647,7 @@ static CURLcode create_conn(struct Curl_easy *data,
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
Curl_attach_connnection(data, conn);
- result = Curl_conncache_add_conn(data->state.conn_cache, conn);
+ result = Curl_conncache_add_conn(data);
if(result)
goto out;
@@ -3820,7 +3817,8 @@ static CURLcode create_conn(struct Curl_easy *data,
/* this gets a lock on the conncache */
const char *bundlehost;
struct connectbundle *bundle =
- Curl_conncache_find_bundle(conn, data->state.conn_cache, &bundlehost);
+ Curl_conncache_find_bundle(data, conn, data->state.conn_cache,
+ &bundlehost);
if(max_host_connections > 0 && bundle &&
(bundle->num_connections >= max_host_connections)) {
@@ -3873,8 +3871,7 @@ static CURLcode create_conn(struct Curl_easy *data,
* cache of ours!
*/
Curl_attach_connnection(data, conn);
-
- result = Curl_conncache_add_conn(data->state.conn_cache, conn);
+ result = Curl_conncache_add_conn(data);
if(result)
goto out;
}
diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
index 3b630bcfa..e702b67b1 100644
--- a/lib/vssh/libssh.c
+++ b/lib/vssh/libssh.c
@@ -131,8 +131,8 @@ CURLcode sftp_perform(struct Curl_easy *data,
bool *connected,
bool *dophase_done);
-static void sftp_quote(struct connectdata *conn);
-static void sftp_quote_stat(struct connectdata *conn);
+static void sftp_quote(struct Curl_easy *data);
+static void sftp_quote_stat(struct Curl_easy *data);
static int myssh_getsock(struct Curl_easy *data,
struct connectdata *conn, curl_socket_t *sock);
@@ -226,12 +226,13 @@ static CURLcode sftp_error_to_CURLE(int err)
* SSH State machine related code
*/
/* This is the ONLY way to change SSH state! */
-static void mystate(struct connectdata *conn, sshstate nowstate
+static void mystate(struct Curl_easy *data, sshstate nowstate
#ifdef DEBUGBUILD
, int lineno
#endif
)
{
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* for debug purposes */
@@ -300,7 +301,7 @@ static void mystate(struct connectdata *conn, sshstate nowstate
if(sshc->state != nowstate) {
- infof(conn->data, "SSH %p state change from %s to %s (line %d)\n",
+ infof(data, "SSH %p state change from %s to %s (line %d)\n",
(void *) sshc, names[sshc->state], names[nowstate],
lineno);
}
@@ -319,10 +320,10 @@ static void mystate(struct connectdata *conn, sshstate nowstate
*
* Returns SSH_OK or SSH_ERROR.
*/
-static int myssh_is_known(struct connectdata *conn)
+static int myssh_is_known(struct Curl_easy *data)
{
int rc;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
ssh_key pubkey;
size_t hlen;
@@ -549,14 +550,14 @@ cleanup:
}
#define MOVE_TO_ERROR_STATE(_r) { \
- state(conn, SSH_SESSION_DISCONNECT); \
+ state(data, SSH_SESSION_DISCONNECT); \
sshc->actualcode = _r; \
rc = SSH_ERROR; \
break; \
}
#define MOVE_TO_SFTP_CLOSE_STATE() { \
- state(conn, SSH_SFTP_CLOSE); \
+ state(data, SSH_SFTP_CLOSE); \
sshc->actualcode = sftp_error_to_CURLE(sftp_get_error(sshc->sftp_session)); \
rc = SSH_ERROR; \
break; \
@@ -565,7 +566,7 @@ cleanup:
#define MOVE_TO_LAST_AUTH \
if(sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD) { \
rc = SSH_OK; \
- state(conn, SSH_AUTH_PASS_INIT); \
+ state(data, SSH_AUTH_PASS_INIT); \
break; \
} \
else { \
@@ -575,7 +576,7 @@ cleanup:
#define MOVE_TO_TERTIARY_AUTH \
if(sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) { \
rc = SSH_OK; \
- state(conn, SSH_AUTH_KEY_INIT); \
+ state(data, SSH_AUTH_KEY_INIT); \
break; \
} \
else { \
@@ -585,7 +586,7 @@ cleanup:
#define MOVE_TO_SECONDARY_AUTH \
if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) { \
rc = SSH_OK; \
- state(conn, SSH_AUTH_GSSAPI); \
+ state(data, SSH_AUTH_GSSAPI); \
break; \
} \
else { \
@@ -692,7 +693,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
non-blocking */
ssh_set_blocking(sshc->ssh_session, 0);
- state(conn, SSH_S_STARTUP);
+ state(data, SSH_S_STARTUP);
/* FALLTHROUGH */
case SSH_S_STARTUP:
@@ -705,17 +706,17 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
MOVE_TO_ERROR_STATE(CURLE_FAILED_INIT);
}
- state(conn, SSH_HOSTKEY);
+ state(data, SSH_HOSTKEY);
/* FALLTHROUGH */
case SSH_HOSTKEY:
- rc = myssh_is_known(conn);
+ rc = myssh_is_known(data);
if(rc != SSH_OK) {
MOVE_TO_ERROR_STATE(CURLE_PEER_FAILED_VERIFICATION);
}
- state(conn, SSH_AUTHLIST);
+ state(data, SSH_AUTHLIST);
/* FALLTHROUGH */
case SSH_AUTHLIST:{
sshc->authed = FALSE;
@@ -729,7 +730,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
if(rc == SSH_AUTH_SUCCESS) {
sshc->authed = TRUE;
infof(data, "Authenticated with none\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
}
else if(rc == SSH_AUTH_ERROR) {
@@ -738,17 +739,17 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->auth_methods = ssh_userauth_list(sshc->ssh_session, NULL);
if(sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
- state(conn, SSH_AUTH_PKEY_INIT);
+ state(data, SSH_AUTH_PKEY_INIT);
infof(data, "Authentication using SSH public key file\n");
}
else if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) {
- state(conn, SSH_AUTH_GSSAPI);
+ state(data, SSH_AUTH_GSSAPI);
}
else if(sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) {
- state(conn, SSH_AUTH_KEY_INIT);
+ state(data, SSH_AUTH_KEY_INIT);
}
else if(sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD) {
- state(conn, SSH_AUTH_PASS_INIT);
+ state(data, SSH_AUTH_PASS_INIT);
}
else { /* unsupported authentication method */
MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
@@ -788,7 +789,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
break;
}
- state(conn, SSH_AUTH_PKEY);
+ state(data, SSH_AUTH_PKEY);
break;
}
@@ -803,7 +804,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
rc = SSH_OK;
sshc->authed = TRUE;
infof(data, "Completed public key authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
}
@@ -820,7 +821,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
if(rc == SSH_AUTH_SUCCESS) {
sshc->authed = TRUE;
infof(data, "Completed public key authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
}
else {
@@ -844,7 +845,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
rc = SSH_OK;
sshc->authed = TRUE;
infof(data, "Completed gssapi authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
}
@@ -853,7 +854,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
case SSH_AUTH_KEY_INIT:
if(data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD) {
- state(conn, SSH_AUTH_KEY);
+ state(data, SSH_AUTH_KEY);
}
else {
MOVE_TO_LAST_AUTH;
@@ -871,7 +872,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->authed = TRUE;
infof(data, "completed keyboard interactive authentication\n");
}
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
case SSH_AUTH_PASS_INIT:
@@ -879,7 +880,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
/* Host key authentication is intentionally not implemented */
MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
}
- state(conn, SSH_AUTH_PASS);
+ state(data, SSH_AUTH_PASS);
/* FALLTHROUGH */
case SSH_AUTH_PASS:
@@ -892,7 +893,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
if(rc == SSH_AUTH_SUCCESS) {
sshc->authed = TRUE;
infof(data, "Completed password authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
}
else {
MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
@@ -911,17 +912,17 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
*/
infof(data, "Authentication complete\n");
- Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSH is connected */
+ Curl_pgrsTime(data, TIMER_APPCONNECT); /* SSH is connected */
conn->sockfd = sock;
conn->writesockfd = CURL_SOCKET_BAD;
if(conn->handler->protocol == CURLPROTO_SFTP) {
- state(conn, SSH_SFTP_INIT);
+ state(data, SSH_SFTP_INIT);
break;
}
infof(data, "SSH CONNECT phase done\n");
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_SFTP_INIT:
@@ -943,7 +944,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
MOVE_TO_ERROR_STATE(sftp_error_to_CURLE(rc));
break;
}
- state(conn, SSH_SFTP_REALPATH);
+ state(data, SSH_SFTP_REALPATH);
/* FALLTHROUGH */
case SSH_SFTP_REALPATH:
/*
@@ -960,7 +961,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
since the homedir will remain the same between request but the
working path will not. */
DEBUGF(infof(data, "SSH CONNECT phase done\n"));
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_SFTP_QUOTE_INIT:
@@ -968,17 +969,17 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_getworkingpath(conn, sshc->homedir, &protop->path);
if(result) {
sshc->actualcode = result;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
if(data->set.quote) {
infof(data, "Sending quote commands\n");
sshc->quote_item = data->set.quote;
- state(conn, SSH_SFTP_QUOTE);
+ state(data, SSH_SFTP_QUOTE);
}
else {
- state(conn, SSH_SFTP_GETINFO);
+ state(data, SSH_SFTP_GETINFO);
}
break;
@@ -986,16 +987,16 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
if(data->set.postquote) {
infof(data, "Sending quote commands\n");
sshc->quote_item = data->set.postquote;
- state(conn, SSH_SFTP_QUOTE);
+ state(data, SSH_SFTP_QUOTE);
}
else {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
case SSH_SFTP_QUOTE:
/* Send any quote commands */
- sftp_quote(conn);
+ sftp_quote(data);
break;
case SSH_SFTP_NEXT_QUOTE:
@@ -1005,21 +1006,21 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->quote_item = sshc->quote_item->next;
if(sshc->quote_item) {
- state(conn, SSH_SFTP_QUOTE);
+ state(data, SSH_SFTP_QUOTE);
}
else {
if(sshc->nextstate != SSH_NO_STATE) {
- state(conn, sshc->nextstate);
+ state(data, sshc->nextstate);
sshc->nextstate = SSH_NO_STATE;
}
else {
- state(conn, SSH_SFTP_GETINFO);
+ state(data, SSH_SFTP_GETINFO);
}
}
break;
case SSH_SFTP_QUOTE_STAT:
- sftp_quote_stat(conn);
+ sftp_quote_stat(data);
break;
case SSH_SFTP_QUOTE_SETSTAT:
@@ -1030,7 +1031,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "Attempt to set SFTP stats failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
/* sshc->actualcode = sftp_error_to_CURLE(err);
@@ -1038,7 +1039,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
* the error the libssh2 backend is returning */
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_SYMLINK:
@@ -1049,12 +1050,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "symlink command failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_MKDIR:
@@ -1064,12 +1065,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "mkdir command failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_RENAME:
@@ -1080,12 +1081,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "rename command failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_RMDIR:
@@ -1094,12 +1095,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "rmdir command failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_UNLINK:
@@ -1108,12 +1109,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "rm command failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_STATVFS:
@@ -1125,7 +1126,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "statvfs command failed: %s",
ssh_get_error(sshc->ssh_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1148,7 +1149,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
if(!tmp) {
result = CURLE_OUT_OF_MEMORY;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
break;
}
@@ -1156,21 +1157,21 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
free(tmp);
if(result) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
}
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
}
case SSH_SFTP_GETINFO:
if(data->set.get_filetime) {
- state(conn, SSH_SFTP_FILETIME);
+ state(data, SSH_SFTP_FILETIME);
}
else {
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(data, SSH_SFTP_TRANS_INIT);
}
break;
@@ -1184,18 +1185,18 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sftp_attributes_free(attrs);
}
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(data, SSH_SFTP_TRANS_INIT);
break;
}
case SSH_SFTP_TRANS_INIT:
if(data->set.upload)
- state(conn, SSH_SFTP_UPLOAD_INIT);
+ state(data, SSH_SFTP_UPLOAD_INIT);
else {
if(protop->path[strlen(protop->path)-1] == '/')
- state(conn, SSH_SFTP_READDIR_INIT);
+ state(data, SSH_SFTP_READDIR_INIT);
else
- state(conn, SSH_SFTP_DOWNLOAD_INIT);
+ state(data, SSH_SFTP_DOWNLOAD_INIT);
}
break;
@@ -1249,7 +1250,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
/* try to create the path remotely */
rc = 0;
sshc->secondCreateDirs = 1;
- state(conn, SSH_SFTP_CREATE_DIRS_INIT);
+ state(data, SSH_SFTP_CREATE_DIRS_INIT);
break;
}
else {
@@ -1332,17 +1333,17 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
timeout here */
Curl_expire(data, 0, EXPIRE_RUN_NOW);
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
case SSH_SFTP_CREATE_DIRS_INIT:
if(strlen(protop->path) > 1) {
sshc->slash_pos = protop->path + 1; /* ignore the leading '/' */
- state(conn, SSH_SFTP_CREATE_DIRS);
+ state(data, SSH_SFTP_CREATE_DIRS);
}
else {
- state(conn, SSH_SFTP_UPLOAD_INIT);
+ state(data, SSH_SFTP_UPLOAD_INIT);
}
break;
@@ -1352,10 +1353,10 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
*sshc->slash_pos = 0;
infof(data, "Creating directory '%s'\n", protop->path);
- state(conn, SSH_SFTP_CREATE_DIRS_MKDIR);
+ state(data, SSH_SFTP_CREATE_DIRS_MKDIR);
break;
}
- state(conn, SSH_SFTP_UPLOAD_INIT);
+ state(data, SSH_SFTP_UPLOAD_INIT);
break;
case SSH_SFTP_CREATE_DIRS_MKDIR:
@@ -1378,13 +1379,13 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
}
rc = 0; /* clear rc and continue */
}
- state(conn, SSH_SFTP_CREATE_DIRS);
+ state(data, SSH_SFTP_CREATE_DIRS);
break;
case SSH_SFTP_READDIR_INIT:
Curl_pgrsSetDownloadSize(data, -1);
if(data->set.opt_no_body) {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
@@ -1399,7 +1400,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
ssh_get_error(sshc->ssh_session));
MOVE_TO_SFTP_CLOSE_STATE();
}
- state(conn, SSH_SFTP_READDIR);
+ state(data, SSH_SFTP_READDIR);
break;
case SSH_SFTP_READDIR:
@@ -1418,7 +1419,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
tmpLine = aprintf("%s\n", sshc->readdir_filename);
if(tmpLine == NULL) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1427,7 +1428,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
free(tmpLine);
if(result) {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
/* since this counts what we send to the client, we include the
@@ -1443,7 +1444,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
if(!sshc->readdir_line) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1455,7 +1456,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
S_IFLNK)) {
sshc->readdir_linkPath = malloc(PATH_MAX + 1);
if(sshc->readdir_linkPath == NULL) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1463,15 +1464,15 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
msnprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", protop->path,
sshc->readdir_filename);
- state(conn, SSH_SFTP_READDIR_LINK);
+ state(data, SSH_SFTP_READDIR_LINK);
break;
}
- state(conn, SSH_SFTP_READDIR_BOTTOM);
+ state(data, SSH_SFTP_READDIR_BOTTOM);
break;
}
}
else if(sftp_dir_eof(sshc->sftp_dir)) {
- state(conn, SSH_SFTP_READDIR_DONE);
+ state(data, SSH_SFTP_READDIR_DONE);
break;
}
else {
@@ -1518,7 +1519,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->readdir_totalLen);
if(!new_readdir_line) {
sshc->readdir_line = NULL;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1536,7 +1537,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->readdir_filename = NULL;
sshc->readdir_longentry = NULL;
- state(conn, SSH_SFTP_READDIR_BOTTOM);
+ state(data, SSH_SFTP_READDIR_BOTTOM);
/* FALLTHROUGH */
case SSH_SFTP_READDIR_BOTTOM:
sshc->readdir_currLen += msnprintf(sshc->readdir_line +
@@ -1558,10 +1559,10 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->readdir_tmp = NULL;
if(result) {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
else
- state(conn, SSH_SFTP_READDIR);
+ state(data, SSH_SFTP_READDIR);
break;
case SSH_SFTP_READDIR_DONE:
@@ -1570,7 +1571,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_SFTP_DOWNLOAD_INIT:
@@ -1589,7 +1590,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
MOVE_TO_SFTP_CLOSE_STATE();
}
- state(conn, SSH_SFTP_DOWNLOAD_STAT);
+ state(data, SSH_SFTP_DOWNLOAD_STAT);
break;
case SSH_SFTP_DOWNLOAD_STAT:
@@ -1711,7 +1712,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
infof(data, "File already completely downloaded\n");
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
Curl_setup_transfer(data, FIRSTSOCKET, data->req.size, FALSE, -1);
@@ -1727,12 +1728,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
if(result) {
/* this should never occur; the close state should be entered
at the time the error occurs */
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = result;
}
else {
sshc->sftp_recv_state = 0;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
@@ -1750,11 +1751,11 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
SSH_SFTP_CLOSE to pass the correct result back */
if(sshc->nextstate != SSH_NO_STATE &&
sshc->nextstate != SSH_SFTP_CLOSE) {
- state(conn, sshc->nextstate);
+ state(data, sshc->nextstate);
sshc->nextstate = SSH_SFTP_CLOSE;
}
else {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
result = sshc->actualcode;
}
break;
@@ -1777,7 +1778,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
SSH_STRING_FREE_CHAR(sshc->homedir);
data->state.most_recent_ftp_entrypath = NULL;
- state(conn, SSH_SESSION_DISCONNECT);
+ state(data, SSH_SESSION_DISCONNECT);
break;
@@ -1785,7 +1786,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_getworkingpath(conn, sshc->homedir, &protop->path);
if(result) {
sshc->actualcode = result;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
@@ -1801,12 +1802,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->scp_session =
ssh_scp_new(sshc->ssh_session, SSH_SCP_WRITE, protop->path);
- state(conn, SSH_SCP_UPLOAD_INIT);
+ state(data, SSH_SCP_UPLOAD_INIT);
}
else {
sshc->scp_session =
ssh_scp_new(sshc->ssh_session, SSH_SCP_READ, protop->path);
- state(conn, SSH_SCP_DOWNLOAD_INIT);
+ state(data, SSH_SCP_DOWNLOAD_INIT);
}
if(!sshc->scp_session) {
@@ -1850,7 +1851,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
with both accordingly */
conn->cselect_bits = CURL_CSELECT_OUT;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
@@ -1862,7 +1863,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
failf(data, "%s", err_msg);
MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
}
- state(conn, SSH_SCP_DOWNLOAD);
+ state(data, SSH_SCP_DOWNLOAD);
/* FALLTHROUGH */
case SSH_SCP_DOWNLOAD:{
@@ -1889,14 +1890,14 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
with both accordingly */
conn->cselect_bits = CURL_CSELECT_IN;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
case SSH_SCP_DONE:
if(data->set.upload)
- state(conn, SSH_SCP_SEND_EOF);
+ state(data, SSH_SCP_SEND_EOF);
else
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
break;
case SSH_SCP_SEND_EOF:
@@ -1914,7 +1915,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
}
}
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
break;
case SSH_SCP_CHANNEL_FREE:
@@ -1926,7 +1927,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
ssh_set_blocking(sshc->ssh_session, 0);
- state(conn, SSH_SESSION_DISCONNECT);
+ state(data, SSH_SESSION_DISCONNECT);
/* FALLTHROUGH */
case SSH_SESSION_DISCONNECT:
@@ -1943,7 +1944,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
SSH_STRING_FREE_CHAR(sshc->homedir);
data->state.most_recent_ftp_entrypath = NULL;
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
/* FALLTHROUGH */
case SSH_SESSION_FREE:
if(sshc->ssh_session) {
@@ -1991,7 +1992,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
connclose(conn, "SSH session free");
sshc->state = SSH_SESSION_FREE; /* current */
sshc->nextstate = SSH_NO_STATE;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_QUIT:
@@ -1999,7 +2000,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
default:
/* internal error */
sshc->nextstate = SSH_NO_STATE;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
@@ -2088,7 +2089,7 @@ static CURLcode myssh_block_statemach(struct Curl_easy *data,
break;
if(!disconnect) {
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
result = Curl_speedcheck(data, now);
@@ -2240,7 +2241,7 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done)
/* we do not verify here, we do it at the state machine,
* after connection */
- state(conn, SSH_INIT);
+ state(data, SSH_INIT);
result = myssh_multi_statemach(data, done);
@@ -2281,7 +2282,7 @@ CURLcode scp_perform(struct Curl_easy *data,
*dophase_done = FALSE; /* not done yet */
/* start the first command in the DO phase */
- state(conn, SSH_SCP_TRANS_INIT);
+ state(data, SSH_SCP_TRANS_INIT);
result = myssh_multi_statemach(data, dophase_done);
@@ -2336,7 +2337,7 @@ static CURLcode scp_disconnect(struct Curl_easy *data,
if(ssh->ssh_session) {
/* only if there's a session still around to use! */
- state(conn, SSH_SESSION_DISCONNECT);
+ state(data, SSH_SESSION_DISCONNECT);
result = myssh_block_statemach(data, TRUE);
}
@@ -2360,7 +2361,7 @@ static CURLcode myssh_done(struct Curl_easy *data, CURLcode status)
if(protop)
Curl_safefree(protop->path);
- if(Curl_pgrsDone(data->conn))
+ if(Curl_pgrsDone(data))
return CURLE_ABORTED_BY_CALLBACK;
data->req.keepon = 0; /* clear all bits */
@@ -2374,7 +2375,7 @@ static CURLcode scp_done(struct Curl_easy *data, CURLcode status,
(void) premature; /* not used */
if(!status)
- state(data->conn, SSH_SCP_DONE);
+ state(data, SSH_SCP_DONE);
return myssh_done(data, status);
@@ -2462,7 +2463,7 @@ CURLcode sftp_perform(struct Curl_easy *data,
*dophase_done = FALSE; /* not done yet */
/* start the first command in the DO phase */
- state(conn, SSH_SFTP_QUOTE_INIT);
+ state(data, SSH_SFTP_QUOTE_INIT);
/* run the state-machine */
result = myssh_multi_statemach(data, dophase_done);
@@ -2501,7 +2502,7 @@ static CURLcode sftp_disconnect(struct Curl_easy *data,
if(conn->proto.sshc.ssh_session) {
/* only if there's a session still around to use! */
- state(conn, SSH_SFTP_SHUTDOWN);
+ state(data, SSH_SFTP_SHUTDOWN);
result = myssh_block_statemach(data, TRUE);
}
@@ -2523,7 +2524,7 @@ static CURLcode sftp_done(struct Curl_easy *data, CURLcode status,
operation */
if(!premature && data->set.postquote && !conn->bits.retry)
sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
}
return myssh_done(data, status);
}
@@ -2606,10 +2607,10 @@ static ssize_t sftp_recv(struct Curl_easy *data, int sockindex,
}
}
-static void sftp_quote(struct connectdata *conn)
+static void sftp_quote(struct Curl_easy *data)
{
const char *cp;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
struct SSHPROTO *protop = data->req.p.ssh;
struct ssh_conn *sshc = &conn->proto.sshc;
CURLcode result;
@@ -2636,7 +2637,7 @@ static void sftp_quote(struct connectdata *conn)
protop->path);
if(!tmp) {
sshc->actualcode = CURLE_OUT_OF_MEMORY;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
return;
}
@@ -2649,12 +2650,12 @@ static void sftp_quote(struct connectdata *conn)
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
free(tmp);
if(result) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
}
else
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
return;
}
@@ -2665,7 +2666,7 @@ static void sftp_quote(struct connectdata *conn)
cp = strchr(cmd, ' ');
if(cp == NULL) {
failf(data, "Syntax error in SFTP command. Supply parameter(s)!");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2681,7 +2682,7 @@ static void sftp_quote(struct connectdata *conn)
failf(data, "Out of memory");
else
failf(data, "Syntax error: Bad first parameter");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
return;
@@ -2710,13 +2711,13 @@ static void sftp_quote(struct connectdata *conn)
failf(data, "Syntax error in chgrp/chmod/chown/atime/mtime: "
"Bad second parameter");
Curl_safefree(sshc->quote_path1);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
return;
}
sshc->quote_attrs = NULL;
- state(conn, SSH_SFTP_QUOTE_STAT);
+ state(data, SSH_SFTP_QUOTE_STAT);
return;
}
if(strncasecompare(cmd, "ln ", 3) ||
@@ -2731,17 +2732,17 @@ static void sftp_quote(struct connectdata *conn)
else
failf(data, "Syntax error in ln/symlink: Bad second parameter");
Curl_safefree(sshc->quote_path1);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
return;
}
- state(conn, SSH_SFTP_QUOTE_SYMLINK);
+ state(data, SSH_SFTP_QUOTE_SYMLINK);
return;
}
else if(strncasecompare(cmd, "mkdir ", 6)) {
/* create dir */
- state(conn, SSH_SFTP_QUOTE_MKDIR);
+ state(data, SSH_SFTP_QUOTE_MKDIR);
return;
}
else if(strncasecompare(cmd, "rename ", 7)) {
@@ -2755,26 +2756,26 @@ static void sftp_quote(struct connectdata *conn)
else
failf(data, "Syntax error in rename: Bad second parameter");
Curl_safefree(sshc->quote_path1);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
return;
}
- state(conn, SSH_SFTP_QUOTE_RENAME);
+ state(data, SSH_SFTP_QUOTE_RENAME);
return;
}
else if(strncasecompare(cmd, "rmdir ", 6)) {
/* delete dir */
- state(conn, SSH_SFTP_QUOTE_RMDIR);
+ state(data, SSH_SFTP_QUOTE_RMDIR);
return;
}
else if(strncasecompare(cmd, "rm ", 3)) {
- state(conn, SSH_SFTP_QUOTE_UNLINK);
+ state(data, SSH_SFTP_QUOTE_UNLINK);
return;
}
#ifdef HAS_STATVFS_SUPPORT
else if(strncasecompare(cmd, "statvfs ", 8)) {
- state(conn, SSH_SFTP_QUOTE_STATVFS);
+ state(data, SSH_SFTP_QUOTE_STATVFS);
return;
}
#endif
@@ -2782,14 +2783,14 @@ static void sftp_quote(struct connectdata *conn)
failf(data, "Unknown SFTP command");
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
}
-static void sftp_quote_stat(struct connectdata *conn)
+static void sftp_quote_stat(struct Curl_easy *data)
{
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
char *cmd = sshc->quote_item->data;
sshc->acceptfail = FALSE;
@@ -2817,7 +2818,7 @@ static void sftp_quote_stat(struct connectdata *conn)
Curl_safefree(sshc->quote_path2);
failf(data, "Attempt to get SFTP stats failed: %d",
sftp_get_error(sshc->sftp_session));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2831,7 +2832,7 @@ static void sftp_quote_stat(struct connectdata *conn)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: chgrp gid not a number");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2846,7 +2847,7 @@ static void sftp_quote_stat(struct connectdata *conn)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: chmod permissions not a number");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2861,7 +2862,7 @@ static void sftp_quote_stat(struct connectdata *conn)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: chown uid not a number");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2874,7 +2875,7 @@ static void sftp_quote_stat(struct connectdata *conn)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: incorrect access date format");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2888,7 +2889,7 @@ static void sftp_quote_stat(struct connectdata *conn)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: incorrect modification date format");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
return;
@@ -2898,7 +2899,7 @@ static void sftp_quote_stat(struct connectdata *conn)
}
/* Now send the completed structure... */
- state(conn, SSH_SFTP_QUOTE_SETSTAT);
+ state(data, SSH_SFTP_QUOTE_SETSTAT);
return;
}
diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
index fb7b50335..f2921352d 100644
--- a/lib/vssh/libssh2.c
+++ b/lib/vssh/libssh2.c
@@ -103,7 +103,7 @@ static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
static LIBSSH2_REALLOC_FUNC(my_libssh2_realloc);
static LIBSSH2_FREE_FUNC(my_libssh2_free);
-static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn);
+static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data);
static CURLcode ssh_connect(struct Curl_easy *data, bool *done);
static CURLcode ssh_multi_statemach(struct Curl_easy *data, bool *done);
static CURLcode ssh_do(struct Curl_easy *data, bool *done);
@@ -302,8 +302,9 @@ static LIBSSH2_FREE_FUNC(my_libssh2_free)
* SSH State machine related code
*/
/* This is the ONLY way to change SSH state! */
-static void state(struct connectdata *conn, sshstate nowstate)
+static void state(struct Curl_easy *data, sshstate nowstate)
{
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* for debug purposes */
@@ -374,7 +375,7 @@ static void state(struct connectdata *conn, sshstate nowstate)
DEBUGASSERT(sizeof(names)/sizeof(names[0]) == SSH_LAST);
if(sshc->state != nowstate) {
- infof(conn->data, "SFTP %p state change from %s to %s\n",
+ infof(data, "SFTP %p state change from %s to %s\n",
(void *)sshc, names[sshc->state], names[nowstate]);
}
#endif
@@ -428,15 +429,14 @@ static int sshkeycallback(struct Curl_easy *easy,
#define libssh2_session_startup(x,y) libssh2_session_handshake(x,y)
#endif
-static CURLcode ssh_knownhost(struct connectdata *conn)
+static CURLcode ssh_knownhost(struct Curl_easy *data)
{
CURLcode result = CURLE_OK;
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
- struct Curl_easy *data = conn->data;
-
if(data->set.str[STRING_SSH_KNOWNHOSTS]) {
/* we're asked to verify the host against a file */
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
struct libssh2_knownhost *host = NULL;
int rc;
@@ -558,7 +558,7 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
default: /* unknown return codes will equal reject */
/* FALLTHROUGH */
case CURLKHSTAT_REJECT:
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
/* FALLTHROUGH */
case CURLKHSTAT_DEFER:
/* DEFER means bail out but keep the SSH_HOSTKEY state */
@@ -603,15 +603,15 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
}
}
#else /* HAVE_LIBSSH2_KNOWNHOST_API */
- (void)conn;
+ (void)data;
#endif
return result;
}
-static CURLcode ssh_check_fingerprint(struct connectdata *conn)
+static CURLcode ssh_check_fingerprint(struct Curl_easy *data)
{
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
- struct Curl_easy *data = conn->data;
const char *pubkey_md5 = data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5];
char md5buffer[33];
@@ -638,7 +638,7 @@ static CURLcode ssh_check_fingerprint(struct connectdata *conn)
else
failf(data,
"Denied establishing ssh session: md5 fingerprint not available");
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION;
return sshc->actualcode;
}
@@ -646,14 +646,14 @@ static CURLcode ssh_check_fingerprint(struct connectdata *conn)
/* as we already matched, we skip the check for known hosts */
return CURLE_OK;
}
- return ssh_knownhost(conn);
+ return ssh_knownhost(data);
}
/*
* ssh_force_knownhost_key_type() will check the known hosts file and try to
* force a specific public key type from the server if an entry is found.
*/
-static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn)
+static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data)
{
CURLcode result = CURLE_OK;
@@ -681,8 +681,8 @@ static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn)
= "ssh-dss";
const char *hostkey_method = NULL;
+ struct connectdata *conn = data->conn;
struct ssh_conn *sshc = &conn->proto.sshc;
- struct Curl_easy *data = conn->data;
struct libssh2_knownhost* store = NULL;
const char *kh_name_end = NULL;
size_t kh_name_size = 0;
@@ -814,14 +814,14 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
non-blocking */
libssh2_session_set_blocking(sshc->ssh_session, 0);
- result = ssh_force_knownhost_key_type(conn);
+ result = ssh_force_knownhost_key_type(data);
if(result) {
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = result;
break;
}
- state(conn, SSH_S_STARTUP);
+ state(data, SSH_S_STARTUP);
/* FALLTHROUGH */
case SSH_S_STARTUP:
@@ -834,12 +834,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
(void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0);
failf(data, "Failure establishing ssh session: %d, %s", rc, err_msg);
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = CURLE_FAILED_INIT;
break;
}
- state(conn, SSH_HOSTKEY);
+ state(data, SSH_HOSTKEY);
/* FALLTHROUGH */
case SSH_HOSTKEY:
@@ -848,9 +848,9 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
* against our known hosts. How that is handled (reading from file,
* whatever) is up to us.
*/
- result = ssh_check_fingerprint(conn);
+ result = ssh_check_fingerprint(data);
if(!result)
- state(conn, SSH_AUTHLIST);
+ state(data, SSH_AUTHLIST);
/* ssh_check_fingerprint sets state appropriately on error */
break;
@@ -873,14 +873,14 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(libssh2_userauth_authenticated(sshc->ssh_session)) {
sshc->authed = TRUE;
infof(data, "SSH user accepted with no authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
}
ssherr = libssh2_session_last_errno(sshc->ssh_session);
if(ssherr == LIBSSH2_ERROR_EAGAIN)
rc = LIBSSH2_ERROR_EAGAIN;
else {
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(ssherr);
}
break;
@@ -888,7 +888,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
infof(data, "SSH authentication methods available: %s\n",
sshc->authlist);
- state(conn, SSH_AUTH_PKEY_INIT);
+ state(data, SSH_AUTH_PKEY_INIT);
break;
case SSH_AUTH_PKEY_INIT:
@@ -960,7 +960,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(out_of_memory || sshc->rsa == NULL) {
Curl_safefree(sshc->rsa);
Curl_safefree(sshc->rsa_pub);
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
@@ -973,10 +973,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub);
infof(data, "Using SSH private key file '%s'\n", sshc->rsa);
- state(conn, SSH_AUTH_PKEY);
+ state(data, SSH_AUTH_PKEY);
}
else {
- state(conn, SSH_AUTH_PASS_INIT);
+ state(data, SSH_AUTH_PASS_INIT);
}
break;
@@ -999,14 +999,14 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(rc == 0) {
sshc->authed = TRUE;
infof(data, "Initialized SSH public key authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
}
else {
char *err_msg = NULL;
(void)libssh2_session_last_error(sshc->ssh_session,
&err_msg, NULL, 0);
infof(data, "SSH public key authentication failed: %s\n", err_msg);
- state(conn, SSH_AUTH_PASS_INIT);
+ state(data, SSH_AUTH_PASS_INIT);
rc = 0; /* clear rc and continue */
}
break;
@@ -1014,10 +1014,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
case SSH_AUTH_PASS_INIT:
if((data->set.ssh_auth_types & CURLSSH_AUTH_PASSWORD) &&
(strstr(sshc->authlist, "password") != NULL)) {
- state(conn, SSH_AUTH_PASS);
+ state(data, SSH_AUTH_PASS);
}
else {
- state(conn, SSH_AUTH_HOST_INIT);
+ state(data, SSH_AUTH_HOST_INIT);
rc = 0; /* clear rc and continue */
}
break;
@@ -1034,10 +1034,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(rc == 0) {
sshc->authed = TRUE;
infof(data, "Initialized password authentication\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
}
else {
- state(conn, SSH_AUTH_HOST_INIT);
+ state(data, SSH_AUTH_HOST_INIT);
rc = 0; /* clear rc and continue */
}
break;
@@ -1045,15 +1045,15 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
case SSH_AUTH_HOST_INIT:
if((data->set.ssh_auth_types & CURLSSH_AUTH_HOST) &&
(strstr(sshc->authlist, "hostbased") != NULL)) {
- state(conn, SSH_AUTH_HOST);
+ state(data, SSH_AUTH_HOST);
}
else {
- state(conn, SSH_AUTH_AGENT_INIT);
+ state(data, SSH_AUTH_AGENT_INIT);
}
break;
case SSH_AUTH_HOST:
- state(conn, SSH_AUTH_AGENT_INIT);
+ state(data, SSH_AUTH_AGENT_INIT);
break;
case SSH_AUTH_AGENT_INIT:
@@ -1069,7 +1069,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(!sshc->ssh_agent) {
infof(data, "Could not create agent object\n");
- state(conn, SSH_AUTH_KEY_INIT);
+ state(data, SSH_AUTH_KEY_INIT);
break;
}
}
@@ -1079,16 +1079,16 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
break;
if(rc < 0) {
infof(data, "Failure connecting to agent\n");
- state(conn, SSH_AUTH_KEY_INIT);
+ state(data, SSH_AUTH_KEY_INIT);
rc = 0; /* clear rc and continue */
}
else {
- state(conn, SSH_AUTH_AGENT_LIST);
+ state(data, SSH_AUTH_AGENT_LIST);
}
}
else
#endif /* HAVE_LIBSSH2_AGENT_API */
- state(conn, SSH_AUTH_KEY_INIT);
+ state(data, SSH_AUTH_KEY_INIT);
break;
case SSH_AUTH_AGENT_LIST:
@@ -1099,11 +1099,11 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
break;
if(rc < 0) {
infof(data, "Failure requesting identities to agent\n");
- state(conn, SSH_AUTH_KEY_INIT);
+ state(data, SSH_AUTH_KEY_INIT);
rc = 0; /* clear rc and continue */
}
else {
- state(conn, SSH_AUTH_AGENT);
+ state(data, SSH_AUTH_AGENT);
sshc->sshagent_prev_identity = NULL;
}
#endif
@@ -1141,10 +1141,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(rc == LIBSSH2_ERROR_NONE) {
sshc->authed = TRUE;
infof(data, "Agent based authentication successful\n");
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
}
else {
- state(conn, SSH_AUTH_KEY_INIT);
+ state(data, SSH_AUTH_KEY_INIT);
rc = 0; /* clear rc and continue */
}
#endif
@@ -1153,10 +1153,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
case SSH_AUTH_KEY_INIT:
if((data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD)
&& (strstr(sshc->authlist, "keyboard-interactive") != NULL)) {
- state(conn, SSH_AUTH_KEY);
+ state(data, SSH_AUTH_KEY);
}
else {
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
}
break;
@@ -1174,13 +1174,13 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->authed = TRUE;
infof(data, "Initialized keyboard interactive authentication\n");
}
- state(conn, SSH_AUTH_DONE);
+ state(data, SSH_AUTH_DONE);
break;
case SSH_AUTH_DONE:
if(!sshc->authed) {
failf(data, "Authentication failure");
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = CURLE_LOGIN_DENIED;
break;
}
@@ -1196,11 +1196,11 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
conn->writesockfd = CURL_SOCKET_BAD;
if(conn->handler->protocol == CURLPROTO_SFTP) {
- state(conn, SSH_SFTP_INIT);
+ state(data, SSH_SFTP_INIT);
break;
}
infof(data, "SSH CONNECT phase done\n");
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_SFTP_INIT:
@@ -1219,11 +1219,11 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
(void)libssh2_session_last_error(sshc->ssh_session,
&err_msg, NULL, 0);
failf(data, "Failure initializing sftp session: %s", err_msg);
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
sshc->actualcode = CURLE_FAILED_INIT;
break;
}
- state(conn, SSH_SFTP_REALPATH);
+ state(data, SSH_SFTP_REALPATH);
break;
case SSH_SFTP_REALPATH:
@@ -1243,7 +1243,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
tempHome[rc] = '\0';
sshc->homedir = strdup(tempHome);
if(!sshc->homedir) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
@@ -1261,7 +1261,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->actualcode = result;
DEBUGF(infof(data, "error = %lu makes libcurl = %d\n",
sftperr, (int)result));
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
}
@@ -1270,7 +1270,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
since the homedir will remain the same between request but the
working path will not. */
DEBUGF(infof(data, "SSH CONNECT phase done\n"));
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_SFTP_QUOTE_INIT:
@@ -1278,17 +1278,17 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
if(result) {
sshc->actualcode = result;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
if(data->set.quote) {
infof(data, "Sending quote commands\n");
sshc->quote_item = data->set.quote;
- state(conn, SSH_SFTP_QUOTE);
+ state(data, SSH_SFTP_QUOTE);
}
else {
- state(conn, SSH_SFTP_GETINFO);
+ state(data, SSH_SFTP_GETINFO);
}
break;
@@ -1296,10 +1296,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(data->set.postquote) {
infof(data, "Sending quote commands\n");
sshc->quote_item = data->set.postquote;
- state(conn, SSH_SFTP_QUOTE);
+ state(data, SSH_SFTP_QUOTE);
}
else {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
@@ -1333,7 +1333,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sftp_scp->path);
if(!tmp) {
result = CURLE_OUT_OF_MEMORY;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
break;
}
@@ -1346,12 +1346,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
free(tmp);
if(result) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
}
else
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
}
{
@@ -1363,7 +1363,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(cp == NULL) {
failf(data, "Syntax error command '%s'. Missing parameter!",
cmd);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1379,7 +1379,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
failf(data, "Out of memory");
else
failf(data, "Syntax error: Bad first parameter to '%s'", cmd);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
break;
@@ -1407,13 +1407,13 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
else
failf(data, "Syntax error in %s: Bad second parameter", cmd);
Curl_safefree(sshc->quote_path1);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
break;
}
memset(&sshc->quote_attrs, 0, sizeof(LIBSSH2_SFTP_ATTRIBUTES));
- state(conn, SSH_SFTP_QUOTE_STAT);
+ state(data, SSH_SFTP_QUOTE_STAT);
break;
}
if(strncasecompare(cmd, "ln ", 3) ||
@@ -1429,17 +1429,17 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
failf(data,
"Syntax error in ln/symlink: Bad second parameter");
Curl_safefree(sshc->quote_path1);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
break;
}
- state(conn, SSH_SFTP_QUOTE_SYMLINK);
+ state(data, SSH_SFTP_QUOTE_SYMLINK);
break;
}
else if(strncasecompare(cmd, "mkdir ", 6)) {
/* create dir */
- state(conn, SSH_SFTP_QUOTE_MKDIR);
+ state(data, SSH_SFTP_QUOTE_MKDIR);
break;
}
else if(strncasecompare(cmd, "rename ", 7)) {
@@ -1453,26 +1453,26 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
else
failf(data, "Syntax error in rename: Bad second parameter");
Curl_safefree(sshc->quote_path1);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
break;
}
- state(conn, SSH_SFTP_QUOTE_RENAME);
+ state(data, SSH_SFTP_QUOTE_RENAME);
break;
}
else if(strncasecompare(cmd, "rmdir ", 6)) {
/* delete dir */
- state(conn, SSH_SFTP_QUOTE_RMDIR);
+ state(data, SSH_SFTP_QUOTE_RMDIR);
break;
}
else if(strncasecompare(cmd, "rm ", 3)) {
- state(conn, SSH_SFTP_QUOTE_UNLINK);
+ state(data, SSH_SFTP_QUOTE_UNLINK);
break;
}
#ifdef HAS_STATVFS_SUPPORT
else if(strncasecompare(cmd, "statvfs ", 8)) {
- state(conn, SSH_SFTP_QUOTE_STATVFS);
+ state(data, SSH_SFTP_QUOTE_STATVFS);
break;
}
#endif
@@ -1480,7 +1480,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
failf(data, "Unknown SFTP command");
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1495,15 +1495,15 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->quote_item = sshc->quote_item->next;
if(sshc->quote_item) {
- state(conn, SSH_SFTP_QUOTE);
+ state(data, SSH_SFTP_QUOTE);
}
else {
if(sshc->nextstate != SSH_NO_STATE) {
- state(conn, sshc->nextstate);
+ state(data, sshc->nextstate);
sshc->nextstate = SSH_NO_STATE;
}
else {
- state(conn, SSH_SFTP_GETINFO);
+ state(data, SSH_SFTP_GETINFO);
}
}
break;
@@ -1541,7 +1541,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "Attempt to get SFTP stats failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1557,7 +1557,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: chgrp gid not a number");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1572,7 +1572,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: chmod permissions not a number");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1586,7 +1586,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: chown uid not a number");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1598,7 +1598,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: incorrect access date format");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1612,7 +1612,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Syntax error: incorrect modification date format");
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1622,7 +1622,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
}
/* Now send the completed structure... */
- state(conn, SSH_SFTP_QUOTE_SETSTAT);
+ state(data, SSH_SFTP_QUOTE_SETSTAT);
break;
}
@@ -1640,12 +1640,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "Attempt to set SFTP stats failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_SYMLINK:
@@ -1663,12 +1663,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "symlink command failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_MKDIR:
@@ -1683,12 +1683,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "mkdir command failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_RENAME:
@@ -1709,12 +1709,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path2);
failf(data, "rename command failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_RMDIR:
@@ -1728,12 +1728,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "rmdir command failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
case SSH_SFTP_QUOTE_UNLINK:
@@ -1746,12 +1746,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
failf(data, "rm command failed: %s", sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
#ifdef HAS_STATVFS_SUPPORT
@@ -1770,7 +1770,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->quote_path1);
failf(data, "statvfs command failed: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
break;
@@ -1791,7 +1791,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
statvfs.f_namemax);
if(!tmp) {
result = CURLE_OUT_OF_MEMORY;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
break;
}
@@ -1799,22 +1799,22 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
free(tmp);
if(result) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
}
}
- state(conn, SSH_SFTP_NEXT_QUOTE);
+ state(data, SSH_SFTP_NEXT_QUOTE);
break;
}
#endif
case SSH_SFTP_GETINFO:
{
if(data->set.get_filetime) {
- state(conn, SSH_SFTP_FILETIME);
+ state(data, SSH_SFTP_FILETIME);
}
else {
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(data, SSH_SFTP_TRANS_INIT);
}
break;
}
@@ -1833,18 +1833,18 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
data->info.filetime = attrs.mtime;
}
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(data, SSH_SFTP_TRANS_INIT);
break;
}
case SSH_SFTP_TRANS_INIT:
if(data->set.upload)
- state(conn, SSH_SFTP_UPLOAD_INIT);
+ state(data, SSH_SFTP_UPLOAD_INIT);
else {
if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
- state(conn, SSH_SFTP_READDIR_INIT);
+ state(data, SSH_SFTP_READDIR_INIT);
else
- state(conn, SSH_SFTP_DOWNLOAD_INIT);
+ state(data, SSH_SFTP_DOWNLOAD_INIT);
}
break;
@@ -1911,7 +1911,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sftperr = LIBSSH2_FX_OK; /* not an sftp error at all */
if(sshc->secondCreateDirs) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = sftperr != LIBSSH2_FX_OK ?
sftp_libssh2_error_to_CURLE(sftperr):CURLE_SSH;
failf(data, "Creating the dir/file failed: %s",
@@ -1926,10 +1926,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
/* try to create the path remotely */
rc = 0; /* clear rc and continue */
sshc->secondCreateDirs = 1;
- state(conn, SSH_SFTP_CREATE_DIRS_INIT);
+ state(data, SSH_SFTP_CREATE_DIRS_INIT);
break;
}
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = sftperr != LIBSSH2_FX_OK ?
sftp_libssh2_error_to_CURLE(sftperr):CURLE_SSH;
if(!sshc->actualcode) {
@@ -2008,7 +2008,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
conn->sockfd = conn->writesockfd;
if(result) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = result;
}
else {
@@ -2026,7 +2026,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
timeout here */
Curl_expire(data, 0, EXPIRE_RUN_NOW);
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
}
@@ -2034,10 +2034,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
case SSH_SFTP_CREATE_DIRS_INIT:
if(strlen(sftp_scp->path) > 1) {
sshc->slash_pos = sftp_scp->path + 1; /* ignore the leading '/' */
- state(conn, SSH_SFTP_CREATE_DIRS);
+ state(data, SSH_SFTP_CREATE_DIRS);
}
else {
- state(conn, SSH_SFTP_UPLOAD_INIT);
+ state(data, SSH_SFTP_UPLOAD_INIT);
}
break;
@@ -2047,10 +2047,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
*sshc->slash_pos = 0;
infof(data, "Creating directory '%s'\n", sftp_scp->path);
- state(conn, SSH_SFTP_CREATE_DIRS_MKDIR);
+ state(data, SSH_SFTP_CREATE_DIRS_MKDIR);
break;
}
- state(conn, SSH_SFTP_UPLOAD_INIT);
+ state(data, SSH_SFTP_UPLOAD_INIT);
break;
case SSH_SFTP_CREATE_DIRS_MKDIR:
@@ -2074,19 +2074,19 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
(sftperr != LIBSSH2_FX_FAILURE) &&
(sftperr != LIBSSH2_FX_PERMISSION_DENIED)) {
result = sftp_libssh2_error_to_CURLE(sftperr);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = result?result:CURLE_SSH;
break;
}
rc = 0; /* clear rc and continue */
}
- state(conn, SSH_SFTP_CREATE_DIRS);
+ state(data, SSH_SFTP_CREATE_DIRS);
break;
case SSH_SFTP_READDIR_INIT:
Curl_pgrsSetDownloadSize(data, -1);
if(data->set.opt_no_body) {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
@@ -2108,26 +2108,26 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
failf(data, "Could not open directory for reading: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
result = sftp_libssh2_error_to_CURLE(sftperr);
sshc->actualcode = result?result:CURLE_SSH;
break;
}
sshc->readdir_filename = malloc(PATH_MAX + 1);
if(!sshc->readdir_filename) {
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
sshc->readdir_longentry = malloc(PATH_MAX + 1);
if(!sshc->readdir_longentry) {
Curl_safefree(sshc->readdir_filename);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
Curl_dyn_init(&sshc->readdir, PATH_MAX * 2);
- state(conn, SSH_SFTP_READDIR);
+ state(data, SSH_SFTP_READDIR);
break;
case SSH_SFTP_READDIR:
@@ -2152,7 +2152,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
result = Curl_client_write(data, CLIENTWRITE_BODY,
(char *)"\n", 1);
if(result) {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
/* since this counts what we send to the client, we include the
@@ -2173,24 +2173,24 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
LIBSSH2_SFTP_S_IFLNK)) {
Curl_dyn_init(&sshc->readdir_link, PATH_MAX);
result = Curl_dyn_add(&sshc->readdir_link, sftp_scp->path);
- state(conn, SSH_SFTP_READDIR_LINK);
+ state(data, SSH_SFTP_READDIR_LINK);
if(!result)
break;
}
else {
- state(conn, SSH_SFTP_READDIR_BOTTOM);
+ state(data, SSH_SFTP_READDIR_BOTTOM);
break;
}
}
sshc->actualcode = result;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
break;
}
}
else if(rc == 0) {
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
- state(conn, SSH_SFTP_READDIR_DONE);
+ state(data, SSH_SFTP_READDIR_DONE);
break;
}
else if(rc < 0) {
@@ -2202,7 +2202,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
libssh2_session_last_errno(sshc->ssh_session));
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
break;
}
break;
@@ -2226,12 +2226,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sshc->readdir_line = NULL;
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = result;
break;
}
- state(conn, SSH_SFTP_READDIR_BOTTOM);
+ state(data, SSH_SFTP_READDIR_BOTTOM);
break;
case SSH_SFTP_READDIR_BOTTOM:
@@ -2250,11 +2250,11 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
}
if(result) {
Curl_dyn_free(&sshc->readdir);
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
else {
Curl_dyn_reset(&sshc->readdir);
- state(conn, SSH_SFTP_READDIR);
+ state(data, SSH_SFTP_READDIR);
}
break;
@@ -2270,7 +2270,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_SFTP_DOWNLOAD_INIT:
@@ -2291,12 +2291,12 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
sftperr = libssh2_sftp_last_error(sshc->sftp_session);
failf(data, "Could not open remote file for reading: %s",
sftp_libssh2_strerror(sftperr));
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
result = sftp_libssh2_error_to_CURLE(sftperr);
sshc->actualcode = result?result:CURLE_SSH;
break;
}
- state(conn, SSH_SFTP_DOWNLOAD_STAT);
+ state(data, SSH_SFTP_DOWNLOAD_STAT);
break;
case SSH_SFTP_DOWNLOAD_STAT:
@@ -2410,7 +2410,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
infof(data, "File already completely downloaded\n");
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
Curl_setup_transfer(data, FIRSTSOCKET, data->req.size, FALSE, -1);
@@ -2426,11 +2426,11 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(result) {
/* this should never occur; the close state should be entered
at the time the error occurs */
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
sshc->actualcode = result;
}
else {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
@@ -2458,11 +2458,11 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
SSH_SFTP_CLOSE to pass the correct result back */
if(sshc->nextstate != SSH_NO_STATE &&
sshc->nextstate != SSH_SFTP_CLOSE) {
- state(conn, sshc->nextstate);
+ state(data, sshc->nextstate);
sshc->nextstate = SSH_SFTP_CLOSE;
}
else {
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
result = sshc->actualcode;
}
break;
@@ -2499,14 +2499,14 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->homedir);
data->state.most_recent_ftp_entrypath = NULL;
- state(conn, SSH_SESSION_DISCONNECT);
+ state(data, SSH_SESSION_DISCONNECT);
break;
case SSH_SCP_TRANS_INIT:
result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
if(result) {
sshc->actualcode = result;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
@@ -2514,13 +2514,13 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
if(data->state.infilesize < 0) {
failf(data, "SCP requires a known file size for upload");
sshc->actualcode = CURLE_UPLOAD_FAILED;
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
break;
}
- state(conn, SSH_SCP_UPLOAD_INIT);
+ state(data, SSH_SCP_UPLOAD_INIT);
}
else {
- state(conn, SSH_SCP_DOWNLOAD_INIT);
+ state(data, SSH_SCP_DOWNLOAD_INIT);
}
break;
@@ -2547,7 +2547,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session,
&err_msg, NULL, 0));
failf(data, "%s", err_msg);
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err);
/* Map generic errors to upload failed */
if(sshc->actualcode == CURLE_SSH ||
@@ -2565,7 +2565,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
conn->sockfd = conn->writesockfd;
if(result) {
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
sshc->actualcode = result;
}
else {
@@ -2578,7 +2578,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
with both accordingly */
conn->cselect_bits = CURL_CSELECT_OUT;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
@@ -2622,7 +2622,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session,
&err_msg, NULL, 0));
failf(data, "%s", err_msg);
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err);
break;
}
@@ -2641,19 +2641,19 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
conn->cselect_bits = CURL_CSELECT_IN;
if(result) {
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
sshc->actualcode = result;
}
else
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
}
break;
case SSH_SCP_DONE:
if(data->set.upload)
- state(conn, SSH_SCP_SEND_EOF);
+ state(data, SSH_SCP_SEND_EOF);
else
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
break;
case SSH_SCP_SEND_EOF:
@@ -2670,7 +2670,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
rc, err_msg);
}
}
- state(conn, SSH_SCP_WAIT_EOF);
+ state(data, SSH_SCP_WAIT_EOF);
break;
case SSH_SCP_WAIT_EOF:
@@ -2686,7 +2686,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
infof(data, "Failed to get channel EOF: %d %s\n", rc, err_msg);
}
}
- state(conn, SSH_SCP_WAIT_CLOSE);
+ state(data, SSH_SCP_WAIT_CLOSE);
break;
case SSH_SCP_WAIT_CLOSE:
@@ -2702,7 +2702,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
infof(data, "Channel failed to close: %d %s\n", rc, err_msg);
}
}
- state(conn, SSH_SCP_CHANNEL_FREE);
+ state(data, SSH_SCP_CHANNEL_FREE);
break;
case SSH_SCP_CHANNEL_FREE:
@@ -2722,9 +2722,9 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
}
DEBUGF(infof(data, "SCP DONE phase complete\n"));
#if 0 /* PREV */
- state(conn, SSH_SESSION_DISCONNECT);
+ state(data, SSH_SESSION_DISCONNECT);
#endif
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
result = sshc->actualcode;
break;
@@ -2764,7 +2764,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
Curl_safefree(sshc->homedir);
data->state.most_recent_ftp_entrypath = NULL;
- state(conn, SSH_SESSION_FREE);
+ state(data, SSH_SESSION_FREE);
break;
case SSH_SESSION_FREE:
@@ -2846,7 +2846,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
connclose(conn, "SSH session free");
sshc->state = SSH_SESSION_FREE; /* current */
sshc->nextstate = SSH_NO_STATE;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
case SSH_QUIT:
@@ -2854,7 +2854,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
default:
/* internal error */
sshc->nextstate = SSH_NO_STATE;
- state(conn, SSH_STOP);
+ state(data, SSH_STOP);
break;
}
@@ -2949,7 +2949,7 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
if(result)
break;
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
return CURLE_ABORTED_BY_CALLBACK;
result = Curl_speedcheck(data, now);
@@ -3003,9 +3003,10 @@ static Curl_send scp_send, sftp_send;
static ssize_t ssh_tls_recv(libssh2_socket_t sock, void *buffer,
size_t length, int flags, void **abstract)
{
- struct connectdata *conn = (struct connectdata *)*abstract;
+ struct Curl_easy *data = (struct Curl_easy *)*abstract;
ssize_t nread;
CURLcode result;
+ struct connectdata *conn = data->conn;
Curl_recv *backup = conn->recv[0];
struct ssh_conn *ssh = &conn->proto.sshc;
(void)flags;
@@ -3013,22 +3014,23 @@ static ssize_t ssh_tls_recv(libssh2_socket_t sock, void *buffer,
/* swap in the TLS reader function for this call only, and then swap back
the SSH one again */
conn->recv[0] = ssh->tls_recv;
- result = Curl_read(conn->data, sock, buffer, length, &nread);
+ result = Curl_read(data, sock, buffer, length, &nread);
conn->recv[0] = backup;
if(result == CURLE_AGAIN)
return -EAGAIN; /* magic return code for libssh2 */
else if(result)
return -1; /* generic error */
- Curl_debug(conn->data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread);
+ Curl_debug(data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread);
return nread;
}
static ssize_t ssh_tls_send(libssh2_socket_t sock, const void *buffer,
size_t length, int flags, void **abstract)
{
- struct connectdata *conn = (struct connectdata *)*abstract;
+ struct Curl_easy *data = (struct Curl_easy *)*abstract;
ssize_t nwrite;
CURLcode result;
+ struct connectdata *conn = data->conn;
Curl_send *backup = conn->send[0];
struct ssh_conn *ssh = &conn->proto.sshc;
(void)flags;
@@ -3036,13 +3038,13 @@ static ssize_t ssh_tls_send(libssh2_socket_t sock, const void *buffer,
/* swap in the TLS writer function for this call only, and then swap back
the SSH one again */
conn->send[0] = ssh->tls_send;
- result = Curl_write(conn->data, sock, buffer, length, &nwrite);
+ result = Curl_write(data, sock, buffer, length, &nwrite);
conn->send[0] = backup;
if(result == CURLE_AGAIN)
return -EAGAIN; /* magic return code for libssh2 */
else if(result)
return -1; /* error */
- Curl_debug(conn->data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite);
+ Curl_debug(data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite);
return nwrite;
}
#endif
@@ -3082,7 +3084,7 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
ssh->ssh_session = libssh2_session_init_ex(my_libssh2_malloc,
my_libssh2_free,
- my_libssh2_realloc, conn);
+ my_libssh2_realloc, data);
if(ssh->ssh_session == NULL) {
failf(data, "Failure initialising ssh session");
return CURLE_FAILED_INIT;
@@ -3174,7 +3176,7 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
infof(data, "SSH socket: %d\n", (int)sock);
#endif /* CURL_LIBSSH2_DEBUG */
- state(conn, SSH_INIT);
+ state(data, SSH_INIT);
result = ssh_multi_statemach(data, done);
@@ -3203,7 +3205,7 @@ CURLcode scp_perform(struct Curl_easy *data,
*dophase_done = FALSE; /* not done yet */
/* start the first command in the DO phase */
- state(conn, SSH_SCP_TRANS_INIT);
+ state(data, SSH_SCP_TRANS_INIT);
/* run the state-machine */
result = ssh_multi_statemach(data, dophase_done);
@@ -3211,7 +3213,7 @@ CURLcode scp_perform(struct Curl_easy *data,
*connected = conn->bits.tcpconnect[FIRSTSOCKET];
if(*dophase_done) {
- DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ DEBUGF(infof(data, "DO phase is complete\n"));
}
return result;
@@ -3277,7 +3279,7 @@ static CURLcode scp_disconnect(struct Curl_easy *data,
if(ssh->ssh_session) {
/* only if there's a session still around to use! */
- state(conn, SSH_SESSION_DISCONNECT);
+ state(data, SSH_SESSION_DISCONNECT);
result = ssh_block_statemach(data, FALSE);
}
@@ -3301,7 +3303,7 @@ static CURLcode ssh_done(struct Curl_easy *data, CURLcode status)
if(sftp_scp)
Curl_safefree(sftp_scp->path);
- if(Curl_pgrsDone(data->conn))
+ if(Curl_pgrsDone(data))
return CURLE_ABORTED_BY_CALLBACK;
data->req.keepon = 0; /* clear all bits */
@@ -3315,7 +3317,7 @@ static CURLcode scp_done(struct Curl_easy *data, CURLcode status,
(void)premature; /* not used */
if(!status)
- state(data->conn, SSH_SCP_DONE);
+ state(data, SSH_SCP_DONE);
return ssh_done(data, status);
@@ -3391,7 +3393,7 @@ CURLcode sftp_perform(struct Curl_easy *data,
*dophase_done = FALSE; /* not done yet */
/* start the first command in the DO phase */
- state(data->conn, SSH_SFTP_QUOTE_INIT);
+ state(data, SSH_SFTP_QUOTE_INIT);
/* run the state-machine */
result = ssh_multi_statemach(data, dophase_done);
@@ -3430,7 +3432,7 @@ static CURLcode sftp_disconnect(struct Curl_easy *data,
if(conn->proto.sshc.ssh_session) {
/* only if there's a session still around to use! */
- state(conn, SSH_SFTP_SHUTDOWN);
+ state(data, SSH_SFTP_SHUTDOWN);
result = ssh_block_statemach(data, FALSE);
}
@@ -3450,9 +3452,9 @@ static CURLcode sftp_done(struct Curl_easy *data, CURLcode status,
/* Post quote commands are executed after the SFTP_CLOSE state to avoid
errors that could happen due to open file handles during POSTQUOTE
operation */
- if(!premature && conn->data->set.postquote && !conn->bits.retry)
+ if(!premature && data->set.postquote && !conn->bits.retry)
sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
- state(conn, SSH_SFTP_CLOSE);
+ state(data, SSH_SFTP_CLOSE);
}
return ssh_done(data, status);
}