libssh.h   libssh.h 
/* /*
* This file is part of the SSH Library * This file is part of the SSH Library
* *
* Copyright (c) 2003-2008 by Aris Adamantiadis * Copyright (c) 2003-2009 by Aris Adamantiadis
* *
* The SSH Library is free software; you can redistribute it and/or modify * The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. * option) any later version.
* *
* The SSH Library is distributed in the hope that it will be useful, but * The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILI TY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILI TY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details. * License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to * along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA. * MA 02111-1307, USA.
*/ */
#ifndef _LIBSSH_H #ifndef _LIBSSH_H
#define _LIBSSH_H #define _LIBSSH_H
#ifndef _MSC_VER #ifdef LIBSSH_STATIC
#include <unistd.h> #define LIBSSH_API
#include <inttypes.h> #else
#if defined _WIN32 || defined __CYGWIN__
#ifdef LIBSSH_EXPORTS
#ifdef __GNUC__
#define LIBSSH_API __attribute__((dllexport))
#else
#define LIBSSH_API __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define LIBSSH_API __attribute__((dllimport))
#else
#define LIBSSH_API __declspec(dllimport)
#endif
#endif
#else
#if __GNUC__ >= 4
#define LIBSSH_API __attribute__((visibility("default")))
#else
#define LIBSSH_API
#endif
#endif
#endif
#ifdef _MSC_VER
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
typedef int int32_t;
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef unsigned long long uint64_t;
typedef int mode_t;
#else /* _MSC_VER */ #else /* _MSC_VER */
//visual studio hasn't inttypes.h so it doesn't know uint32_t #include <unistd.h>
typedef unsigned int uint32_t; #include <inttypes.h>
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef unsigned long long uint64_t;
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
#else #else /* _WIN32 */
#include <sys/select.h> /* for fd_set * */ #include <sys/select.h> /* for fd_set * */
#include <netdb.h> #include <netdb.h>
#endif /* _WIN32 */ #endif /* _WIN32 */
#define SSH_STRINGIFY(s) SSH_TOSTRING(s) #define SSH_STRINGIFY(s) SSH_TOSTRING(s)
#define SSH_TOSTRING(s) #s #define SSH_TOSTRING(s) #s
/* libssh version macros */ /* libssh version macros */
#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c)) #define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
#define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c #define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
#define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c) #define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
/* libssh version */ /* libssh version */
#define LIBSSH_VERSION_MAJOR 0 #define LIBSSH_VERSION_MAJOR 0
#define LIBSSH_VERSION_MINOR 3 #define LIBSSH_VERSION_MINOR 4
#define LIBSSH_VERSION_MICRO 4 #define LIBSSH_VERSION_MICRO 0
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \ #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \ LIBSSH_VERSION_MINOR, \
LIBSSH_VERSION_MICRO) LIBSSH_VERSION_MICRO)
#define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \ #define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \ LIBSSH_VERSION_MINOR, \
LIBSSH_VERSION_MICRO) LIBSSH_VERSION_MICRO)
/* GCC have printf type attribute check. */ /* GCC have printf type attribute check. */
#ifdef __GNUC__ #ifdef __GNUC__
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b) )) #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b) ))
#else #else
#define PRINTF_ATTRIBUTE(a,b) #define PRINTF_ATTRIBUTE(a,b)
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#ifdef __GNUC__
#define SSH_DEPRECATED __attribute__ ((deprecated))
#else
#define SSH_DEPRECATED
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct string_struct STRING; typedef struct ssh_agent_struct* ssh_agent;
typedef struct buffer_struct BUFFER; typedef struct ssh_buffer_struct* ssh_buffer;
typedef struct public_key_struct PUBLIC_KEY; typedef struct ssh_channel_struct* ssh_channel;
typedef struct private_key_struct PRIVATE_KEY; typedef struct ssh_message_struct* ssh_message;
typedef struct ssh_options_struct SSH_OPTIONS; typedef struct ssh_pcap_file_struct* ssh_pcap_file;
typedef struct channel_struct CHANNEL; typedef struct ssh_private_key_struct* ssh_private_key;
typedef struct agent_struct AGENT; typedef struct ssh_public_key_struct* ssh_public_key;
typedef struct ssh_session SSH_SESSION; typedef struct ssh_scp_struct* ssh_scp;
typedef struct ssh_kbdint SSH_KBDINT; typedef struct ssh_session_struct* ssh_session;
typedef struct ssh_string_struct* ssh_string;
/* integer values */
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint64_t u64;
typedef uint8_t u8;
/* Socket type */ /* Socket type */
#ifdef _WIN32 #ifdef _WIN32
#define socket_t SOCKET #define socket_t SOCKET
#else #else
typedef int socket_t; typedef int socket_t;
#endif #endif
/* the offsets of methods */ /* the offsets of methods */
#define SSH_KEX 0 enum ssh_kex_types_e {
#define SSH_HOSTKEYS 1 SSH_KEX=0,
#define SSH_CRYPT_C_S 2 SSH_HOSTKEYS,
#define SSH_CRYPT_S_C 3 SSH_CRYPT_C_S,
#define SSH_MAC_C_S 4 SSH_CRYPT_S_C,
#define SSH_MAC_S_C 5 SSH_MAC_C_S,
#define SSH_COMP_C_S 6 SSH_MAC_S_C,
#define SSH_COMP_S_C 7 SSH_COMP_C_S,
#define SSH_LANG_C_S 8 SSH_COMP_S_C,
#define SSH_LANG_S_C 9 SSH_LANG_C_S,
SSH_LANG_S_C
};
#define SSH_CRYPT 2 #define SSH_CRYPT 2
#define SSH_MAC 3 #define SSH_MAC 3
#define SSH_COMP 4 #define SSH_COMP 4
#define SSH_LANG 5 #define SSH_LANG 5
#define SSH_AUTH_SUCCESS 0 enum ssh_auth_e {
#define SSH_AUTH_DENIED 1 SSH_AUTH_SUCCESS=0,
#define SSH_AUTH_PARTIAL 2 SSH_AUTH_DENIED,
#define SSH_AUTH_INFO 3 SSH_AUTH_PARTIAL,
#define SSH_AUTH_ERROR -1 SSH_AUTH_INFO,
SSH_AUTH_ERROR=-1
#define SSH_AUTH_METHOD_PASSWORD 0x0001 };
#define SSH_AUTH_METHOD_PUBLICKEY 0x0002
#define SSH_AUTH_METHOD_HOSTBASED 0x0004
#define SSH_AUTH_METHOD_INTERACTIVE 0x0008
/* status flags */ /* auth flags */
#define SSH_AUTH_METHOD_UNKNOWN 0
#define SSH_AUTH_METHOD_NONE 0x0001
#define SSH_AUTH_METHOD_PASSWORD 0x0002
#define SSH_AUTH_METHOD_PUBLICKEY 0x0004
#define SSH_AUTH_METHOD_HOSTBASED 0x0008
#define SSH_AUTH_METHOD_INTERACTIVE 0x0010
/* messages */
enum ssh_requests_e {
SSH_REQUEST_AUTH=1,
SSH_REQUEST_CHANNEL_OPEN,
SSH_REQUEST_CHANNEL,
SSH_REQUEST_SERVICE,
SSH_REQUEST_GLOBAL,
};
enum ssh_channel_type_e {
SSH_CHANNEL_UNKNOWN=0,
SSH_CHANNEL_SESSION,
SSH_CHANNEL_DIRECT_TCPIP,
SSH_CHANNEL_FORWARDED_TCPIP,
SSH_CHANNEL_X11
};
enum ssh_channel_requests_e {
SSH_CHANNEL_REQUEST_UNKNOWN=0,
SSH_CHANNEL_REQUEST_PTY,
SSH_CHANNEL_REQUEST_EXEC,
SSH_CHANNEL_REQUEST_SHELL,
SSH_CHANNEL_REQUEST_ENV,
SSH_CHANNEL_REQUEST_SUBSYSTEM,
SSH_CHANNEL_REQUEST_WINDOW_CHANGE,
};
#define SSH_CLOSED (1<<0) /* status flags */
#define SSH_READ_PENDING (1<<1) #define SSH_CLOSED 0x01
#define SSH_CLOSED_ERROR (1<<2) #define SSH_READ_PENDING 0x02
#define SSH_CLOSED_ERROR 0x04
#define SSH_SERVER_ERROR -1
#define SSH_SERVER_NOT_KNOWN 0 enum ssh_server_known_e {
#define SSH_SERVER_KNOWN_OK 1 SSH_SERVER_ERROR=-1,
#define SSH_SERVER_KNOWN_CHANGED 2 SSH_SERVER_NOT_KNOWN=0,
#define SSH_SERVER_FOUND_OTHER 3 SSH_SERVER_KNOWN_OK,
#define SSH_SERVER_FILE_NOT_FOUND 4 SSH_SERVER_KNOWN_CHANGED,
SSH_SERVER_FOUND_OTHER,
SSH_SERVER_FILE_NOT_FOUND,
};
#ifndef MD5_DIGEST_LEN #ifndef MD5_DIGEST_LEN
#define MD5_DIGEST_LEN 16 #define MD5_DIGEST_LEN 16
#endif #endif
/* errors */ /* errors */
#define SSH_NO_ERROR 0 enum ssh_error_types_e {
#define SSH_REQUEST_DENIED 1 SSH_NO_ERROR=0,
#define SSH_FATAL 2 SSH_REQUEST_DENIED,
#define SSH_EINTR 3 SSH_FATAL,
SSH_EINTR
};
/* Error return codes */ /* Error return codes */
#define SSH_OK 0 /* No error */ #define SSH_OK 0 /* No error */
#define SSH_ERROR -1 /* Error of some kind */ #define SSH_ERROR -1 /* Error of some kind */
#define SSH_AGAIN -2 /* The nonblocking call must be repeated */ #define SSH_AGAIN -2 /* The nonblocking call must be repeated */
#define SSH_EOF -127 /* We have already a eof */ #define SSH_EOF -127 /* We have already a eof */
const char *ssh_get_error(void *error);
int ssh_get_error_code(void *error);
/* version checks */
const char *ssh_version(int req_version);
/** \addtogroup ssh_log /** \addtogroup ssh_log
* @{ * @{
*/ */
/** \brief Verbosity level for logging and help to debugging /** \brief Verbosity level for logging and help to debugging
*/ */
enum { enum {
/** No logging at all /** No logging at all
*/ */
SSH_LOG_NOLOG=0, SSH_LOG_NOLOG=0,
skipping to change at line 185 skipping to change at line 245
SSH_LOG_PROTOCOL, SSH_LOG_PROTOCOL,
/** Lower level protocol infomations, packet level /** Lower level protocol infomations, packet level
*/ */
SSH_LOG_PACKET, SSH_LOG_PACKET,
/** Every function path /** Every function path
*/ */
SSH_LOG_FUNCTIONS SSH_LOG_FUNCTIONS
}; };
/** @} /** @}
*/ */
/*#define SSH_LOG_NOLOG 0 // no log
#define SSH_LOG_RARE 1 // rare conditions
#define SSH_LOG_ENTRY 2 // user-accessible entrypoints
#define SSH_LOG_PACKET 3 // packet id and size
#define SSH_LOG_FUNCTIONS 4 // every function in and return
*/
/* log.c */
void ssh_log(SSH_SESSION *session, int prioriry, const char *format, ...) P
RINTF_ATTRIBUTE(3, 4);
/* session.c */
SSH_SESSION *ssh_new(void);
socket_t ssh_get_fd(SSH_SESSION *session);
int ssh_get_version(SSH_SESSION *session);
int ssh_get_status(SSH_SESSION *session);
const char *ssh_get_disconnect_message(SSH_SESSION *session);
void ssh_set_options(SSH_SESSION *session, SSH_OPTIONS *options);
void ssh_set_fd_toread(SSH_SESSION *session);
void ssh_set_fd_towrite(SSH_SESSION *session);
void ssh_set_fd_except(SSH_SESSION *session);
void ssh_set_blocking(SSH_SESSION *session, int blocking);
void ssh_silent_disconnect(SSH_SESSION *session);
/* client.c */
int ssh_connect(SSH_SESSION *session);
void ssh_disconnect(SSH_SESSION *session);
int ssh_service_request(SSH_SESSION *session, const char *service);
char *ssh_get_issue_banner(SSH_SESSION *session);
int ssh_get_openssh_version(SSH_SESSION *session);
/* get copyright informations */
const char *ssh_copyright(void);
/* string.h */
/* You can use these functions, they won't change */
/* string_from_char returns a newly allocated string from a char *ptr */
STRING *string_from_char(const char *what);
/* it returns the string len in host byte orders. str->size is big endian w
arning ! */
size_t string_len(STRING *str);
STRING *string_new(size_t size);
/* string_fill copies the data in the string. */
int string_fill(STRING *str, const void *data, size_t len);
/* returns a newly allocated char array with the str string and a final nul
caracter */
char *string_to_char(STRING *str);
STRING *string_copy(STRING *str);
/* burns the data inside a string */
void string_burn(STRING *str);
void *string_data(STRING *str);
void string_free(STRING *str);
/* useful for debug */
char *ssh_get_hexa(const unsigned char *what, size_t len);
void ssh_print_hexa(const char *descr, const unsigned char *what, size_t le
n);
int ssh_get_random(void *where,int len,int strong);
/* this one can be called by the client to see the hash of the public key b
efore accepting it */
int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash);
STRING *ssh_get_pubkey(SSH_SESSION *session);
/* in connect.c */
int ssh_fd_poll(SSH_SESSION *session,int *write, int *except);
int ssh_select(CHANNEL **channels, CHANNEL **outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout);
void publickey_free(PUBLIC_KEY *key);
/* in keyfiles.c */ enum ssh_options_e {
SSH_OPTIONS_HOST,
SSH_OPTIONS_PORT,
SSH_OPTIONS_PORT_STR,
SSH_OPTIONS_FD,
SSH_OPTIONS_USER,
SSH_OPTIONS_SSH_DIR,
SSH_OPTIONS_IDENTITY,
SSH_OPTIONS_KNOWNHOSTS,
SSH_OPTIONS_TIMEOUT,
SSH_OPTIONS_TIMEOUT_USEC,
SSH_OPTIONS_SSH1,
SSH_OPTIONS_SSH2,
SSH_OPTIONS_LOG_VERBOSITY,
SSH_OPTIONS_LOG_VERBOSITY_STR,
SSH_OPTIONS_CIPHERS_C_S,
SSH_OPTIONS_CIPHERS_S_C,
SSH_OPTIONS_COMPRESSION_C_S,
SSH_OPTIONS_COMPRESSION_S_C
};
PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filenam enum {
e, /** Code is going to write/create remote files */
int type, const char *passphrase); SSH_SCP_WRITE,
STRING *publickey_to_string(PUBLIC_KEY *key); /** Code is going to read remote files */
PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv); SSH_SCP_READ,
void privatekey_free(PRIVATE_KEY *prv); SSH_SCP_RECURSIVE=0x10
STRING *publickey_from_file(SSH_SESSION *session, const char *filename, };
int *type);
int ssh_is_server_known(SSH_SESSION *session);
int ssh_write_knownhost(SSH_SESSION *session);
/* in channels.c */ enum ssh_scp_request_types {
/** A new directory is going to be pulled */
SSH_SCP_REQUEST_NEWDIR=1,
/** A new file is going to be pulled */
SSH_SCP_REQUEST_NEWFILE,
/** End of requests */
SSH_SCP_REQUEST_EOF,
/** End of directory */
SSH_SCP_REQUEST_ENDDIR,
/** Warning received */
SSH_SCP_REQUEST_WARNING
};
CHANNEL *channel_new(SSH_SESSION *session); LIBSSH_API void buffer_free(ssh_buffer buffer);
int channel_open_forward(CHANNEL *channel, const char *remotehost, LIBSSH_API void *buffer_get(ssh_buffer buffer);
LIBSSH_API uint32_t buffer_get_len(ssh_buffer buffer);
LIBSSH_API ssh_buffer buffer_new(void);
LIBSSH_API ssh_channel channel_accept_x11(ssh_channel channel, int timeout_
ms);
LIBSSH_API int channel_change_pty_size(ssh_channel channel,int cols,int row
s);
LIBSSH_API ssh_channel channel_forward_accept(ssh_session session, int time
out_ms);
LIBSSH_API int channel_close(ssh_channel channel);
LIBSSH_API int channel_forward_cancel(ssh_session session, const char *addr
ess, int port);
LIBSSH_API int channel_forward_listen(ssh_session session, const char *addr
ess, int port, int *bound_port);
LIBSSH_API void channel_free(ssh_channel channel);
LIBSSH_API int channel_get_exit_status(ssh_channel channel);
LIBSSH_API ssh_session channel_get_session(ssh_channel channel);
LIBSSH_API int channel_is_closed(ssh_channel channel);
LIBSSH_API int channel_is_eof(ssh_channel channel);
LIBSSH_API int channel_is_open(ssh_channel channel);
LIBSSH_API ssh_channel channel_new(ssh_session session);
LIBSSH_API int channel_open_forward(ssh_channel channel, const char *remote
host,
int remoteport, const char *sourcehost, int localport); int remoteport, const char *sourcehost, int localport);
int channel_open_session(CHANNEL *channel); LIBSSH_API int channel_open_session(ssh_channel channel);
void channel_free(CHANNEL *channel); LIBSSH_API int channel_poll(ssh_channel channel, int is_stderr);
int channel_request_pty(CHANNEL *channel); LIBSSH_API int channel_read(ssh_channel channel, void *dest, uint32_t count
int channel_request_pty_size(CHANNEL *channel, const char *term, , int is_stderr);
int cols, int rows); LIBSSH_API int channel_read_buffer(ssh_channel channel, ssh_buffer buffer,
int channel_change_pty_size(CHANNEL *channel,int cols,int rows); uint32_t count,
int channel_request_shell(CHANNEL *channel);
int channel_request_subsystem(CHANNEL *channel, const char *system);
int channel_request_env(CHANNEL *channel, const char *name, const char *val
ue);
int channel_request_exec(CHANNEL *channel, const char *cmd);
int channel_request_sftp(CHANNEL *channel);
int channel_write(CHANNEL *channel, const void *data, u32 len);
int channel_send_eof(CHANNEL *channel);
int channel_is_eof(CHANNEL *channel);
int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr);
int channel_read_buffer(CHANNEL *channel, BUFFER *buffer, u32 count,
int is_stderr); int is_stderr);
int channel_poll(CHANNEL *channel, int is_stderr); LIBSSH_API int channel_read_nonblocking(ssh_channel channel, void *dest, ui
int channel_close(CHANNEL *channel); nt32_t count,
void channel_set_blocking(CHANNEL *channel, int blocking);
int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count,
int is_stderr); int is_stderr);
int channel_is_open(CHANNEL *channel); LIBSSH_API int channel_request_env(ssh_channel channel, const char *name, c
int channel_is_closed(CHANNEL *channel); onst char *value);
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exc LIBSSH_API int channel_request_exec(ssh_channel channel, const char *cmd);
eptchans, struct LIBSSH_API int channel_request_pty(ssh_channel channel);
LIBSSH_API int channel_request_pty_size(ssh_channel channel, const char *te
rm,
int cols, int rows);
LIBSSH_API int channel_request_shell(ssh_channel channel);
LIBSSH_API int channel_request_send_signal(ssh_channel channel, const char
*signum);
LIBSSH_API int channel_request_sftp(ssh_channel channel);
LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *s
ubsystem);
LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connecti
on, const char *protocol,
const char *cookie, int screen_number);
LIBSSH_API int channel_send_eof(ssh_channel channel);
LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel *writecha
ns, ssh_channel *exceptchans, struct
timeval * timeout); timeval * timeout);
SSH_SESSION *channel_get_session(CHANNEL *channel); LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking);
int channel_get_exit_status(CHANNEL *channel); LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_
/* in options.c */ t len);
/** LIBSSH_API void privatekey_free(ssh_private_key prv);
* @brief SSH authentication callback. LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const
* char *filename,
* @param prompt Prompt to be displayed. int type, const char *passphrase);
* @param buf Buffer to save the password. You should null-termin LIBSSH_API void publickey_free(ssh_public_key key);
ate it. LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *
* @param len Length of the buffer. filename,
* @param echo Enable or disable the echo of what you type. int *type);
* @param verify Should the password be verified? LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv);
* @param userdata Userdata to be passed to the callback function. Use LIBSSH_API ssh_string publickey_to_string(ssh_public_key key);
ful
* for GUI applications.
*
* @return 0 on success, < 0 on error.
*/
typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len
,
int echo, int verify, void *userdata);
SSH_OPTIONS *ssh_options_new(void);
SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt);
void ssh_options_free(SSH_OPTIONS *opt);
int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *li
st);
int ssh_options_set_username(SSH_OPTIONS *opt, const char *username);
int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port);
int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv);
int ssh_options_set_host(SSH_OPTIONS *opt, const char *host);
int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port);
int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir);
int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner);
int ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
(void *arg, float status), void *arg);
int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
int ssh_options_set_log_function(SSH_OPTIONS *opt,
void (*callback)(const char *message, SSH_SESSION *session, int verbosi
ty));
int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity);
int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);
int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey);
int ssh_options_set_auth_callback(SSH_OPTIONS *opt, ssh_auth_callback cb,
void *userdata);
/* buffer.c */
/** creates a new buffer LIBSSH_API int ssh_auth_list(ssh_session session);
*/ LIBSSH_API char *ssh_basename (const char *path);
BUFFER *buffer_new(void); LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
void buffer_free(BUFFER *buffer); LIBSSH_API int ssh_connect(ssh_session session);
/* buffer_get returns a pointer to the begining of the buffer. no position LIBSSH_API const char *ssh_copyright(void);
is taken into account */ LIBSSH_API void ssh_disconnect(ssh_session session);
void *buffer_get(BUFFER *buffer); LIBSSH_API char *ssh_dirname (const char *path);
/* same here */ LIBSSH_API int ssh_finalize(void);
u32 buffer_get_len(BUFFER *buffer); LIBSSH_API void ssh_free(ssh_session session);
LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session);
/* in auth.c */ LIBSSH_API const char *ssh_get_error(void *error);
int ssh_auth_list(SSH_SESSION *session); LIBSSH_API int ssh_get_error_code(void *error);
/* these functions returns AUTH_ERROR is some serious error has happened, LIBSSH_API socket_t ssh_get_fd(ssh_session session);
AUTH_SUCCESS if success, LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
AUTH_PARTIAL if partial success, LIBSSH_API char *ssh_get_issue_banner(ssh_session session);
AUTH_DENIED if refused */ LIBSSH_API int ssh_get_openssh_version(ssh_session session);
int ssh_userauth_list(SSH_SESSION *session, const char *username); LIBSSH_API ssh_string ssh_get_pubkey(ssh_session session);
int ssh_userauth_none(SSH_SESSION *session, const char *username); LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **has
int ssh_userauth_password(SSH_SESSION *session, const char *username, const h);
char *password); LIBSSH_API int ssh_get_random(void *where,int len,int strong);
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, i LIBSSH_API int ssh_get_version(ssh_session session);
nt type, STRING *publickey); LIBSSH_API int ssh_get_status(ssh_session session);
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, STRING LIBSSH_API int ssh_init(void);
*publickey, PRIVATE_KEY *privatekey); LIBSSH_API int ssh_is_server_known(ssh_session session);
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username, LIBSSH_API void ssh_log(ssh_session session, int prioriry, const char *form
PUBLIC_KEY *publickey); at, ...) PRINTF_ATTRIBUTE(3, 4);
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase); LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_me
int ssh_userauth_kbdint(SSH_SESSION *session, const char *user, const char ssage msg);
*submethods); LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
int ssh_userauth_kbdint_getnprompts(SSH_SESSION *session); LIBSSH_API void ssh_message_free(ssh_message msg);
const char *ssh_userauth_kbdint_getname(SSH_SESSION *session); LIBSSH_API ssh_message ssh_message_get(ssh_session session);
const char *ssh_userauth_kbdint_getinstruction(SSH_SESSION *session); LIBSSH_API ssh_message ssh_message_retrieve(ssh_session session, uint32_t p
const char *ssh_userauth_kbdint_getprompt(SSH_SESSION *session, unsigned in ackettype);
t i, char *echo); LIBSSH_API int ssh_message_subtype(ssh_message msg);
int ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i, LIBSSH_API int ssh_message_type(ssh_message msg);
LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
LIBSSH_API ssh_session ssh_new(void);
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char *
*argv);
LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *fi
lename);
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type
,
const void *value);
LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap);
LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap);
LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename)
;
LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what
, size_t len);
LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
LIBSSH_API int ssh_scp_close(ssh_scp scp);
LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
LIBSSH_API void ssh_scp_free(ssh_scp scp);
LIBSSH_API int ssh_scp_init(ssh_scp scp);
LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *l
ocation);
LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int
mode);
LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t
size, int perms);
LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels,
socket_t maxfd,
fd_set *readfds, struct timeval *timeout);
LIBSSH_API int ssh_service_request(ssh_session session, const char *service
);
LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
LIBSSH_API void ssh_set_fd_except(ssh_session session);
LIBSSH_API void ssh_set_fd_toread(ssh_session session);
LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
LIBSSH_API void ssh_silent_disconnect(ssh_session session);
LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfil
e);
#ifndef _WIN32
LIBSSH_API int ssh_userauth_agent_pubkey(ssh_session session, const char *u
sername,
ssh_public_key publickey);
#endif
LIBSSH_API int ssh_userauth_autopubkey(ssh_session session, const char *pas
sphrase);
LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, c
onst char *submethods);
LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session sessi
on);
LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session);
LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session);
LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, u
nsigned int i, char *echo);
LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned
int i,
const char *answer); const char *answer);
LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username)
/* misc.c */ ;
int ssh_mkdir (const char *pathname, mode_t mode); LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username)
char *ssh_dirname (const char *path); ;
char *ssh_basename (const char *path); LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *u
sername, int type, ssh_string publickey);
/* init.c */ LIBSSH_API int ssh_userauth_password(ssh_session session, const char *usern
int ssh_init(void); ame, const char *password);
int ssh_finalize(void); LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *usernam
e, ssh_string publickey, ssh_private_key privatekey);
LIBSSH_API const char *ssh_version(int req_version);
LIBSSH_API int ssh_write_knownhost(ssh_session session);
LIBSSH_API void string_burn(ssh_string str);
LIBSSH_API ssh_string string_copy(ssh_string str);
LIBSSH_API void *string_data(ssh_string str);
LIBSSH_API int string_fill(ssh_string str, const void *data, size_t len);
LIBSSH_API void string_free(ssh_string str);
LIBSSH_API ssh_string string_from_char(const char *what);
LIBSSH_API size_t string_len(ssh_string str);
LIBSSH_API ssh_string string_new(size_t size);
LIBSSH_API char *string_to_char(ssh_string str);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _LIBSSH_H */ #endif /* _LIBSSH_H */
/* vim: set ts=2 sw=2 et cindent: */ /* vim: set ts=2 sw=2 et cindent: */
 End of changes. 25 change blocks. 
275 lines changed or deleted 359 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/