summaryrefslogtreecommitdiff
path: root/src/rpc/virnetclient.h
blob: 1647a6cc71502b01afb60118dae77e7206d11d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * virnetclient.h: generic network RPC client
 *
 * Copyright (C) 2006-2012 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "virnettlscontext.h"
#include "virnetmessage.h"
#ifdef WITH_SASL
# include "virnetsaslcontext.h"
#endif
#include "virnetclientprogram.h"
#include "virnetclientstream.h"
#include "viruri.h"

typedef enum {
    VIR_NET_CLIENT_PROXY_AUTO,
    VIR_NET_CLIENT_PROXY_NETCAT,
    VIR_NET_CLIENT_PROXY_NATIVE,

    VIR_NET_CLIENT_PROXY_LAST,
} virNetClientProxy;

VIR_ENUM_DECL(virNetClientProxy);

char *
virNetClientSSHHelperCommand(virNetClientProxy proxy,
                             const char *netcatPath,
                             const char *socketPath,
                             const char *driverURI,
                             bool readonly);

virNetClient *virNetClientNewUNIX(const char *path,
                                  const char *spawnDaemonPath);

virNetClient *virNetClientNewTCP(const char *nodename,
                                   const char *service,
                                   int family);

virNetClient *virNetClientNewSSH(const char *nodename,
                                   const char *service,
                                   const char *binary,
                                   const char *username,
                                   bool noTTY,
                                   bool noVerify,
                                   const char *keyfile,
                                   virNetClientProxy proxy,
                                   const char *netcatPath,
                                   const char *socketPath,
                                   const char *driverURI,
                                   bool readonly);

virNetClient *virNetClientNewLibSSH2(const char *host,
                                       const char *port,
                                       int family,
                                       const char *username,
                                       const char *privkeyPath,
                                       const char *knownHostsPath,
                                       const char *knownHostsVerify,
                                       const char *authMethods,
                                       virNetClientProxy proxy,
                                       const char *netcatPath,
                                       const char *socketPath,
                                       const char *driverURI,
                                       bool readonly,
                                       virConnectAuthPtr authPtr,
                                       virURI *uri);

virNetClient *virNetClientNewLibssh(const char *host,
                                      const char *port,
                                      int family,
                                      const char *username,
                                      const char *privkeyPath,
                                      const char *knownHostsPath,
                                      const char *knownHostsVerify,
                                      const char *authMethods,
                                      virNetClientProxy proxy,
                                      const char *netcatPath,
                                      const char *socketPath,
                                      const char *driverURI,
                                      bool readonly,
                                      virConnectAuthPtr authPtr,
                                      virURI *uri);

virNetClient *virNetClientNewExternal(const char **cmdargv);

int virNetClientRegisterAsyncIO(virNetClient *client);
int virNetClientRegisterKeepAlive(virNetClient *client);

typedef void (*virNetClientCloseFunc)(virNetClient *client,
                                      int reason,
                                      void *opaque);

void virNetClientSetCloseCallback(virNetClient *client,
                                  virNetClientCloseFunc cb,
                                  void *opaque,
                                  virFreeCallback ff);

int virNetClientGetFD(virNetClient *client);
int virNetClientDupFD(virNetClient *client, bool cloexec);

bool virNetClientHasPassFD(virNetClient *client);

int virNetClientAddProgram(virNetClient *client,
                           virNetClientProgram *prog);

int virNetClientAddStream(virNetClient *client,
                          virNetClientStream *st);

void virNetClientRemoveStream(virNetClient *client,
                              virNetClientStream *st);

int virNetClientSendWithReply(virNetClient *client,
                              virNetMessage *msg);

int virNetClientSendNonBlock(virNetClient *client,
                             virNetMessage *msg);

int virNetClientSendStream(virNetClient *client,
                           virNetMessage *msg,
                           virNetClientStream *st);

#ifdef WITH_SASL
void virNetClientSetSASLSession(virNetClient *client,
                                virNetSASLSession *sasl);
#endif

int virNetClientSetTLSSession(virNetClient *client,
                              virNetTLSContext *tls);

bool virNetClientIsEncrypted(virNetClient *client);
bool virNetClientIsOpen(virNetClient *client);

const char *virNetClientLocalAddrStringSASL(virNetClient *client);
const char *virNetClientRemoteAddrStringSASL(virNetClient *client);

int virNetClientGetTLSKeySize(virNetClient *client);

void virNetClientClose(virNetClient *client);

bool virNetClientKeepAliveIsSupported(virNetClient *client);
int virNetClientKeepAliveStart(virNetClient *client,
                               int interval,
                               unsigned int count);

void virNetClientKeepAliveStop(virNetClient *client);