diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2005-07-05 21:10:50 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2005-07-05 21:10:50 +0000 |
commit | 55846a4c7b09af2d105c7f7dfd0a43aab2f6e5a5 (patch) | |
tree | 14a9b2f68ddbf29eb80e119e85d0bff4627f1d3f /include/libssh | |
parent | d40f16d48ec1ed9670c20ffaad1005c59a689484 (diff) | |
download | libssh-55846a4c7b09af2d105c7f7dfd0a43aab2f6e5a5.tar.gz libssh-55846a4c7b09af2d105c7f7dfd0a43aab2f6e5a5.tar.xz libssh-55846a4c7b09af2d105c7f7dfd0a43aab2f6e5a5.zip |
Beginning of the SSH_BIND implementation
hack for errors handling so it supports an Object-oriented kind of errors (generic for ssh_bind and ssh_session data types)
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@3 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/libssh.h | 4 | ||||
-rw-r--r-- | include/libssh/priv.h | 27 | ||||
-rw-r--r-- | include/libssh/server.h | 24 |
3 files changed, 41 insertions, 14 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 9e3495b8..0fc40178 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -91,8 +91,8 @@ typedef u_int8_t u8; #define SSH_EINTR 3 -char *ssh_get_error(SSH_SESSION *session); -int ssh_get_error_code(SSH_SESSION *session); +char *ssh_get_error(void *error); +int ssh_get_error_code(void *error); void ssh_say(int priority,char *format,...); void ssh_set_verbosity(int num); diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 5899fb6a..4c5b9d30 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -223,12 +223,23 @@ struct channel_struct { int blocking; }; + +struct error_struct { +/* error handling */ + int error_code; + char error_buffer[ERROR_BUFFERLEN]; +}; + + struct ssh_session { + struct error_struct error; int fd; SSH_OPTIONS *options; char *serverbanner; char *clientbanner; int protoversion; + int server; + int client; u32 send_seq; u32 recv_seq; /* status flags */ @@ -272,9 +283,6 @@ struct ssh_session { int exec_channel_opened; /* version 1 only. more info in channels1.c */ -/* error handling */ - int error_code; - char error_buffer[ERROR_BUFFERLEN]; /* keyb interactive data */ struct ssh_kbdint *kbdint; int version; /* 1 or 2 */ @@ -294,7 +302,7 @@ void ssh_cleanup(SSH_SESSION *session); /* errors.c */ -void ssh_set_error(SSH_SESSION *session,int code,char *descr,...); +void ssh_set_error(void *error,int code,char *descr,...); /* in dh.c */ /* DH key generation */ @@ -360,12 +368,15 @@ void channel_handle(SSH_SESSION *session, int type); CHANNEL *channel_new(SSH_SESSION *session); void channel_default_bufferize(CHANNEL *channel, void *data, int len, int is_stderr); + + /* options.c */ -void options_free(SSH_OPTIONS *opt); + +void ssh_options_free(SSH_OPTIONS *opt); /* this function must be called when no specific username has been asked. it has to guess it */ -int options_default_username(SSH_OPTIONS *opt); -int options_default_ssh_dir(SSH_OPTIONS *opt); -int options_default_known_hosts_file(SSH_OPTIONS *opt); +int ssh_options_default_username(SSH_OPTIONS *opt); +int ssh_options_default_ssh_dir(SSH_OPTIONS *opt); +int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt); /* buffer.c */ void buffer_add_ssh_string(BUFFER *buffer,STRING *string); diff --git a/include/libssh/server.h b/include/libssh/server.h index 90c280ee..8e68f137 100644 --- a/include/libssh/server.h +++ b/include/libssh/server.h @@ -20,12 +20,28 @@ MA 02111-1307, USA. */ #ifndef SERVER_H #define SERVER_H -/* the client banner doesn't say hey! look i'm a client ! */ + #include "libssh/libssh.h" +#include "libssh/priv.h" #define SERVERBANNER CLIENTBANNER -int bind_socket(); -int listen_socket(int s); -int accept_socket(int s); +struct ssh_bind_struct { + struct error_struct error; + int bindfd; + SSH_OPTIONS *options; + int blocking; + int toaccept; +}; + +typedef struct ssh_bind_struct SSH_BIND; + +SSH_BIND *ssh_bind_new(); +void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options); +int ssh_bind_listen(SSH_BIND *ssh_bind); +void ssh_bind_set_blocking(SSH_BIND *ssh_bind,int blocking); +int ssh_bind_get_fd(SSH_BIND *ssh_bind); +int ssh_bind_set_toaccept(SSH_BIND *ssh_bind); +SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind); + #endif |