open-vm-tools 10.3.0
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;
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 void
145 RpcChannel_Free(void *ptr);
146 
147 #if !defined(USE_RPCI_ONLY)
148 gboolean
149 RpcChannel_BuildXdrCommand(const char *cmd,
150  void *xdrProc,
151  void *xdrData,
152  char **result,
153  size_t *resultLen);
154 gboolean
155 RpcChannel_Dispatch(RpcInData *data);
156 
157 void
158 RpcChannel_Setup(RpcChannel *chan,
159  const gchar *appName,
160  GMainContext *mainCtx,
161  gpointer appCtx,
162  RpcChannelResetCb resetCb,
163  gpointer resetData);
164 
165 void
166 RpcChannel_RegisterCallback(RpcChannel *chan,
167  RpcChannelCallback *rpc);
168 
169 void
170 RpcChannel_UnregisterCallback(RpcChannel *chan,
171  RpcChannelCallback *rpc);
172 #endif
173 
174 RpcChannel *
175 RpcChannel_Create(void);
176 
177 void
178 RpcChannel_Shutdown(RpcChannel *chan);
179 
180 gboolean
181 RpcChannel_Destroy(RpcChannel *chan);
182 
183 gboolean
184 RpcChannel_SetRetVals(RpcInData *data,
185  char const *result,
186  gboolean retVal);
187 
188 gboolean
189 RpcChannel_SetRetValsF(RpcInData *data,
190  char *result,
191  gboolean retVal);
192 
193 gboolean
194 RpcChannel_SendOneRaw(const char *data,
195  size_t dataLen,
196  char **result,
197  size_t *resultLen);
198 
199 gboolean
200 RpcChannel_SendOne(char **reply,
201  size_t *repLen,
202  const char *reqFmt,
203  ...);
204 
205 RpcChannel *
206 RpcChannel_New(void);
207 
208 void
209 RpcChannel_SetBackdoorOnly(void);
210 
211 G_END_DECLS
212 
215 #endif
216 
const char * args
Definition: guestrpc.h:58
const char * name
Definition: guestrpc.h:53
Definition: guestrpc.h:51
gpointer clientData
Definition: guestrpc.h:100
gpointer xdrIn
Definition: guestrpc.h:102
size_t argsSize
Definition: guestrpc.h:60
void(* RpcChannelResetCb)(RpcChannel *chan, gboolean success, gpointer data)
Definition: guestrpc.h:124
void * appCtx
Definition: guestrpc.h:74
struct RpcChannelCallback RpcChannelCallback
gpointer xdrOut
Definition: guestrpc.h:109
char * result
Definition: guestrpc.h:65
size_t xdrInSize
Definition: guestrpc.h:114
size_t resultLen
Definition: guestrpc.h:67
void * clientData
Definition: guestrpc.h:76
RpcIn_Callback callback
Definition: guestrpc.h:98
const char * name
Definition: guestrpc.h:96
gboolean(* RpcIn_Callback)(RpcInData *data)
Definition: guestrpc.h:90
struct RpcInData RpcInData
gboolean freeResult
Definition: guestrpc.h:72
Definition: guestrpc.h:94