experimental callback system

This commit is contained in:
Aris Adamantiadis
2009-08-23 16:33:59 +02:00
parent e707af1cd7
commit 8bae43876f
7 changed files with 53 additions and 8 deletions

43
include/libssh/callback.h Normal file
View File

@@ -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;

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);

View File

@@ -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:

View File

@@ -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;
}

View File

@@ -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