libssh  0.5.4
Data Structures | Typedefs | Functions
The libssh server API

Data Structures

struct  ssh_bind_callbacks
 These are the callbacks exported by the ssh_bind structure. More...
 

Typedefs

typedef void(* ssh_bind_incoming_connection_callback )(ssh_bind sshbind, void *userdata)
 Incoming connection callback. More...
 

Functions

LIBSSH_API int ssh_bind_accept (ssh_bind ssh_bind_o, ssh_session session)
 Accept an incoming ssh connection and initialize the session. More...
 
LIBSSH_API void ssh_bind_fd_toaccept (ssh_bind ssh_bind_o)
 Allow the file descriptor to accept new sessions. More...
 
LIBSSH_API void ssh_bind_free (ssh_bind ssh_bind_o)
 Free a ssh servers bind. More...
 
LIBSSH_API socket_t ssh_bind_get_fd (ssh_bind ssh_bind_o)
 Recover the file descriptor from the session. More...
 
LIBSSH_API int ssh_bind_listen (ssh_bind ssh_bind_o)
 Start listening to the socket. More...
 
LIBSSH_API ssh_bind ssh_bind_new (void)
 Creates a new SSH server bind. More...
 
LIBSSH_API int ssh_bind_options_set (ssh_bind sshbind, enum ssh_bind_options_e type, const void *value)
 Set the options for the current SSH server bind. More...
 
LIBSSH_API void ssh_bind_set_blocking (ssh_bind ssh_bind_o, int blocking)
 Set the session to blocking/nonblocking mode. More...
 
LIBSSH_API int ssh_bind_set_callbacks (ssh_bind sshbind, ssh_bind_callbacks callbacks, void *userdata)
 Set the callback for this bind. More...
 
LIBSSH_API void ssh_bind_set_fd (ssh_bind ssh_bind_o, socket_t fd)
 Set the file descriptor for a session. More...
 
LIBSSH_API int ssh_handle_key_exchange (ssh_session session)
 Handles the key exchange and set up encryption. More...
 
LIBSSH_API void ssh_set_message_callback (ssh_session session, int(*ssh_bind_message_callback)(ssh_session session, ssh_message msg, void *data), void *data)
 defines the ssh_message callback More...
 

Detailed Description

Typedef Documentation

typedef void(* ssh_bind_incoming_connection_callback)(ssh_bind sshbind, void *userdata)

Incoming connection callback.

This callback is called when a ssh_bind has a new incoming connection.

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

Function Documentation

int ssh_bind_accept ( ssh_bind  ssh_bind_o,
ssh_session  session 
)

Accept an incoming ssh connection and initialize the session.

Parameters
ssh_bind_oThe ssh server bind to accept a connection.
sessionA preallocated ssh session
See Also
ssh_new
Returns
SSH_OK when a connection is established

References privatekey_free().

void ssh_bind_fd_toaccept ( ssh_bind  ssh_bind_o)

Allow the file descriptor to accept new sessions.

Parameters
ssh_bind_oThe ssh server bind to use.
void ssh_bind_free ( ssh_bind  ssh_bind_o)

Free a ssh servers bind.

Parameters
ssh_bind_oThe ssh server bind to free.
socket_t ssh_bind_get_fd ( ssh_bind  ssh_bind_o)

Recover the file descriptor from the session.

Parameters
ssh_bind_oThe ssh server bind to get the fd from.
Returns
The file descriptor.
int ssh_bind_listen ( ssh_bind  ssh_bind_o)

Start listening to the socket.

Parameters
ssh_bind_oThe ssh server bind to use.
Returns
0 on success, < 0 on error.

References ssh_init().

ssh_bind ssh_bind_new ( void  )

Creates a new SSH server bind.

Returns
A newly allocated ssh_bind session pointer.
LIBSSH_API int ssh_bind_options_set ( ssh_bind  sshbind,
enum ssh_bind_options_e  type,
const void *  value 
)

Set the options for the current SSH server bind.

