1libssh2_session_callback_set(3) libssh2 manual libssh2_session_callback_set(3)
2
3
4

NAME

6       libssh2_session_callback_set - set a callback function
7

SYNOPSIS

9       #include <libssh2.h>
10
11       void *libssh2_session_callback_set(LIBSSH2_SESSION *session,
12                                          int cbtype, void *callback);
13

DESCRIPTION

15       Sets a custom callback handler for a previously initialized session ob‐
16       ject. Callbacks are triggered by the receipt of special packets at  the
17       Transport layer. To disable a callback, set it to NULL.
18
19       session - Session instance as returned by libssh2_session_init_ex(3)
20
21       cbtype - Callback type. One of the types listed in Callback Types.
22
23       callback  - Pointer to custom callback function. The prototype for this
24       function must match the associated callback declaration macro.
25

CALLBACK TYPES

27       LIBSSH2_CALLBACK_IGNORE
28              Called when a SSH_MSG_IGNORE message is received
29
30       LIBSSH2_CALLBACK_DEBUG
31              Called when a SSH_MSG_DEBUG message is received
32
33       LIBSSH2_CALLBACK_DISCONNECT
34              Called when a SSH_MSG_DISCONNECT message is received
35
36       LIBSSH2_CALLBACK_MACERROR
37              Called when a mismatched MAC has been detected in the  transport
38              layer.  If  the  function returns 0, the packet will be accepted
39              nonetheless.
40
41       LIBSSH2_CALLBACK_X11
42              Called when an X11 connection has been accepted
43
44       LIBSSH2_CALLBACK_SEND
45              Called when libssh2 wants to send data on the  connection.   Can
46              be set to a custom function to handle I/O your own way.
47
48              The prototype of the callback:
49
50              ssize_t sendcb(libssh2_socket_t sockfd, const void *buffer,
51                             size_t length, int flags, void **abstract);
52
53              sockfd  is  the socket to write to, buffer points to the data to
54              send, length is the size of the data, flags is  the  flags  that
55              would've been used to a send() call and abstract is a pointer to
56              the abstract pointer set in the libssh2_session_init_ex(3) call.
57
58              The callback returns the number of bytes sent, or -1 for  error.
59              The  special  return code -EAGAIN can be returned to signal that
60              the send was aborted to prevent getting blocked and it needs  to
61              be called again.
62
63       LIBSSH2_CALLBACK_RECV
64              Called  when libssh2 wants to read data from the connection. Can
65              be set to a custom function to handle I/O your own way.
66
67              The prototype of the callback:
68
69              ssize_t recvcb(libssh2_socket_t sockfd, void *buffer,
70                             size_t length, int flags, void **abstract);
71
72              sockfd is the socket to read from, buffer  where  to  store  re‐
73              ceived data into, length is the size of the buffer, flags is the
74              flags that would've been used to a recv() call and abstract is a
75              pointer   to  the  abstract  pointer  set  in  the  libssh2_ses‐
76              sion_init_ex(3) call.
77
78              The callback returns the number of bytes read, or -1 for  error.
79              The  special  return code -EAGAIN can be returned to signal that
80              the read was aborted to prevent getting blocked and it needs  to
81              be called again.
82

RETURN VALUE

84       Pointer to previous callback handler. Returns NULL if no prior callback
85       handler was set or the callback type was unknown.
86

SEE ALSO

88       libssh2_session_init_ex(3)
89
90
91
92libssh2 0.15                      1 Jun 2007   libssh2_session_callback_set(3)
Impressum