Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
ssh-base.h File Reference
#include <libssh/libssh.h>
#include <glib.h>
#include <extcap/extcap-base.h>

Go to the source code of this file.

Classes

struct  _ssh_params
 Holds the connection parameters required to establish an SSH session for an SSH-based extcap capture. More...
 

Macros

#define STDERR_FILENO   2
 
#define STDOUT_FILENO   1
 
#define SSH_BASE_OPTIONS
 
#define SSH_BASE_PACKET_OPTIONS
 

Typedefs

typedef struct _ssh_params ssh_params_t
 Holds the connection parameters required to establish an SSH session for an SSH-based extcap capture.
 

Functions

void add_libssh_info (extcap_parameters *extcap_conf)
 Adds information about the libssh library version to the extcap parameters.
 
ssh_session create_ssh_connection (const ssh_params_t *ssh_params, char **err_info)
 Creates an SSH session based on the provided parameters.
 
int ssh_channel_printf (ssh_channel channel, const char *fmt,...)
 Writes a formatted message to an SSH channel.
 
void ssh_cleanup (ssh_session *sshs, ssh_channel *channel)
 Cleans up SSH session and channel resources.
 
ssh_params_tssh_params_new (void)
 Create a new SSH parameters structure.
 
void ssh_params_free (ssh_params_t *ssh_params)
 Frees the memory allocated for an ssh_params_t structure.
 
void ssh_params_set_log_level (ssh_params_t *ssh_params, enum ws_log_level level)
 Set the log level for SSH parameters.
 

Detailed Description

ssh-base has base utility functions to connect to hosts via ssh

Copyright 2016, Dario Lombardo

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Macro Definition Documentation

◆ SSH_BASE_OPTIONS

#define SSH_BASE_OPTIONS
Value:
{ "remote-host", ws_required_argument, NULL, OPT_REMOTE_HOST}, \
{ "remote-port", ws_required_argument, NULL, OPT_REMOTE_PORT}, \
{ "remote-username", ws_required_argument, NULL, OPT_REMOTE_USERNAME}, \
{ "remote-password", ws_required_argument, NULL, OPT_REMOTE_PASSWORD}, \
{ "remote-count", ws_required_argument, NULL, OPT_REMOTE_COUNT}, \
{ "sshkey", ws_required_argument, NULL, OPT_SSHKEY}, \
{ "sshkey-passphrase", ws_required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \
{ "proxycommand", ws_required_argument, NULL, OPT_PROXYCOMMAND}, \
{ "ssh-sha1", ws_no_argument, NULL, OPT_SSH_SHA1}

◆ SSH_BASE_PACKET_OPTIONS

#define SSH_BASE_PACKET_OPTIONS
Value:
SSH_BASE_OPTIONS, \
{ "remote-interface", ws_required_argument, NULL, OPT_REMOTE_INTERFACE}, \
{ "remote-filter", ws_required_argument, NULL, OPT_REMOTE_FILTER}

Function Documentation

◆ add_libssh_info()

void add_libssh_info ( extcap_parameters extcap_conf)

Adds information about the libssh library version to the extcap parameters.

Parameters
extcap_confPointer to the extcap parameters structure.

◆ create_ssh_connection()

ssh_session create_ssh_connection ( const ssh_params_t ssh_params,
char **  err_info 
)

Creates an SSH session based on the provided parameters.

Create a ssh connection using all the possible authentication methods

Parameters
ssh_paramsPointer to the SSH parameters structure containing connection details.
err_infoPointer to a string that will hold error information if the function fails.
Returns
A pointer to the created SSH session, or NULL if an error occurs.

◆ ssh_channel_printf()

int ssh_channel_printf ( ssh_channel  channel,
const char *  fmt,
  ... 
)

Writes a formatted message to an SSH channel.

Parameters
channelThe SSH channel to write to.
fmtThe format string for the message.
Returns
EXIT_SUCCESS if successful, EXIT_FAILURE otherwise.

◆ ssh_cleanup()

void ssh_cleanup ( ssh_session *  sshs,
ssh_channel *  channel 
)

Cleans up SSH session and channel resources.

This function is responsible for properly closing and freeing the SSH session and channel resources.

Parameters
sshsPointer to the SSH session to be cleaned up.
channelPointer to the SSH channel to be closed.

◆ ssh_params_free()

void ssh_params_free ( ssh_params_t ssh_params)

Frees the memory allocated for an ssh_params_t structure.

Parameters
ssh_paramsPointer to the ssh_params_t structure to be freed.

◆ ssh_params_new()

ssh_params_t * ssh_params_new ( void  )

Create a new SSH parameters structure.

Returns
A pointer to the newly created ssh_params_t structure, or NULL on failure.

◆ ssh_params_set_log_level()

void ssh_params_set_log_level ( ssh_params_t ssh_params,
enum ws_log_level  level 
)

Set the log level for SSH parameters.

Parameters
ssh_paramsPointer to the SSH parameters structure.
levelThe desired log level from the ws_log_level enumeration.