Parameters
sshbindThe ssh server bind to configure.
typeThe option type to set. This could be one of the following:
  • SSH_BIND_OPTIONS_BINDADDR The ip address to bind (const char *).
  • SSH_BIND_OPTIONS_BINDPORT The port to bind (unsigned int).
  • SSH_BIND_OPTIONS_BINDPORT_STR The port to bind (const char *).
  • SSH_BIND_OPTIONS_HOSTKEY This specifies the file containing the private host key used by SSHv1. (const char *).
  • SSH_BIND_OPTIONS_DSAKEY This specifies the file containing the private host dsa key used by SSHv2. (const char *).
  • SSH_BIND_OPTIONS_RSAKEY This specifies the file containing the private host dsa key used by SSHv2. (const char *).
  • SSH_BIND_OPTIONS_BANNER That the server banner (version string) for SSH. (const char *).
  • SSH_BIND_OPTIONS_LOG_VERBOSITY Set the session logging verbosity (int).

    The verbosity of the messages. Every log smaller or equal to verbosity will be shown.
    • SSH_LOG_NOLOG: No logging
    • SSH_LOG_RARE: Rare conditions or warnings
    • SSH_LOG_ENTRY: API-accessible entrypoints
    • SSH_LOG_PACKET: Packet id and size
    • SSH_LOG_FUNCTIONS: Function entering and leaving
  • SSH_BIND_OPTIONS_LOG_VERBOSITY_STR Set the session logging verbosity (const char *).

    The verbosity of the messages. Every log smaller or equal to verbosity will be shown.
    • SSH_LOG_NOLOG: No logging
    • SSH_LOG_RARE: Rare conditions or warnings
    • SSH_LOG_ENTRY: API-accessible entrypoints
    • SSH_LOG_PACKET: Packet id and size
    • SSH_LOG_FUNCTIONS: Function entering and leaving
      See the corresponding numbers in libssh.h.
Parameters
valueThe value to set. This is a generic pointer and the datatype which is used should be set according to the type set.
Returns
SSH_OK on success, SSH_ERROR on invalid option or parameter.
void ssh_bind_set_blocking ( ssh_bind  ssh_bind_o,
int  blocking 
)

Set the session to blocking/nonblocking mode.

Parameters
ssh_bind_oThe ssh server bind to use.
blockingZero for nonblocking mode.
int ssh_bind_set_callbacks ( ssh_bind  sshbind,
ssh_bind_callbacks  callbacks,
void *  userdata 
)

Set the callback for this bind.

Parameters
[in]sshbindThe bind to set the callback on.
[in]callbacksAn already set up ssh_bind_callbacks instance.
[in]userdataA pointer to private data to pass to the callbacks.
Returns
SSH_OK on success, SSH_ERROR if an error occured.
struct ssh_callbacks_struct cb = {
.userdata = data,
.auth_function = my_auth_function
};
ssh_bind_set_callbacks(session, &cb);
void ssh_bind_set_fd ( ssh_bind  ssh_bind_o,
socket_t  fd 
)

Set the file descriptor for a session.

Parameters
ssh_bind_oThe ssh server bind to set the fd.
fdThe file descriptssh_bind B
int ssh_handle_key_exchange ( ssh_session  session)

Handles the key exchange and set up encryption.

Parameters
sessionA connected ssh session
See Also
ssh_bind_accept
Returns
SSH_OK if the key exchange was successful

References ssh_log(), and SSH_LOG_PACKET.

void ssh_set_message_callback ( ssh_session  session,
int(*)(ssh_session session, ssh_message msg, void *data)  ssh_bind_message_callback,
void *  data 
)

defines the ssh_message callback

Parameters
sessionthe current ssh session
[in]ssh_bind_message_callbacka function pointer to a callback taking the current ssh session and received message as parameters. the function returns 0 if the message has been parsed and treated successfully, 1 otherwise (libssh must take care of the response).
[in]datavoid pointer to be passed to callback functions