open-vm-tools 2013.09.16
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 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;
100  gpointer clientData;
102  gpointer xdrIn;
109  gpointer xdrOut;
114  size_t xdrInSize;
116 
124 typedef void (*RpcChannelResetCb)(RpcChannel *chan,
125  gboolean success,
126  gpointer data);
127 
128 gboolean
129 RpcChannel_Start(RpcChannel *chan);
130 
131 void
132 RpcChannel_Stop(RpcChannel *chan);
133 
134 RpcChannelType
135 RpcChannel_GetType(RpcChannel *chan);
136 
137 gboolean
138 RpcChannel_Send(RpcChannel *chan,
139  char const *data,
140  size_t dataLen,
141  char **result,
142  size_t *resultLen);
143 
144 gboolean
145 RpcChannel_BuildXdrCommand(const char *cmd,
146  void *xdrProc,
147  void *xdrData,
148  char **result,
149  size_t *resultLen);
150 
151 RpcChannel *
152 RpcChannel_Create(void);
153 
154 void
155 RpcChannel_Shutdown(RpcChannel *chan);
156 
157 gboolean
158 RpcChannel_Destroy(RpcChannel *chan);
159 
160 gboolean
161 RpcChannel_Dispatch(RpcInData *data);
162 
163 void
164 RpcChannel_Setup(RpcChannel *chan,
165  const gchar *appName,
166  GMainContext *mainCtx,
167  gpointer appCtx,
168  RpcChannelResetCb resetCb,
169  gpointer resetData);
170 
171 void
172 RpcChannel_RegisterCallback(RpcChannel *chan,
173  RpcChannelCallback *rpc);
174 
175 gboolean
176 RpcChannel_SetRetVals(RpcInData *data,
177  char const *result,
178  gboolean retVal);
179 
180 gboolean
181 RpcChannel_SetRetValsF(RpcInData *data,
182  char *result,
183  gboolean retVal);
184 
185 void
186 RpcChannel_UnregisterCallback(RpcChannel *chan,
187  RpcChannelCallback *rpc);
188 
189 gboolean
190 RpcChannel_SendOneRaw(const char *data,
191  size_t dataLen,
192  char **result,
193  size_t *resultLen);
194 
195 gboolean
196 RpcChannel_SendOne(char **reply,
197  size_t *repLen,
198  const char *reqFmt,
199  ...);
200 
201 RpcChannel *
202 RpcChannel_New(void);
203 
204 void
205 RpcChannel_SetBackdoorOnly(void);
206 
207 G_END_DECLS
208 
211 #endif
212