libssh  0.10.90
The SSH library
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
The libssh callbacks
Collaboration diagram for The libssh callbacks:

Data Structures

struct  ssh_callbacks_struct
 
struct  ssh_server_callbacks_struct
 
struct  ssh_socket_callbacks_struct
 

Macros

#define ssh_callbacks_init(p)
 Initializes an ssh_callbacks_struct A call to this macro is mandatory when you have set a new ssh_callback_struct structure. Its goal is to maintain the binary compatibility with future versions of libssh as the structure evolves with time.
 
#define ssh_callbacks_exists(p, c)
 
#define ssh_callbacks_execute_list(list, cbtype, c, ...)
 
#define ssh_callbacks_iterate(_cb_list, _cb_type, _cb_name)
 
#define ssh_callbacks_iterate_exec(_cb_name, ...)    _cb->_cb_name(__VA_ARGS__, _cb->userdata)
 
#define ssh_callbacks_iterate_end()
 
#define SSH_PACKET_USED   1
 
#define SSH_PACKET_NOT_USED   2
 
#define SSH_PACKET_CALLBACK(name)    int name (ssh_session session, uint8_t type, ssh_buffer packet, void *user)
 This macro declares a packet callback handler.
 

Typedefs

typedef 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.
 
typedef void(* ssh_logging_callback) (int priority, const char *function, const char *buffer, void *userdata)
 SSH log callback.
 
typedef void(* ssh_status_callback) (ssh_session session, float status, void *userdata)
 SSH Connection status callback.
 
typedef 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.
 
typedef 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 connection attempt. This is a client-side API.
 
typedef 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 "auth-agent" connection attempt. This is a client-side API.
 
typedef 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 incoming TCP connection on a port it was previously requested to listen on. This is a client-side API.
 
typedef int(* ssh_auth_password_callback) (ssh_session session, const char *user, const char *password, void *userdata)
 SSH authentication callback.
 
typedef 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 passwordless.
 
typedef 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.
 
typedef int(* ssh_auth_pubkey_callback) (ssh_session session, const char *user, struct ssh_key_struct *pubkey, char signature_state, void *userdata)
 SSH authentication callback.
 
typedef int(* ssh_service_request_callback) (ssh_session session, const char *service, void *userdata)
 Handles an SSH service request.
 
typedef ssh_channel(* ssh_channel_open_request_session_callback) (ssh_session session, void *userdata)
 Handles an SSH new channel open session request.
 
typedef 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.
 
typedef 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.
 
typedef void(* ssh_channel_eof_callback) (ssh_session session, ssh_channel channel, void *userdata)
 SSH channel eof callback. Called when a channel receives EOF.
 
typedef 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.
 
typedef 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.
 
typedef 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.
 
typedef 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.
 
typedef 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.
 
typedef int(* ssh_channel_shell_request_callback) (ssh_session session, ssh_channel channel, void *userdata)
 SSH channel Shell request from a client.
 
typedef 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 available. Server is free to ignore this callback, no answer is expected.
 
typedef 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(and available). Server is free to ignore this callback, no answer is expected.
 
typedef 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.
 
typedef int(* ssh_channel_exec_request_callback) (ssh_session session, ssh_channel channel, const char *command, void *userdata)
 SSH channel Exec request from a client.
 
typedef 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.
 
typedef int(* ssh_channel_subsystem_request_callback) (ssh_session session, ssh_channel channel, const char *subsystem, void *userdata)
 SSH channel subsystem request from a client.
 
typedef 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).
 
typedef 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.
 
typedef 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.
 

Functions

LIBSSH_API int ssh_set_server_callbacks (ssh_session session, ssh_server_callbacks cb)
 Set the session server callback functions.
 
LIBSSH_API int ssh_set_callbacks (ssh_session session, ssh_callbacks cb)
 Set the session callback functions.
 
LIBSSH_API int ssh_set_channel_callbacks (ssh_channel channel, ssh_channel_callbacks cb)
 Set the channel callback functions.
 
LIBSSH_API int ssh_add_channel_callbacks (ssh_channel channel, ssh_channel_callbacks cb)
 Add channel callback functions.
 
