25 #if defined _WIN32 || defined __CYGWIN__
31 #define LIBSSH_API __attribute__((dllexport))
33 #define LIBSSH_API __declspec(dllexport)
37 #define LIBSSH_API __attribute__((dllimport))
39 #define LIBSSH_API __declspec(dllimport)
44 #if __GNUC__ >= 4 && !defined(__OS2__)
45 #define LIBSSH_API __attribute__((visibility("default")))
54 typedef unsigned int uint32_t;
55 typedef unsigned short uint16_t;
56 typedef unsigned char uint8_t;
57 typedef unsigned long long uint64_t;
67 #include <sys/select.h>
71 #define SSH_STRINGIFY(s) SSH_TOSTRING(s)
72 #define SSH_TOSTRING(s) #s
75 #define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
76 #define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
77 #define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
80 #define LIBSSH_VERSION_MAJOR 0
81 #define LIBSSH_VERSION_MINOR 5
82 #define LIBSSH_VERSION_MICRO 2
84 #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
85 LIBSSH_VERSION_MINOR, \
87 #define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
88 LIBSSH_VERSION_MINOR, \
93 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
95 #define PRINTF_ATTRIBUTE(a,b)
99 #define SSH_DEPRECATED __attribute__ ((deprecated))
101 #define SSH_DEPRECATED
109 typedef struct ssh_agent_struct* ssh_agent;
110 typedef struct ssh_buffer_struct* ssh_buffer;
111 typedef struct ssh_channel_struct* ssh_channel;
112 typedef struct ssh_message_struct* ssh_message;
113 typedef struct ssh_pcap_file_struct* ssh_pcap_file;
114 typedef struct ssh_private_key_struct* ssh_private_key;
115 typedef struct ssh_public_key_struct* ssh_public_key;
116 typedef struct ssh_key_struct* ssh_key;
117 typedef struct ssh_scp_struct* ssh_scp;
118 typedef struct ssh_session_struct* ssh_session;
119 typedef struct ssh_string_struct* ssh_string;
124 typedef SOCKET socket_t;
128 typedef int socket_t;
132 #define SSH_INVALID_SOCKET ((socket_t) -1)
135 enum ssh_kex_types_e {
163 #define SSH_AUTH_METHOD_UNKNOWN 0
164 #define SSH_AUTH_METHOD_NONE 0x0001
165 #define SSH_AUTH_METHOD_PASSWORD 0x0002
166 #define SSH_AUTH_METHOD_PUBLICKEY 0x0004
167 #define SSH_AUTH_METHOD_HOSTBASED 0x0008
168 #define SSH_AUTH_METHOD_INTERACTIVE 0x0010
171 enum ssh_requests_e {
173 SSH_REQUEST_CHANNEL_OPEN,
179 enum ssh_channel_type_e {
180 SSH_CHANNEL_UNKNOWN=0,
182 SSH_CHANNEL_DIRECT_TCPIP,
183 SSH_CHANNEL_FORWARDED_TCPIP,
187 enum ssh_channel_requests_e {
188 SSH_CHANNEL_REQUEST_UNKNOWN=0,
189 SSH_CHANNEL_REQUEST_PTY,
190 SSH_CHANNEL_REQUEST_EXEC,
191 SSH_CHANNEL_REQUEST_SHELL,
192 SSH_CHANNEL_REQUEST_ENV,
193 SSH_CHANNEL_REQUEST_SUBSYSTEM,
194 SSH_CHANNEL_REQUEST_WINDOW_CHANGE
197 enum ssh_global_requests_e {
198 SSH_GLOBAL_REQUEST_UNKNOWN=0,
199 SSH_GLOBAL_REQUEST_TCPIP_FORWARD,
200 SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD,
203 enum ssh_publickey_state_e {
204 SSH_PUBLICKEY_STATE_ERROR=-1,
205 SSH_PUBLICKEY_STATE_NONE=0,
206 SSH_PUBLICKEY_STATE_VALID=1,
207 SSH_PUBLICKEY_STATE_WRONG=2
211 #define SSH_CLOSED 0x01
212 #define SSH_READ_PENDING 0x02
213 #define SSH_CLOSED_ERROR 0x04
215 enum ssh_server_known_e {
217 SSH_SERVER_NOT_KNOWN=0,
219 SSH_SERVER_KNOWN_CHANGED,
220 SSH_SERVER_FOUND_OTHER,
221 SSH_SERVER_FILE_NOT_FOUND
224 #ifndef MD5_DIGEST_LEN
225 #define MD5_DIGEST_LEN 16
229 enum ssh_error_types_e {
238 SSH_KEYTYPE_UNKNOWN=0,
281 SSH_OPTIONS_PORT_STR,
285 SSH_OPTIONS_IDENTITY,
286 SSH_OPTIONS_ADD_IDENTITY,
287 SSH_OPTIONS_KNOWNHOSTS,
289 SSH_OPTIONS_TIMEOUT_USEC,
292 SSH_OPTIONS_LOG_VERBOSITY,
293 SSH_OPTIONS_LOG_VERBOSITY_STR,
294 SSH_OPTIONS_CIPHERS_C_S,
295 SSH_OPTIONS_CIPHERS_S_C,
296 SSH_OPTIONS_COMPRESSION_C_S,
297 SSH_OPTIONS_COMPRESSION_S_C,
298 SSH_OPTIONS_PROXYCOMMAND,
299 SSH_OPTIONS_BINDADDR,
300 SSH_OPTIONS_STRICTHOSTKEYCHECK,
301 SSH_OPTIONS_COMPRESSION,
302 SSH_OPTIONS_COMPRESSION_LEVEL
310 SSH_SCP_RECURSIVE=0x10
313 enum ssh_scp_request_types {
315 SSH_SCP_REQUEST_NEWDIR=1,
317 SSH_SCP_REQUEST_NEWFILE,
321 SSH_SCP_REQUEST_ENDDIR,
323 SSH_SCP_REQUEST_WARNING
338 int remoteport,
const char *sourcehost,
int localport);
341 LIBSSH_API
int ssh_channel_read(ssh_channel channel,
void *dest, uint32_t count,
int is_stderr);
351 LIBSSH_API
int ssh_channel_request_sftp(ssh_channel channel);
354 const char *cookie,
int screen_number);
356 LIBSSH_API
int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans,
struct
359 LIBSSH_API
int ssh_channel_write(ssh_channel channel,
const void *data, uint32_t len);
360 LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel);
363 ssh_string *publickey,
int *type);
369 LIBSSH_API
const char *ssh_copyright(
void);
374 LIBSSH_API
int ssh_forward_cancel(ssh_session session,
const char *address,
int port);
375 LIBSSH_API
int ssh_forward_listen(ssh_session session,
const char *address,
int port,
int *bound_port);
376 LIBSSH_API
void ssh_free(ssh_session session);
380 LIBSSH_API socket_t
ssh_get_fd(ssh_session session);
381 LIBSSH_API
char *ssh_get_hexa(
const unsigned char *what,
size_t len);
384 LIBSSH_API ssh_string ssh_get_pubkey(ssh_session session);
386 LIBSSH_API
int ssh_get_random(
void *where,
int len,
int strong);
393 LIBSSH_API
void ssh_log(ssh_session session,
int prioriry,
const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
394 LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
395 LIBSSH_API
int ssh_message_channel_request_reply_success(ssh_message msg);
396 LIBSSH_API
void ssh_message_free(ssh_message msg);
398 LIBSSH_API
int ssh_message_subtype(ssh_message msg);
399 LIBSSH_API
int ssh_message_type(ssh_message msg);
400 LIBSSH_API
int ssh_mkdir (const
char *pathname, mode_t mode);
401 LIBSSH_API ssh_session
ssh_new(
void);
406 LIBSSH_API
int ssh_options_set(ssh_session session, enum ssh_options_e type,
408 LIBSSH_API
int ssh_pcap_file_close(ssh_pcap_file pcap);
409 LIBSSH_API
void ssh_pcap_file_free(ssh_pcap_file pcap);
410 LIBSSH_API ssh_pcap_file ssh_pcap_file_new(
void);
411 LIBSSH_API
int ssh_pcap_file_open(ssh_pcap_file pcap, const
char *filename);
415 LIBSSH_API
void ssh_print_hexa(const
char *descr, const
unsigned char *what,
size_t len);
417 LIBSSH_API
int ssh_scp_close(ssh_scp scp);
419 LIBSSH_API
void ssh_scp_free(ssh_scp scp);
420 LIBSSH_API
int ssh_scp_init(ssh_scp scp);
422 LIBSSH_API ssh_scp
ssh_scp_new(ssh_session session,
int mode, const
char *location);
425 LIBSSH_API
int ssh_scp_push_file(ssh_scp scp, const
char *filename,
size_t size,
int perms);
426 LIBSSH_API
int ssh_scp_read(ssh_scp scp,
void *buffer,
size_t size);
431 LIBSSH_API
int ssh_scp_write(ssh_scp scp, const
void *buffer,
size_t len);
432 LIBSSH_API
int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
433 fd_set *readfds, struct timeval *timeout);
434 LIBSSH_API
int ssh_service_request(ssh_session session, const
char *service);
440 LIBSSH_API
int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile);
443 ssh_public_key publickey);
446 LIBSSH_API
int ssh_userauth_kbdint(ssh_session session,
const char *user,
const char *submethods);
456 LIBSSH_API
int ssh_userauth_password(ssh_session session,
const char *username,
const char *password);
457 LIBSSH_API
int ssh_userauth_pubkey(ssh_session session,
const char *username, ssh_string publickey, ssh_private_key privatekey);
459 const char *filename,
const char *passphrase);
460 LIBSSH_API
const char *
ssh_version(
int req_version);
466 LIBSSH_API
int ssh_string_fill(ssh_string str,
const void *data,
size_t len);
474 LIBSSH_API
int ssh_getpass(
const char *prompt,
char *buf,
size_t len,
int echo,
477 #ifndef LIBSSH_LEGACY_0_4
478 #include "libssh/legacy.h"