Lines Matching refs:conn
140 #define FTP_DSTATE(d) (((d) && (d)->conn)? \
141 ftp_state_names[(d)->conn->proto.ftpc.state] : "???")
153 struct connectdata *conn = data->conn; in _ftp_state() local
154 struct ftp_conn *ftpc = &conn->proto.ftpc; in _ftp_state()
183 struct connectdata *conn,
185 static CURLcode ftp_quit(struct Curl_easy *data, struct connectdata *conn);
199 struct connectdata *conn,
201 static int ftp_need_type(struct connectdata *conn,
208 struct connectdata *conn, bool dead_connection);
211 static int ftp_getsock(struct Curl_easy *data, struct connectdata *conn,
214 struct connectdata *conn, curl_socket_t *socks);
218 struct connectdata *conn);
297 Curl_conn_cf_discard_all(data, data->conn, SECONDARYSOCKET); in close_secondarysocket()
351 data->conn->proto.ftpc.transfertype != 'A') in ftp_cw_lc_write()
427 struct connectdata *conn = data->conn; in ftp_check_ctrl_on_data_wait() local
428 curl_socket_t ctrl_sock = conn->sock[FIRSTSOCKET]; in ftp_check_ctrl_on_data_wait()
429 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_check_ctrl_on_data_wait()
509 struct connectdata *conn = data->conn; in InitiateTransfer() local
517 if(conn->proto.ftpc.state_saved == FTP_STOR) { in InitiateTransfer()
523 Curl_sndbuf_init(conn->sock[SECONDARYSOCKET]); in InitiateTransfer()
532 conn->proto.ftpc.retr_size_saved, TRUE, FALSE); in InitiateTransfer()
535 conn->proto.ftpc.pp.pending_resp = TRUE; /* expect server response */ in InitiateTransfer()
541 static bool ftp_endofresp(struct Curl_easy *data, struct connectdata *conn, in ftp_endofresp() argument
545 (void)conn; in ftp_endofresp()
566 struct connectdata *conn = data->conn; in ftp_readresp() local
567 char * const buf = Curl_dyn_ptr(&data->conn->proto.ftpc.pp.recvbuf); in ftp_readresp()
572 code = Curl_sec_read_msg(data, conn, buf, PROT_SAFE); in ftp_readresp()
575 code = Curl_sec_read_msg(data, conn, buf, PROT_PRIVATE); in ftp_readresp()
578 code = Curl_sec_read_msg(data, conn, buf, PROT_CONFIDENTIAL); in ftp_readresp()
628 struct connectdata *conn = data->conn; in Curl_GetFTPResponse() local
629 curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; in Curl_GetFTPResponse()
631 struct ftp_conn *ftpc = &conn->proto.ftpc; in Curl_GetFTPResponse()
730 struct connectdata *conn) in ftp_state_user() argument
733 &conn->proto.ftpc.pp, "USER %s", in ftp_state_user()
734 conn->user ? conn->user : ""); in ftp_state_user()
736 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_user()
744 struct connectdata *conn) in ftp_state_pwd() argument
746 CURLcode result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", "PWD"); in ftp_state_pwd()
755 struct connectdata *conn, in ftp_getsock() argument
758 return Curl_pp_getsock(data, &conn->proto.ftpc.pp, socks); in ftp_getsock()
763 struct connectdata *conn, curl_socket_t *socks) in ftp_domore_getsock() argument
765 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_domore_getsock()
777 DEBUGASSERT(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD || in ftp_domore_getsock()
778 (conn->cfilter[SECONDARYSOCKET] && in ftp_domore_getsock()
779 !Curl_conn_is_connected(conn, SECONDARYSOCKET))); in ftp_domore_getsock()
780 socks[0] = conn->sock[FIRSTSOCKET]; in ftp_domore_getsock()
785 return Curl_pp_getsock(data, &conn->proto.ftpc.pp, socks); in ftp_domore_getsock()
795 struct connectdata *conn) in ftp_state_cwd() argument
798 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_cwd()
810 if(conn->bits.reuse && ftpc->entrypath && in ftp_state_cwd()
851 struct connectdata *conn = data->conn; in ftp_state_use_port() local
852 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_use_port()
956 switch(Curl_if2ip(conn->remote_addr->family, in ftp_state_use_port()
958 Curl_ipv6_scope(&conn->remote_addr->curl_sa_addr), in ftp_state_use_port()
959 conn->scope_id, in ftp_state_use_port()
983 if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { in ftp_state_use_port()
1025 if(Curl_socket_open(data, ai, NULL, conn->transport, &portsock)) { in ftp_state_use_port()
1063 if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { in ftp_state_use_port()
1118 if(!conn->bits.ftp_use_eprt && conn->bits.ipv6) in ftp_state_use_port()
1121 conn->bits.ftp_use_eprt = TRUE; in ftp_state_use_port()
1126 if(!conn->bits.ftp_use_eprt && (EPRT == fcmd)) in ftp_state_use_port()
1199 result = Curl_conn_tcp_listen_set(data, conn, SECONDARYSOCKET, &portsock); in ftp_state_use_port()
1212 if(conn->bits.ftp_use_data_ssl && data->set.ftp_use_port && in ftp_state_use_port()
1213 !Curl_conn_is_ssl(conn, SECONDARYSOCKET)) { in ftp_state_use_port()
1214 result = Curl_ssl_cfilter_add(data, conn, SECONDARYSOCKET); in ftp_state_use_port()
1216 data->conn->bits.do_more = FALSE; in ftp_state_use_port()
1223 Curl_socket_close(data, conn, portsock); in ftp_state_use_port()
1228 struct connectdata *conn) in ftp_state_use_pasv() argument
1230 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_use_pasv()
1250 if(!conn->bits.ftp_use_epsv && conn->bits.ipv6) in ftp_state_use_pasv()
1253 conn->bits.ftp_use_epsv = TRUE; in ftp_state_use_pasv()
1256 modeoff = conn->bits.ftp_use_epsv ? 0 : 1; in ftp_state_use_pasv()
1278 struct connectdata *conn = data->conn; in ftp_state_prepare_transfer() local
1296 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_prepare_transfer()
1297 if(!conn->proto.ftpc.file) in ftp_state_prepare_transfer()
1304 conn->proto.ftpc.file); in ftp_state_prepare_transfer()
1307 conn->proto.ftpc.file); in ftp_state_prepare_transfer()
1312 result = ftp_state_use_pasv(data, conn); in ftp_state_prepare_transfer()
1318 struct connectdata *conn) in ftp_state_rest() argument
1322 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_rest()
1340 struct connectdata *conn) in ftp_state_size() argument
1344 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_size()
1355 result = ftp_state_rest(data, conn); in ftp_state_size()
1364 struct connectdata *conn = data->conn; in ftp_state_list() local
1416 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", cmd); in ftp_state_list()
1441 struct connectdata *conn = data->conn; in ftp_state_type() local
1442 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_type()
1448 ftp_need_type(conn, data->state.prefer_ascii)) { in ftp_state_type()
1458 result = ftp_nb_type(data, conn, data->state.prefer_ascii, FTP_TYPE); in ftp_state_type()
1463 result = ftp_state_size(data, conn); in ftp_state_type()
1473 struct connectdata *conn = data->conn; in ftp_state_mdtm() local
1474 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_mdtm()
1498 struct connectdata *conn = data->conn; in ftp_state_ul_setup() local
1500 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_ul_setup()
1600 struct connectdata *conn = data->conn; in ftp_state_quote() local
1601 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_quote()
1660 result = ftp_state_cwd(data, conn); in ftp_state_quote()
1710 struct connectdata *conn) in ftp_epsv_disable() argument
1714 if(conn->bits.ipv6 in ftp_epsv_disable()
1716 && !(conn->bits.tunnel_proxy || conn->bits.socksproxy) in ftp_epsv_disable()
1726 conn->bits.ftp_use_epsv = FALSE; in ftp_epsv_disable()
1728 Curl_conn_cf_discard_all(data, conn, SECONDARYSOCKET); in ftp_epsv_disable()
1731 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", "PASV"); in ftp_epsv_disable()
1733 conn->proto.ftpc.count1++; in ftp_epsv_disable()
1741 static char *control_address(struct connectdata *conn) in control_address() argument
1748 if(conn->bits.tunnel_proxy || conn->bits.socksproxy) in control_address()
1749 return conn->host.name; in control_address()
1751 return conn->primary.remote_ip; in control_address()
1780 struct connectdata *conn = data->conn; in ftp_state_pasv_resp() local
1781 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_pasv_resp()
1815 ftpc->newhost = strdup(control_address(conn)); in ftp_state_pasv_resp()
1859 conn->host.name); in ftp_state_pasv_resp()
1860 ftpc->newhost = strdup(control_address(conn)); in ftp_state_pasv_resp()
1872 return ftp_epsv_disable(data, conn); in ftp_state_pasv_resp()
1880 if(conn->bits.proxy) { in ftp_state_pasv_resp()
1886 const char * const host_name = conn->bits.socksproxy ? in ftp_state_pasv_resp()
1887 conn->socks_proxy.host.name : conn->http_proxy.host.name; in ftp_state_pasv_resp()
1888 rc = Curl_resolv(data, host_name, conn->primary.remote_port, FALSE, &addr); in ftp_state_pasv_resp()
1895 connectport = (unsigned short)conn->primary.remote_port; in ftp_state_pasv_resp()
1909 if(conn->bits.tcp_fastopen && !conn->bits.reuse && !ftpc->newhost[0]) { in ftp_state_pasv_resp()
1911 ftpc->newhost = strdup(control_address(conn)); in ftp_state_pasv_resp()
1930 result = Curl_conn_setup(data, conn, SECONDARYSOCKET, addr, in ftp_state_pasv_resp()
1931 conn->bits.ftp_use_data_ssl ? in ftp_state_pasv_resp()
1937 return ftp_epsv_disable(data, conn); in ftp_state_pasv_resp()
1955 Curl_safefree(conn->secondaryhostname); in ftp_state_pasv_resp()
1956 conn->secondary_port = ftpc->newport; in ftp_state_pasv_resp()
1957 conn->secondaryhostname = strdup(ftpc->newhost); in ftp_state_pasv_resp()
1958 if(!conn->secondaryhostname) in ftp_state_pasv_resp()
1961 conn->bits.do_more = TRUE; in ftp_state_pasv_resp()
1970 struct connectdata *conn = data->conn; in ftp_state_port_resp() local
1971 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_port_resp()
1982 conn->bits.ftp_use_eprt = FALSE; in ftp_state_port_resp()
2057 struct connectdata *conn = data->conn; in ftp_state_mdtm_resp() local
2058 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_mdtm_resp()
2165 struct connectdata *conn = data->conn; in ftp_state_type_resp() local
2179 result = ftp_state_size(data, conn); in ftp_state_type_resp()
2195 struct connectdata *conn = data->conn; in ftp_state_retr() local
2196 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_retr()
2280 char *buf = Curl_dyn_ptr(&data->conn->proto.ftpc.pp.recvbuf); in ftp_state_size_resp()
2281 size_t len = data->conn->proto.ftpc.pp.nfinal; in ftp_state_size_resp()
2324 result = ftp_state_rest(data, data->conn); in ftp_state_size_resp()
2339 struct connectdata *conn, in ftp_state_rest_resp() argument
2344 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_rest_resp()
2380 struct connectdata *conn = data->conn; in ftp_state_stor_resp() local
2389 conn->proto.ftpc.state_saved = instate; in ftp_state_stor_resp()
2393 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_stor_resp()
2419 struct connectdata *conn = data->conn; in ftp_state_get_resp() local
2464 char *buf = Curl_dyn_ptr(&conn->proto.ftpc.pp.recvbuf); in ftp_state_get_resp()
2503 conn->proto.ftpc.state_saved = instate; in ftp_state_get_resp()
2504 conn->proto.ftpc.retr_size_saved = size; in ftp_state_get_resp()
2507 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_get_resp()
2545 struct connectdata *conn = data->conn; in ftp_state_loggedin() local
2547 if(conn->bits.ftp_use_control_ssl) { in ftp_state_loggedin()
2562 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "PBSZ %d", 0); in ftp_state_loggedin()
2567 result = ftp_state_pwd(data, conn); in ftp_state_loggedin()
2577 struct connectdata *conn = data->conn; in ftp_state_user_resp() local
2578 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_state_user_resp()
2585 conn->passwd ? conn->passwd : ""); in ftp_state_user_resp()
2648 struct connectdata *conn) in ftp_statemachine() argument
2652 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_statemachine()
2671 conn->bits.ftp_use_control_ssl) in ftp_statemachine()
2686 Curl_sec_request_prot(conn, "private"); in ftp_statemachine()
2689 Curl_sec_request_prot(conn, data->set.str[STRING_KRB_LEVEL]); in ftp_statemachine()
2691 if(Curl_sec_login(data, conn)) { in ftp_statemachine()
2699 if(data->set.use_ssl && !conn->bits.ftp_use_control_ssl) { in ftp_statemachine()
2725 result = ftp_state_user(data, conn); in ftp_statemachine()
2744 if(!Curl_conn_is_ssl(conn, FIRSTSOCKET)) { in ftp_statemachine()
2745 result = Curl_ssl_cfilter_add(data, conn, FIRSTSOCKET); in ftp_statemachine()
2753 conn->bits.ftp_use_data_ssl = FALSE; /* clear-text data */ in ftp_statemachine()
2754 conn->bits.ftp_use_control_ssl = TRUE; /* SSL on control */ in ftp_statemachine()
2755 result = ftp_state_user(data, conn); in ftp_statemachine()
2771 result = ftp_state_user(data, conn); in ftp_statemachine()
2795 conn->bits.ftp_use_data_ssl = in ftp_statemachine()
2811 result = ftp_state_pwd(data, conn); in ftp_statemachine()
2830 result = ftp_state_pwd(data, conn); in ftp_statemachine()
2969 ftp_state_pwd(data, conn); in ftp_statemachine()
3061 result = ftp_state_rest_resp(data, conn, ftpcode, ftpc->state); in ftp_statemachine()
3070 result = ftp_state_use_pasv(data, conn); in ftp_statemachine()
3106 struct connectdata *conn = data->conn; in ftp_multi_statemach() local
3107 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_multi_statemach()
3119 struct connectdata *conn) in ftp_block_statemach() argument
3121 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_block_statemach()
3146 struct connectdata *conn = data->conn; in ftp_connect() local
3147 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_connect()
3153 connkeep(conn, "FTP default"); in ftp_connect()
3157 if(conn->handler->flags & PROTOPT_SSL) { in ftp_connect()
3162 conn->bits.ftp_use_control_ssl = TRUE; in ftp_connect()
3188 struct connectdata *conn = data->conn; in ftp_done() local
3190 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_done()
3228 connclose(conn, "FTP ended with bad error code"); in ftp_done()
3250 connclose(conn, "FTP: out of memory!"); /* mark for connection closure */ in ftp_done()
3286 shutdown(conn->sock[SECONDARYSOCKET], 2); /* SD_BOTH */ in ftp_done()
3289 if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { in ftp_done()
3297 connclose(conn, "ABOR command failed"); /* connection closure */ in ftp_done()
3324 connclose(conn, "Timeout or similar in FTP DONE operation"); /* close */ in ftp_done()
3336 connclose(conn, "Partial download with no ability to check"); in ftp_done()
3395 result = ftp_sendquote(data, conn, data->set.postquote); in ftp_done()
3413 struct connectdata *conn, struct curl_slist *quote) in ftp_sendquote() argument
3416 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_sendquote()
3464 static int ftp_need_type(struct connectdata *conn, in ftp_need_type() argument
3467 return conn->proto.ftpc.transfertype != (ascii_wanted ? 'A' : 'I'); in ftp_need_type()
3479 struct connectdata *conn, in ftp_nb_type() argument
3482 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_nb_type()
3536 struct connectdata *conn = data->conn; in ftp_do_more() local
3537 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_do_more()
3555 if(conn->cfilter[SECONDARYSOCKET]) { in ftp_do_more()
3563 return ftp_epsv_disable(data, conn); in ftp_do_more()
3620 result = ftp_nb_type(data, conn, data->state.prefer_ascii, in ftp_do_more()
3648 result = ftp_nb_type(data, conn, TRUE, FTP_LIST_TYPE); in ftp_do_more()
3655 result = ftp_nb_type(data, conn, data->state.prefer_ascii, in ftp_do_more()
3716 *connected = Curl_conn_is_connected(data->conn, SECONDARYSOCKET); in ftp_perform()
3835 struct connectdata *conn = data->conn; in wc_statemach() local
3873 struct ftp_conn *ftpc = &conn->proto.ftpc; in wc_statemach()
3977 struct connectdata *conn = data->conn; in ftp_do() local
3978 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_do()
4032 static CURLcode ftp_quit(struct Curl_easy *data, struct connectdata *conn) in ftp_quit() argument
4036 if(conn->proto.ftpc.ctl_valid) { in ftp_quit()
4037 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", "QUIT"); in ftp_quit()
4041 conn->proto.ftpc.ctl_valid = FALSE; /* mark control connection as bad */ in ftp_quit()
4042 connclose(conn, "QUIT command failed"); /* mark for connection closure */ in ftp_quit()
4049 result = ftp_block_statemach(data, conn); in ftp_quit()
4063 struct connectdata *conn, in ftp_disconnect() argument
4066 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_disconnect()
4080 (void)ftp_quit(data, conn); /* ignore errors on the QUIT */ in ftp_disconnect()
4095 Curl_sec_end(conn); in ftp_disconnect()
4116 struct connectdata *conn = data->conn; in ftp_parse_url_path() local
4117 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_parse_url_path()
4239 const char *oldPath = conn->bits.reuse ? ftpc->prevpath : ""; in ftp_parse_url_path()
4261 struct connectdata *conn = data->conn; in ftp_dophase_done() local
4263 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_dophase_done()
4280 conn->bits.do_more = TRUE; in ftp_dophase_done()
4321 struct connectdata *conn = data->conn; in ftp_regular_transfer() local
4322 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_regular_transfer()
4354 struct connectdata *conn) in ftp_setup_connection() argument
4359 struct ftp_conn *ftpc = &conn->proto.ftpc; in ftp_setup_connection()
4391 type = strstr(conn->host.rawalloc, ";type="); in ftp_setup_connection()
4422 CURL_TRC_FTP(data, "[%s] setup connection -> %d", FTP_CSTATE(conn), result); in ftp_setup_connection()