Lines Matching defs:conn

85 get_handle(struct sftp_conn *conn, u_int expected_id, u_int *len,
99 send_msg(struct sftp_conn *conn, Buffer *m)
114 if (atomiciov6(writev, conn->fd_out, iov, 2,
115 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_out) !=
123 get_msg(struct sftp_conn *conn, Buffer *m)
128 if (atomicio6(read, conn->fd_in, buffer_ptr(m), 4,
129 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) != 4) {
141 if (atomicio6(read, conn->fd_in, buffer_ptr(m), msg_len,
142 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in)
152 send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
161 send_msg(conn, &msg);
162 debug3("Sent message fd %d T:%u I:%u", conn->fd_out, code, id);
167 send_string_attrs_request(struct sftp_conn *conn, u_int id, u_int code,
177 send_msg(conn, &msg);
178 debug3("Sent message fd %d T:%u I:%u", conn->fd_out, code, id);
183 get_status(struct sftp_conn *conn, u_int expected_id)
189 get_msg(conn, &msg);
208 get_handle(struct sftp_conn *conn, u_int expected_id, u_int *len,
223 get_msg(conn, &msg);
247 get_decode_stat(struct sftp_conn *conn, u_int expected_id, int quiet)
254 get_msg(conn, &msg);
282 get_decode_statvfs(struct sftp_conn *conn, struct sftp_statvfs *st,
289 get_msg(conn, &msg);
419 sftp_proto_version(struct sftp_conn *conn)
421 return conn->version;
425 do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
432 id = conn->msg_id++;
436 send_msg(conn, &msg);
439 status = get_status(conn, id);
450 do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
457 id = conn->msg_id++;
463 send_msg(conn, &msg);
465 handle = get_handle(conn, id, &handle_len,
479 id = expected_id = conn->msg_id++;
487 send_msg(conn, &msg);
491 get_msg(conn, &msg);
511 do_close(conn, handle, handle_len);
561 do_close(conn, handle, handle_len);
575 do_readdir(struct sftp_conn *conn, char *path, SFTP_DIRENT ***dir)
577 return(do_lsreaddir(conn, path, 0, dir));
593 do_rm(struct sftp_conn *conn, char *path)
599 id = conn->msg_id++;
600 send_string_request(conn, id, SSH2_FXP_REMOVE, path, strlen(path));
601 status = get_status(conn, id);
608 do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag)
612 id = conn->msg_id++;
613 send_string_attrs_request(conn, id, SSH2_FXP_MKDIR, path,
616 status = get_status(conn, id);
624 do_rmdir(struct sftp_conn *conn, char *path)
628 id = conn->msg_id++;
629 send_string_request(conn, id, SSH2_FXP_RMDIR, path,
632 status = get_status(conn, id);
640 do_stat(struct sftp_conn *conn, char *path, int quiet)
644 id = conn->msg_id++;
646 send_string_request(conn, id,
647 conn->version == 0 ? SSH2_FXP_STAT_VERSION_0 : SSH2_FXP_STAT,
650 return(get_decode_stat(conn, id, quiet));
654 do_lstat(struct sftp_conn *conn, char *path, int quiet)
658 if (conn->version == 0) {
663 return(do_stat(conn, path, quiet));
666 id = conn->msg_id++;
667 send_string_request(conn, id, SSH2_FXP_LSTAT, path,
670 return(get_decode_stat(conn, id, quiet));
675 do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
679 id = conn->msg_id++;
680 send_string_request(conn, id, SSH2_FXP_FSTAT, handle,
683 return(get_decode_stat(conn, id, quiet));
688 do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
692 id = conn->msg_id++;
693 send_string_attrs_request(conn, id, SSH2_FXP_SETSTAT, path,
696 status = get_status(conn, id);
705 do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
710 id = conn->msg_id++;
711 send_string_attrs_request(conn, id, SSH2_FXP_FSETSTAT, handle,
714 status = get_status(conn, id);
722 do_realpath(struct sftp_conn *conn, char *path)
729 expected_id = id = conn->msg_id++;
730 send_string_request(conn, id, SSH2_FXP_REALPATH, path,
735 get_msg(conn, &msg);
771 do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
779 id = conn->msg_id++;
780 if ((conn->exts & SFTP_EXT_POSIX_RENAME)) {
790 send_msg(conn, &msg);
792 (conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" :
796 status = get_status(conn, id);
805 do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
810 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) {
818 id = conn->msg_id++;
824 send_msg(conn, &msg);
829 status = get_status(conn, id);
838 do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
843 if (conn->version < 3) {
851 id = conn->msg_id++;
856 send_msg(conn, &msg);
861 status = get_status(conn, id);
871 do_readlink(struct sftp_conn *conn, char *path)
878 expected_id = id = conn->msg_id++;
879 send_string_request(conn, id, SSH2_FXP_READLINK, path, strlen(path));
883 get_msg(conn, &msg);
919 do_statvfs(struct sftp_conn *conn, const char *path, struct sftp_statvfs *st,
925 if ((conn->exts & SFTP_EXT_STATVFS) == 0) {
930 id = conn->msg_id++;
938 send_msg(conn, &msg);
941 return get_decode_statvfs(conn, st, id, quiet);
946 do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len,
952 if ((conn->exts & SFTP_EXT_FSTATVFS) == 0) {
957 id = conn->msg_id++;
965 send_msg(conn, &msg);
968 return get_decode_statvfs(conn, st, id, quiet);
973 send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
985 send_msg(conn, &msg);
990 do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1013 if (a == NULL && (a = do_stat(conn, remote_path, 0)) == NULL)
1033 buflen = conn->transfer_buflen;
1037 id = conn->msg_id++;
1044 send_msg(conn, &msg);
1047 handle = get_handle(conn, id, &handle_len,
1072 do_close(conn, handle, handle_len);
1109 req->id = conn->msg_id++;
1115 send_read_request(conn, req->id, req->offset,
1120 get_msg(conn, &msg);
1176 req->id = conn->msg_id++;
1179 send_read_request(conn, req->id,
1193 } else if (max_req <= conn->num_requests) {
1222 do_close(conn, handle, handle_len);
1227 do_close(conn, handle, handle_len);
1229 status = do_close(conn, handle, handle_len);
1258 download_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1272 (dirattrib = do_stat(conn, src, 1)) == NULL) {
1295 if (do_readdir(conn, src, &dir_entries) == -1) {
1310 if (download_dir_internal(conn, new_src, new_dst,
1315 if (do_download(conn, new_src, new_dst,
1348 download_dir(struct sftp_conn *conn, char *src, char *dst,
1354 if ((src_canon = do_realpath(conn, src)) == NULL) {
1359 ret = download_dir_internal(conn, src_canon, dst,
1366 do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1417 id = conn->msg_id++;
1423 send_msg(conn, &msg);
1428 handle = get_handle(conn, id, &handle_len,
1437 data = xmalloc(conn->transfer_buflen);
1457 len = read(local_fd, data, conn->transfer_buflen);
1478 send_msg(conn, &msg);
1488 id - ackid >= conn->num_requests) {
1492 get_msg(conn, &msg);
1541 do_fsetstat(conn, handle, handle_len, &a);
1543 if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
1551 upload_dir_internal(struct sftp_conn *conn, char *src, char *dst,
1586 status = do_mkdir(conn, dst, &a, 0);
1595 if (do_stat(conn, dst, 0) == NULL)
1620 if (upload_dir_internal(conn, new_src, new_dst,
1624 if (do_upload(conn, new_src, new_dst, pflag) == -1) {
1635 do_setstat(conn, dst, &a);
1642 upload_dir(struct sftp_conn *conn, char *src, char *dst, int printflag,
1648 if ((dst_canon = do_realpath(conn, dst)) == NULL) {
1653 ret = upload_dir_internal(conn, src, dst_canon, pflag, printflag, 0);