Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ssh-base.h
Go to the documentation of this file.
1
13
14#ifndef __SSHBASE_H__
15#define __SSHBASE_H__
16
17#include <libssh/libssh.h>
18
19#include <glib.h>
20
21#include <extcap/extcap-base.h>
22
23#ifndef STDERR_FILENO
24#define STDERR_FILENO 2
25#endif
26
27#ifndef STDOUT_FILENO
28#define STDOUT_FILENO 1
29#endif
30
31/* Server and Authentication Options */
32#define SSH_BASE_OPTIONS \
33 { "remote-host", ws_required_argument, NULL, OPT_REMOTE_HOST}, \
34 { "remote-port", ws_required_argument, NULL, OPT_REMOTE_PORT}, \
35 { "remote-username", ws_required_argument, NULL, OPT_REMOTE_USERNAME}, \
36 { "remote-password", ws_required_argument, NULL, OPT_REMOTE_PASSWORD}, \
37 { "remote-count", ws_required_argument, NULL, OPT_REMOTE_COUNT}, \
38 { "sshkey", ws_required_argument, NULL, OPT_SSHKEY}, \
39 { "sshkey-passphrase", ws_required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \
40 { "proxycommand", ws_required_argument, NULL, OPT_PROXYCOMMAND}, \
41 { "ssh-sha1", ws_no_argument, NULL, OPT_SSH_SHA1}, \
42 { "update-known-hosts", ws_no_argument, NULL, OPT_UPDATE_KNOWN_HOSTS}
43
44#define SSH_BASE_OPTIONS_ENUM \
45 OPT_REMOTE_HOST, \
46 OPT_REMOTE_PORT, \
47 OPT_REMOTE_USERNAME, \
48 OPT_REMOTE_PASSWORD, \
49 OPT_SSHKEY, \
50 OPT_SSHKEY_PASSPHRASE, \
51 OPT_PROXYCOMMAND, \
52 OPT_SSH_SHA1, \
53 OPT_UPDATE_KNOWN_HOSTS
54
55#define SSH_BASE_PACKET_OPTIONS \
56 SSH_BASE_OPTIONS, \
57 { "remote-interface", ws_required_argument, NULL, OPT_REMOTE_INTERFACE}, \
58 { "remote-filter", ws_required_argument, NULL, OPT_REMOTE_FILTER}
59
60#define SSH_BASE_PACKET_OPTIONS_ENUM \
61 SSH_BASE_OPTIONS_ENUM, \
62 OPT_REMOTE_INTERFACE, \
63 OPT_REMOTE_FILTER
64
68typedef struct _ssh_params {
69 char* host;
70 uint16_t port;
71 char* username;
72 char* password;
76 bool ssh_sha1;
77 bool update_known_hosts;
78 int debug;
80
86void ssh_base_list_config(unsigned *count);
87
94
95/* Add libssh version information to an extcap_parameters structure */
96
102void add_libssh_info(extcap_parameters * extcap_conf);
103
113ssh_session create_ssh_connection(const ssh_params_t* ssh_params, char** err_info);
114
122int ssh_channel_printf(ssh_channel channel, const char* fmt, ...);
123
139
155int ssh_async_loop_read(ssh_session sshs, ssh_channel channel, FILE* fp);
156
157/* Clean the current ssh session and channel. */
158
167void ssh_cleanup(ssh_session* sshs, ssh_channel* channel);
168
169/* Init the ssh_params_t structure */
170
177
178/* Clean the ssh params */
179
185void ssh_params_free(ssh_params_t* ssh_params);
186
187/* Sets the libssh log level to match the ws log level */
188
195void ssh_params_set_log_level(ssh_params_t* ssh_params, enum ws_log_level level);
196
197#endif
198
199/*
200 * Editor modelines - https://www.wireshark.org/tools/modelines.html
201 *
202 * Local variables:
203 * c-basic-offset: 8
204 * tab-width: 8
205 * indent-tabs-mode: t
206 * End:
207 *
208 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
209 * :indentSize=8:tabSize=8:noTabs=false:
210 */
struct _extcap_parameters extcap_parameters
Holds all runtime parameters and state for an extcap plugin, parsed from command-line arguments and u...
ssh_session create_ssh_connection(const ssh_params_t *ssh_params, char **err_info)
Creates an SSH session based on the provided parameters.
Definition ssh-base.c:261
ssh_params_t * ssh_params_new(void)
Create a new SSH parameters structure.
Definition ssh-base.c:622
struct _ssh_params ssh_params_t
Holds the connection parameters required to establish an SSH session for an SSH-based extcap capture.
void ssh_base_list_config(unsigned *count)
Print SSH base server and authentication configuration options.
Definition ssh-base.c:131
void add_libssh_info(extcap_parameters *extcap_conf)
Adds information about the libssh library version to the extcap parameters.
Definition ssh-base.c:181
void ssh_params_free(ssh_params_t *ssh_params)
Frees the memory allocated for an ssh_params_t structure.
Definition ssh-base.c:639
void ssh_params_set_log_level(ssh_params_t *ssh_params, enum ws_log_level level)
Set the log level for SSH parameters.
Definition ssh-base.c:659
bool ssh_base_setup_graceful_shutdown(extcap_parameters *extcap_conf)
Sets up ssh_async_loop_read to allow graceful shutdown.
Definition ssh-base.c:493
int ssh_channel_printf(ssh_channel channel, const char *fmt,...)
Writes a formatted message to an SSH channel.
Definition ssh-base.c:466
int ssh_async_loop_read(ssh_session sshs, ssh_channel channel, FILE *fp)
Asynchronously reads the output of a single SSH command.
Definition ssh-base.c:511
void ssh_cleanup(ssh_session *sshs, ssh_channel *channel)
Cleans up SSH session and channel resources.
Definition ssh-base.c:605
void ssh_base_add_help_options(extcap_parameters *extcap_conf)
Adds SSH base server and authentication options to the help options.
Definition ssh-base.c:168
Holds the connection parameters required to establish an SSH session for an SSH-based extcap capture.
Definition ssh-base.h:68
char * username
Definition ssh-base.h:71
char * password
Definition ssh-base.h:72
bool ssh_sha1
Definition ssh-base.h:76
int debug
Definition ssh-base.h:78
char * sshkey_passphrase
Definition ssh-base.h:74
char * proxycommand
Definition ssh-base.h:75
uint16_t port
Definition ssh-base.h:70
char * sshkey_path
Definition ssh-base.h:73
char * host
Definition ssh-base.h:69