25#ifndef _SSH_CALLBACK_H
26#define _SSH_CALLBACK_H
28#include <libssh/libssh.h>
50typedef void (*ssh_callback_int) (
int code,
void *user);
60typedef size_t (*ssh_callback_data) (
const void *data,
size_t len,
void *user);
62typedef void (*ssh_callback_int_int) (
int code,
int errno_code,
void *user);
64typedef int (*ssh_message_callback) (ssh_session, ssh_message message,
void *user);
65typedef int (*ssh_channel_callback_int) (ssh_channel channel,
int code,
void *user);
66typedef int (*ssh_channel_callback_data) (ssh_channel channel,
int code,
void *data,
size_t len,
void *user);
76 const char *message,
void *userdata);
114 ssh_message message,
void *userdata);
128 const char * originator_address,
int originator_port,
void *userdata);
158 const char *destination_address,
int destination_port,
159 const char *originator_address,
int originator_port,
260 char signature_state,
void *userdata);
296typedef ssh_string (*ssh_gssapi_select_oid_callback) (ssh_session session,
const char *user,
297 int n_oid, ssh_string *oids,
void *userdata);
311typedef int (*ssh_gssapi_accept_sec_ctx_callback) (ssh_session session,
312 ssh_string input_token, ssh_string *output_token,
void *userdata);
325typedef int (*ssh_gssapi_verify_mic_callback) (ssh_session session,
326 ssh_string mic,
void *mic_buffer,
size_t mic_buffer_size,
void *userdata);
377 ssh_gssapi_verify_mic_callback gssapi_verify_mic_function;
436#define SSH_SOCKET_FLOW_WRITEWILLBLOCK 1
437#define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2
439#define SSH_SOCKET_EXCEPTION_EOF 1
440#define SSH_SOCKET_EXCEPTION_ERROR 2
442#define SSH_SOCKET_CONNECTED_OK 1
443#define SSH_SOCKET_CONNECTED_ERROR 2
444#define SSH_SOCKET_CONNECTED_TIMEOUT 3
453#define ssh_callbacks_init(p) do {\
454 (p)->size=sizeof(*(p)); \
466#define ssh_callbacks_exists(p,c) (\
467 (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
487#define ssh_callbacks_execute_list(list, cbtype, c, ...) \
489 struct ssh_iterator *i = ssh_list_get_iterator(list); \
492 cb = ssh_iterator_value(cbtype, i); \
493 if (ssh_callbacks_exists(cb, c)) \
494 cb-> c (__VA_ARGS__, cb->userdata); \
519#define ssh_callbacks_iterate(_cb_list, _cb_type, _cb_name) \
521 struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
523 for (; _cb_i != NULL; _cb_i = _cb_i->next) { \
524 _cb = ssh_iterator_value(_cb_type, _cb_i); \
525 if (ssh_callbacks_exists(_cb, _cb_name))
527#define ssh_callbacks_iterate_exec(_cb_name, ...) \
528 _cb->_cb_name(__VA_ARGS__, _cb->userdata)
530#define ssh_callbacks_iterate_end() \
547#define SSH_PACKET_USED 1
550#define SSH_PACKET_NOT_USED 2
560#define SSH_PACKET_CALLBACK(name) \
561 int name (ssh_session session, uint8_t type, ssh_buffer packet, void *user)
563struct ssh_packet_callbacks_struct {
576typedef struct ssh_packet_callbacks_struct *ssh_packet_callbacks;
700 int width,
int height,
701 int pxwidth,
int pwheight,
741 int single_connection,
742 const char *auth_protocol,
743 const char *auth_cookie,
744 uint32_t screen_number,
760 int width,
int height,
761 int pxwidth,
int pwheight,
792 const char *env_name,
793 const char *env_value,
806 const char *subsystem,
850struct ssh_channel_callbacks_struct {
927typedef struct ssh_channel_callbacks_struct *ssh_channel_callbacks;
957 ssh_channel_callbacks cb);
976 ssh_channel_callbacks cb);
991 ssh_channel_callbacks cb);
999typedef int (*ssh_thread_callback) (
void **lock);
1001typedef unsigned long (*ssh_thread_id_callback) (void);
1002struct ssh_threads_callbacks_struct {
1004 ssh_thread_callback mutex_init;
1005 ssh_thread_callback mutex_destroy;
1006 ssh_thread_callback mutex_lock;
1007 ssh_thread_callback mutex_unlock;
1008 ssh_thread_id_callback thread_id;
1087typedef int (*ssh_jump_before_connection_callback)(ssh_session session,
1098typedef int (*ssh_jump_verify_knownhost_callback)(ssh_session session,
1108typedef int (*ssh_jump_authenticate_callback)(ssh_session session,
1113 ssh_jump_before_connection_callback before_connection;
1114 ssh_jump_verify_knownhost_callback verify_knownhost;
1115 ssh_jump_authenticate_callback authenticate;
int(* ssh_auth_callback)(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata)
SSH authentication callback for password and publickey auth.
Definition libssh.h:699
void(* ssh_channel_request_resp_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel request response callback. Called when a response to the pending request is received.
Definition callbacks.h:846
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:697
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb)
Set the session callback functions.
Definition callbacks.c:57
LIBSSH_API int ssh_add_channel_callbacks(ssh_channel channel, ssh_channel_callbacks cb)
Add channel callback functions.
Definition callbacks.c:118
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:758
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:773
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. This request is sent by a client when X11 forwarding is requested(an...
Definition callbacks.h:739
int(* ssh_channel_shell_request_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel Shell request from a client.
Definition callbacks.h:712
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. Called when data is available on a channel.
Definition callbacks.h:615
void(* ssh_channel_eof_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel eof callback. Called when a channel receives EOF.
Definition callbacks.h:628
void(* ssh_channel_close_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH channel close callback. Called when a channel is closed by remote peer.
Definition callbacks.h:638
void(* ssh_channel_signal_callback)(ssh_session session, ssh_channel channel, const char *signal, void *userdata)
SSH channel signal callback. Called when a channel has received a signal.
Definition callbacks.h:649
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:259
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:543
void(* ssh_channel_exit_status_callback)(ssh_session session, ssh_channel channel, int exit_status, void *userdata)
SSH channel exit status callback. Called when a channel has received an exit status.
Definition callbacks.h:661
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. This happens when the server sends back an X11 connectio...
Definition callbacks.h:127
int(* ssh_auth_none_callback)(ssh_session session, const char *user, void *userdata)
SSH authentication callback. Tries to authenticates user with the "none" method which is anonymous or...
Definition callbacks.h:229
void(* ssh_channel_open_resp_callback)(ssh_session session, ssh_channel channel, bool is_success, void *userdata)
SSH channel open callback. Called when a channel open succeeds or fails.
Definition callbacks.h:835
void(* ssh_log_callback)(ssh_session session, int priority, const char *message, void *userdata)
SSH log callback. All logging messages will go through this callback.
Definition callbacks.h:75
int(* ssh_service_request_callback)(ssh_session session, const char *service, void *userdata)
Handles an SSH service request.
Definition callbacks.h:272
ssh_channel(* ssh_channel_open_request_forwarded_tcpip_callback)(ssh_session session, const char *destination_address, int destination_port, const char *originator_address, int originator_port, void *userdata)
Handles an SSH new channel open "forwarded-tcpip" request. This happens when the server forwards an i...
Definition callbacks.h:157
LIBSSH_API int ssh_set_server_callbacks(ssh_session session, ssh_server_callbacks cb)
Set the session server callback functions.
Definition callbacks.c:142
ssh_channel(* ssh_channel_open_request_auth_agent_callback)(ssh_session session, void *userdata)
Handles an SSH new channel open "auth-agent" request. This happens when the server sends back an "aut...
Definition callbacks.h:139
int(* ssh_channel_write_wontblock_callback)(ssh_session session, ssh_channel channel, uint32_t bytes, void *userdata)
SSH channel write will not block (flow control).
Definition callbacks.h:823
int(* ssh_auth_gssapi_mic_callback)(ssh_session session, const char *user, const char *principal, void *userdata)
SSH authentication callback. Tries to authenticates user with the "gssapi-with-mic" method.
Definition callbacks.h:243
void(* ssh_logging_callback)(int priority, const char *function, const char *buffer, void *userdata)
SSH log callback.
Definition callbacks.h:91
void(* ssh_status_callback)(ssh_session session, float status, void *userdata)
SSH Connection status callback.
Definition callbacks.h:103
ssh_channel(* ssh_channel_open_request_session_callback)(ssh_session session, void *userdata)
Handles an SSH new channel open session request.
Definition callbacks.h:282
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. Called when a channel has received an exit signal.
Definition callbacks.h:676
LIBSSH_API int ssh_set_channel_callbacks(ssh_channel channel, ssh_channel_callbacks cb)
Set the channel callback functions.
Definition callbacks.c:113
int(* ssh_auth_password_callback)(ssh_session session, const char *user, const char *password, void *userdata)
SSH authentication callback.
Definition callbacks.h:216
LIBSSH_API int ssh_remove_channel_callbacks(ssh_channel channel, ssh_channel_callbacks cb)
Remove a channel callback.
Definition callbacks.c:123
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:790
void(* ssh_global_request_callback)(ssh_session session, ssh_message message, void *userdata)
SSH global request callback. All global request will go through this callback.
Definition callbacks.h:113
void(* ssh_channel_auth_agent_req_callback)(ssh_session session, ssh_channel channel, void *userdata)
SSH auth-agent-request from the client. This request is sent by a client when agent forwarding is ava...
Definition callbacks.h:723
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:804
LIBSSH_API ssh_logging_callback ssh_get_log_callback(void)
Get the pointer to the logging callback function.
Definition log.c:230
LIBSSH_API int ssh_set_log_callback(ssh_logging_callback cb)
Set the logging callback function.
Definition log.c:214
LIBSSH_API struct ssh_threads_callbacks_struct * ssh_threads_get_pthread(void)
Returns a pointer on the pthread threads callbacks, to be used with ssh_threads_set_callbacks.
Definition pthread.c:137
LIBSSH_API struct ssh_threads_callbacks_struct * ssh_threads_get_default(void)
Returns a pointer to the appropriate callbacks structure for the environment, to be used with ssh_thr...
Definition noop.c:65
LIBSSH_API struct ssh_threads_callbacks_struct * ssh_threads_get_noop(void)
Get the noop threads callbacks structure.
Definition noop.c:71
LIBSSH_API int ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct *cb)
Set the thread callbacks structure.
Definition threads.c:71
Definition callbacks.h:165
ssh_channel_open_request_auth_agent_callback channel_open_request_auth_agent_function
Definition callbacks.h:194
ssh_log_callback log_function
Definition callbacks.h:179
ssh_auth_callback auth_function
Definition callbacks.h:175
ssh_channel_open_request_x11_callback channel_open_request_x11_function
Definition callbacks.h:191
void * userdata
Definition callbacks.h:171
ssh_channel_open_request_forwarded_tcpip_callback channel_open_request_forwarded_tcpip_function
Definition callbacks.h:199
size_t size
Definition callbacks.h:167
void(* connect_status_function)(void *userdata, float status)
Definition callbacks.h:184
ssh_global_request_callback global_request_function
Definition callbacks.h:188
Definition callbacks.h:1111
Definition callbacks.h:333
ssh_gssapi_accept_sec_ctx_callback gssapi_accept_sec_ctx_function
Definition callbacks.h:374
ssh_service_request_callback service_request_function
Definition callbacks.h:363
size_t size
Definition callbacks.h:335
ssh_auth_none_callback auth_none_function
Definition callbacks.h:348
ssh_auth_gssapi_mic_callback auth_gssapi_mic_function
Definition callbacks.h:353
ssh_channel_open_request_session_callback channel_open_request_session_function
Definition callbacks.h:367
ssh_auth_password_callback auth_password_function
Definition callbacks.h:343
ssh_auth_pubkey_callback auth_pubkey_function
Definition callbacks.h:358
void * userdata
Definition callbacks.h:339
ssh_gssapi_select_oid_callback gssapi_select_oid_function
Definition callbacks.h:371
Definition callbacks.h:411
void * userdata
Definition callbacks.h:415
ssh_callback_data data
Definition callbacks.h:420
ssh_callback_int_int connected
Definition callbacks.h:432
ssh_callback_int controlflow
Definition callbacks.h:424
ssh_callback_int_int exception
Definition callbacks.h:428