Callbacks
From Libssh2
[edit]
Allocators
#define LIBSSH2_ALLOC_FUNC(name) void *name(size_t count, void **abstract) #define LIBSSH2_REALLOC_FUNC(name) void *name(void *ptr, size_t count, void **abstract) #define LIBSSH2_FREE_FUNC(name) void name(void *ptr, void **abstract)
Allocator callbacks are called by the library anytime memory needs to be allocated, reallocated, or freed. If no alternate allocator functions are declared when calling libssh2_session_init_ex(), the system allocation functions: malloc(), realloc(), and free() are used instead.
- name
- Name to be assigned to allocator function. This is also the name which will be passed to libssh2_session_init_ex().
- count
- Number of bytes to allocate or reallocate.
- ptr
- Existing pointer to free or reallocate.
- abstract
- Doubly derefferenced pointer to abstract data stored in the session object. The singly deferenced void* which this pointer refers to may be modified in place by the callback if necessary.
[edit]
Transport
#define LIBSSH2_IGNORE_FUNC(name) void name(LIBSSH2_SESSION *session, const char *message, int message_len, void **abstract) #define LIBSSH2_DEBUG_FUNC(name) void name(LIBSSH2_SESSION *session, int always_display, const char *message, int message_len, const char *language, int language_len, void **abstract) #define LIBSSH2_DISCONNECT_FUNC(name) void name(LIBSSH2_SESSION *session, int reason, const char *message, int message_len, const char *language, int language_len, void **abstract) #define LIBSSH2_MACERROR_FUNC(name) int name(LIBSSH2_SESSION *session, const char *packet, int packet_len, void **abstract) #define LIBSSH2_X11_OPEN_FUNC(name) void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, char *shost, int sport, void **abstract)
Transport callbacks are triggered in response to special events at the transport layer such as the receipt of a special packet or a security exception. These callbacks are set following session initialization using libssh2_session_callback_set().
- name
- Name to be assigned to allocator function. This is also the name which will be passed to libssh2_session_callback_set().
- session
- Reference to the session object which received the special event.
- always_display
- Boolean flag. When set, recipient is strongly advised to display the message to any interactive user.
- reason
- Numeric reason code for disconnection, one of the Disconnect Reason constants.
- message
- Human readable message relevant to the callback.
- message_len
- Length of message in bytes.
- language
- Language/encoding specifier
- language_len
- Length of language parameter.
- packet
- Raw packet encountered during MAC verification failure
- packet_len
- Length of packet
- channel
- Channel object associated with the X11 request. X11 requests are considered by this library as a transport layer event as they occur out-of-band from channel data.
- shost
- Source host which generated the X11 request.
- sport
- Source port X11 request originated from.
- abstract
- Doubly derefferenced pointer to abstract data stored in the session object. The singly deferenced void* which this pointer refers to may be modified in place by the callback if necessary.
[edit]
Authentication
#define LIBSSH2_PASSWD_CHANGEREQ_FUNC(name) void name(LIBSSH2_SESSION *session, char **newpw, int *newpw_len, void **abstract)
- name
- Name to be assigned to allocator function. This is also the name which will be passed to libssh2_userauth_password_ex().
- session
- Reference to the session object which received the password change request.
- newpw
- Callback populates this variable reference with the new password for the account being changed.
- newpw_len
- Callback populates this variable reference with the length of newpw
- abstract
- Doubly derefferenced pointer to abstract data stored in the session object. The singly deferenced void* which this pointer refers to may be modified in place by the callback if necessary.
#define LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(name_) void name_(const char *name, int name_len, const char *instruction, int instruction_len, int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, void **abstract)
- name_
- Name to be assigned to allocator function. This is also the name which will be passed to libssh2_userauth_keyboard_interactive_ex().
- name
- Name given by host to the current authentication challenge.
- name_len
- Length of name
- instruction
- Human readable instructions for associated prompts.
- instruction_len
- Length of instruction parameter.
- num_prompts
- Number of elements in prompts vector.
- prompts
- Vector of num_prompts instances of LIBSSH2_USERAUTH_KBDINT_PROMPT structures.
- responses
- Preallocated vector of num_prompts instances of LIBSSH2_USERAUTH_KBDINT_RESPONSE structures. Callback populates this vector with appropriate responses to the prompts in the corresponding indices of the prompts vector.
- abstract
- Doubly derefferenced pointer to abstract data stored in the session object. The singly deferenced void* which this pointer refers to may be modified in place by the callback if necessary.
