20
20
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
21
* KIND, either express or implied.
23
* $Id: ssh.h,v 1.19 2009-05-19 23:21:25 gknauf Exp $
24
***************************************************************************/
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 */
26
147
#ifdef USE_LIBSSH2
41
162
extern const struct Curl_handler Curl_handler_scp;
42
163
extern const struct Curl_handler Curl_handler_sftp;
44
ssize_t Curl_scp_send(struct connectdata *conn, int sockindex,
45
const void *mem, size_t len);
46
ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex,
47
char *mem, size_t len);
49
ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex,
50
const void *mem, size_t len);
51
ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex,
52
char *mem, size_t len);
54
#define Curl_ssh_enabled(conn,prot) (conn->protocol & prot)
56
#else /* USE_LIBSSH2 */
58
#define Curl_ssh_enabled(x,y) 0
59
#define Curl_scp_send(a,b,c,d) 0
60
#define Curl_sftp_send(a,b,c,d) 0
61
#define Curl_scp_recv(a,b,c,d) 0
62
#define Curl_sftp_recv(a,b,c,d) 0
64
165
#endif /* USE_LIBSSH2 */
66
167
#endif /* HEADER_CURL_SSH_H */