open-vm-tools 12.1.5: lib/include/vmware/tools/guestrpc.h Source File

open-vm-tools 12.1.5

guestrpc.h
Go to the documentation of this file.
1/*********************************************************
2 * Copyright (C) 2008,2014-2016,2018-2020 VMware, Inc. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation version 2.1 and no later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11 * License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 *********************************************************/
18
19#ifndef _VMWARE_TOOLS_GUESTRPC_H_
20#define _VMWARE_TOOLS_GUESTRPC_H_
21
39#include <glib.h>
40#include "vmware/tools/utils.h"
41
42G_BEGIN_DECLS
43
45#define RPCIN_SETRETVALS RpcChannel_SetRetVals
46#define RPCIN_SETRETVALSF RpcChannel_SetRetValsF
47
50#define RPCCHANNEL_SEND_PERMISSION_DENIED "Permission denied"
51
52typedef struct _RpcChannel RpcChannel;
53
55 typedef struct RpcInData {
57 const char *name;
62 const char *args;
64 size_t argsSize;
69 char *result;
71 size_t resultLen;
76 gboolean freeResult;
78 void *appCtx;
80 void *clientData;
81} RpcInData;
82
83typedef enum RpcChannelType {
84 RPCCHANNEL_TYPE_INACTIVE,
85 RPCCHANNEL_TYPE_BKDOOR,
86 RPCCHANNEL_TYPE_PRIV_VSOCK,
87 RPCCHANNEL_TYPE_UNPRIV_VSOCK
88} RpcChannelType;
89
94 typedef gboolean (*RpcIn_Callback)(RpcInData *data);
95
96
98 typedef struct RpcChannelCallback {
100 const char *name;
102 RpcIn_Callback callback;
104 gpointer clientData;
106 gpointer xdrIn;
113 gpointer xdrOut;
118 size_t xdrInSize;
119} RpcChannelCallback;
120
128 typedef void (*RpcChannelResetCb)(RpcChannel *chan,
129 gboolean success,
130 gpointer data);
131
138 typedef void (*RpcChannelFailureCb)(gpointer _state);
139
140
141gboolean
142RpcChannel_Start(RpcChannel *chan);
143
144void
145RpcChannel_Stop(RpcChannel *chan);
146
147RpcChannelType
148RpcChannel_GetType(RpcChannel *chan);
149
150gboolean
151RpcChannel_Send(RpcChannel *chan,
152 char const *data,
153 size_t dataLen,
154 char **result,
155 size_t *resultLen);
156
157void
158RpcChannel_Free(void *ptr);
159
160#if !defined(USE_RPCI_ONLY)
161gboolean
162RpcChannel_BuildXdrCommand(const char *cmd,
163 void *xdrProc,
164 void *xdrData,
165 char **result,
166 size_t *resultLen);
167gboolean
168RpcChannel_Dispatch(RpcInData *data);
169
170void
171RpcChannel_Setup(RpcChannel *chan,
172 const gchar *appName,
173 GMainContext *mainCtx,
174 gpointer appCtx,
175 RpcChannelResetCb resetCb,
176 gpointer resetData,
177 RpcChannelFailureCb failureCb,
178 guint maxFailures);
179
180void
181RpcChannel_RegisterCallback(RpcChannel *chan,
182 RpcChannelCallback *rpc);
183
184void
185RpcChannel_UnregisterCallback(RpcChannel *chan,
186 RpcChannelCallback *rpc);
187#endif
188
189RpcChannel *
190RpcChannel_Create(void);
191
192void
193RpcChannel_Destroy(RpcChannel *chan);
194
195gboolean
196RpcChannel_SetRetVals(RpcInData *data,
197 char const *result,
198 gboolean retVal);
199
200gboolean
201RpcChannel_SetRetValsF(RpcInData *data,
202 char *result,
203 gboolean retVal);
204
205gboolean
206RpcChannel_SendOneRaw(const char *data,
207 size_t dataLen,
208 char **result,
209 size_t *resultLen);
210
211#if defined(__linux__) || defined(_WIN32)
212gboolean
213RpcChannel_SendOneRawPriv(const char *data,
214 size_t dataLen,
215 char **result,
216 size_t *resultLen);
217#endif
218
219gboolean
220RpcChannel_SendOne(char **reply,
221 size_t *repLen,
222 const char *reqFmt,
223 ...);
224
225#if defined(__linux__) || defined(_WIN32)
226gboolean
227RpcChannel_SendOnePriv(char **reply,
228 size_t *repLen,
229 const char *reqFmt,
230 ...);
231#endif
232
233RpcChannel *
234RpcChannel_New(void);
235
236#if defined(__linux__) || defined(_WIN32)
237RpcChannel *
238VSockChannel_New(int flags);
239#endif
240
241void
242RpcChannel_SetBackdoorOnly(void);
243
244RpcChannel *
245BackdoorChannel_New(void);
246
247G_END_DECLS
248
251#endif
252
RpcIn_Callback
gboolean(* RpcIn_Callback)(RpcInData *data)
Definition: guestrpc.h:94
RpcChannelFailureCb
void(* RpcChannelFailureCb)(gpointer _state)
Definition: guestrpc.h:138
RpcInData
struct RpcInData RpcInData
RpcChannelResetCb
void(* RpcChannelResetCb)(RpcChannel *chan, gboolean success, gpointer data)
Definition: guestrpc.h:128
RpcChannelCallback
struct RpcChannelCallback RpcChannelCallback
RpcChannelCallback
Definition: guestrpc.h:98
RpcChannelCallback::xdrInSize
size_t xdrInSize
Definition: guestrpc.h:118
RpcChannelCallback::clientData
gpointer clientData
Definition: guestrpc.h:104
RpcChannelCallback::xdrIn
gpointer xdrIn
Definition: guestrpc.h:106
RpcChannelCallback::name
const char * name
Definition: guestrpc.h:100
RpcChannelCallback::xdrOut
gpointer xdrOut
Definition: guestrpc.h:113
RpcChannelCallback::callback
RpcIn_Callback callback
Definition: guestrpc.h:102
RpcInData
Definition: guestrpc.h:55
RpcInData::name
const char * name
Definition: guestrpc.h:57
RpcInData::freeResult
gboolean freeResult
Definition: guestrpc.h:76
RpcInData::result
char * result
Definition: guestrpc.h:69
RpcInData::argsSize
size_t argsSize
Definition: guestrpc.h:64
RpcInData::args
const char * args
Definition: guestrpc.h:62
RpcInData::appCtx
void * appCtx
Definition: guestrpc.h:78
RpcInData::clientData
void * clientData
Definition: guestrpc.h:80
RpcInData::resultLen
size_t resultLen
Definition: guestrpc.h:71
utils.h