LIBSSH_API int ssh_remove_channel_callbacks (ssh_channel channel, ssh_channel_callbacks cb)
 Remove a channel callback.
 

Detailed Description

Callback which can be replaced in libssh.

Macro Definition Documentation

◆ ssh_callbacks_execute_list

#define ssh_callbacks_execute_list ( list,
cbtype,
c,
... )
Value:
do { \
struct ssh_iterator *i = ssh_list_get_iterator(list); \
cbtype cb; \
while (i != NULL){ \
cb = ssh_iterator_value(cbtype, i); \
if (ssh_callbacks_exists(cb, c)) \
cb-> c (__VA_ARGS__, cb->userdata); \
i = i->next; \
} \
} while(0)

◆ ssh_callbacks_exists

#define ssh_callbacks_exists ( p,
c )
Value:
(\
(p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
((p)-> c != NULL) \
)

◆ ssh_callbacks_init

#define ssh_callbacks_init ( p)
Value:
do {\
(p)->size=sizeof(*(p)); \
} while(0);

Initializes an ssh_callbacks_struct A call to this macro is mandatory when you have set a new ssh_callback_struct structure. Its goal is to maintain the binary compatibility with future versions of libssh as the structure evolves with time.

◆ ssh_callbacks_iterate

#define ssh_callbacks_iterate ( _cb_list,
_cb_type,
_cb_name )
Value:
do { \
struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
_cb_type _cb; \
for (; _cb_i != NULL; _cb_i = _cb_i->next) { \
_cb = ssh_iterator_value(_cb_type, _cb_i); \
if (ssh_callbacks_exists(_cb, _cb_name))

◆ ssh_callbacks_iterate_end

#define ssh_callbacks_iterate_end ( )
Value:
} \
} while(0)

◆ SSH_PACKET_CALLBACK

#define SSH_PACKET_CALLBACK ( name)     int name (ssh_session session, uint8_t type, ssh_buffer packet, void *user)

This macro declares a packet callback handler.

SSH_PACKET_CALLBACK(mycallback){
...
}
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition callbacks.h:558

◆ SSH_PACKET_NOT_USED

#define SSH_PACKET_NOT_USED   2

Packet was not used and should be passed to any other callback available

◆ SSH_PACKET_USED

#define SSH_PACKET_USED   1

return values for a ssh_packet_callback Packet was used and should not be parsed by another callback

Typedef Documentation

◆ ssh_auth_gssapi_mic_callback

typedef 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.

Parameters
sessionCurrent session handler
userUsername of the user (can be spoofed)
principalAuthenticated principal of the user, including realm.
userdataUserdata to be passed to the callback function.
Returns
SSH_AUTH_SUCCESS Authentication is accepted.
SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed.
SSH_AUTH_DENIED Authentication failed.
Warning
Implementations should verify that parameter user matches in some way the principal. user and principal can be different. Only the latter is guaranteed to be safe.

◆ ssh_auth_none_callback

typedef 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 passwordless.

Parameters
sessionCurrent session handler
userUser that wants to authenticate
userdataUserdata to be passed to the callback function.
Returns
SSH_AUTH_SUCCESS Authentication is accepted.
SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed.
SSH_AUTH_DENIED Authentication failed.

◆ ssh_auth_password_callback

typedef int(* ssh_auth_password_callback) (ssh_session session, const char *user, const char *password, void *userdata)

SSH authentication callback.

These are callbacks used specifically in SSH servers.

Parameters
sessionCurrent session handler
userUser that wants to authenticate
passwordPassword used for authentication
userdataUserdata to be passed to the callback function.
Returns
SSH_AUTH_SUCCESS Authentication is accepted.
SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed.
SSH_AUTH_DENIED Authentication failed.

◆ ssh_auth_pubkey_callback

typedef int(* ssh_auth_pubkey_callback) (ssh_session session, const char *user, struct ssh_key_struct *pubkey, char signature_state, void *userdata)

SSH authentication callback.

