25 #ifndef _SSH_CALLBACK_H
26 #define _SSH_CALLBACK_H
28 #include <libssh/libssh.h>
49 typedef void (*ssh_callback_int) (
int code,
void *user);
59 typedef int (*ssh_callback_data) (
const void *data,
size_t len,
void *user);
61 typedef void (*ssh_callback_int_int) (
int code,
int errno_code,
void *user);
63 typedef int (*ssh_message_callback) (ssh_session, ssh_message message,
void *user);
64 typedef int (*ssh_channel_callback_int) (ssh_channel channel,
int code,
void *user);
65 typedef int (*ssh_channel_callback_data) (ssh_channel channel,
int code,
void *data,
size_t len,
void *user);
75 const char *message,
void *userdata);
113 ssh_message message,
void *userdata);
125 const char * originator_address,
int originator_port,
void *userdata);
217 char signature_state,
void *userdata);
252 typedef ssh_string (*ssh_gssapi_select_oid_callback) (ssh_session session,
const char *user,
253 int n_oid, ssh_string *oids,
void *userdata);
267 typedef int (*ssh_gssapi_accept_sec_ctx_callback) (ssh_session session,
268 ssh_string input_token, ssh_string *output_token,
void *userdata);
281 typedef int (*ssh_gssapi_verify_mic_callback) (ssh_session session,
282 ssh_string mic,
void *mic_buffer,
size_t mic_buffer_size,
void *userdata);
332 ssh_gssapi_verify_mic_callback gssapi_verify_mic_function;
388 #define SSH_SOCKET_FLOW_WRITEWILLBLOCK 1
389 #define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2
391 #define SSH_SOCKET_EXCEPTION_EOF 1
392 #define SSH_SOCKET_EXCEPTION_ERROR 2
394 #define SSH_SOCKET_CONNECTED_OK 1
395 #define SSH_SOCKET_CONNECTED_ERROR 2
396 #define SSH_SOCKET_CONNECTED_TIMEOUT 3
405 #define ssh_callbacks_init(p) do {\
406 (p)->size=sizeof(*(p)); \
418 #define ssh_callbacks_exists(p,c) (\
419 (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
436 #define SSH_PACKET_USED 1
439 #define SSH_PACKET_NOT_USED 2
449 #define SSH_PACKET_CALLBACK(name) \
450 int name (ssh_session session, uint8_t type, ssh_buffer packet, void *user)
452 struct ssh_packet_callbacks_struct {
465 typedef struct ssh_packet_callbacks_struct *ssh_packet_callbacks;
584 int width,
int height,
585 int pxwidth,
int pwheight,
618 int single_connection,
619 const char *auth_protocol,
620 const char *auth_cookie,
621 uint32_t screen_number,
636 int width,
int height,
637 int pxwidth,
int pwheight,
666 const char *env_name,
667 const char *env_value,
679 const char *subsystem,
683 struct ssh_channel_callbacks_struct {
748 typedef struct ssh_channel_callbacks_struct *ssh_channel_callbacks;
772 ssh_channel_callbacks cb);
780 typedef int (*ssh_thread_callback) (
void **lock);
782 typedef unsigned long (*ssh_thread_id_callback) (void);
783 struct ssh_threads_callbacks_struct {
785 ssh_thread_callback mutex_init;
786 ssh_thread_callback mutex_destroy;
787 ssh_thread_callback mutex_lock;
788 ssh_thread_callback mutex_unlock;
789 ssh_thread_id_callback thread_id;
818 LIBSSH_API
struct ssh_threads_callbacks_struct *ssh_threads_get_pthread(
void);
ssh_auth_callback auth_function
This functions will be called if e.g.
Definition: callbacks.h:140
void(* ssh_status_callback)(ssh_session session, float status, void *userdata)
SSH Connection status callback.
Definition: callbacks.h:102
void(* ssh_channel_auth_agent_req_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH auth-agent-request from the client.
Definition: callbacks.h:605
These are the callbacks exported by the socket structure They are called by the socket module when a ...
Definition: callbacks.h:363
int(* ssh_channel_pty_window_change_callback)(ssh_session session, ssh_channel channel, int width, int height, int pxwidth, int pwheight, void *userdata)
SSH channel PTY windows change (terminal size) from a client.
Definition: callbacks.h:634
The structure to replace libssh functions with appropriate callbacks.
Definition: callbacks.h:130
int(* ssh_channel_data_callback)(ssh_session session, ssh_channel channel, void *data, uint32_t len, int is_stderr, void *userdata)
SSH channel data callback.
Definition: callbacks.h:501
ssh_auth_password_callback auth_password_function
This function gets called when a client tries to authenticate through password method.
Definition: callbacks.h:299
void(* connect_status_function)(void *userdata, float status)
This function gets called during connection time to indicate the percentage of connection steps compl...
Definition: callbacks.h:149
ssh_callback_int controlflow
This function will be called each time a controlflow state changes, i.e.
Definition: callbacks.h:376
int(* ssh_service_request_callback)(ssh_session session, const char *service, void *userdata)
Handles an SSH service request.
Definition: callbacks.h:229
void * userdata
User-provided data.
Definition: callbacks.h:136
ssh_gssapi_select_oid_callback gssapi_select_oid_function
This function will be called when a new gssapi authentication is attempted.
Definition: callbacks.h:326
int(* ssh_auth_none_callback)(ssh_session session, const char *user, void *userdata)
SSH authentication callback.
Definition: callbacks.h:186
int(* ssh_auth_password_callback)(ssh_session session, const char *user, const char *password, void *userdata)
These are callbacks used specifically in SSH servers.
Definition: callbacks.h:173
void * userdata
User-provided data.
Definition: callbacks.h:295
int(* ssh_channel_pty_request_callback)(ssh_session session, ssh_channel channel, const char *term, int width, int height, int pxwidth, int pwheight, void *userdata)
SSH channel PTY request from a client.
Definition: callbacks.h:581
ssh_auth_none_callback auth_none_function
This function gets called when a client tries to authenticate through none method.
Definition: callbacks.h:304
int(* ssh_packet_callback)(ssh_session session, uint8_t type, ssh_buffer packet, void *user)
Prototype for a packet callback, to be called when a new packet arrives.
Definition: callbacks.h:432
ssh_callback_data data
This function will be called each time data appears on socket.
Definition: callbacks.h:372
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb)
Set the session callback functions.
Definition: callbacks.c:45
ssh_auth_gssapi_mic_callback auth_gssapi_mic_function
This function gets called when a client tries to authenticate through gssapi-mic method.
Definition: callbacks.h:309
LIBSSH_API struct ssh_threads_callbacks_struct * ssh_threads_get_noop(void)
Get the noop threads callbacks structure.
Definition: threads.c:55
ssh_callback_int_int exception
This function will be called each time an exception appears on socket.
Definition: callbacks.h:380
ssh_global_request_callback global_request_function
This function will be called each time a global request is received.
Definition: callbacks.h:153
size_t size
DON'T SET THIS use ssh_callbacks_init() instead.
Definition: callbacks.h:132
ssh_channel(* ssh_channel_open_request_session_callback)(ssh_session session, void *userdata)
Handles an SSH new channel open session request.
Definition: callbacks.h:239
int(* ssh_channel_env_request_callback)(ssh_session session, ssh_channel channel, const char *env_name, const char *env_value, void *userdata)
SSH channel environment request from a client.
Definition: callbacks.h:664
void(* ssh_global_request_callback)(ssh_session session, ssh_message message, void *userdata)
SSH global request callback.
Definition: callbacks.h:112
LIBSSH_API int ssh_set_channel_callbacks(ssh_channel channel, ssh_channel_callbacks cb)
Set the channel callback functions.
Definition: callbacks.c:67
ssh_gssapi_accept_sec_ctx_callback gssapi_accept_sec_ctx_function
This function will be called when a gssapi token comes in.
Definition: callbacks.h:329
LIBSSH_API int ssh_set_server_callbacks(ssh_session session, ssh_server_callbacks cb)
Set the session server callback functions.
Definition: callbacks.c:85
This structure can be used to implement a libssh server, with appropriate callbacks.
Definition: callbacks.h:289
void(* ssh_logging_callback)(int priority, const char *function, const char *buffer, void *userdata)
SSH log callback.
Definition: callbacks.h:90
void(* ssh_channel_x11_req_callback)(ssh_session session, ssh_channel channel, int single_connection, const char *auth_protocol, const char *auth_cookie, uint32_t screen_number, void *userdata)
SSH X11 request from the client.
Definition: callbacks.h:616
void(* ssh_channel_eof_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel eof callback.
Definition: callbacks.h:514
int(* ssh_channel_shell_request_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel Shell request from a client.
Definition: callbacks.h:595
LIBSSH_API ssh_logging_callback ssh_get_log_callback(void)
Get the pointer to the logging callback function.
Definition: log.c:207
void * userdata
User-provided data.
Definition: callbacks.h:367
size_t size
DON'T SET THIS use ssh_callbacks_init() instead.
Definition: callbacks.h:291
int(* ssh_auth_pubkey_callback)(ssh_session session, const char *user, struct ssh_key_struct *pubkey, char signature_state, void *userdata)
SSH authentication callback.
Definition: callbacks.h:216
ssh_channel_open_request_session_callback channel_open_request_session_function
This functions gets called when a new channel request is issued by the client.
Definition: callbacks.h:323
void(* ssh_channel_close_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel close callback.
Definition: callbacks.h:524
void(* ssh_channel_exit_signal_callback)(ssh_session session, ssh_channel channel, const char *signal, int core, const char *errmsg, const char *lang, void *userdata)
SSH channel exit signal callback.
Definition: callbacks.h:561
LIBSSH_API int ssh_set_log_callback(ssh_logging_callback cb)
Set the logging callback function.
Definition: log.c:197
void(* ssh_log_callback)(ssh_session session, int priority, const char *message, void *userdata)
SSH log callback.
Definition: callbacks.h:74
int(* ssh_channel_subsystem_request_callback)(ssh_session session, ssh_channel channel, const char *subsystem, void *userdata)
SSH channel subsystem request from a client.
Definition: callbacks.h:677
void(* ssh_channel_signal_callback)(ssh_session session, ssh_channel channel, const char *signal, void *userdata)
SSH channel signal callback.
Definition: callbacks.h:535
void(* ssh_channel_exit_status_callback)(ssh_session session, ssh_channel channel, int exit_status, void *userdata)
SSH channel exit status callback.
Definition: callbacks.h:546
LIBSSH_API int ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct *cb)
Set the thread callbacks structure.
Definition: threads.c:184
int(* ssh_auth_gssapi_mic_callback)(ssh_session session, const char *user, const char *principal, void *userdata)
SSH authentication callback.
Definition: callbacks.h:200
ssh_service_request_callback service_request_function
This functions gets called when a service request is issued by the client.
Definition: callbacks.h:319
ssh_callback_int_int connected
This function is called when the ssh_socket_connect was used on the socket on nonblocking state...
Definition: callbacks.h:384
ssh_channel(* ssh_channel_open_request_x11_callback)(ssh_session session, const char *originator_address, int originator_port, void *userdata)
Handles an SSH new channel open X11 request.
Definition: callbacks.h:124
ssh_log_callback log_function
This function will be called each time a loggable event happens.
Definition: callbacks.h:144
ssh_channel_open_request_x11_callback channel_open_request_x11_function
This function will be called when an incoming X11 request is received.
Definition: callbacks.h:156
int(* ssh_channel_exec_request_callback)(ssh_session session, ssh_channel channel, const char *command, void *userdata)
SSH channel Exec request from a client.
Definition: callbacks.h:648
ssh_auth_pubkey_callback auth_pubkey_function
this function gets called when a client tries to authenticate or offer a public key.
Definition: callbacks.h:314