libssh  0.6.3
libssh.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2003-2009 by Aris Adamantiadis
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef _LIBSSH_H
22 #define _LIBSSH_H
23 
24 #if defined _WIN32 || defined __CYGWIN__
25  #ifdef LIBSSH_STATIC
26  #define LIBSSH_API
27  #else
28  #ifdef LIBSSH_EXPORTS
29  #ifdef __GNUC__
30  #define LIBSSH_API __attribute__((dllexport))
31  #else
32  #define LIBSSH_API __declspec(dllexport)
33  #endif
34  #else
35  #ifdef __GNUC__
36  #define LIBSSH_API __attribute__((dllimport))
37  #else
38  #define LIBSSH_API __declspec(dllimport)
39  #endif
40  #endif
41  #endif
42 #else
43  #if __GNUC__ >= 4 && !defined(__OS2__)
44  #define LIBSSH_API __attribute__((visibility("default")))
45  #else
46  #define LIBSSH_API
47  #endif
48 #endif
49 
50 #ifdef _MSC_VER
51  /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
52  typedef int int32_t;
53  typedef unsigned int uint32_t;
54  typedef unsigned short uint16_t;
55  typedef unsigned char uint8_t;
56  typedef unsigned long long uint64_t;
57  typedef int mode_t;
58 #else /* _MSC_VER */
59  #include <unistd.h>
60  #include <inttypes.h>
61 #endif /* _MSC_VER */
62 
63 #ifdef _WIN32
64  #include <winsock2.h>
65 #else /* _WIN32 */
66  #include <sys/select.h> /* for fd_set * */
67  #include <netdb.h>
68 #endif /* _WIN32 */
69 
70 #define SSH_STRINGIFY(s) SSH_TOSTRING(s)
71 #define SSH_TOSTRING(s) #s
72 
73 /* libssh version macros */
74 #define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
75 #define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
76 #define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
77 
78 /* libssh version */
79 #define LIBSSH_VERSION_MAJOR 0
80 #define LIBSSH_VERSION_MINOR 6
81 #define LIBSSH_VERSION_MICRO 3
82 
83 #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
84  LIBSSH_VERSION_MINOR, \
85  LIBSSH_VERSION_MICRO)
86 #define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
87  LIBSSH_VERSION_MINOR, \
88  LIBSSH_VERSION_MICRO)
89 
90 /* GCC have printf type attribute check. */
91 #ifdef __GNUC__
92 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
93 #else
94 #define PRINTF_ATTRIBUTE(a,b)
95 #endif /* __GNUC__ */
96 
97 #ifdef __GNUC__
98 #define SSH_DEPRECATED __attribute__ ((deprecated))
99 #else
100 #define SSH_DEPRECATED
101 #endif
102 
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 
107 
108 typedef struct ssh_agent_struct* ssh_agent;
109 typedef struct ssh_buffer_struct* ssh_buffer;
110 typedef struct ssh_channel_struct* ssh_channel;
111 typedef struct ssh_message_struct* ssh_message;
112 typedef struct ssh_pcap_file_struct* ssh_pcap_file;
113 typedef struct ssh_key_struct* ssh_key;
114 typedef struct ssh_scp_struct* ssh_scp;
115 typedef struct ssh_session_struct* ssh_session;
116 typedef struct ssh_string_struct* ssh_string;
117 typedef struct ssh_event_struct* ssh_event;
118 typedef void* ssh_gssapi_creds;
119 
120 /* Socket type */
121 #ifdef _WIN32
122 #ifndef socket_t
123 typedef SOCKET socket_t;
124 #endif /* socket_t */
125 #else /* _WIN32 */
126 #ifndef socket_t
127 typedef int socket_t;
128 #endif
129 #endif /* _WIN32 */
130 
131 #define SSH_INVALID_SOCKET ((socket_t) -1)
132 
133 /* the offsets of methods */
134 enum ssh_kex_types_e {
135  SSH_KEX=0,
136  SSH_HOSTKEYS,
137  SSH_CRYPT_C_S,
138  SSH_CRYPT_S_C,
139  SSH_MAC_C_S,
140  SSH_MAC_S_C,
141  SSH_COMP_C_S,
142  SSH_COMP_S_C,
143  SSH_LANG_C_S,
144  SSH_LANG_S_C
145 };
146 
147 #define SSH_CRYPT 2
148 #define SSH_MAC 3
149 #define SSH_COMP 4
150 #define SSH_LANG 5
151 
152 enum ssh_auth_e {
153  SSH_AUTH_SUCCESS=0,
154  SSH_AUTH_DENIED,
155  SSH_AUTH_PARTIAL,
156  SSH_AUTH_INFO,
157  SSH_AUTH_AGAIN,
158  SSH_AUTH_ERROR=-1
159 };
160 
161 /* auth flags */
162 #define SSH_AUTH_METHOD_UNKNOWN 0
163 #define SSH_AUTH_METHOD_NONE 0x0001
164 #define SSH_AUTH_METHOD_PASSWORD 0x0002
165 #define SSH_AUTH_METHOD_PUBLICKEY 0x0004
166 #define SSH_AUTH_METHOD_HOSTBASED 0x0008
167 #define SSH_AUTH_METHOD_INTERACTIVE 0x0010
168 #define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020
169 
170 /* messages */
171 enum ssh_requests_e {
172  SSH_REQUEST_AUTH=1,
173  SSH_REQUEST_CHANNEL_OPEN,
174  SSH_REQUEST_CHANNEL,
175  SSH_REQUEST_SERVICE,
176  SSH_REQUEST_GLOBAL
177 };
178 
179 enum ssh_channel_type_e {
180  SSH_CHANNEL_UNKNOWN=0,
181  SSH_CHANNEL_SESSION,
182  SSH_CHANNEL_DIRECT_TCPIP,
183  SSH_CHANNEL_FORWARDED_TCPIP,
184  SSH_CHANNEL_X11
185 };
186 
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,
195  SSH_CHANNEL_REQUEST_X11
196 };
197 
198 enum ssh_global_requests_e {
199  SSH_GLOBAL_REQUEST_UNKNOWN=0,
200  SSH_GLOBAL_REQUEST_TCPIP_FORWARD,
201  SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD,
202 };
203 
204 enum ssh_publickey_state_e {
205  SSH_PUBLICKEY_STATE_ERROR=-1,
206  SSH_PUBLICKEY_STATE_NONE=0,
207  SSH_PUBLICKEY_STATE_VALID=1,
208  SSH_PUBLICKEY_STATE_WRONG=2
209 };
210 
211 /* Status flags */
213 #define SSH_CLOSED 0x01
214 
215 #define SSH_READ_PENDING 0x02
216 
217 #define SSH_CLOSED_ERROR 0x04
218 
219 #define SSH_WRITE_PENDING 0x08
220 
221 enum ssh_server_known_e {
222  SSH_SERVER_ERROR=-1,
223  SSH_SERVER_NOT_KNOWN=0,
224  SSH_SERVER_KNOWN_OK,
225  SSH_SERVER_KNOWN_CHANGED,
226  SSH_SERVER_FOUND_OTHER,
227  SSH_SERVER_FILE_NOT_FOUND
228 };
229 
230 #ifndef MD5_DIGEST_LEN
231  #define MD5_DIGEST_LEN 16
232 #endif
233 /* errors */
234 
235 enum ssh_error_types_e {
236  SSH_NO_ERROR=0,
237  SSH_REQUEST_DENIED,
238  SSH_FATAL,
239  SSH_EINTR
240 };
241 
242 /* some types for keys */
243 enum ssh_keytypes_e{
244  SSH_KEYTYPE_UNKNOWN=0,
245  SSH_KEYTYPE_DSS=1,
246  SSH_KEYTYPE_RSA,
247  SSH_KEYTYPE_RSA1,
248  SSH_KEYTYPE_ECDSA
249 };
250 
251 enum ssh_keycmp_e {
252  SSH_KEY_CMP_PUBLIC = 0,
253  SSH_KEY_CMP_PRIVATE
254 };
255 
256 /* Error return codes */
257 #define SSH_OK 0 /* No error */
258 #define SSH_ERROR -1 /* Error of some kind */
259 #define SSH_AGAIN -2 /* The nonblocking call must be repeated */
260 #define SSH_EOF -127 /* We have already a eof */
261 
268 enum {
284 };
286 #define SSH_LOG_RARE SSH_LOG_WARNING
287 
296 #define SSH_LOG_NONE 0
297 
298 #define SSH_LOG_WARN 1
299 
300 #define SSH_LOG_INFO 2
301 
302 #define SSH_LOG_DEBUG 3
303 
304 #define SSH_LOG_TRACE 4
305 
308 enum ssh_options_e {
309  SSH_OPTIONS_HOST,
310  SSH_OPTIONS_PORT,
311  SSH_OPTIONS_PORT_STR,
312  SSH_OPTIONS_FD,
313  SSH_OPTIONS_USER,
314  SSH_OPTIONS_SSH_DIR,
315  SSH_OPTIONS_IDENTITY,
316  SSH_OPTIONS_ADD_IDENTITY,
317  SSH_OPTIONS_KNOWNHOSTS,
318  SSH_OPTIONS_TIMEOUT,
319  SSH_OPTIONS_TIMEOUT_USEC,
320  SSH_OPTIONS_SSH1,
321  SSH_OPTIONS_SSH2,
322  SSH_OPTIONS_LOG_VERBOSITY,
323  SSH_OPTIONS_LOG_VERBOSITY_STR,
324  SSH_OPTIONS_CIPHERS_C_S,
325  SSH_OPTIONS_CIPHERS_S_C,
326  SSH_OPTIONS_COMPRESSION_C_S,
327  SSH_OPTIONS_COMPRESSION_S_C,
328  SSH_OPTIONS_PROXYCOMMAND,
329  SSH_OPTIONS_BINDADDR,
330  SSH_OPTIONS_STRICTHOSTKEYCHECK,
331  SSH_OPTIONS_COMPRESSION,
332  SSH_OPTIONS_COMPRESSION_LEVEL,
333  SSH_OPTIONS_KEY_EXCHANGE,
334  SSH_OPTIONS_HOSTKEYS,
335  SSH_OPTIONS_GSSAPI_SERVER_IDENTITY,
336  SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY,
337  SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS,
338 };
339 
340 enum {
342  SSH_SCP_WRITE,
344  SSH_SCP_READ,
345  SSH_SCP_RECURSIVE=0x10
346 };
347 
348 enum ssh_scp_request_types {
350  SSH_SCP_REQUEST_NEWDIR=1,
352  SSH_SCP_REQUEST_NEWFILE,
354  SSH_SCP_REQUEST_EOF,
356  SSH_SCP_REQUEST_ENDDIR,
358  SSH_SCP_REQUEST_WARNING
359 };
360 
361 LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout);
362 LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms);
363 LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows);
364 LIBSSH_API int ssh_channel_close(ssh_channel channel);
365 LIBSSH_API void ssh_channel_free(ssh_channel channel);
366 LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel);
367 LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel);
368 LIBSSH_API int ssh_channel_is_closed(ssh_channel channel);
369 LIBSSH_API int ssh_channel_is_eof(ssh_channel channel);
370 LIBSSH_API int ssh_channel_is_open(ssh_channel channel);
371 LIBSSH_API ssh_channel ssh_channel_new(ssh_session session);
372 LIBSSH_API int ssh_channel_open_auth_agent(ssh_channel channel);
373 LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost,
374  int remoteport, const char *sourcehost, int localport);
375 LIBSSH_API int ssh_channel_open_session(ssh_channel channel);
376 LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port);
377 LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr);
378 LIBSSH_API int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr);
379 LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr);
380 LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms);
381 LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
382  int is_stderr);
383 LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value);
384 LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd);
385 LIBSSH_API int ssh_channel_request_pty(ssh_channel channel);
386 LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term,
387  int cols, int rows);
388 LIBSSH_API int ssh_channel_request_shell(ssh_channel channel);
389 LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum);
390 LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel);
391 LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem);
392 LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
393  const char *cookie, int screen_number);
394 LIBSSH_API int ssh_channel_send_eof(ssh_channel channel);
395 LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
396  timeval * timeout);
397 LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
398 LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len);
399 LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel);
400 
401 LIBSSH_API char *ssh_basename (const char *path);
402 LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
403 LIBSSH_API int ssh_connect(ssh_session session);
404 LIBSSH_API const char *ssh_copyright(void);
405 LIBSSH_API void ssh_disconnect(ssh_session session);
406 LIBSSH_API char *ssh_dirname (const char *path);
407 LIBSSH_API int ssh_finalize(void);
408 LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms);
409 LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session, int timeout_ms, int *destination_port);
410 LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port);
411 LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port);
412 LIBSSH_API void ssh_free(ssh_session session);
413 LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session);
414 LIBSSH_API const char *ssh_get_error(void *error);
415 LIBSSH_API int ssh_get_error_code(void *error);
416 LIBSSH_API socket_t ssh_get_fd(ssh_session session);
417 LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
418 LIBSSH_API char *ssh_get_issue_banner(ssh_session session);
419 LIBSSH_API int ssh_get_openssh_version(ssh_session session);
420 
421 LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key);
422 
423 enum ssh_publickey_hash_type {
424  SSH_PUBLICKEY_HASH_SHA1,
425  SSH_PUBLICKEY_HASH_MD5
426 };
427 LIBSSH_API int ssh_get_publickey_hash(const ssh_key key,
428  enum ssh_publickey_hash_type type,
429  unsigned char **hash,
430  size_t *hlen);
431 
432 SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
433 
434 LIBSSH_API int ssh_get_random(void *where,int len,int strong);
435 LIBSSH_API int ssh_get_version(ssh_session session);
436 LIBSSH_API int ssh_get_status(ssh_session session);
437 LIBSSH_API int ssh_get_poll_flags(ssh_session session);
438 LIBSSH_API int ssh_init(void);
439 LIBSSH_API int ssh_is_blocking(ssh_session session);
440 LIBSSH_API int ssh_is_connected(ssh_session session);
441 LIBSSH_API int ssh_is_server_known(ssh_session session);
442 
443 /* LOGGING */
444 LIBSSH_API int ssh_set_log_level(int level);
445 LIBSSH_API int ssh_get_log_level(void);
446 LIBSSH_API void *ssh_get_log_userdata(void);
447 LIBSSH_API int ssh_set_log_userdata(void *data);
448 LIBSSH_API void _ssh_log(int verbosity,
449  const char *function,
450  const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
451 
452 /* legacy */
453 SSH_DEPRECATED LIBSSH_API void ssh_log(ssh_session session,
454  int prioriry,
455  const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
456 
457 LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
458 LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
459 LIBSSH_API void ssh_message_free(ssh_message msg);
460 LIBSSH_API ssh_message ssh_message_get(ssh_session session);
461 LIBSSH_API int ssh_message_subtype(ssh_message msg);
462 LIBSSH_API int ssh_message_type(ssh_message msg);
463 LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
464 LIBSSH_API ssh_session ssh_new(void);
465 
466 LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
467 LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv);
468 LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename);
469 LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
470  const void *value);
471 LIBSSH_API int ssh_options_get(ssh_session session, enum ssh_options_e type,
472  char **value);
473 LIBSSH_API int ssh_options_get_port(ssh_session session, unsigned int * port_target);
474 LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap);
475 LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap);
476 LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
477 LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
478 
492 typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
493  int echo, int verify, void *userdata);
494 
495 LIBSSH_API ssh_key ssh_key_new(void);
496 LIBSSH_API void ssh_key_free (ssh_key key);
497 LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key);
498 LIBSSH_API const char *ssh_key_type_to_char(enum ssh_keytypes_e type);
499 LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name);
500 LIBSSH_API int ssh_key_is_public(const ssh_key k);
501 LIBSSH_API int ssh_key_is_private(const ssh_key k);
502 LIBSSH_API int ssh_key_cmp(const ssh_key k1,
503  const ssh_key k2,
504  enum ssh_keycmp_e what);
505 
506 LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
507  ssh_key *pkey);
508 LIBSSH_API int ssh_pki_import_privkey_base64(const char *b64_key,
509  const char *passphrase,
510  ssh_auth_callback auth_fn,
511  void *auth_data,
512  ssh_key *pkey);
513 LIBSSH_API int ssh_pki_import_privkey_file(const char *filename,
514  const char *passphrase,
515  ssh_auth_callback auth_fn,
516  void *auth_data,
517  ssh_key *pkey);
518 LIBSSH_API int ssh_pki_export_privkey_file(const ssh_key privkey,
519  const char *passphrase,
520  ssh_auth_callback auth_fn,
521  void *auth_data,
522  const char *filename);
523 
524 LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key,
525  enum ssh_keytypes_e type,
526  ssh_key *pkey);
527 LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename,
528  ssh_key *pkey);
529 
530 LIBSSH_API int ssh_pki_export_privkey_to_pubkey(const ssh_key privkey,
531  ssh_key *pkey);
532 LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key,
533  char **b64_key);
534 LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key,
535  const char *filename);
536 
537 LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
538 LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data);
539 LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display);
540 LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds);
541 LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
542 LIBSSH_API int ssh_scp_close(ssh_scp scp);
543 LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
544 LIBSSH_API void ssh_scp_free(ssh_scp scp);
545 LIBSSH_API int ssh_scp_init(ssh_scp scp);
546 LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
547 LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
548 LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
549 LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
550 LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
551 LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms);
552 LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
553 LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
554 LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
555 LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
556 LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp);
557 LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
558 LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
559 LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
560  fd_set *readfds, struct timeval *timeout);
561 LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
562 LIBSSH_API int ssh_set_agent_channel(ssh_session session, ssh_channel channel);
563 LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
564 LIBSSH_API void ssh_set_fd_except(ssh_session session);
565 LIBSSH_API void ssh_set_fd_toread(ssh_session session);
566 LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
567 LIBSSH_API void ssh_silent_disconnect(ssh_session session);
568 LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile);
569 
570 /* USERAUTH */
571 LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username);
572 LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username);
573 LIBSSH_API int ssh_userauth_try_publickey(ssh_session session,
574  const char *username,
575  const ssh_key pubkey);
576 LIBSSH_API int ssh_userauth_publickey(ssh_session session,
577  const char *username,
578  const ssh_key privkey);
579 #ifndef _WIN32
580 LIBSSH_API int ssh_userauth_agent(ssh_session session,
581  const char *username);
582 #endif
583 LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
584  const char *username,
585  const char *passphrase);
586 LIBSSH_API int ssh_userauth_password(ssh_session session,
587  const char *username,
588  const char *password);
589 
590 LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods);
591 LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session session);
592 LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session);
593 LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session);
594 LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo);
595 LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session);
596 LIBSSH_API const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i);
597 LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i,
598  const char *answer);
599 LIBSSH_API int ssh_userauth_gssapi(ssh_session session);
600 LIBSSH_API const char *ssh_version(int req_version);
601 LIBSSH_API int ssh_write_knownhost(ssh_session session);
602 
603 LIBSSH_API void ssh_string_burn(ssh_string str);
604 LIBSSH_API ssh_string ssh_string_copy(ssh_string str);
605 LIBSSH_API void *ssh_string_data(ssh_string str);
606 LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len);
607 LIBSSH_API void ssh_string_free(ssh_string str);
608 LIBSSH_API ssh_string ssh_string_from_char(const char *what);
609 LIBSSH_API size_t ssh_string_len(ssh_string str);
610 LIBSSH_API ssh_string ssh_string_new(size_t size);
611 LIBSSH_API const char *ssh_string_get_char(ssh_string str);
612 LIBSSH_API char *ssh_string_to_char(ssh_string str);
613 LIBSSH_API void ssh_string_free_char(char *s);
614 
615 LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo,
616  int verify);
617 
618 
619 typedef int (*ssh_event_callback)(socket_t fd, int revents, void *userdata);
620 
621 LIBSSH_API ssh_event ssh_event_new(void);
622 LIBSSH_API int ssh_event_add_fd(ssh_event event, socket_t fd, short events,
623  ssh_event_callback cb, void *userdata);
624 LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session);
625 LIBSSH_API int ssh_event_dopoll(ssh_event event, int timeout);
626 LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd);
627 LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session);
628 LIBSSH_API void ssh_event_free(ssh_event event);
629 LIBSSH_API const char* ssh_get_clientbanner(ssh_session session);
630 LIBSSH_API const char* ssh_get_serverbanner(ssh_session session);
631 LIBSSH_API const char* ssh_get_cipher_in(ssh_session session);
632 LIBSSH_API const char* ssh_get_cipher_out(ssh_session session);
633 
634 #ifndef LIBSSH_LEGACY_0_4
635 #include "libssh/legacy.h"
636 #endif
637 
638 #ifdef __cplusplus
639 }
640 #endif
641 #endif /* _LIBSSH_H */
642 /* vim: set ts=2 sw=2 et cindent: */