open-vm-tools 10.3.10
guestrpc.h
Go to the documentation of this file.
1/*********************************************************
2 * Copyright (C) 2008,2014-2016,2018 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
48typedef struct _RpcChannel RpcChannel;
49
51typedef struct RpcInData {
53 const char *name;
58 const char *args;
60 size_t argsSize;
65 char *result;
67 size_t resultLen;
72 gboolean freeResult;
74 void *appCtx;
78
79typedef enum RpcChannelType {
80 RPCCHANNEL_TYPE_INACTIVE,
81 RPCCHANNEL_TYPE_BKDOOR,
82 RPCCHANNEL_TYPE_PRIV_VSOCK,
83 RPCCHANNEL_TYPE_UNPRIV_VSOCK
84} RpcChannelType;
85
90typedef gboolean (*RpcIn_Callback)(RpcInData *data);
91
92
94typedef struct RpcChannelCallback {
96 const char *name;
100 gpointer clientData;
102 gpointer xdrIn;
109 gpointer xdrOut;
114 size_t xdrInSize;
116
124typedef void (*RpcChannelResetCb)(RpcChannel *chan,
125 gboolean success,
126 gpointer data);
127
134typedef void (*RpcChannelFailureCb)(gpointer _state);
135
136
137gboolean
138RpcChannel_Start(RpcChannel *chan);
139
140void
141RpcChannel_Stop(RpcChannel *chan);
142
143RpcChannelType
144RpcChannel_GetType(RpcChannel *chan);
145
146gboolean
147RpcChannel_Send(RpcChannel *chan,
148 char const *data,
149 size_t dataLen,
150 char **result,
151 size_t *resultLen);
152
153void
154RpcChannel_Free(void *ptr);
155
156#if !defined(USE_RPCI_ONLY)
157gboolean
158RpcChannel_BuildXdrCommand(const char *cmd,
159 void *xdrProc,
160 void *xdrData,
161 char **result,
162 size_t *resultLen);
163gboolean
164RpcChannel_Dispatch(RpcInData *data);
165
166void
167RpcChannel_Setup(RpcChannel *chan,
168 const gchar *appName,
169 GMainContext *mainCtx,
170 gpointer appCtx,
171 RpcChannelResetCb resetCb,
172 gpointer resetData,
173 RpcChannelFailureCb failureCb,
174 guint maxFailures);
175
176void
177RpcChannel_RegisterCallback(RpcChannel *chan,
178 RpcChannelCallback *rpc);
179
180void
181RpcChannel_UnregisterCallback(RpcChannel *chan,
182 RpcChannelCallback *rpc);
183#endif
184
185RpcChannel *
186RpcChannel_Create(void);
187
188void
189RpcChannel_Shutdown(RpcChannel *chan);
190
191gboolean
192RpcChannel_Destroy(RpcChannel *chan);
193
194gboolean
195RpcChannel_SetRetVals(RpcInData *data,
196 char const *result,
197 gboolean retVal);
198
199gboolean
200RpcChannel_SetRetValsF(RpcInData *data,
201 char *result,
202 gboolean retVal);
203
204gboolean
205RpcChannel_SendOneRaw(const char *data,
206 size_t dataLen,
207 char **result,
208 size_t *resultLen);
209
210gboolean
211RpcChannel_SendOne(char **reply,
212 size_t *repLen,
213 const char *reqFmt,
214 ...);
215
216RpcChannel *
217RpcChannel_New(void);
218
219void
220RpcChannel_SetBackdoorOnly(void);
221
222G_END_DECLS
223
226#endif
227
gboolean(* RpcIn_Callback)(RpcInData *data)
Definition: guestrpc.h:90
void(* RpcChannelFailureCb)(gpointer _state)
Definition: guestrpc.h:134
struct RpcInData RpcInData
void(* RpcChannelResetCb)(RpcChannel *chan, gboolean success, gpointer data)
Definition: guestrpc.h:124
struct RpcChannelCallback RpcChannelCallback
Definition: guestrpc.h:94
size_t xdrInSize
Definition: guestrpc.h:114
gpointer clientData
Definition: guestrpc.h:100
gpointer xdrIn
Definition: guestrpc.h:102
const char * name
Definition: guestrpc.h:96
gpointer xdrOut
Definition: guestrpc.h:109
RpcIn_Callback callback
Definition: guestrpc.h:98
Definition: guestrpc.h:51
const char * name
Definition: guestrpc.h:53
gboolean freeResult
Definition: guestrpc.h:72
char * result
Definition: guestrpc.h:65
size_t argsSize
Definition: guestrpc.h:60
const char * args
Definition: guestrpc.h:58
void * appCtx
Definition: guestrpc.h:74
void * clientData
Definition: guestrpc.h:76
size_t resultLen
Definition: guestrpc.h:67