guestrpc.h
Go to the documentation of this file.
/*********************************************************
* Copyright (C) 2008,2014-2016,2018-2020,2023 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
#ifndef _VMWARE_TOOLS_GUESTRPC_H_
#define _VMWARE_TOOLS_GUESTRPC_H_
/*
* glib.h should not be placed inside `extern "C"' blocks.
* However, this header is often placed inside such blocks.
* Here we change back into C++ for glib.h
*/
#ifdef __cplusplus
extern "C++" {
#endif
#include <glib.h>
#ifdef __cplusplus
}
#endif
#include "vmware/tools/utils.h"
G_BEGIN_DECLS
#define RPCIN_SETRETVALS RpcChannel_SetRetVals
#define RPCIN_SETRETVALSF RpcChannel_SetRetValsF
#define RPCCHANNEL_SEND_PERMISSION_DENIED "Permission denied"
typedef struct _RpcChannel RpcChannel;
typedef struct RpcInData {
const char *name;
const char *args;
size_t argsSize;
char *result;
size_t resultLen;
gboolean freeResult;
void *appCtx;
void *clientData;
} RpcInData;
typedef enum RpcChannelType {
RPCCHANNEL_TYPE_INACTIVE,
RPCCHANNEL_TYPE_BKDOOR,
RPCCHANNEL_TYPE_PRIV_VSOCK,
RPCCHANNEL_TYPE_UNPRIV_VSOCK
} RpcChannelType;
typedef gboolean (*RpcIn_Callback)(RpcInData *data);
typedef struct RpcChannelCallback {
const char *name;
RpcIn_Callback callback;
gpointer clientData;
gpointer xdrIn;
gpointer xdrOut;
size_t xdrInSize;
} RpcChannelCallback;
typedef void (*RpcChannelResetCb)(RpcChannel *chan,
gboolean success,
gpointer data);
typedef void (*RpcChannelFailureCb)(gpointer _state);
gboolean
RpcChannel_Start(RpcChannel *chan);
void
RpcChannel_Stop(RpcChannel *chan);
RpcChannelType
RpcChannel_GetType(RpcChannel *chan);
gboolean
RpcChannel_Send(RpcChannel *chan,
char const *data,
size_t dataLen,
char **result,
size_t *resultLen);
void
RpcChannel_Free(void *ptr);
#if !defined(USE_RPCI_ONLY)
gboolean
RpcChannel_BuildXdrCommand(const char *cmd,
void *xdrProc,
void *xdrData,
char **result,
size_t *resultLen);
gboolean
RpcChannel_Dispatch(RpcInData *data);
void
RpcChannel_Setup(RpcChannel *chan,
const gchar *appName,
GMainContext *mainCtx,
gpointer appCtx,
RpcChannelResetCb resetCb,
gpointer resetData,
RpcChannelFailureCb failureCb,
guint maxFailures);
void
RpcChannel_RegisterCallback(RpcChannel *chan,
RpcChannelCallback *rpc);
void
RpcChannel_UnregisterCallback(RpcChannel *chan,
RpcChannelCallback *rpc);
#endif
RpcChannel *
RpcChannel_Create(void);
void
RpcChannel_Destroy(RpcChannel *chan);
gboolean
RpcChannel_SetRetVals(RpcInData *data,
char const *result,
gboolean retVal);
gboolean
RpcChannel_SetRetValsF(RpcInData *data,
char *result,
gboolean retVal);
gboolean
RpcChannel_SendOneRaw(const char *data,
size_t dataLen,
char **result,
size_t *resultLen);
#if defined(__linux__) || defined(_WIN32)
gboolean
RpcChannel_SendOneRawPriv(const char *data,
size_t dataLen,
char **result,
size_t *resultLen);
#endif
gboolean
RpcChannel_SendOne(char **reply,
size_t *repLen,
const char *reqFmt,
...);
#if defined(__linux__) || defined(_WIN32)
gboolean
RpcChannel_SendOnePriv(char **reply,
size_t *repLen,
const char *reqFmt,
...);
#endif
RpcChannel *
RpcChannel_New(void);
#if defined(__linux__) || defined(_WIN32)
RpcChannel *
VSockChannel_New(int flags);
#endif
void
RpcChannel_SetBackdoorOnly(void);
RpcChannel *
BackdoorChannel_New(void);
G_END_DECLS
#endif
RpcIn_Callback
gboolean(* RpcIn_Callback)(RpcInData *data)
Definition guestrpc.h:106
RpcChannelFailureCb
void(* RpcChannelFailureCb)(gpointer _state)
Definition guestrpc.h:150
RpcChannelResetCb
void(* RpcChannelResetCb)(RpcChannel *chan, gboolean success, gpointer data)
Definition guestrpc.h:140
RpcChannelCallback
Definition guestrpc.h:110
RpcChannelCallback::xdrInSize
size_t xdrInSize
Definition guestrpc.h:130
RpcChannelCallback::clientData
gpointer clientData
Definition guestrpc.h:116
RpcChannelCallback::xdrIn
gpointer xdrIn
Definition guestrpc.h:118
RpcChannelCallback::name
const char * name
Definition guestrpc.h:112
RpcChannelCallback::xdrOut
gpointer xdrOut
Definition guestrpc.h:125
RpcChannelCallback::callback
RpcIn_Callback callback
Definition guestrpc.h:114
RpcInData
Definition guestrpc.h:67
RpcInData::name
const char * name
Definition guestrpc.h:69
RpcInData::freeResult
gboolean freeResult
Definition guestrpc.h:88
RpcInData::result
char * result
Definition guestrpc.h:81
RpcInData::argsSize
size_t argsSize
Definition guestrpc.h:76
RpcInData::args
const char * args
Definition guestrpc.h:74
RpcInData::appCtx
void * appCtx
Definition guestrpc.h:90
RpcInData::clientData
void * clientData
Definition guestrpc.h:92
RpcInData::resultLen
size_t resultLen
Definition guestrpc.h:83
utils.h