Parameters
sessionCurrent session handler
userUser that wants to authenticate
pubkeypublic key used for authentication
signature_stateSSH_PUBLICKEY_STATE_NONE if the key is not signed (simple public key probe), SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be replied with a SSH_AUTH_DENIED.
userdataUserdata to be passed to the callback function.
Returns
SSH_AUTH_SUCCESS Authentication is accepted.
SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed.
SSH_AUTH_DENIED Authentication failed.

◆ ssh_channel_auth_agent_req_callback

typedef 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 available. Server is free to ignore this callback, no answer is expected.

Parameters
sessionthe session
channelthe channel
userdataUserdata to be passed to the callback function.

◆ ssh_channel_close_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
userdataUserdata to be passed to the callback function.

◆ ssh_channel_data_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
datathe data that has been read on the channel
lenthe length of the data
is_stderris 0 for stdout or 1 for stderr
userdataUserdata to be passed to the callback function.
Returns
number of bytes processed by the callee. The remaining bytes will be sent in the next callback message, when more data is available.

◆ ssh_channel_env_request_callback

typedef 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.

Parameters
sessionthe session
channelthe channel
env_namename of the environment value to be set
env_valuevalue of the environment value to be set
userdataUserdata to be passed to the callback function.
Returns
0 if the env request is accepted
1 if the request is denied
Warning
some environment variables can be dangerous if changed (e.g. LD_PRELOAD) and should not be fulfilled.

◆ ssh_channel_eof_callback

typedef void(* ssh_channel_eof_callback) (ssh_session session, ssh_channel channel, void *userdata)

SSH channel eof callback. Called when a channel receives EOF.

Parameters
sessionCurrent session handler
channelthe actual channel
userdataUserdata to be passed to the callback function.

◆ ssh_channel_exec_request_callback

typedef int(* ssh_channel_exec_request_callback) (ssh_session session, ssh_channel channel, const char *command, void *userdata)

SSH channel Exec request from a client.

Parameters
sessionthe session
channelthe channel
commandthe shell command to be executed
userdataUserdata to be passed to the callback function.
Returns
0 if the exec request is accepted
1 if the request is denied

◆ ssh_channel_exit_signal_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
signalthe signal name (without the SIG prefix)
corea boolean telling whether a core has been dumped or not
errmsgthe description of the exception
langthe language of the description (format: RFC 3066)
userdataUserdata to be passed to the callback function.

◆ ssh_channel_exit_status_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
exit_statusExit status of the ran command
userdataUserdata to be passed to the callback function.

◆ ssh_channel_open_request_auth_agent_callback

typedef 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 "auth-agent" connection attempt. This is a client-side API.

Parameters
sessioncurrent session handler
userdataUserdata to be passed to the callback function.
Returns
a valid ssh_channel handle if the request is to be allowed
NULL if the request should not be allowed
Warning
The channel pointer returned by this callback must be closed by the application.

◆ ssh_channel_open_request_forwarded_tcpip_callback

typedef 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 incoming TCP connection on a port it was previously requested to listen on. This is a client-side API.

Parameters
sessioncurrent session handler
destination_addressthe address that the TCP connection connected to
destination_portthe port that the TCP connection connected to
originator_addressthe originator IP address
originator_portthe originator port
userdataUserdata to be passed to the callback function.
Returns
a valid ssh_channel handle if the request is to be allowed
NULL if the request should not be allowed
Warning
The channel pointer returned by this callback must be closed by the application.

◆ ssh_channel_open_request_session_callback

typedef ssh_channel(* ssh_channel_open_request_session_callback) (ssh_session session, void *userdata)

Handles an SSH new channel open session request.

Parameters
sessioncurrent session handler
userdataUserdata to be passed to the callback function.
Returns
a valid ssh_channel handle if the request is to be allowed
NULL if the request should not be allowed
Warning
The channel pointer returned by this callback must be closed by the application.

◆ ssh_channel_open_request_x11_callback

typedef 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 connection attempt. This is a client-side API.

Parameters
sessioncurrent session handler
userdataUserdata to be passed to the callback function.
originator_addressIP address of the machine who sent the request
originator_portport number of the machine who sent the request
Returns
a valid ssh_channel handle if the request is to be allowed
NULL if the request should not be allowed
Warning
The channel pointer returned by this callback must be closed by the application.

