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