1 /* 2 * virnetclient.h: generic network RPC client 3 * 4 * Copyright (C) 2006-2012 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 "virnettlscontext.h" 24 #include "virnetmessage.h" 25 #ifdef WITH_SASL 26 # include "virnetsaslcontext.h" 27 #endif 28 #include "virnetclientprogram.h" 29 #include "virnetclientstream.h" 30 #include "virobject.h" 31 #include "viruri.h" 32 33 typedef enum { 34 VIR_NET_CLIENT_PROXY_AUTO, 35 VIR_NET_CLIENT_PROXY_NETCAT, 36 VIR_NET_CLIENT_PROXY_NATIVE, 37 38 VIR_NET_CLIENT_PROXY_LAST, 39 } virNetClientProxy; 40 41 VIR_ENUM_DECL(virNetClientProxy); 42 43 char * 44 virNetClientSSHHelperCommand(virNetClientProxy proxy, 45 const char *netcatPath, 46 const char *socketPath, 47 const char *driverURI, 48 bool readonly); 49 50 virNetClient *virNetClientNewUNIX(const char *path, 51 const char *spawnDaemonPath); 52 53 virNetClient *virNetClientNewTCP(const char *nodename, 54 const char *service, 55 int family); 56 57 virNetClient *virNetClientNewSSH(const char *nodename, 58 const char *service, 59 const char *binary, 60 const char *username, 61 bool noTTY, 62 bool noVerify, 63 const char *keyfile, 64 virNetClientProxy proxy, 65 const char *netcatPath, 66 const char *socketPath, 67 const char *driverURI, 68 bool readonly); 69 70 virNetClient *virNetClientNewLibSSH2(const char *host, 71 const char *port, 72 int family, 73 const char *username, 74 const char *privkeyPath, 75 const char *knownHostsPath, 76 const char *knownHostsVerify, 77 const char *authMethods, 78 virNetClientProxy proxy, 79 const char *netcatPath, 80 const char *socketPath, 81 const char *driverURI, 82 bool readonly, 83 virConnectAuthPtr authPtr, 84 virURI *uri); 85 86 virNetClient *virNetClientNewLibssh(const char *host, 87 const char *port, 88 int family, 89 const char *username, 90 const char *privkeyPath, 91 const char *knownHostsPath, 92 const char *knownHostsVerify, 93 const char *authMethods, 94 virNetClientProxy proxy, 95 const char *netcatPath, 96 const char *socketPath, 97 const char *driverURI, 98 bool readonly, 99 virConnectAuthPtr authPtr, 100 virURI *uri); 101 102 virNetClient *virNetClientNewExternal(const char **cmdargv); 103 104 int virNetClientRegisterAsyncIO(virNetClient *client); 105 int virNetClientRegisterKeepAlive(virNetClient *client); 106 107 typedef void (*virNetClientCloseFunc)(virNetClient *client, 108 int reason, 109 void *opaque); 110 111 void virNetClientSetCloseCallback(virNetClient *client, 112 virNetClientCloseFunc cb, 113 void *opaque, 114 virFreeCallback ff); 115 116 int virNetClientGetFD(virNetClient *client); 117 int virNetClientDupFD(virNetClient *client, bool cloexec); 118 119 bool virNetClientHasPassFD(virNetClient *client); 120 121 int virNetClientAddProgram(virNetClient *client, 122 virNetClientProgram *prog); 123 124 int virNetClientAddStream(virNetClient *client, 125 virNetClientStream *st); 126 127 void virNetClientRemoveStream(virNetClient *client, 128 virNetClientStream *st); 129 130 int virNetClientSendWithReply(virNetClient *client, 131 virNetMessage *msg); 132 133 int virNetClientSendNonBlock(virNetClient *client, 134 virNetMessage *msg); 135 136 int virNetClientSendStream(virNetClient *client, 137 virNetMessage *msg, 138 virNetClientStream *st); 139 140 #ifdef WITH_SASL 141 void virNetClientSetSASLSession(virNetClient *client, 142 virNetSASLSession *sasl); 143 #endif 144 145 int virNetClientSetTLSSession(virNetClient *client, 146 virNetTLSContext *tls); 147 148 bool virNetClientIsEncrypted(virNetClient *client); 149 bool virNetClientIsOpen(virNetClient *client); 150 151 const char *virNetClientLocalAddrStringSASL(virNetClient *client); 152 const char *virNetClientRemoteAddrStringSASL(virNetClient *client); 153 154 int virNetClientGetTLSKeySize(virNetClient *client); 155 156 void virNetClientClose(virNetClient *client); 157 158 bool virNetClientKeepAliveIsSupported(virNetClient *client); 159 int virNetClientKeepAliveStart(virNetClient *client, 160 int interval, 161 unsigned int count); 162 163 void virNetClientKeepAliveStop(virNetClient *client); 164