◆ ssh_channel_open_resp_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
is_successis 1 when the open succeeds, and 0 otherwise.
userdataUserdata to be passed to the callback function.

◆ ssh_channel_pty_request_callback

typedef 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.

Parameters
sessionthe session
channelthe channel
termThe type of terminal emulation
widthwidth of the terminal, in characters
heightheight of the terminal, in characters
pxwidthwidth of the terminal, in pixels
pwheightheight of the terminal, in pixels
userdataUserdata to be passed to the callback function.
Returns
0 if the pty request is accepted
-1 if the request is denied

◆ ssh_channel_pty_window_change_callback

typedef 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.

Parameters
sessionthe session
channelthe channel
widthwidth of the terminal, in characters
heightheight of the terminal, in characters
pxwidthwidth of the terminal, in pixels
pwheightheight of the terminal, in pixels
userdataUserdata to be passed to the callback function.
Returns
0 if the pty request is accepted
-1 if the request is denied

◆ ssh_channel_request_resp_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
userdataUserdata to be passed to the callback function.

◆ ssh_channel_shell_request_callback

typedef int(* ssh_channel_shell_request_callback) (ssh_session session, ssh_channel channel, void *userdata)

SSH channel Shell request from a client.

Parameters
sessionthe session
channelthe channel
userdataUserdata to be passed to the callback function.
Returns
0 if the shell request is accepted
1 if the request is denied

◆ ssh_channel_signal_callback

typedef 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.

Parameters
sessionCurrent session handler
channelthe actual channel
signalthe signal name (without the SIG prefix)
userdataUserdata to be passed to the callback function.

◆ ssh_channel_subsystem_request_callback

typedef int(* ssh_channel_subsystem_request_callback) (ssh_session session, ssh_channel channel, const char *subsystem, void *userdata)

SSH channel subsystem request from a client.

Parameters
sessionthe session
channelthe channel
subsystemthe subsystem required
userdataUserdata to be passed to the callback function.
Returns
0 if the subsystem request is accepted
1 if the request is denied

◆ ssh_channel_write_wontblock_callback

typedef 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).

Parameters
sessionthe session
channelthe channel
[in]bytessize of the remote window in bytes. Writing as much data will not block.
[in]userdataUserdata to be passed to the callback function.
Returns
0 default return value (other return codes may be added in future).

◆ ssh_channel_x11_req_callback

typedef 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(and available). Server is free to ignore this callback, no answer is expected.

Parameters
sessionthe session
channelthe channel
single_connectionIf true, only one channel should be forwarded
auth_protocolThe X11 authentication method to be used
auth_cookieAuthentication cookie encoded hexadecimal
screen_numberScreen number
userdataUserdata to be passed to the callback function.

◆ ssh_global_request_callback

typedef 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.

Parameters
sessionCurrent session handler
messagethe actual message
userdataUserdata to be passed to the callback function.

◆ ssh_log_callback

typedef 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.

Parameters
sessionCurrent session handler
priorityPriority of the log, the smaller being the more important
messagethe actual message
userdataUserdata to be passed to the callback function.

◆ ssh_logging_callback

typedef void(* ssh_logging_callback) (int priority, const char *function, const char *buffer, void *userdata)

SSH log callback.

All logging messages will go through this callback.

Parameters
priorityPriority of the log, the smaller being the more important.
functionThe function name calling the logging functions.
bufferThe actual message
userdataUserdata to be passed to the callback function.

◆ ssh_packet_callback

typedef 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.

Parameters
sessionThe current session of the packet
typepacket type (see ssh2.h)
packetbuffer containing the packet, excluding size, type and padding fields
useruser argument to the callback and are called each time a packet shows up
Returns
SSH_PACKET_USED Packet was parsed and used
SSH_PACKET_NOT_USED Packet was not used or understood, processing must continue

◆ ssh_service_request_callback

typedef int(* ssh_service_request_callback) (ssh_session session, const char *service, void *userdata)

Handles an SSH service request.

