knsxip: fix header
[metze/wireshark/wip.git] / extcap / ssh-base.h
1 /* ssh-base.h
2  * ssh-base has base utility functions to connect to hosts via ssh
3  *
4  * Copyright 2016, Dario Lombardo
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12
13 #ifndef __SSHBASE_H__
14 #define __SSHBASE_H__
15
16 #include <libssh/libssh.h>
17
18 #include <glib.h>
19
20 #ifndef STDERR_FILENO
21 #define STDERR_FILENO 2
22 #endif
23
24 #ifndef STDOUT_FILENO
25 #define STDOUT_FILENO 1
26 #endif
27
28 #define SSH_BASE_OPTIONS \
29         { "remote-host", required_argument, NULL, OPT_REMOTE_HOST}, \
30         { "remote-port", required_argument, NULL, OPT_REMOTE_PORT}, \
31         { "remote-username", required_argument, NULL, OPT_REMOTE_USERNAME}, \
32         { "remote-password", required_argument, NULL, OPT_REMOTE_PASSWORD}, \
33         { "remote-interface", required_argument, NULL, OPT_REMOTE_INTERFACE}, \
34         { "remote-filter", required_argument, NULL, OPT_REMOTE_FILTER}, \
35         { "remote-count", required_argument, NULL, OPT_REMOTE_COUNT}, \
36         { "sshkey", required_argument, NULL, OPT_SSHKEY}, \
37         { "sshkey-passphrase", required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \
38         { "proxycommand", required_argument, NULL, OPT_PROXYCOMMAND}
39
40 typedef struct _ssh_params {
41         gchar* host;
42         guint16 port;
43         gchar* username;
44         gchar* password;
45         gchar* sshkey_path;
46         gchar* sshkey_passphrase;
47         gchar* proxycommand;
48         gboolean debug;
49 } ssh_params_t;
50
51 /* Create a ssh connection using all the possible authentication menthods */
52 ssh_session create_ssh_connection(const ssh_params_t* ssh_params, char** err_info);
53
54 /* Write a formatted message in the channel */
55 int ssh_channel_printf(ssh_channel channel, const char* fmt, ...);
56
57 /* Clean the current ssh session and channel. */
58 void ssh_cleanup(ssh_session* sshs, ssh_channel* channel);
59
60 /* Init the ssh_params_t structure */
61 ssh_params_t* ssh_params_new(void);
62
63 /* Clean the ssh params */
64 void ssh_params_free(ssh_params_t* ssh_params);
65
66 #endif
67
68 /*
69  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
70  *
71  * Local variables:
72  * c-basic-offset: 8
73  * tab-width: 8
74  * indent-tabs-mode: t
75  * End:
76  *
77  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
78  * :indentSize=8:tabSize=8:noTabs=false:
79  */