open-vm-tools 12.5.0
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
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
62#define RPCCHANNEL_SEND_PERMISSION_DENIED "Permission denied"
63
64typedef struct _RpcChannel RpcChannel;
65
67typedef 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;
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
106typedef gboolean (*RpcIn_Callback)(RpcInData *data);
107
108
132
140typedef void (*RpcChannelResetCb)(RpcChannel *chan,
141 gboolean success,
142 gpointer data);
143
150typedef 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