Parameters
sessioncurrent session handler
servicename of the service (e.g. "ssh-userauth") requested
userdataUserdata to be passed to the callback function.
Returns
0 if the request is to be allowed
-1 if the request should not be allowed

◆ ssh_status_callback

typedef void(* ssh_status_callback) (ssh_session session, float status, void *userdata)

SSH Connection status callback.

Parameters
sessionCurrent session handler
statusPercentage of connection status, going from 0.0 to 1.0 once connection is done.
userdataUserdata to be passed to the callback function.

Function Documentation

◆ ssh_add_channel_callbacks()

LIBSSH_API int ssh_add_channel_callbacks ( ssh_channel channel,
ssh_channel_callbacks cb )

Add channel callback functions.

This function will add channel callback functions to the channel callback list. Callbacks missing from a callback structure will be probed in the next on the list.

Parameters
channelThe channel to set the callback structure.
cbThe callback structure itself.
Returns
SSH_OK on success, SSH_ERROR on error.
See also
ssh_set_channel_callbacks

◆ ssh_remove_channel_callbacks()

LIBSSH_API int ssh_remove_channel_callbacks ( ssh_channel channel,
ssh_channel_callbacks cb )

Remove a channel callback.

The channel has been added with ssh_add_channel_callbacks or ssh_set_channel_callbacks in this case.

Parameters
channelThe channel to remove the callback structure from.
cbThe callback structure to remove
Returns
SSH_OK on success, SSH_ERROR on error.

◆ ssh_set_callbacks()

LIBSSH_API int ssh_set_callbacks ( ssh_session session,
ssh_callbacks cb )

Set the session callback functions.

This functions sets the callback structure to use your own callback functions for auth, logging and status.

Note, that the callback structure is not copied into the session so it needs to be valid for the whole session lifetime.

struct ssh_callbacks_struct cb = {
.userdata = data,
.auth_function = my_auth_function
};
ssh_set_callbacks(session, &cb);
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb)
Set the session callback functions.
Definition callbacks.c:48
#define ssh_callbacks_init(p)
Initializes an ssh_callbacks_struct A call to this macro is mandatory when you have set a new ssh_cal...
Definition callbacks.h:451
Definition callbacks.h:165
void * userdata
Definition callbacks.h:171
Parameters
sessionThe session to set the callback structure.
cbThe callback structure itself.
Returns
SSH_OK on success, SSH_ERROR on error.

◆ ssh_set_channel_callbacks()

LIBSSH_API int ssh_set_channel_callbacks ( ssh_channel channel,
ssh_channel_callbacks cb )

Set the channel callback functions.

This functions sets the callback structure to use your own callback functions for channel data and exceptions.

Note, that the structure is not copied to the channel structure so it needs to be valid as for the whole life of the channel or until it is removed with ssh_remove_channel_callbacks().

struct ssh_channel_callbacks_struct cb = {
.userdata = data,
.channel_data_function = my_channel_data_function
};
LIBSSH_API int ssh_set_channel_callbacks(ssh_channel channel, ssh_channel_callbacks cb)
Set the channel callback functions.
Definition callbacks.c:104
Parameters
channelThe channel to set the callback structure.
cbThe callback structure itself.
Returns
SSH_OK on success, SSH_ERROR on error.
Warning
this function will not replace existing callbacks but set the new one atop of them.

◆ ssh_set_server_callbacks()

LIBSSH_API int ssh_set_server_callbacks ( ssh_session session,
ssh_server_callbacks cb )

Set the session server callback functions.

This functions sets the callback structure to use your own callback functions for user authentication, new channels and requests.

Note, that the structure is not copied to the session structure so it needs to be valid for the whole session lifetime.

.userdata = data,
.auth_password_function = my_auth_function
};
LIBSSH_API int ssh_set_server_callbacks(ssh_session session, ssh_server_callbacks cb)
Set the session server callback functions.
Definition callbacks.c:133
Definition callbacks.h:332
void * userdata
Definition callbacks.h:338
Parameters
sessionThe session to set the callback structure.
cbThe callback structure itself.
Returns
SSH_OK on success, SSH_ERROR on error.