open-vm-tools 9.4.6

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

guestrpc.h
Go to the documentation of this file.
1 /*********************************************************
2 * Copyright (C) 2008 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 struct 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
84 typedef gboolean (*RpcIn_Callback)(RpcInData *data);
85
86
88 typedef struct RpcChannelCallback {
90 const char *name;
92 RpcIn_Callback callback;
94 gpointer clientData;
96 gpointer xdrIn;
103 gpointer xdrOut;
108 size_t xdrInSize;
109 } RpcChannelCallback;
110
111
112 typedef gboolean (*RpcChannelStartFn)(struct RpcChannel *);
113 typedef void (*RpcChannelStopFn)(struct RpcChannel *);
114 typedef void (*RpcChannelShutdownFn)(struct RpcChannel *);
115 typedef gboolean (*RpcChannelSendFn)(struct RpcChannel *,
116 char const *data,
117 size_t dataLen,
118 char **result,
119 size_t *resultLen);
120 typedef void (*RpcChannelSetupFn)(struct RpcChannel *chan,
121 GMainContext *mainCtx,
122 const char *appName,
123 gpointer appCtx);
124
125
133 typedef void (*RpcChannelResetCb)(struct RpcChannel *chan,
134 gboolean success,
135 gpointer data);
136
137
139 typedef struct RpcChannel {
140 RpcChannelStartFn start;
141 RpcChannelStopFn stop;
142 RpcChannelSendFn send;
143 RpcChannelSetupFn setup;
144 RpcChannelShutdownFn shutdown;
145 gpointer _private;
146 } RpcChannel;
147
148
157 G_INLINE_FUNC gboolean
158 RpcChannel_Start(RpcChannel *chan)
159 {
160 g_return_val_if_fail(chan != NULL, FALSE);
161 g_return_val_if_fail(chan->start != NULL, FALSE);
162
163 return chan->start(chan);
164 }
165
166
173 G_INLINE_FUNC void
174 RpcChannel_Stop(RpcChannel *chan)
175 {
176 g_return_if_fail(chan != NULL);
177 g_return_if_fail(chan->stop != NULL);
178
179 chan->stop(chan);
180 }
181
182
195 G_INLINE_FUNC gboolean
196 RpcChannel_Send(RpcChannel *chan,
197 char const *data,
198 size_t dataLen,
199 char **result,
200 size_t *resultLen)
201 {
202 g_return_val_if_fail(chan != NULL, FALSE);
203 g_return_val_if_fail(chan->send != NULL, FALSE);
204
205 return chan->send(chan, data, dataLen, result, resultLen);
206 }
207
208 gboolean
209 RpcChannel_BuildXdrCommand(const char *cmd,
210 void *xdrProc,
211 void *xdrData,
212 char **result,
213 size_t *resultLen);
214
215 RpcChannel *
216 RpcChannel_Create(void);
217
218 gboolean
219 RpcChannel_Destroy(RpcChannel *chan);
220
221 gboolean
222 RpcChannel_Dispatch(RpcInData *data);
223
224 void
225 RpcChannel_Setup(RpcChannel *chan,
226 const gchar *appName,
227 GMainContext *mainCtx,
228 gpointer appCtx,
229 RpcChannelResetCb resetCb,
230 gpointer resetData);
231
232 void
233 RpcChannel_RegisterCallback(RpcChannel *chan,
234 RpcChannelCallback *rpc);
235
236 gboolean
237 RpcChannel_SetRetVals(RpcInData *data,
238 char const *result,
239 gboolean retVal);
240
241 gboolean
242 RpcChannel_SetRetValsF(RpcInData *data,
243 char *result,
244 gboolean retVal);
245
246 void
247 RpcChannel_UnregisterCallback(RpcChannel *chan,
248 RpcChannelCallback *rpc);
249
250
251 RpcChannel *
252 BackdoorChannel_New(void);
253
254 G_END_DECLS
255
258 #endif
259
RpcInData::args
const char * args
Definition: guestrpc.h:58
RpcChannel_Start
G_INLINE_FUNC gboolean RpcChannel_Start(RpcChannel *chan)
Definition: guestrpc.h:158
RpcChannel
Definition: guestrpc.h:139
RpcInData::name
const char * name
Definition: guestrpc.h:53
RpcInData
Definition: guestrpc.h:51
RpcChannelCallback::clientData
gpointer clientData
Definition: guestrpc.h:94
RpcChannelCallback::xdrIn
gpointer xdrIn
Definition: guestrpc.h:96
RpcInData::argsSize
size_t argsSize
Definition: guestrpc.h:60
RpcChannel_Send
G_INLINE_FUNC gboolean RpcChannel_Send(RpcChannel *chan, char const *data, size_t dataLen, char **result, size_t *resultLen)
Definition: guestrpc.h:196
utils.h
RpcInData::appCtx
void * appCtx
Definition: guestrpc.h:74
RpcChannelCallback
struct RpcChannelCallback RpcChannelCallback
RpcChannelCallback::xdrOut
gpointer xdrOut
Definition: guestrpc.h:103
RpcChannelResetCb
void(* RpcChannelResetCb)(struct RpcChannel *chan, gboolean success, gpointer data)
Definition: guestrpc.h:133
RpcChannel_Stop
G_INLINE_FUNC void RpcChannel_Stop(RpcChannel *chan)
Definition: guestrpc.h:174
RpcInData::result
char * result
Definition: guestrpc.h:65
RpcChannelCallback::xdrInSize
size_t xdrInSize
Definition: guestrpc.h:108
RpcChannel
struct RpcChannel RpcChannel
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:92
RpcChannelCallback::name
const char * name
Definition: guestrpc.h:90
RpcInData
struct RpcInData RpcInData
RpcIn_Callback
gboolean(* RpcIn_Callback)(RpcInData *data)
Definition: guestrpc.h:84
RpcInData::freeResult
gboolean freeResult
Definition: guestrpc.h:72
RpcChannelCallback
Definition: guestrpc.h:88