Lines Matching refs:data

50 static CURLcode wssh_connect(struct Curl_easy *data, bool *done);
51 static CURLcode wssh_multi_statemach(struct Curl_easy *data, bool *done);
52 static CURLcode wssh_do(struct Curl_easy *data, bool *done);
54 static CURLcode wscp_done(struct Curl_easy *data,
56 static CURLcode wscp_doing(struct Curl_easy *data,
58 static CURLcode wscp_disconnect(struct Curl_easy *data,
62 static CURLcode wsftp_done(struct Curl_easy *data,
64 static CURLcode wsftp_doing(struct Curl_easy *data,
66 static CURLcode wsftp_disconnect(struct Curl_easy *data,
69 static int wssh_getsock(struct Curl_easy *data,
72 static CURLcode wssh_setup_connection(struct Curl_easy *data,
139 static void state(struct Curl_easy *data, sshstate nowstate) in state() argument
141 struct connectdata *conn = data->conn; in state()
212 infof(data, "wolfssh %p state change from %s to %s", in state()
220 static ssize_t wscp_send(struct Curl_easy *data, int sockindex, in wscp_send() argument
225 (void)data; in wscp_send()
235 static ssize_t wscp_recv(struct Curl_easy *data, int sockindex, in wscp_recv() argument
239 (void)data; in wscp_recv()
249 static ssize_t wsftp_send(struct Curl_easy *data, int sockindex, in wsftp_send() argument
252 struct connectdata *conn = data->conn; in wsftp_send()
280 failf(data, "wolfSSH_SFTP_SendWritePacket returned %d", rc); in wsftp_send()
284 infof(data, "sent %zu bytes SFTP from offset %" FMT_OFF_T, in wsftp_send()
294 static ssize_t wsftp_recv(struct Curl_easy *data, int sockindex, in wsftp_recv() argument
298 struct connectdata *conn = data->conn; in wsftp_recv()
326 failf(data, "wolfSSH_SFTP_SendReadPacket returned %d", rc); in wsftp_recv()
337 static CURLcode wssh_setup_connection(struct Curl_easy *data, in wssh_setup_connection() argument
343 data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); in wssh_setup_connection()
354 struct Curl_easy *data = ctx; in userauth() local
355 DEBUGF(infof(data, "wolfssh callback: type %s", in userauth()
359 authdata->sf.password.password = (byte *)data->conn->passwd; in userauth()
360 authdata->sf.password.passwordSz = (word32) strlen(data->conn->passwd); in userauth()
366 static CURLcode wssh_connect(struct Curl_easy *data, bool *done) in wssh_connect() argument
368 struct connectdata *conn = data->conn; in wssh_connect()
374 if(!data->req.p.ssh) in wssh_connect()
375 wssh_setup_connection(data, conn); in wssh_connect()
392 failf(data, "No wolfSSH context"); in wssh_connect()
398 failf(data, "No wolfSSH session"); in wssh_connect()
404 failf(data, "wolfSSH failed to set username"); in wssh_connect()
410 wolfSSH_SetUserAuthCtx(sshc->ssh_session, data); in wssh_connect()
414 failf(data, "wolfSSH failed to set socket"); in wssh_connect()
424 state(data, SSH_INIT); in wssh_connect()
426 state(data, SSH_SFTP_INIT); in wssh_connect()
428 return wssh_multi_statemach(data, done); in wssh_connect()
442 static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) in wssh_statemach_act() argument
445 struct connectdata *conn = data->conn; in wssh_statemach_act()
447 struct SSHPROTO *sftp_scp = data->req.p.ssh; in wssh_statemach_act()
455 state(data, SSH_S_STARTUP); in wssh_statemach_act()
473 state(data, SSH_STOP); in wssh_statemach_act()
476 infof(data, "wolfssh connected"); in wssh_statemach_act()
477 state(data, SSH_STOP); in wssh_statemach_act()
497 infof(data, "wolfssh SFTP connected"); in wssh_statemach_act()
498 state(data, SSH_SFTP_REALPATH); in wssh_statemach_act()
501 failf(data, "wolfssh SFTP connect error %d", rc); in wssh_statemach_act()
523 state(data, SSH_STOP); in wssh_statemach_act()
526 failf(data, "wolfssh SFTP realpath %d", rc); in wssh_statemach_act()
530 result = Curl_getworkingpath(data, sshc->homedir, &sftp_scp->path); in wssh_statemach_act()
533 state(data, SSH_STOP); in wssh_statemach_act()
537 if(data->set.quote) { in wssh_statemach_act()
538 infof(data, "Sending quote commands"); in wssh_statemach_act()
539 sshc->quote_item = data->set.quote; in wssh_statemach_act()
540 state(data, SSH_SFTP_QUOTE); in wssh_statemach_act()
543 state(data, SSH_SFTP_GETINFO); in wssh_statemach_act()
547 if(data->set.get_filetime) { in wssh_statemach_act()
548 state(data, SSH_SFTP_FILETIME); in wssh_statemach_act()
551 state(data, SSH_SFTP_TRANS_INIT); in wssh_statemach_act()
555 if(data->state.upload) in wssh_statemach_act()
556 state(data, SSH_SFTP_UPLOAD_INIT); in wssh_statemach_act()
559 state(data, SSH_SFTP_READDIR_INIT); in wssh_statemach_act()
561 state(data, SSH_SFTP_DOWNLOAD_INIT); in wssh_statemach_act()
567 if(data->state.resume_from) { in wssh_statemach_act()
569 if(data->state.resume_from < 0) { in wssh_statemach_act()
576 data->state.resume_from = 0; in wssh_statemach_act()
581 failf(data, "Bad file size (%" FMT_OFF_T ")", size); in wssh_statemach_act()
584 data->state.resume_from = size; in wssh_statemach_act()
589 if(data->set.remote_append) in wssh_statemach_act()
592 else if(data->state.resume_from > 0) in wssh_statemach_act()
600 createattrs.per = (word32)data->set.new_file_perms; in wssh_statemach_act()
618 infof(data, "wolfssh SFTP open succeeded"); in wssh_statemach_act()
621 failf(data, "wolfssh SFTP upload open failed: %d", rc); in wssh_statemach_act()
624 state(data, SSH_SFTP_DOWNLOAD_STAT); in wssh_statemach_act()
628 if(data->state.resume_from > 0) { in wssh_statemach_act()
631 if(data->set.seek_func) { in wssh_statemach_act()
632 Curl_set_in_callback(data, TRUE); in wssh_statemach_act()
633 seekerr = data->set.seek_func(data->set.seek_client, in wssh_statemach_act()
634 data->state.resume_from, SEEK_SET); in wssh_statemach_act()
635 Curl_set_in_callback(data, FALSE); in wssh_statemach_act()
642 failf(data, "Could not seek stream"); in wssh_statemach_act()
649 (data->state.resume_from - passed > in wssh_statemach_act()
651 sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); in wssh_statemach_act()
654 Curl_set_in_callback(data, TRUE); in wssh_statemach_act()
655 actuallyread = data->state.fread_func(scratch, 1, in wssh_statemach_act()
657 data->state.in); in wssh_statemach_act()
658 Curl_set_in_callback(data, FALSE); in wssh_statemach_act()
664 failf(data, "Failed to read data"); in wssh_statemach_act()
667 } while(passed < data->state.resume_from); in wssh_statemach_act()
671 if(data->state.infilesize > 0) { in wssh_statemach_act()
672 data->state.infilesize -= data->state.resume_from; in wssh_statemach_act()
673 data->req.size = data->state.infilesize; in wssh_statemach_act()
674 Curl_pgrsSetUploadSize(data, data->state.infilesize); in wssh_statemach_act()
677 sshc->offset += data->state.resume_from; in wssh_statemach_act()
679 if(data->state.infilesize > 0) { in wssh_statemach_act()
680 data->req.size = data->state.infilesize; in wssh_statemach_act()
681 Curl_pgrsSetUploadSize(data, data->state.infilesize); in wssh_statemach_act()
684 Curl_xfer_setup1(data, CURL_XFER_SEND, -1, FALSE); in wssh_statemach_act()
690 state(data, SSH_SFTP_CLOSE); in wssh_statemach_act()
696 sshc->orig_waitfor = data->req.keepon; in wssh_statemach_act()
701 data->state.select_bits = CURL_CSELECT_OUT; in wssh_statemach_act()
706 Curl_expire(data, 0, EXPIRE_RUN_NOW); in wssh_statemach_act()
708 state(data, SSH_STOP); in wssh_statemach_act()
730 infof(data, "wolfssh SFTP open succeeded"); in wssh_statemach_act()
731 state(data, SSH_SFTP_DOWNLOAD_STAT); in wssh_statemach_act()
735 failf(data, "wolfssh SFTP open failed: %d", rc); in wssh_statemach_act()
756 infof(data, "wolfssh STAT succeeded"); in wssh_statemach_act()
759 failf(data, "wolfssh SFTP open failed: %d", rc); in wssh_statemach_act()
760 data->req.size = -1; in wssh_statemach_act()
761 data->req.maxdownload = -1; in wssh_statemach_act()
762 Curl_pgrsSetDownloadSize(data, -1); in wssh_statemach_act()
768 data->req.size = size; in wssh_statemach_act()
769 data->req.maxdownload = size; in wssh_statemach_act()
770 Curl_pgrsSetDownloadSize(data, size); in wssh_statemach_act()
772 infof(data, "SFTP download %" FMT_OFF_T " bytes", size); in wssh_statemach_act()
776 if(data->state.use_range || data->state.resume_from) { in wssh_statemach_act()
777 infof(data, "wolfSSH cannot do range/seek on SFTP"); in wssh_statemach_act()
782 if(data->req.size == 0) { in wssh_statemach_act()
784 Curl_xfer_setup_nop(data); in wssh_statemach_act()
785 infof(data, "File already completely downloaded"); in wssh_statemach_act()
786 state(data, SSH_STOP); in wssh_statemach_act()
789 Curl_xfer_setup1(data, CURL_XFER_RECV, data->req.size, FALSE); in wssh_statemach_act()
797 data->state.select_bits = CURL_CSELECT_IN; in wssh_statemach_act()
802 state(data, SSH_SFTP_CLOSE); in wssh_statemach_act()
806 state(data, SSH_STOP); in wssh_statemach_act()
827 state(data, SSH_STOP); in wssh_statemach_act()
831 failf(data, "wolfssh SFTP CLOSE failed: %d", rc); in wssh_statemach_act()
835 Curl_pgrsSetDownloadSize(data, -1); in wssh_statemach_act()
836 if(data->req.no_body) { in wssh_statemach_act()
837 state(data, SSH_STOP); in wssh_statemach_act()
840 state(data, SSH_SFTP_READDIR); in wssh_statemach_act()
865 data->set.list_only ? in wssh_statemach_act()
868 state(data, SSH_SFTP_CLOSE); in wssh_statemach_act()
872 result = Curl_client_write(data, CLIENTWRITE_BODY, in wssh_statemach_act()
882 state(data, SSH_STOP); in wssh_statemach_act()
885 failf(data, "wolfssh SFTP ls failed: %d", rc); in wssh_statemach_act()
892 state(data, SSH_STOP); in wssh_statemach_act()
902 static CURLcode wssh_multi_statemach(struct Curl_easy *data, bool *done) in wssh_multi_statemach() argument
904 struct connectdata *conn = data->conn; in wssh_multi_statemach()
910 result = wssh_statemach_act(data, &block); in wssh_multi_statemach()
915 DEBUGF(infof(data, "wssh_statemach_act says DONE")); in wssh_multi_statemach()
923 CURLcode wscp_perform(struct Curl_easy *data, in wscp_perform() argument
927 (void)data; in wscp_perform()
934 CURLcode wsftp_perform(struct Curl_easy *data, in wsftp_perform() argument
940 DEBUGF(infof(data, "DO phase starts")); in wsftp_perform()
945 state(data, SSH_SFTP_QUOTE_INIT); in wsftp_perform()
948 result = wssh_multi_statemach(data, dophase_done); in wsftp_perform()
950 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in wsftp_perform()
953 DEBUGF(infof(data, "DO phase is complete")); in wsftp_perform()
962 static CURLcode wssh_do(struct Curl_easy *data, bool *done) in wssh_do() argument
966 struct connectdata *conn = data->conn; in wssh_do()
970 data->req.size = -1; /* make sure this is unknown at this point */ in wssh_do()
975 Curl_pgrsSetUploadCounter(data, 0); in wssh_do()
976 Curl_pgrsSetDownloadCounter(data, 0); in wssh_do()
977 Curl_pgrsSetUploadSize(data, -1); in wssh_do()
978 Curl_pgrsSetDownloadSize(data, -1); in wssh_do()
981 result = wscp_perform(data, &connected, done); in wssh_do()
983 result = wsftp_perform(data, &connected, done); in wssh_do()
988 static CURLcode wssh_block_statemach(struct Curl_easy *data, in wssh_block_statemach() argument
991 struct connectdata *conn = data->conn; in wssh_block_statemach()
1000 result = wssh_statemach_act(data, &block); in wssh_block_statemach()
1005 if(Curl_pgrsUpdate(data)) in wssh_block_statemach()
1008 result = Curl_speedcheck(data, now); in wssh_block_statemach()
1012 left = Curl_timeleft(data, NULL, FALSE); in wssh_block_statemach()
1014 failf(data, "Operation timed out"); in wssh_block_statemach()
1040 static CURLcode wssh_done(struct Curl_easy *data, CURLcode status) in wssh_done() argument
1043 struct SSHPROTO *sftp_scp = data->req.p.ssh; in wssh_done()
1047 result = wssh_block_statemach(data, FALSE); in wssh_done()
1054 if(Curl_pgrsDone(data)) in wssh_done()
1057 data->req.keepon = 0; /* clear all bits */ in wssh_done()
1062 static CURLcode wscp_done(struct Curl_easy *data,
1073 static CURLcode wscp_doing(struct Curl_easy *data,
1083 static CURLcode wscp_disconnect(struct Curl_easy *data,
1087 (void)data;
1095 static CURLcode wsftp_done(struct Curl_easy *data, in wsftp_done() argument
1099 state(data, SSH_SFTP_CLOSE); in wsftp_done()
1101 return wssh_done(data, code); in wsftp_done()
1104 static CURLcode wsftp_doing(struct Curl_easy *data, in wsftp_doing() argument
1107 CURLcode result = wssh_multi_statemach(data, dophase_done); in wsftp_doing()
1110 DEBUGF(infof(data, "DO phase is complete")); in wsftp_doing()
1115 static CURLcode wsftp_disconnect(struct Curl_easy *data, in wsftp_disconnect() argument
1122 DEBUGF(infof(data, "SSH DISCONNECT starts now")); in wsftp_disconnect()
1126 state(data, SSH_SFTP_SHUTDOWN); in wsftp_disconnect()
1127 result = wssh_block_statemach(data, TRUE); in wsftp_disconnect()
1130 DEBUGF(infof(data, "SSH DISCONNECT is done")); in wsftp_disconnect()
1134 static int wssh_getsock(struct Curl_easy *data, in wssh_getsock() argument
1140 (void)data; in wssh_getsock()