1 #ifndef HEADER_CURL_SSH_H
2 #define HEADER_CURL_SSH_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
29 #include <libssh2_sftp.h>
30 #endif /* HAVE_LIBSSH2_H */
32 /****************************************************************************
34 ***************************************************************************/
36 SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */
37 SSH_STOP = 0, /* do nothing state, stops the state machine */
39 SSH_INIT, /* First state in SSH-CONNECT */
40 SSH_S_STARTUP, /* Session startup */
41 SSH_HOSTKEY, /* verify hostkey */
53 SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
55 SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
56 SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
60 SSH_SFTP_QUOTE_SETSTAT,
61 SSH_SFTP_QUOTE_SYMLINK,
63 SSH_SFTP_QUOTE_RENAME,
65 SSH_SFTP_QUOTE_UNLINK,
68 SSH_SFTP_CREATE_DIRS_INIT,
70 SSH_SFTP_CREATE_DIRS_MKDIR,
71 SSH_SFTP_READDIR_INIT,
73 SSH_SFTP_READDIR_LINK,
74 SSH_SFTP_READDIR_BOTTOM,
75 SSH_SFTP_READDIR_DONE,
76 SSH_SFTP_DOWNLOAD_INIT,
77 SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
78 SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */
79 SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
80 SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
82 SSH_SCP_DOWNLOAD_INIT,
87 SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */
88 SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
89 SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */
91 SSH_LAST /* never used */
94 /* this struct is used in the HandleData struct which is part of the
95 SessionHandle, which means this is used on a per-easy handle basis.
96 Everything that is strictly related to a connection is banned from this
99 char *path; /* the path we operate on */
102 /* ssh_conn is used for struct connection-oriented data in the connectdata
105 const char *authlist; /* List of auth. methods, managed by libssh2 */
107 const char *passphrase; /* pass-phrase to use */
108 char *rsa_pub; /* path name */
109 char *rsa; /* path name */
110 bool authed; /* the connection has been authenticated fine */
111 sshstate state; /* always use ssh.c:state() to change state! */
112 sshstate nextstate; /* the state to goto after stopping */
113 CURLcode actualcode; /* the actual error code */
114 struct curl_slist *quote_item; /* for the quote option */
115 char *quote_path1; /* two generic pointers for the QUOTE stuff */
117 LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
118 bool acceptfail; /* used by the SFTP_QUOTE (continue if
119 quote command fails) */
120 char *homedir; /* when doing SFTP we figure out home dir in the
123 /* Here's a set of struct members used by the SFTP_READDIR state */
124 LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
125 char *readdir_filename;
126 char *readdir_longentry;
127 int readdir_len, readdir_totalLen, readdir_currLen;
129 char *readdir_linkPath;
130 /* end of READDIR stuff */
132 int secondCreateDirs; /* counter use by the code to see if the
133 second attempt has been made to change
134 to/create a directory */
135 char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
136 LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
137 LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
138 LIBSSH2_SFTP *sftp_session; /* SFTP handle */
139 LIBSSH2_SFTP_HANDLE *sftp_handle;
140 int orig_waitfor; /* default READ/WRITE bits wait for */
142 /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
144 #ifdef HAVE_LIBSSH2_KNOWNHOST_API
145 LIBSSH2_KNOWNHOSTS *kh;
147 #endif /* USE_LIBSSH2 */
152 #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000)
153 # error "SCP/SFTP protocols require libssh2 0.16 or later"
156 #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000)
157 # define HAVE_LIBSSH2_SFTP_SEEK64 1
159 # undef HAVE_LIBSSH2_SFTP_SEEK64
162 #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010206)
163 # define HAVE_LIBSSH2_SCP_SEND64 1
165 # undef HAVE_LIBSSH2_SCP_SEND64
169 extern const struct Curl_handler Curl_handler_scp;
170 extern const struct Curl_handler Curl_handler_sftp;
172 #endif /* USE_LIBSSH2 */
174 #endif /* HEADER_CURL_SSH_H */