summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-08-23 16:33:59 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-08-23 16:33:59 +0200
commit8bae43876fff891e33d48b177778ee4cb882c45a (patch)
tree5c30ea9b6f73de5b116ad35e73f6da5bb2e6a301
parente707af1cd78f730e80da7b109ee33985d0ee3419 (diff)
downloadlibssh-8bae43876fff891e33d48b177778ee4cb882c45a.tar.gz
libssh-8bae43876fff891e33d48b177778ee4cb882c45a.tar.xz
libssh-8bae43876fff891e33d48b177778ee4cb882c45a.zip
experimental callback system
-rw-r--r--include/libssh/callback.h43
-rw-r--r--include/libssh/libssh.h3
-rw-r--r--include/libssh/priv.h8
-rw-r--r--include/libssh/server.h2
-rw-r--r--libssh/keys.c2
-rw-r--r--libssh/server.c2
-rw-r--r--libssh/session.c1
7 files changed, 53 insertions, 8 deletions
diff --git a/include/libssh/callback.h b/include/libssh/callback.h
new file mode 100644
index 0000000..759db0e
--- /dev/null
+++ b/include/libssh/callback.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the SSH Library
+ *
+ * Copyright (c) 2009 Aris Adamantiadis <aris@0xbadc0de.be>
+ *
+ * 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
+ * the Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * The SSH Library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * 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
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/* callback.h
+ * This file includes the declarations for the libssh callback mechanism
+ */
+
+#include "libssh.h"
+
+typedef int (*ssh_callback_int) (ssh_session session, void *user, int code);
+typedef int (*ssh_message_callback) (ssh_session, void *user, ssh_message message);
+typedef int (*ssh_channel_callback_int) (ssh_channel channel, void *user, int code);
+typedef int (*ssh_channel_callback_data) (ssh_channel channel, void *user, int code, void *data, int len);
+
+struct ssh_callbacks_struct {
+ ssh_callback_int connection_progress;
+ void *connection_progress_user;
+ ssh_channel_callback_int channel_write_confirm;
+ void *channel_write_confirm_user;
+ ssh_channel_callback_data channel_read_available;
+ void *channel_read_available_user;
+};
+
+typedef struct ssh_callbacks_struct * ssh_callbacks;
+
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 62a74ff..e544787 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -441,7 +441,8 @@ LIBSSH_API int ssh_init(void);
LIBSSH_API int ssh_finalize(void);
/* messages.c */
-typedef struct ssh_message SSH_MESSAGE;
+typedef struct ssh_message_struct SSH_MESSAGE;
+typedef struct ssh_message_struct *ssh_message;
LIBSSH_API SSH_MESSAGE *ssh_message_retrieve(SSH_SESSION *session, uint32_t packettype);
LIBSSH_API SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 152753a..bf348d4 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -372,7 +372,7 @@ struct ssh_scp_struct {
size_t processed;
};
-struct ssh_message;
+struct ssh_message_struct;
struct ssh_session_struct {
struct error_struct error;
@@ -438,7 +438,7 @@ struct ssh_session_struct {
int auth_methods;
int hostkeys; /* contains type of host key wanted by client, in server impl */
struct ssh_list *ssh_message_list; /* list of delayed SSH messages */
- int (*ssh_message_callback)( struct ssh_session_struct *session,struct ssh_message *msg);
+ int (*ssh_message_callback)( struct ssh_session_struct *session, ssh_message msg);
int log_verbosity; /*cached copy of the option structure */
int log_indent; /* indentation level in enter_function logs */
};
@@ -506,7 +506,7 @@ struct ssh_channel_request {
char *subsystem;
};
-struct ssh_message {
+struct ssh_message_struct {
SSH_SESSION *session;
int type;
struct ssh_auth_request auth_request;
@@ -707,7 +707,7 @@ ssh_string try_publickey_from_file(SSH_SESSION *session,
/* in keys.c */
const char *ssh_type_to_char(int type);
int ssh_type_from_name(const char *name);
-ssh_buffer ssh_userauth_build_digest(SSH_SESSION *session, struct ssh_message *msg, char *service);
+ssh_buffer ssh_userauth_build_digest(SSH_SESSION *session, ssh_message msg, char *service);
ssh_private_key privatekey_make_dss(SSH_SESSION *session, ssh_buffer buffer);
ssh_private_key privatekey_make_rsa(SSH_SESSION *session, ssh_buffer buffer,
diff --git a/include/libssh/server.h b/include/libssh/server.h
index e71e285..26f16b5 100644
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -137,7 +137,7 @@ LIBSSH_API int ssh_message_service_reply_success(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_service_service(SSH_MESSAGE *msg);
LIBSSH_API void ssh_set_message_callback(SSH_SESSION *session,
- int(*ssh_message_callback)(ssh_session session, struct ssh_message *msg));
+ int(*ssh_message_callback)(ssh_session session, ssh_message msg));
LIBSSH_API char *ssh_message_channel_request_open_originator(SSH_MESSAGE *msg);
LIBSSH_API int ssh_message_channel_request_open_originator_port(SSH_MESSAGE *msg);
diff --git a/libssh/keys.c b/libssh/keys.c
index 77d554d..1382b76 100644
--- a/libssh/keys.c
+++ b/libssh/keys.c
@@ -1152,7 +1152,7 @@ ssh_string ssh_do_sign_with_agent(ssh_session session,
/*
* This function concats in a buffer the values needed to do a signature
* verification. */
-ssh_buffer ssh_userauth_build_digest(SSH_SESSION *session, struct ssh_message *msg, char *service) {
+ssh_buffer ssh_userauth_build_digest(SSH_SESSION *session, ssh_message msg, char *service) {
/*
The value of 'signature' is a signature by the corresponding private
key over the following data, in the following order:
diff --git a/libssh/server.c b/libssh/server.c
index 4f7f73b..43b1d31 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -829,7 +829,7 @@ char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg){
* must take care of the response).
*/
void ssh_set_message_callback(SSH_SESSION *session,
- int(*ssh_message_callback)(ssh_session session, struct ssh_message *msg)){
+ int(*ssh_message_callback)(ssh_session session, ssh_message msg)){
session->ssh_message_callback=ssh_message_callback;
}
diff --git a/libssh/session.c b/libssh/session.c
index e85bd5f..38e1b11 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -26,6 +26,7 @@
#include "libssh/libssh.h"
#include "libssh/priv.h"
#include "libssh/server.h"
+#include "libssh/callback.h"
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
/** \defgroup ssh_session SSH Session