1 #ifndef HEADER_CURL_SSH_H
2 #define HEADER_CURL_SSH_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2010, 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_S_STARTUP, /* Session startup, First state in SSH-CONNECT */
40 SSH_HOSTKEY, /* verify hostkey */
52 SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
54 SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
55 SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
59 SSH_SFTP_QUOTE_SETSTAT,
60 SSH_SFTP_QUOTE_SYMLINK,
62 SSH_SFTP_QUOTE_RENAME,
64 SSH_SFTP_QUOTE_UNLINK,
67 SSH_SFTP_CREATE_DIRS_INIT,
69 SSH_SFTP_CREATE_DIRS_MKDIR,
70 SSH_SFTP_READDIR_INIT,
72 SSH_SFTP_READDIR_LINK,
73 SSH_SFTP_READDIR_BOTTOM,
74 SSH_SFTP_READDIR_DONE,
75 SSH_SFTP_DOWNLOAD_INIT,
76 SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
77 SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */
78 SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
79 SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
81 SSH_SCP_DOWNLOAD_INIT,
86 SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */
87 SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
88 SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */
90 SSH_LAST /* never used */
93 /* this struct is used in the HandleData struct which is part of the
94 SessionHandle, which means this is used on a per-easy handle basis.
95 Everything that is strictly related to a connection is banned from this
98 char *path; /* the path we operate on */
101 /* ssh_conn is used for struct connection-oriented data in the connectdata
104 const char *authlist; /* List of auth. methods, managed by libssh2 */
106 const char *passphrase; /* pass-phrase to use */
107 char *rsa_pub; /* path name */
108 char *rsa; /* path name */
109 bool authed; /* the connection has been authenticated fine */
110 sshstate state; /* always use ssh.c:state() to change state! */
111 sshstate nextstate; /* the state to goto after stopping */
112 CURLcode actualcode; /* the actual error code */
113 struct curl_slist *quote_item; /* for the quote option */
114 char *quote_path1; /* two generic pointers for the QUOTE stuff */
116 LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
117 char *homedir; /* when doing SFTP we figure out home dir in the
120 /* Here's a set of struct members used by the SFTP_READDIR state */
121 LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
122 char *readdir_filename;
123 char *readdir_longentry;
124 int readdir_len, readdir_totalLen, readdir_currLen;
126 char *readdir_linkPath;
127 /* end of READDIR stuff */
129 int secondCreateDirs; /* counter use by the code to see if the
130 second attempt has been made to change
131 to/create a directory */
132 char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
133 LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
134 LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
135 LIBSSH2_SFTP *sftp_session; /* SFTP handle */
136 LIBSSH2_SFTP_HANDLE *sftp_handle;
137 int orig_waitfor; /* default READ/WRITE bits wait for */
139 /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
141 #ifdef HAVE_LIBSSH2_KNOWNHOST_API
142 LIBSSH2_KNOWNHOSTS *kh;
144 #endif /* USE_LIBSSH2 */
149 #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000)
150 # error "SCP/SFTP protocols require libssh2 0.16 or later"
153 #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000)
154 # define HAVE_LIBSSH2_SFTP_SEEK64 1
156 # undef HAVE_LIBSSH2_SFTP_SEEK64
159 #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010206)
160 # define HAVE_LIBSSH2_SCP_SEND64 1
162 # undef HAVE_LIBSSH2_SCP_SEND64
166 extern const struct Curl_handler Curl_handler_scp;
167 extern const struct Curl_handler Curl_handler_sftp;
169 #endif /* USE_LIBSSH2 */
171 #endif /* HEADER_CURL_SSH_H */