Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ssh-base.h
Go to the documentation of this file.
1
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#define SSH_BASE_OPTIONS \
32 { "remote-host", ws_required_argument, NULL, OPT_REMOTE_HOST}, \
33 { "remote-port", ws_required_argument, NULL, OPT_REMOTE_PORT}, \
34 { "remote-username", ws_required_argument, NULL, OPT_REMOTE_USERNAME}, \
35 { "remote-password", ws_required_argument, NULL, OPT_REMOTE_PASSWORD}, \
36 { "remote-count", ws_required_argument, NULL, OPT_REMOTE_COUNT}, \
37 { "sshkey", ws_required_argument, NULL, OPT_SSHKEY}, \
38 { "sshkey-passphrase", ws_required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \
39 { "proxycommand", ws_required_argument, NULL, OPT_PROXYCOMMAND}, \
40 { "ssh-sha1", ws_no_argument, NULL, OPT_SSH_SHA1}
41
42#define SSH_BASE_PACKET_OPTIONS \
43 SSH_BASE_OPTIONS, \
44 { "remote-interface", ws_required_argument, NULL, OPT_REMOTE_INTERFACE}, \
45 { "remote-filter", ws_required_argument, NULL, OPT_REMOTE_FILTER}
46
50typedef struct _ssh_params {
51 char* host;
52 uint16_t port;
53 char* username;
54 char* password;
58 bool ssh_sha1;
59 int debug;
61
62/* Add libssh version information to an extcap_parameters structure */
63
69void add_libssh_info(extcap_parameters * extcap_conf);
70
80ssh_session create_ssh_connection(const ssh_params_t* ssh_params, char** err_info);
81
89int ssh_channel_printf(ssh_channel channel, const char* fmt, ...);
90
91/* Clean the current ssh session and channel. */
92
101void ssh_cleanup(ssh_session* sshs, ssh_channel* channel);
102
103/* Init the ssh_params_t structure */
104
111
112/* Clean the ssh params */
113
119void ssh_params_free(ssh_params_t* ssh_params);
120
121/* Sets the libssh log level to match the ws log level */
122
129void ssh_params_set_log_level(ssh_params_t* ssh_params, enum ws_log_level level);
130
131#endif
132
133/*
134 * Editor modelines - https://www.wireshark.org/tools/modelines.html
135 *
136 * Local variables:
137 * c-basic-offset: 8
138 * tab-width: 8
139 * indent-tabs-mode: t
140 * End:
141 *
142 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
143 * :indentSize=8:tabSize=8:noTabs=false:
144 */
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:128
ssh_params_t * ssh_params_new(void)
Create a new SSH parameters structure.
Definition ssh-base.c:360
struct _ssh_params ssh_params_t
Holds the connection parameters required to establish an SSH session for an SSH-based extcap capture.
void add_libssh_info(extcap_parameters *extcap_conf)
Adds information about the libssh library version to the extcap parameters.
Definition ssh-base.c:122
void ssh_params_free(ssh_params_t *ssh_params)
Frees the memory allocated for an ssh_params_t structure.
Definition ssh-base.c:365
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:378
int ssh_channel_printf(ssh_channel channel, const char *fmt,...)
Writes a formatted message to an SSH channel.
Definition ssh-base.c:327
void ssh_cleanup(ssh_session *sshs, ssh_channel *channel)
Cleans up SSH session and channel resources.
Definition ssh-base.c:344
Holds all runtime parameters and state for an extcap plugin, parsed from command-line arguments and u...
Definition extcap-base.h:69
Holds the connection parameters required to establish an SSH session for an SSH-based extcap capture.
Definition ssh-base.h:50
char * username
Definition ssh-base.h:53
char * password
Definition ssh-base.h:54
bool ssh_sha1
Definition ssh-base.h:58
int debug
Definition ssh-base.h:59
char * sshkey_passphrase
Definition ssh-base.h:56
char * proxycommand
Definition ssh-base.h:57
uint16_t port
Definition ssh-base.h:52
char * sshkey_path
Definition ssh-base.h:55
char * host
Definition ssh-base.h:51