The libssh server API


Data Structures

struct  ssh_bind_callbacks_struct
 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.

Functions

LIBSSH_API int ssh_bind_accept (ssh_bind ssh_bind_o, ssh_session session)
 Accept an incoming ssh connection and initialize the session.
LIBSSH_API void ssh_bind_fd_toaccept (ssh_bind ssh_bind_o)
 Allow the file descriptor to accept new sessions.
LIBSSH_API void ssh_bind_free (ssh_bind ssh_bind_o)
 Free a ssh servers bind.
LIBSSH_API socket_t ssh_bind_get_fd (ssh_bind ssh_bind_o)
 Recover the file descriptor from the session.
LIBSSH_API int ssh_bind_listen (ssh_bind ssh_bind_o)
 Start listening to the socket.
LIBSSH_API ssh_bind ssh_bind_new (void)
 Creates a new SSH server bind.
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.
LIBSSH_API void ssh_bind_set_blocking (ssh_bind ssh_bind_o, int blocking)
 Set the session to blocking/nonblocking mode.
LIBSSH_API int ssh_bind_set_callbacks (ssh_bind sshbind, ssh_bind_callbacks callbacks, void *userdata)
 Set the callback for this bind.
LIBSSH_API void ssh_bind_set_fd (ssh_bind ssh_bind_o, socket_t fd)
 Set the file descriptor for a session.
LIBSSH_API int ssh_handle_key_exchange (ssh_session session)
 Handles the key exchange and set up encryption.
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

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:
sshbind Current sshbind session handler
message the actual message
userdata Userdata 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_o The ssh server bind to accept a connection.
session A 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_o The ssh server bind to use.

void ssh_bind_free ( ssh_bind  ssh_bind_o  ) 

Free a ssh servers bind.

Parameters:
ssh_bind_o The 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_o The 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_o The 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:
sshbind The ssh server bind to configure.
type The 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:
value The 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_o The ssh server bind to use.
blocking Zero 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] sshbind The bind to set the callback on.
[in] callbacks An already set up ssh_bind_callbacks instance.
[in] userdata A 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_callbacks_init(&cb);
     ssh_bind_set_callbacks(session, &cb);

References ssh_bind_callbacks_struct::size.

void ssh_bind_set_fd ( ssh_bind  ssh_bind_o,
socket_t  fd 
)

Set the file descriptor for a session.

Parameters:
ssh_bind_o The ssh server bind to set the fd.
fd The file descriptssh_bind B

int ssh_handle_key_exchange ( ssh_session  session  ) 

Handles the key exchange and set up encryption.

Parameters:
session A 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:
session the current ssh session
[in] ssh_bind_message_callback a 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] data void pointer to be passed to callback functions


Generated on Sat Jun 1 12:51:48 2013 for libssh by  doxygen 1.5.6