1 /*
2  * virnetlibsshsession.h: ssh transport provider based on libssh
3  *
4  * Copyright (C) 2012-2016 Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #pragma once
22 
23 #include "internal.h"
24 #include "viruri.h"
25 
26 typedef struct _virNetLibsshSession virNetLibsshSession;
27 
28 virNetLibsshSession *virNetLibsshSessionNew(const char *username);
29 void virNetLibsshSessionFree(virNetLibsshSession *sess);
30 
31 typedef enum {
32     VIR_NET_LIBSSH_HOSTKEY_VERIFY_NORMAL,
33     VIR_NET_LIBSSH_HOSTKEY_VERIFY_AUTO_ADD,
34     VIR_NET_LIBSSH_HOSTKEY_VERIFY_IGNORE
35 } virNetLibsshHostkeyVerify;
36 
37 void virNetLibsshSessionSetChannelCommand(virNetLibsshSession *sess,
38                                           const char *command);
39 
40 int virNetLibsshSessionAuthSetCallback(virNetLibsshSession *sess,
41                                        virConnectAuthPtr auth);
42 
43 int virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess,
44                                            virURI *uri);
45 
46 int virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess);
47 
48 int virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSession *sess,
49                                           const char *keyfile,
50                                           const char *password);
51 
52 int virNetLibsshSessionAuthAddKeyboardAuth(virNetLibsshSession *sess,
53                                            int tries);
54 
55 int virNetLibsshSessionSetHostKeyVerification(virNetLibsshSession *sess,
56                                               const char *hostname,
57                                               int port,
58                                               const char *hostsfile,
59                                               virNetLibsshHostkeyVerify opt);
60 
61 int virNetLibsshSessionConnect(virNetLibsshSession *sess,
62                                int sock);
63 
64 ssize_t virNetLibsshChannelRead(virNetLibsshSession *sess,
65                                 char *buf,
66                                 size_t len);
67 
68 ssize_t virNetLibsshChannelWrite(virNetLibsshSession *sess,
69                                  const char *buf,
70                                  size_t len);
71 
72 bool virNetLibsshSessionHasCachedData(virNetLibsshSession *sess);
73