00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _RPCCHANNEL_H_
00020 #define _RPCCHANNEL_H_
00021
00039 #if !defined(VMTOOLS_USE_GLIB)
00040 # error "This library needs to be compiled with VMTOOLS_USE_GLIB."
00041 #endif
00042
00043 #include <rpc/rpc.h>
00044 #include "vm_basic_types.h"
00045 #include "rpcin.h"
00046
00047 struct RpcChannel;
00048
00050 typedef struct RpcChannelCallback {
00052 const char *name;
00054 RpcIn_Callback callback;
00056 gpointer clientData;
00058 gpointer xdrIn;
00065 gpointer xdrOut;
00070 size_t xdrInSize;
00071 } RpcChannelCallback;
00072
00073
00074 typedef Bool (*RpcChannelStartFn)(struct RpcChannel *);
00075 typedef void (*RpcChannelStopFn)(struct RpcChannel *);
00076 typedef void (*RpcChannelShutdownFn)(struct RpcChannel *);
00077 typedef Bool (*RpcChannelSendFn)(struct RpcChannel *,
00078 char *data,
00079 size_t dataLen,
00080 char **result,
00081 size_t *resultLen);
00082
00083
00091 typedef void (*RpcChannelResetCb)(struct RpcChannel *chan,
00092 gboolean success,
00093 gpointer data);
00094
00095
00097 typedef struct RpcChannel {
00098 RpcChannelStartFn start;
00099 RpcChannelStopFn stop;
00100 RpcChannelSendFn send;
00101
00102 RpcChannelShutdownFn shutdown;
00103 gchar *appName;
00104 GHashTable *rpcs;
00105 GMainContext *mainCtx;
00106 GSource *resetCheck;
00107 gpointer appCtx;
00108 RpcChannelCallback resetReg;
00109 RpcChannelResetCb resetCb;
00110 gpointer resetData;
00111 gboolean rpcError;
00112 guint rpcErrorCount;
00113 gpointer _private;
00114 } RpcChannel;
00115
00116
00129 static INLINE Bool
00130 RpcChannel_Send(RpcChannel *chan,
00131 char *data,
00132 size_t dataLen,
00133 char **result,
00134 size_t *resultLen)
00135 {
00136 return chan->send(chan, data, dataLen, result, resultLen);
00137 }
00138
00139 Bool
00140 RpcChannel_BuildXdrCommand(const char *cmd,
00141 void *xdrProc,
00142 void *xdrData,
00143 char **result,
00144 size_t *resultLen);
00145
00146 gboolean
00147 RpcChannel_Destroy(RpcChannel *chan);
00148
00149 Bool
00150 RpcChannel_Dispatch(RpcInData *data);
00151
00152 void
00153 RpcChannel_Setup(RpcChannel *chan,
00154 const gchar *appName,
00155 GMainContext *mainCtx,
00156 gpointer appCtx,
00157 RpcChannelResetCb resetCb,
00158 gpointer resetData);
00159
00160 void
00161 RpcChannel_RegisterCallback(RpcChannel *chan,
00162 RpcChannelCallback *rpc);
00163
00164 void
00165 RpcChannel_UnregisterCallback(RpcChannel *chan,
00166 RpcChannelCallback *rpc);
00167
00168
00169 RpcChannel *
00170 RpcChannel_NewBackdoorChannel(GMainContext *mainCtx);
00171
00174 #endif
00175