diff options
Diffstat (limited to 'Utilities/cmcurl/lib/vssh/wolfssh.c')
-rw-r--r-- | Utilities/cmcurl/lib/vssh/wolfssh.c | 243 |
1 files changed, 127 insertions, 116 deletions
diff --git a/Utilities/cmcurl/lib/vssh/wolfssh.c b/Utilities/cmcurl/lib/vssh/wolfssh.c index b0dfb20..6020180 100644 --- a/Utilities/cmcurl/lib/vssh/wolfssh.c +++ b/Utilities/cmcurl/lib/vssh/wolfssh.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2019 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2019 - 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 @@ -45,27 +45,30 @@ #include "curl_memory.h" #include "memdebug.h" -static CURLcode wssh_connect(struct connectdata *conn, bool *done); -static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done); -static CURLcode wssh_do(struct connectdata *conn, bool *done); +static CURLcode wssh_connect(struct Curl_easy *data, bool *done); +static CURLcode wssh_multi_statemach(struct Curl_easy *data, bool *done); +static CURLcode wssh_do(struct Curl_easy *data, bool *done); #if 0 -static CURLcode wscp_done(struct connectdata *conn, +static CURLcode wscp_done(struct Curl_easy *data, CURLcode, bool premature); -static CURLcode wscp_doing(struct connectdata *conn, +static CURLcode wscp_doing(struct Curl_easy *data, bool *dophase_done); -static CURLcode wscp_disconnect(struct connectdata *conn, +static CURLcode wscp_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead_connection); #endif -static CURLcode wsftp_done(struct connectdata *conn, +static CURLcode wsftp_done(struct Curl_easy *data, CURLcode, bool premature); -static CURLcode wsftp_doing(struct connectdata *conn, +static CURLcode wsftp_doing(struct Curl_easy *data, bool *dophase_done); -static CURLcode wsftp_disconnect(struct connectdata *conn, bool dead); -static int wssh_getsock(struct connectdata *conn, +static CURLcode wsftp_disconnect(struct Curl_easy *data, + struct connectdata *conn, + bool dead); +static int wssh_getsock(struct Curl_easy *data, + struct connectdata *conn, curl_socket_t *sock); -static int wssh_perform_getsock(const struct connectdata *conn, - curl_socket_t *sock); -static CURLcode wssh_setup_connection(struct connectdata *conn); +static CURLcode wssh_setup_connection(struct Curl_easy *data, + struct connectdata *conn); #if 0 /* @@ -84,7 +87,7 @@ const struct Curl_handler Curl_handler_scp = { wssh_getsock, /* proto_getsock */ wssh_getsock, /* doing_getsock */ ZERO_NULL, /* domore_getsock */ - wssh_perform_getsock, /* perform_getsock */ + wssh_getsock, /* perform_getsock */ wscp_disconnect, /* disconnect */ ZERO_NULL, /* readwrite */ ZERO_NULL, /* connection_check */ @@ -112,12 +115,13 @@ const struct Curl_handler Curl_handler_sftp = { wssh_getsock, /* proto_getsock */ wssh_getsock, /* doing_getsock */ ZERO_NULL, /* domore_getsock */ - wssh_perform_getsock, /* perform_getsock */ + wssh_getsock, /* perform_getsock */ wsftp_disconnect, /* disconnect */ ZERO_NULL, /* readwrite */ ZERO_NULL, /* connection_check */ PORT_SSH, /* defport */ CURLPROTO_SFTP, /* protocol */ + CURLPROTO_SFTP, /* family */ PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY /* flags */ }; @@ -126,8 +130,9 @@ const struct Curl_handler Curl_handler_sftp = { * 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 */ @@ -198,7 +203,7 @@ static void state(struct connectdata *conn, sshstate nowstate) DEBUGASSERT(sizeof(names)/sizeof(names[0]) == SSH_LAST); if(sshc->state != nowstate) { - infof(conn->data, "wolfssh %p state change from %s to %s\n", + infof(data, "wolfssh %p state change from %s to %s\n", (void *)sshc, names[sshc->state], names[nowstate]); } #endif @@ -206,11 +211,11 @@ static void state(struct connectdata *conn, sshstate nowstate) sshc->state = nowstate; } -static ssize_t wscp_send(struct connectdata *conn, int sockindex, +static ssize_t wscp_send(struct Curl_easy *data, int sockindex, const void *mem, size_t len, CURLcode *err) { ssize_t nwrite = 0; - (void)conn; + (void)data; (void)sockindex; /* we only support SCP on the fixed known primary socket */ (void)mem; (void)len; @@ -219,11 +224,11 @@ static ssize_t wscp_send(struct connectdata *conn, int sockindex, return nwrite; } -static ssize_t wscp_recv(struct connectdata *conn, int sockindex, +static ssize_t wscp_recv(struct Curl_easy *data, int sockindex, char *mem, size_t len, CURLcode *err) { ssize_t nread = 0; - (void)conn; + (void)data; (void)sockindex; /* we only support SCP on the fixed known primary socket */ (void)mem; (void)len; @@ -233,9 +238,10 @@ static ssize_t wscp_recv(struct connectdata *conn, int sockindex, } /* return number of sent bytes */ -static ssize_t wsftp_send(struct connectdata *conn, int sockindex, +static ssize_t wsftp_send(struct Curl_easy *data, int sockindex, const void *mem, size_t len, CURLcode *err) { + struct connectdata *conn = data->conn; struct ssh_conn *sshc = &conn->proto.sshc; word32 offset[2]; int rc; @@ -262,11 +268,11 @@ static ssize_t wsftp_send(struct connectdata *conn, int sockindex, return -1; } if(rc < 0) { - failf(conn->data, "wolfSSH_SFTP_SendWritePacket returned %d\n", rc); + failf(data, "wolfSSH_SFTP_SendWritePacket returned %d", rc); return -1; } DEBUGASSERT(rc == (int)len); - infof(conn->data, "sent %zd bytes SFTP from offset %zd\n", + infof(data, "sent %zd bytes SFTP from offset %zd\n", len, sshc->offset); sshc->offset += len; return (ssize_t)rc; @@ -276,10 +282,11 @@ static ssize_t wsftp_send(struct connectdata *conn, int sockindex, * Return number of received (decrypted) bytes * or <0 on error */ -static ssize_t wsftp_recv(struct connectdata *conn, int sockindex, +static ssize_t wsftp_recv(struct Curl_easy *data, int sockindex, char *mem, size_t len, CURLcode *err) { int rc; + struct connectdata *conn = data->conn; struct ssh_conn *sshc = &conn->proto.sshc; word32 offset[2]; (void)sockindex; @@ -307,7 +314,7 @@ static ssize_t wsftp_recv(struct connectdata *conn, int sockindex, DEBUGASSERT(rc <= (int)len); if(rc < 0) { - failf(conn->data, "wolfSSH_SFTP_SendReadPacket returned %d\n", rc); + failf(data, "wolfSSH_SFTP_SendReadPacket returned %d", rc); return -1; } sshc->offset += len; @@ -318,11 +325,13 @@ static ssize_t wsftp_recv(struct connectdata *conn, int sockindex, /* * SSH setup and connection */ -static CURLcode wssh_setup_connection(struct connectdata *conn) +static CURLcode wssh_setup_connection(struct Curl_easy *data, + struct connectdata *conn) { struct SSHPROTO *ssh; + (void)conn; - conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); + data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); if(!ssh) return CURLE_OUT_OF_MEMORY; @@ -336,28 +345,28 @@ static int userauth(byte authtype, WS_UserAuthData* authdata, void *ctx) { - struct connectdata *conn = ctx; - DEBUGF(infof(conn->data, "wolfssh callback: type %s\n", + struct Curl_easy *data = ctx; + DEBUGF(infof(data, "wolfssh callback: type %s\n", authtype == WOLFSSH_USERAUTH_PASSWORD ? "PASSWORD" : "PUBLICCKEY")); if(authtype == WOLFSSH_USERAUTH_PASSWORD) { - authdata->sf.password.password = (byte *)conn->passwd; - authdata->sf.password.passwordSz = (word32) strlen(conn->passwd); + authdata->sf.password.password = (byte *)data->conn->passwd; + authdata->sf.password.passwordSz = (word32) strlen(data->conn->passwd); } return 0; } -static CURLcode wssh_connect(struct connectdata *conn, bool *done) +static CURLcode wssh_connect(struct Curl_easy *data, bool *done) { - struct Curl_easy *data = conn->data; + struct connectdata *conn = data->conn; struct ssh_conn *sshc; curl_socket_t sock = conn->sock[FIRSTSOCKET]; int rc; /* initialize per-handle data if not already */ if(!data->req.p.ssh) - wssh_setup_connection(conn); + wssh_setup_connection(data, conn); /* We default to persistent connections. We set this already in this connect function to make the re-use checks properly be able to check this bit. */ @@ -392,7 +401,7 @@ static CURLcode wssh_connect(struct connectdata *conn, bool *done) /* set callback for authentication */ wolfSSH_SetUserAuth(sshc->ctx, userauth); - wolfSSH_SetUserAuthCtx(sshc->ssh_session, conn); + wolfSSH_SetUserAuthCtx(sshc->ssh_session, data); rc = wolfSSH_set_fd(sshc->ssh_session, (int)sock); if(rc) { @@ -406,11 +415,11 @@ static CURLcode wssh_connect(struct connectdata *conn, bool *done) *done = TRUE; if(conn->handler->protocol & CURLPROTO_SCP) - state(conn, SSH_INIT); + state(data, SSH_INIT); else - state(conn, SSH_SFTP_INIT); + state(data, SSH_SFTP_INIT); - return wssh_multi_statemach(conn, done); + return wssh_multi_statemach(data, done); error: wolfSSH_free(sshc->ssh_session); wolfSSH_CTX_free(sshc->ctx); @@ -424,11 +433,11 @@ static CURLcode wssh_connect(struct connectdata *conn, bool *done) * wants to be called again when the socket is ready */ -static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) +static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) { CURLcode result = CURLE_OK; + struct connectdata *conn = data->conn; struct ssh_conn *sshc = &conn->proto.sshc; - struct Curl_easy *data = conn->data; struct SSHPROTO *sftp_scp = data->req.p.ssh; WS_SFTPNAME *name; int rc = 0; @@ -437,7 +446,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) do { switch(sshc->state) { case SSH_INIT: - state(conn, SSH_S_STARTUP); + state(data, SSH_S_STARTUP); /* FALLTHROUGH */ case SSH_S_STARTUP: rc = wolfSSH_connect(sshc->ssh_session); @@ -454,11 +463,11 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) return CURLE_OK; } else if(rc != WS_SUCCESS) { - state(conn, SSH_STOP); + state(data, SSH_STOP); return CURLE_SSH; } infof(data, "wolfssh connected!\n"); - state(conn, SSH_STOP); + state(data, SSH_STOP); break; case SSH_STOP: break; @@ -479,7 +488,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) } else if(rc == WS_SUCCESS) { infof(data, "wolfssh SFTP connected!\n"); - state(conn, SSH_SFTP_REALPATH); + state(data, SSH_SFTP_REALPATH); } else { failf(data, "wolfssh SFTP connect error %d", rc); @@ -510,45 +519,45 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) infof(data, "wolfssh SFTP realpath succeeded!\n"); } wolfSSH_SFTPNAME_list_free(name); - state(conn, SSH_STOP); + state(data, SSH_STOP); return CURLE_OK; } failf(data, "wolfssh SFTP realpath %d", rc); return CURLE_SSH; case SSH_SFTP_QUOTE_INIT: - result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path); + result = Curl_getworkingpath(data, 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; 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; 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; case SSH_SFTP_UPLOAD_INIT: { @@ -583,7 +592,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) /* If we have restart position then open for append */ flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_APPEND; else - /* Clear file before writing (normal behaviour) */ + /* Clear file before writing (normal behavior) */ flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_CREAT|WOLFSSH_FXF_TRUNC; memset(&createattrs, 0, sizeof(createattrs)); @@ -611,7 +620,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) failf(data, "wolfssh SFTP upload open failed: %d", rc); return CURLE_SSH; } - state(conn, SSH_SFTP_DOWNLOAD_STAT); + state(data, SSH_SFTP_DOWNLOAD_STAT); /* If we have a restart point then we need to seek to the correct position. */ @@ -676,7 +685,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) conn->sockfd = conn->writesockfd; if(result) { - state(conn, SSH_SFTP_CLOSE); + state(data, SSH_SFTP_CLOSE); sshc->actualcode = result; } else { @@ -694,7 +703,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) timeout here */ Curl_expire(data, 0, EXPIRE_RUN_NOW); - state(conn, SSH_STOP); + state(data, SSH_STOP); } break; } @@ -717,7 +726,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) } else if(rc == WS_SUCCESS) { infof(data, "wolfssh SFTP open succeeded!\n"); - state(conn, SSH_SFTP_DOWNLOAD_STAT); + state(data, SSH_SFTP_DOWNLOAD_STAT); return CURLE_OK; } @@ -762,7 +771,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) /* We cannot seek with wolfSSH so resuming and range requests are not possible */ - if(conn->data->state.use_range || data->state.resume_from) { + if(data->state.use_range || data->state.resume_from) { infof(data, "wolfSSH cannot do range/seek on SFTP\n"); return CURLE_BAD_DOWNLOAD_RESUME; } @@ -772,7 +781,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, 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); @@ -788,11 +797,11 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, 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; } @@ -813,7 +822,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) return CURLE_OK; } else if(rc == WS_SUCCESS) { - state(conn, SSH_STOP); + state(data, SSH_STOP); return CURLE_OK; } @@ -823,10 +832,10 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) case SSH_SFTP_READDIR_INIT: Curl_pgrsSetDownloadSize(data, -1); if(data->set.opt_no_body) { - state(conn, SSH_STOP); + state(data, SSH_STOP); break; } - state(conn, SSH_SFTP_READDIR); + state(data, SSH_SFTP_READDIR); /* FALLTHROUGH */ case SSH_SFTP_READDIR: name = wolfSSH_SFTP_LS(sshc->ssh_session, sftp_scp->path); @@ -853,11 +862,11 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) data->set.ftp_list_only ? name->fName : name->lName); if(line == NULL) { - state(conn, SSH_SFTP_CLOSE); + state(data, SSH_SFTP_CLOSE); sshc->actualcode = CURLE_OUT_OF_MEMORY; break; } - result = Curl_client_write(conn, CLIENTWRITE_BODY, + result = Curl_client_write(data, CLIENTWRITE_BODY, line, strlen(line)); free(line); if(result) { @@ -867,7 +876,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) name = name->next; } wolfSSH_SFTPNAME_list_free(origname); - state(conn, SSH_STOP); + state(data, SSH_STOP); return result; } failf(data, "wolfssh SFTP ls failed: %d", rc); @@ -877,7 +886,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) Curl_safefree(sshc->homedir); wolfSSH_free(sshc->ssh_session); wolfSSH_CTX_free(sshc->ctx); - state(conn, SSH_STOP); + state(data, SSH_STOP); return CURLE_OK; default: break; @@ -887,19 +896,20 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) } /* called repeatedly until done from multi.c */ -static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done) +static CURLcode wssh_multi_statemach(struct Curl_easy *data, bool *done) { + struct connectdata *conn = data->conn; struct ssh_conn *sshc = &conn->proto.sshc; CURLcode result = CURLE_OK; bool block; /* we store the status and use that to provide a ssh_getsock() implementation */ do { - result = wssh_statemach_act(conn, &block); + result = wssh_statemach_act(data, &block); *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; /* if there's no error, it isn't done and it didn't EWOULDBLOCK, then try again */ if(*done) { - DEBUGF(infof(conn->data, "wssh_statemach_act says DONE\n")); + DEBUGF(infof(data, "wssh_statemach_act says DONE\n")); } } while(!result && !*done && !block); @@ -907,37 +917,38 @@ static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done) } static -CURLcode wscp_perform(struct connectdata *conn, +CURLcode wscp_perform(struct Curl_easy *data, bool *connected, bool *dophase_done) { - (void)conn; + (void)data; (void)connected; (void)dophase_done; return CURLE_OK; } static -CURLcode wsftp_perform(struct connectdata *conn, +CURLcode wsftp_perform(struct Curl_easy *data, bool *connected, bool *dophase_done) { CURLcode result = CURLE_OK; + struct connectdata *conn = data->conn; - DEBUGF(infof(conn->data, "DO phase starts\n")); + DEBUGF(infof(data, "DO phase starts\n")); *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 = wssh_multi_statemach(conn, dophase_done); + result = wssh_multi_statemach(data, dophase_done); *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; @@ -946,11 +957,11 @@ CURLcode wsftp_perform(struct connectdata *conn, /* * The DO function is generic for both protocols. */ -static CURLcode wssh_do(struct connectdata *conn, bool *done) +static CURLcode wssh_do(struct Curl_easy *data, bool *done) { CURLcode result; bool connected = 0; - struct Curl_easy *data = conn->data; + struct connectdata *conn = data->conn; struct ssh_conn *sshc = &conn->proto.sshc; *done = FALSE; /* default to false */ @@ -965,31 +976,31 @@ static CURLcode wssh_do(struct connectdata *conn, bool *done) Curl_pgrsSetDownloadSize(data, -1); if(conn->handler->protocol & CURLPROTO_SCP) - result = wscp_perform(conn, &connected, done); + result = wscp_perform(data, &connected, done); else - result = wsftp_perform(conn, &connected, done); + result = wsftp_perform(data, &connected, done); return result; } -static CURLcode wssh_block_statemach(struct connectdata *conn, +static CURLcode wssh_block_statemach(struct Curl_easy *data, bool disconnect) { + struct connectdata *conn = data->conn; struct ssh_conn *sshc = &conn->proto.sshc; CURLcode result = CURLE_OK; - struct Curl_easy *data = conn->data; while((sshc->state != SSH_STOP) && !result) { bool block; timediff_t left = 1000; struct curltime now = Curl_now(); - result = wssh_statemach_act(conn, &block); + result = wssh_statemach_act(data, &block); if(result) break; if(!disconnect) { - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) return CURLE_ABORTED_BY_CALLBACK; result = Curl_speedcheck(data, now); @@ -1024,29 +1035,29 @@ static CURLcode wssh_block_statemach(struct connectdata *conn, /* generic done function for both SCP and SFTP called from their specific done functions */ -static CURLcode wssh_done(struct connectdata *conn, CURLcode status) +static CURLcode wssh_done(struct Curl_easy *data, CURLcode status) { CURLcode result = CURLE_OK; - struct SSHPROTO *sftp_scp = conn->data->req.p.ssh; + struct SSHPROTO *sftp_scp = data->req.p.ssh; if(!status) { /* run the state-machine */ - result = wssh_block_statemach(conn, FALSE); + result = wssh_block_statemach(data, FALSE); } else result = status; if(sftp_scp) Curl_safefree(sftp_scp->path); - if(Curl_pgrsDone(conn)) + if(Curl_pgrsDone(data)) return CURLE_ABORTED_BY_CALLBACK; - conn->data->req.keepon = 0; /* clear all bits */ + data->req.keepon = 0; /* clear all bits */ return result; } #if 0 -static CURLcode wscp_done(struct connectdata *conn, +static CURLcode wscp_done(struct Curl_easy *data, CURLcode code, bool premature) { CURLcode result = CURLE_OK; @@ -1057,7 +1068,7 @@ static CURLcode wscp_done(struct connectdata *conn, return result; } -static CURLcode wscp_doing(struct connectdata *conn, +static CURLcode wscp_doing(struct Curl_easy *data, bool *dophase_done) { CURLcode result = CURLE_OK; @@ -1067,9 +1078,11 @@ static CURLcode wscp_doing(struct connectdata *conn, return result; } -static CURLcode wscp_disconnect(struct connectdata *conn, bool dead_connection) +static CURLcode wscp_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead_connection) { CURLcode result = CURLE_OK; + (void)data; (void)conn; (void)dead_connection; @@ -1077,54 +1090,52 @@ static CURLcode wscp_disconnect(struct connectdata *conn, bool dead_connection) } #endif -static CURLcode wsftp_done(struct connectdata *conn, +static CURLcode wsftp_done(struct Curl_easy *data, CURLcode code, bool premature) { (void)premature; - state(conn, SSH_SFTP_CLOSE); + state(data, SSH_SFTP_CLOSE); - return wssh_done(conn, code); + return wssh_done(data, code); } -static CURLcode wsftp_doing(struct connectdata *conn, +static CURLcode wsftp_doing(struct Curl_easy *data, bool *dophase_done) { - CURLcode result = wssh_multi_statemach(conn, dophase_done); + CURLcode result = wssh_multi_statemach(data, dophase_done); if(*dophase_done) { - DEBUGF(infof(conn->data, "DO phase is complete\n")); + DEBUGF(infof(data, "DO phase is complete\n")); } return result; } -static CURLcode wsftp_disconnect(struct connectdata *conn, bool dead) +static CURLcode wsftp_disconnect(struct Curl_easy *data, + struct connectdata *conn, + bool dead) { CURLcode result = CURLE_OK; (void)dead; - DEBUGF(infof(conn->data, "SSH DISCONNECT starts now\n")); + DEBUGF(infof(data, "SSH DISCONNECT starts now\n")); if(conn->proto.sshc.ssh_session) { /* only if there's a session still around to use! */ - state(conn, SSH_SFTP_SHUTDOWN); - result = wssh_block_statemach(conn, TRUE); + state(data, SSH_SFTP_SHUTDOWN); + result = wssh_block_statemach(data, TRUE); } - DEBUGF(infof(conn->data, "SSH DISCONNECT is done\n")); + DEBUGF(infof(data, "SSH DISCONNECT is done\n")); return result; } -static int wssh_getsock(struct connectdata *conn, +static int wssh_getsock(struct Curl_easy *data, + struct connectdata *conn, curl_socket_t *sock) { - return wssh_perform_getsock(conn, sock); -} - -static int wssh_perform_getsock(const struct connectdata *conn, - curl_socket_t *sock) -{ int bitmap = GETSOCK_BLANK; int dir = conn->waitfor; + (void)data; sock[0] = conn->sock[FIRSTSOCKET]; if(dir == KEEP_RECV) |