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

open-vm-tools 13.0.10

guestrpc.h
Go to the documentation of this file.
1/*********************************************************
2 * Copyright (C) 2008,2014-2016,2018-2020,2023 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
38
39/*
40 * glib.h should not be placed inside `extern "C"' blocks.
41 * However, this header is often placed inside such blocks.
42 * Here we change back into C++ for glib.h
43 */
44#ifdef __cplusplus
45extern "C++" {
46#endif
47#include <glib.h>
48#ifdef __cplusplus
49}
50#endif
51
52#include "vmware/tools/utils.h"
53
54G_BEGIN_DECLS
55
57#define RPCIN_SETRETVALS RpcChannel_SetRetVals
58#define RPCIN_SETRETVALSF RpcChannel_SetRetValsF
59
61
62#define RPCCHANNEL_SEND_PERMISSION_DENIED "Permission denied"
63
64typedef struct _RpcChannel RpcChannel;
65
67 typedef struct RpcInData {
69 const char *name;
74 const char *args;
76 size_t argsSize;
81 char *result;
83 size_t resultLen;
88 gboolean freeResult;
90 void *appCtx;
92 void *clientData;
93} RpcInData;
94
95typedef enum RpcChannelType {
96 RPCCHANNEL_TYPE_INACTIVE,
97 RPCCHANNEL_TYPE_BKDOOR,
98 RPCCHANNEL_TYPE_PRIV_VSOCK,
99 RPCCHANNEL_TYPE_UNPRIV_VSOCK
100} RpcChannelType;
101
106 typedef gboolean (*RpcIn_Callback)(RpcInData *data);
107
108
110 typedef struct RpcChannelCallback {
112 const char *name;
114 RpcIn_Callback callback;
116 gpointer clientData;
118 gpointer xdrIn;
125 gpointer xdrOut;
130 size_t xdrInSize;
131} RpcChannelCallback;
132
140 typedef void (*RpcChannelResetCb)(RpcChannel *chan,
141 gboolean success,
142 gpointer data);
143
150 typedef void (*RpcChannelFailureCb)(gpointer _state);
151
152
153gboolean
154RpcChannel_Start(RpcChannel *chan);
155
156void
157RpcChannel_Stop(RpcChannel *chan);
158
159RpcChannelType
160RpcChannel_GetType(RpcChannel *chan);
161
162gboolean
163RpcChannel_Send(RpcChannel *chan,
164 char const *data,
165 size_t dataLen,
166 char **result,
167 size_t *resultLen);
168
169void
170RpcChannel_Free(void *ptr);
171
172#if !defined(USE_RPCI_ONLY)
173gboolean
174RpcChannel_BuildXdrCommand(const char *cmd,
175 void *xdrProc,
176 void *xdrData,
177 char **result,
178 size_t *resultLen);
179gboolean
180RpcChannel_Dispatch(RpcInData *data);
181
182void
183RpcChannel_Setup(RpcChannel *chan,
184 const gchar *appName,
185 GMainContext *mainCtx,
186 gpointer appCtx,
187 RpcChannelResetCb resetCb,
188 gpointer resetData,
189 RpcChannelFailureCb failureCb,
190 guint maxFailures);
191
192void
193RpcChannel_RegisterCallback(RpcChannel *chan,
194 RpcChannelCallback *rpc);
195
196void
197RpcChannel_UnregisterCallback(RpcChannel *chan,
198 RpcChannelCallback *rpc);
199#endif
200
201RpcChannel *
202RpcChannel_Create(void);
203
204void
205RpcChannel_Destroy(RpcChannel *chan);
206
207gboolean
208RpcChannel_SetRetVals(RpcInData *data,
209 char const *result,
210 gboolean retVal);
211
212gboolean
213RpcChannel_SetRetValsF(RpcInData *data,
214 char *result,
215 gboolean retVal);
216
217gboolean
218RpcChannel_SendOneRaw(const char *data,
219 size_t dataLen,
220 char **result,
221 size_t *resultLen);
222
223#if defined(__linux__) || defined(_WIN32)
224gboolean
225RpcChannel_SendOneRawPriv(const char *data,
226 size_t dataLen,
227 char **result,
228 size_t *resultLen);
229#endif
230
231gboolean
232RpcChannel_SendOne(char **reply,
233 size_t *repLen,
234 const char *reqFmt,
235 ...);
236
237#if defined(__linux__) || defined(_WIN32)
238gboolean
239RpcChannel_SendOnePriv(char **reply,
240 size_t *repLen,
241 const char *reqFmt,
242 ...);
243#endif
244
245RpcChannel *
246RpcChannel_New(void);
247
248#if defined(__linux__) || defined(_WIN32)
249RpcChannel *
250VSockChannel_New(int flags);
251#endif
252
253void
254RpcChannel_SetBackdoorOnly(void);
255
256RpcChannel *
257BackdoorChannel_New(void);
258
259G_END_DECLS
260
262
263#endif
264
RpcIn_Callback
gboolean(* RpcIn_Callback)(RpcInData *data)
Definition guestrpc.h:106
RpcChannelFailureCb
void(* RpcChannelFailureCb)(gpointer _state)
Definition guestrpc.h:150
RpcChannelResetCb
void(* RpcChannelResetCb)(RpcChannel *chan, gboolean success, gpointer data)
Definition guestrpc.h:140
RpcChannelCallback
Definition guestrpc.h:110
RpcChannelCallback::xdrInSize
size_t xdrInSize
Definition guestrpc.h:130
RpcChannelCallback::clientData
gpointer clientData
Definition guestrpc.h:116
RpcChannelCallback::xdrIn
gpointer xdrIn
Definition guestrpc.h:118
RpcChannelCallback::name
const char * name
Definition guestrpc.h:112
RpcChannelCallback::xdrOut
gpointer xdrOut
Definition guestrpc.h:125
RpcChannelCallback::callback
RpcIn_Callback callback
Definition guestrpc.h:114
RpcInData
Definition guestrpc.h:67
RpcInData::name
const char * name
Definition guestrpc.h:69
RpcInData::freeResult
gboolean freeResult
Definition guestrpc.h:88
RpcInData::result
char * result
Definition guestrpc.h:81
RpcInData::argsSize
size_t argsSize
Definition guestrpc.h:76
RpcInData::args
const char * args
Definition guestrpc.h:74
RpcInData::appCtx
void * appCtx
Definition guestrpc.h:90
RpcInData::clientData
void * clientData
Definition guestrpc.h:92
RpcInData::resultLen
size_t resultLen
Definition guestrpc.h:83
utils.h