open-vm-tools 2015.01.29
lib/include/vmware/tools/guestrpc.h
Go to the documentation of this file.
00001 /*********************************************************
00002  * Copyright (C) 2008,2014-2015 VMware, Inc. All rights reserved.
00003  *
00004  * This program is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published
00006  * by the Free Software Foundation version 2.1 and no later version.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00010  * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
00011  * License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
00016  *
00017  *********************************************************/
00018 
00019 #ifndef _VMWARE_TOOLS_GUESTRPC_H_
00020 #define _VMWARE_TOOLS_GUESTRPC_H_
00021 
00039 #include <glib.h>
00040 #include "vmware/tools/utils.h"
00041 
00042 G_BEGIN_DECLS
00043 
00045 #define RPCIN_SETRETVALS  RpcChannel_SetRetVals
00046 #define RPCIN_SETRETVALSF RpcChannel_SetRetValsF
00047 
00048 typedef struct _RpcChannel RpcChannel;
00049 
00051 typedef struct RpcInData {
00053    const char *name;
00058    const char *args;
00060    size_t argsSize;
00065    char *result;
00067    size_t resultLen;
00072    gboolean freeResult;
00074    void *appCtx;
00076    void *clientData;
00077 } RpcInData;
00078 
00079 typedef enum RpcChannelType {
00080    RPCCHANNEL_TYPE_INACTIVE,
00081    RPCCHANNEL_TYPE_BKDOOR,
00082    RPCCHANNEL_TYPE_PRIV_VSOCK,
00083    RPCCHANNEL_TYPE_UNPRIV_VSOCK
00084 } RpcChannelType;
00085 
00090 typedef gboolean (*RpcIn_Callback)(RpcInData *data);
00091 
00092 
00094 typedef struct RpcChannelCallback {
00096    const char       *name;
00098    RpcIn_Callback    callback;
00100    gpointer          clientData;
00102    gpointer          xdrIn;
00109    gpointer          xdrOut;
00114    size_t            xdrInSize;
00115 } RpcChannelCallback;
00116 
00124 typedef void (*RpcChannelResetCb)(RpcChannel *chan,
00125                                   gboolean success,
00126                                   gpointer data);
00127 
00128 gboolean
00129 RpcChannel_Start(RpcChannel *chan);
00130 
00131 void
00132 RpcChannel_Stop(RpcChannel *chan);
00133 
00134 RpcChannelType
00135 RpcChannel_GetType(RpcChannel *chan);
00136 
00137 gboolean
00138 RpcChannel_Send(RpcChannel *chan,
00139                 char const *data,
00140                 size_t dataLen,
00141                 char **result,
00142                 size_t *resultLen);
00143 
00144 void
00145 RpcChannel_Free(void *ptr);
00146 
00147 gboolean
00148 RpcChannel_BuildXdrCommand(const char *cmd,
00149                            void *xdrProc,
00150                            void *xdrData,
00151                            char **result,
00152                            size_t *resultLen);
00153 
00154 RpcChannel *
00155 RpcChannel_Create(void);
00156 
00157 void
00158 RpcChannel_Shutdown(RpcChannel *chan);
00159 
00160 gboolean
00161 RpcChannel_Destroy(RpcChannel *chan);
00162 
00163 gboolean
00164 RpcChannel_Dispatch(RpcInData *data);
00165 
00166 void
00167 RpcChannel_Setup(RpcChannel *chan,
00168                  const gchar *appName,
00169                  GMainContext *mainCtx,
00170                  gpointer appCtx,
00171                  RpcChannelResetCb resetCb,
00172                  gpointer resetData);
00173 
00174 void
00175 RpcChannel_RegisterCallback(RpcChannel *chan,
00176                             RpcChannelCallback *rpc);
00177 
00178 gboolean
00179 RpcChannel_SetRetVals(RpcInData *data,
00180                       char const *result,
00181                       gboolean retVal);
00182 
00183 gboolean
00184 RpcChannel_SetRetValsF(RpcInData *data,
00185                        char *result,
00186                        gboolean retVal);
00187 
00188 void
00189 RpcChannel_UnregisterCallback(RpcChannel *chan,
00190                               RpcChannelCallback *rpc);
00191 
00192 gboolean
00193 RpcChannel_SendOneRaw(const char *data,
00194                       size_t dataLen,
00195                       char **result,
00196                       size_t *resultLen);
00197 
00198 gboolean
00199 RpcChannel_SendOne(char **reply,
00200                    size_t *repLen,
00201                    const char *reqFmt,
00202                    ...);
00203 
00204 RpcChannel *
00205 RpcChannel_New(void);
00206 
00207 void
00208 RpcChannel_SetBackdoorOnly(void);
00209 
00210 G_END_DECLS
00211 
00214 #endif
00215