libevent  2.2.1
Event notification library
Macros | Enumerations | Functions
rpc.h File Reference

This header files provides basic support for an RPC server and client. More...

#include <event2/util.h>
#include <event2/visibility.h>

Go to the source code of this file.

Macros

#define EVRPC_GENERATE(rpcname, reqstruct, rplystruct)
 Generates the code for receiving and sending an RPC message. More...
 
#define EVRPC_HEADER(rpcname, reqstruct, rplystruct)
 Creates the definitions and prototypes for an RPC. More...
 
#define EVRPC_MAKE_CTX(rpcname, reqstruct, rplystruct, pool, request, reply, cb, cbarg)
 Creates a context structure that contains rpc specific information. More...
 
#define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg)   evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg))
 launches an RPC and sends it to the server More...
 
#define EVRPC_REGISTER(base, name, request, reply, callback, cbarg)
 register RPCs with the HTTP Server More...
 
#define EVRPC_REQUEST_DONE(rpc_req)
 Creates the reply to an RPC request. More...
 
#define EVRPC_REQUEST_HTTP(rpc_req)   (rpc_req)->http_req
 Provides access to the HTTP request object underlying an RPC. More...
 
#define EVRPC_STRUCT(rpcname)   struct evrpc_req__##rpcname
 The type of a specific RPC Message. More...
 
#define EVRPC_UNREGISTER(base, name)   evrpc_unregister_rpc((base), #name)
 Unregisters an already registered RPC. More...
 
#define EVTAG_ARRAY_ADD(msg, member)   (*(msg)->base->member##_add)(msg)
 Allocates a new entry in the array and returns it.
 
#define EVTAG_ARRAY_ADD_VALUE(msg, member, value)   (*(msg)->base->member##_add)((msg), (value))
 Adds a value to an array.
 
#define EVTAG_ARRAY_GET(msg, member, offset, pvalue)   (*(msg)->base->member##_get)((msg), (offset), (pvalue))
 Gets a variable at the specified offset from the array.
 
#define EVTAG_ARRAY_LEN(msg, member)   ((msg)->member##_length)
 Returns the number of entries in the array.
 
#define EVTAG_ASSIGN(msg, member, value)   (*(msg)->base->member##_assign)((msg), (value))
 Assigns a value to the member in the message. More...
 
#define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len)   (*(msg)->base->member##_assign)((msg), (value), (len))
 Assigns a value to the member in the message. More...
 
#define EVTAG_GET(msg, member, pvalue)   (*(msg)->base->member##_get)((msg), (pvalue))
 Returns the value for a member. More...
 
#define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen)   (*(msg)->base->member##_get)((msg), (pvalue), (plen))
 Returns the value for a member. More...
 
#define EVTAG_HAS(msg, member)   ((msg)->member##_set == 1)
 Determines if the member has been set in the message. More...
 
#define INPUT   EVRPC_INPUT
 Deprecated alias for EVRPC_INPUT. More...
 
#define OUTPUT   EVRPC_OUTPUT
 Deprecated alias for EVRPC_OUTPUT. More...
 

Enumerations

enum  EVRPC_HOOK_RESULT { EVRPC_TERMINATE = -1, EVRPC_CONTINUE = 0, EVRPC_PAUSE = 1 }
 Return value from hook processing functions. More...
 
enum  EVRPC_HOOK_TYPE { EVRPC_INPUT, EVRPC_OUTPUT }
 Hooks for changing the input and output of RPCs; this can be used to implement compression, authentication, encryption, ... More...
 

Functions

EVENT2_EXPORT_SYMBOL void * evrpc_add_hook (void *vbase, enum EVRPC_HOOK_TYPE hook_type, int(*cb)(void *, struct evhttp_request *, struct evbuffer *, void *), void *cb_arg)
 adds a processing hook to either an rpc base or rpc pool More...
 
EVENT2_EXPORT_SYMBOL void evrpc_free (struct evrpc_base *base)
 Frees the evrpc base. More...
 
EVENT2_EXPORT_SYMBOL void * evrpc_get_reply (struct evrpc_req_generic *req)
 
EVENT2_EXPORT_SYMBOL void * evrpc_get_request (struct evrpc_req_generic *req)
 accessors for request and reply
 
EVENT2_EXPORT_SYMBOL int evrpc_hook_add_meta (void *ctx, const char *key, const void *data, size_t data_size)
 adds meta data to request More...
 
EVENT2_EXPORT_SYMBOL int evrpc_hook_find_meta (void *ctx, const char *key, void **data, size_t *data_size)
 retrieves meta data previously associated More...
 
EVENT2_EXPORT_SYMBOL struct evhttp_connection * evrpc_hook_get_connection (void *ctx)
 returns the connection object associated with the request More...
 
EVENT2_EXPORT_SYMBOL struct evrpc_base * evrpc_init (struct evhttp *server)
 Creates a new rpc base from which RPC requests can be received. More...
 
EVENT2_EXPORT_SYMBOL int evrpc_make_request (struct evrpc_request_wrapper *ctx)
 Makes an RPC request based on the provided context. More...
 
EVENT2_EXPORT_SYMBOL struct evrpc_request_wrapper * evrpc_make_request_ctx (struct evrpc_pool *pool, void *request, void *reply, const char *rpcname, void(*req_marshal)(struct evbuffer *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct evbuffer *), void(*cb)(struct evrpc_status *, void *, void *, void *), void *cbarg)
 use EVRPC_GENERATE instead
 
EVENT2_EXPORT_SYMBOL void evrpc_pool_add_connection (struct evrpc_pool *pool, struct evhttp_connection *evcon)
 Adds a connection over which rpc can be dispatched to the pool. More...
 
EVENT2_EXPORT_SYMBOL void evrpc_pool_free (struct evrpc_pool *pool)
 frees an rpc connection pool More...
 
EVENT2_EXPORT_SYMBOL struct evrpc_pool * evrpc_pool_new (struct event_base *base)
 creates an rpc connection pool More...
 
EVENT2_EXPORT_SYMBOL void evrpc_pool_remove_connection (struct evrpc_pool *pool, struct evhttp_connection *evcon)
 Removes a connection from the pool. More...
 
EVENT2_EXPORT_SYMBOL void evrpc_pool_set_timeout (struct evrpc_pool *pool, int timeout_in_secs)
 Sets the timeout in secs after which a request has to complete. More...
 
EVENT2_EXPORT_SYMBOL int evrpc_register_generic (struct evrpc_base *base, const char *name, void(*callback)(struct evrpc_req_generic *, void *), void *cbarg, void *(*req_new)(void *), void *req_new_arg, void(*req_free)(void *), int(*req_unmarshal)(void *, struct evbuffer *), void *(*rpl_new)(void *), void *rpl_new_arg, void(*rpl_free)(void *), int(*rpl_complete)(void *), void(*rpl_marshal)(struct evbuffer *, void *))
 Function for registering a generic RPC with the RPC base. More...
 
EVENT2_EXPORT_SYMBOL int evrpc_register_rpc (struct evrpc_base *, struct evrpc *, void(*)(struct evrpc_req_generic *, void *), void *)
 Low level function for registering an RPC with a server. More...
 
EVENT2_EXPORT_SYMBOL int evrpc_remove_hook (void *vbase, enum EVRPC_HOOK_TYPE hook_type, void *handle)
 removes a previously added hook More...
 
EVENT2_EXPORT_SYMBOL void evrpc_request_done (struct evrpc_req_generic *req)
 completes the server response to an rpc request
 
EVENT2_EXPORT_SYMBOL struct evrpc_pool * evrpc_request_get_pool (struct evrpc_request_wrapper *ctx)
 accessors for obscure and undocumented functionality
 
EVENT2_EXPORT_SYMBOL void evrpc_request_set_cb (struct evrpc_request_wrapper *ctx, void(*cb)(struct evrpc_status *, void *request, void *reply, void *arg), void *cb_arg)
 
EVENT2_EXPORT_SYMBOL void evrpc_request_set_pool (struct evrpc_request_wrapper *ctx, struct evrpc_pool *pool)
 
EVENT2_EXPORT_SYMBOL int evrpc_resume_request (void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res)
 resume a paused request More...
 
EVENT2_EXPORT_SYMBOL int evrpc_send_request_generic (struct evrpc_pool *pool, void *request, void *reply, void(*cb)(struct evrpc_status *, void *, void *, void *), void *cb_arg, const char *rpcname, void(*req_marshal)(struct evbuffer *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct evbuffer *))
 Function for sending a generic RPC request. More...
 
EVENT2_EXPORT_SYMBOL int evrpc_unregister_rpc (struct evrpc_base *base, const char *name)
 

Detailed Description

This header files provides basic support for an RPC server and client.

To support RPCs in a server, every supported RPC command needs to be defined and registered.

EVRPC_HEADER(SendCommand, Request, Reply);

SendCommand is the name of the RPC command. Request is the name of a structure generated by event_rpcgen.py. It contains all parameters relating to the SendCommand RPC. The server needs to fill in the Reply structure. Reply is the name of a structure generated by event_rpcgen.py. It contains the answer to the RPC.

To register an RPC with an HTTP server, you need to first create an RPC base with:

struct evrpc_base *base = evrpc_init(http);

A specific RPC can then be registered with

EVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg);

when the server receives an appropriately formatted RPC, the user callback is invoked. The callback needs to fill in the reply structure.

void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg);

To send the reply, call EVRPC_REQUEST_DONE(rpc);

See the regression test for an example.

Macro Definition Documentation

◆ EVRPC_GENERATE

#define EVRPC_GENERATE (   rpcname,
  reqstruct,
  rplystruct 
)
Value:
int evrpc_send_request_##rpcname(struct evrpc_pool *pool, \
struct reqstruct *request, struct rplystruct *reply, \
void (*cb)(struct evrpc_status *, \
struct reqstruct *, struct rplystruct *, void *cbarg), \
void *cbarg) { \
return evrpc_send_request_generic(pool, request, reply, \
(void (*)(struct evrpc_status *, void *, void *, void *))cb, \
cbarg, \
#rpcname, \
(void (*)(struct evbuffer *, void *))reqstruct##_marshal, \
(void (*)(void *))rplystruct##_clear, \
(int (*)(void *, struct evbuffer *))rplystruct##_unmarshal); \
}

Generates the code for receiving and sending an RPC message.

EVRPC_GENERATE is used to create the code corresponding to sending and receiving a particular RPC message

Parameters
rpcnamethe name of the RPC
reqstructthe name of the RPC request structure
rplystructthe name of the RPC reply structure
See also
EVRPC_HEADER()

◆ EVRPC_HEADER

#define EVRPC_HEADER (   rpcname,
  reqstruct,
  rplystruct 
)
Value:
EVRPC_STRUCT(rpcname) { \
struct evrpc_hook_meta *hook_meta; \
struct reqstruct* request; \
struct rplystruct* reply; \
struct evrpc* rpc; \
struct evhttp_request* http_req; \
struct evbuffer* rpc_data; \
}; \
EVENT2_EXPORT_SYMBOL \
int evrpc_send_request_##rpcname(struct evrpc_pool *, \
struct reqstruct *, struct rplystruct *, \
void (*)(struct evrpc_status *, \
struct reqstruct *, struct rplystruct *, void *cbarg), \
void *);

Creates the definitions and prototypes for an RPC.

You need to use EVRPC_HEADER to create structures and function prototypes needed by the server and client implementation. The structures have to be defined in an .rpc file and converted to source code via event_rpcgen.py

Parameters
rpcnamethe name of the RPC
reqstructthe name of the RPC request structure
rplystructthe name of the RPC reply structure
See also
EVRPC_GENERATE()

◆ EVRPC_MAKE_CTX

#define EVRPC_MAKE_CTX (   rpcname,
  reqstruct,
  rplystruct,
  pool,
  request,
  reply,
  cb,
  cbarg 
)
Value:
evrpc_make_request_ctx(pool, request, reply, \
#rpcname, \
(void (*)(struct evbuffer *, void *))reqstruct##_marshal, \
(void (*)(void *))rplystruct##_clear, \
(int (*)(void *, struct evbuffer *))rplystruct##_unmarshal, \
(void (*)(struct evrpc_status *, void *, void *, void *))cb, \
cbarg)

Creates a context structure that contains rpc specific information.

EVRPC_MAKE_CTX is used to populate a RPC specific context that contains information about marshaling the RPC data types.

Parameters
rpcnamethe name of the RPC
reqstructthe name of the RPC request structure
rplystructthe name of the RPC reply structure
poolthe evrpc_pool over which to make the request
requesta pointer to the RPC request structure object
replya pointer to the RPC reply structure object
cbthe callback function to call when the RPC has completed
cbargthe argument to supply to the callback

◆ EVRPC_MAKE_REQUEST

#define EVRPC_MAKE_REQUEST (   name,
  pool,
  request,
  reply,
  cb,
  cbarg 
)    evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg))

launches an RPC and sends it to the server

EVRPC_MAKE_REQUEST() is used by the client to send an RPC to the server.

Parameters
namethe name of the RPC
poolthe evrpc_pool that contains the connection objects over which the request should be sent.
requesta pointer to the RPC request structure - it contains the data to be sent to the server.
replya pointer to the RPC reply structure. It is going to be filled if the request was answered successfully
cbthe callback to invoke when the RPC request has been answered
cbargan additional argument to be passed to the client
Returns
0 on success, -1 on failure

◆ EVRPC_REGISTER

#define EVRPC_REGISTER (   base,
  name,
  request,
  reply,
  callback,
  cbarg 
)
Value:
evrpc_register_generic(base, #name, \
(void (*)(struct evrpc_req_generic *, void *))callback, cbarg, \
(void *(*)(void *))request##_new_with_arg, NULL, \
(void (*)(void *))request##_free, \
(int (*)(void *, struct evbuffer *))request##_unmarshal, \
(void *(*)(void *))reply##_new_with_arg, NULL, \
(void (*)(void *))reply##_free, \
(int (*)(void *))reply##_complete, \
(void (*)(struct evbuffer *, void *))reply##_marshal)

register RPCs with the HTTP Server

registers a new RPC with the HTTP server, each RPC needs to have a unique name under which it can be identified.

Parameters
basethe evrpc_base structure in which the RPC should be registered.
namethe name of the RPC
requestthe name of the RPC request structure
replythe name of the RPC reply structure
callbackthe callback that should be invoked when the RPC is received. The callback has the following prototype void (callback)(EVRPC_STRUCT(Message) rpc, void *arg)
cbargan additional parameter that can be passed to the callback. The parameter can be used to carry around state.

◆ EVRPC_REQUEST_DONE

#define EVRPC_REQUEST_DONE (   rpc_req)
Value:
do { \
struct evrpc_req_generic *req_ = (struct evrpc_req_generic *)(rpc_req); \
evrpc_request_done(req_); \
} while (0)

Creates the reply to an RPC request.

EVRPC_REQUEST_DONE is used to answer a request; the reply is expected to have been filled in. The request and reply pointers become invalid after this call has finished.

Parameters
rpc_reqthe rpc request structure provided to the server callback

◆ EVRPC_REQUEST_HTTP

#define EVRPC_REQUEST_HTTP (   rpc_req)    (rpc_req)->http_req

Provides access to the HTTP request object underlying an RPC.

Access to the underlying http object; can be used to look at headers or for getting the remote ip address

Parameters
rpc_reqthe rpc request structure provided to the server callback
Returns
an struct evhttp_request object that can be inspected for HTTP headers or sender information.

◆ EVRPC_STRUCT

#define EVRPC_STRUCT (   rpcname)    struct evrpc_req__##rpcname

The type of a specific RPC Message.

Parameters
rpcnamethe name of the RPC message

◆ EVRPC_UNREGISTER

#define EVRPC_UNREGISTER (   base,
  name 
)    evrpc_unregister_rpc((base), #name)

Unregisters an already registered RPC.

Parameters
basethe evrpc_base object from which to unregister an RPC
namethe name of the rpc to unregister
Returns
-1 on error or 0 when successful.
See also
EVRPC_REGISTER()

◆ EVTAG_ASSIGN

#define EVTAG_ASSIGN (   msg,
  member,
  value 
)    (*(msg)->base->member##_assign)((msg), (value))

Assigns a value to the member in the message.

Parameters
msgthe message to which to assign a value
memberthe name of the member variable
valuethe value to assign

◆ EVTAG_ASSIGN_WITH_LEN

#define EVTAG_ASSIGN_WITH_LEN (   msg,
  member,
  value,
  len 
)    (*(msg)->base->member##_assign)((msg), (value), (len))

Assigns a value to the member in the message.

Parameters
msgthe message to which to assign a value
memberthe name of the member variable
valuethe value to assign
lenthe length of the value

◆ EVTAG_GET

#define EVTAG_GET (   msg,
  member,
  pvalue 
)    (*(msg)->base->member##_get)((msg), (pvalue))

Returns the value for a member.

Parameters
msgthe message from which to get the value
memberthe name of the member variable
pvaluea pointer to the variable to hold the value
Returns
0 on success, -1 otherwise.

◆ EVTAG_GET_WITH_LEN

#define EVTAG_GET_WITH_LEN (   msg,
  member,
  pvalue,
  plen 
)    (*(msg)->base->member##_get)((msg), (pvalue), (plen))

Returns the value for a member.

Parameters
msgthe message from which to get the value
memberthe name of the member variable
pvaluea pointer to the variable to hold the value
plena pointer to the length of the value
Returns
0 on success, -1 otherwise.

◆ EVTAG_HAS

#define EVTAG_HAS (   msg,
  member 
)    ((msg)->member##_set == 1)

Determines if the member has been set in the message.

Parameters
msgthe message to inspect
memberthe member variable to test for presences
Returns
1 if it's present or 0 otherwise.

◆ INPUT

#define INPUT   EVRPC_INPUT

Deprecated alias for EVRPC_INPUT.

Not available on windows, where it conflicts with platform headers.

◆ OUTPUT

#define OUTPUT   EVRPC_OUTPUT

Deprecated alias for EVRPC_OUTPUT.

Not available on windows, where it conflicts with platform headers.

Enumeration Type Documentation

◆ EVRPC_HOOK_RESULT

Return value from hook processing functions.

Enumerator
EVRPC_TERMINATE 

indicates the rpc should be terminated

EVRPC_CONTINUE 

continue processing the rpc

EVRPC_PAUSE 

pause processing request until resumed

◆ EVRPC_HOOK_TYPE

Hooks for changing the input and output of RPCs; this can be used to implement compression, authentication, encryption, ...

Enumerator
EVRPC_INPUT 

apply the function to an input hook

EVRPC_OUTPUT 

apply the function to an output hook

Function Documentation

◆ evrpc_add_hook()

EVENT2_EXPORT_SYMBOL void* evrpc_add_hook ( void *  vbase,
enum EVRPC_HOOK_TYPE  hook_type,
int(*)(void *, struct evhttp_request *, struct evbuffer *, void *)  cb,
void *  cb_arg 
)

adds a processing hook to either an rpc base or rpc pool

If a hook returns TERMINATE, the processing is aborted. On CONTINUE, the request is immediately processed after the hook returns. If the hook returns PAUSE, request processing stops until evrpc_resume_request() has been called.

The add functions return handles that can be used for removing hooks.

Parameters
vbasea pointer to either struct evrpc_base or struct evrpc_pool
hook_typeeither INPUT or OUTPUT
cbthe callback to call when the hook is activated
cb_argan additional argument for the callback
Returns
a handle to the hook so it can be removed later
See also
evrpc_remove_hook()

◆ evrpc_free()

EVENT2_EXPORT_SYMBOL void evrpc_free ( struct evrpc_base *  base)

Frees the evrpc base.

For now, you are responsible for making sure that no rpcs are ongoing.

Parameters
basethe evrpc_base object to be freed
See also
evrpc_init

◆ evrpc_hook_add_meta()

EVENT2_EXPORT_SYMBOL int evrpc_hook_add_meta ( void *  ctx,
const char *  key,
const void *  data,
size_t  data_size 
)

adds meta data to request

evrpc_hook_add_meta() allows hooks to add meta data to a request. for a client request, the meta data can be inserted by an outgoing request hook and retrieved by the incoming request hook.

Parameters
ctxthe context provided to the hook call
keya NUL-terminated c-string
datathe data to be associated with the key
data_sizethe size of the data
Returns
0 on success or -1 on failure (in case of memory allocation failures)

◆ evrpc_hook_find_meta()

EVENT2_EXPORT_SYMBOL int evrpc_hook_find_meta ( void *  ctx,
const char *  key,
void **  data,
size_t *  data_size 
)

retrieves meta data previously associated

evrpc_hook_find_meta() can be used to retrieve meta data associated to a request by a previous hook.

Parameters
ctxthe context provided to the hook call
keya NUL-terminated c-string
datapointer to a data pointer that will contain the retrieved data
data_sizepointer to the size of the data
Returns
0 on success or -1 on failure

◆ evrpc_hook_get_connection()

EVENT2_EXPORT_SYMBOL struct evhttp_connection* evrpc_hook_get_connection ( void *  ctx)

returns the connection object associated with the request

Parameters
ctxthe context provided to the hook call
Returns
a pointer to the evhttp_connection object or NULL if an error occurred

◆ evrpc_init()

EVENT2_EXPORT_SYMBOL struct evrpc_base* evrpc_init ( struct evhttp *  server)

Creates a new rpc base from which RPC requests can be received.

Parameters
servera pointer to an existing HTTP server
Returns
a newly allocated evrpc_base struct or NULL if an error occurred
See also
evrpc_free()

◆ evrpc_make_request()

EVENT2_EXPORT_SYMBOL int evrpc_make_request ( struct evrpc_request_wrapper *  ctx)

Makes an RPC request based on the provided context.

This is a low-level function and should not be used directly unless a custom context object is provided. Use EVRPC_MAKE_REQUEST() instead.

Parameters
ctxa context from EVRPC_MAKE_CTX()
Returns
0 on success, -1 otherwise.
See also
EVRPC_MAKE_REQUEST(), EVRPC_MAKE_CTX()

◆ evrpc_pool_add_connection()

EVENT2_EXPORT_SYMBOL void evrpc_pool_add_connection ( struct evrpc_pool *  pool,
struct evhttp_connection *  evcon 
)

Adds a connection over which rpc can be dispatched to the pool.

The connection object must have been newly created.

Parameters
poolthe pool to which to add the connection
evconthe connection to add to the pool.

◆ evrpc_pool_free()

EVENT2_EXPORT_SYMBOL void evrpc_pool_free ( struct evrpc_pool *  pool)

frees an rpc connection pool

Parameters
poola pointer to an evrpc_pool allocated via evrpc_pool_new()
See also
evrpc_pool_new()

◆ evrpc_pool_new()

EVENT2_EXPORT_SYMBOL struct evrpc_pool* evrpc_pool_new ( struct event_base base)

creates an rpc connection pool

a pool has a number of connections associated with it. rpc requests are always made via a pool.

Parameters
basea pointer to an struct event_based object; can be left NULL in singled-threaded applications
Returns
a newly allocated struct evrpc_pool object or NULL if an error occurred
See also
evrpc_pool_free()

◆ evrpc_pool_remove_connection()

EVENT2_EXPORT_SYMBOL void evrpc_pool_remove_connection ( struct evrpc_pool *  pool,
struct evhttp_connection *  evcon 
)

Removes a connection from the pool.

The connection object must have been newly created.

Parameters
poolthe pool from which to remove the connection
evconthe connection to remove from the pool.

◆ evrpc_pool_set_timeout()

EVENT2_EXPORT_SYMBOL void evrpc_pool_set_timeout ( struct evrpc_pool *  pool,
int  timeout_in_secs 
)

Sets the timeout in secs after which a request has to complete.

The RPC is completely aborted if it does not complete by then. Setting the timeout to 0 means that it never timeouts and can be used to implement callback type RPCs.

Any connection already in the pool will be updated with the new timeout. Connections added to the pool after set_timeout has be called receive the pool timeout only if no timeout has been set for the connection itself.

Parameters
poola pointer to a struct evrpc_pool object
timeout_in_secsthe number of seconds after which a request should timeout and a failure be returned to the callback.

◆ evrpc_register_generic()

EVENT2_EXPORT_SYMBOL int evrpc_register_generic ( struct evrpc_base *  base,
const char *  name,
void(*)(struct evrpc_req_generic *, void *)  callback,
void *  cbarg,
void *(*)(void *)  req_new,
void *  req_new_arg,
void(*)(void *)  req_free,
int(*)(void *, struct evbuffer *)  req_unmarshal,
void *(*)(void *)  rpl_new,
void *  rpl_new_arg,
void(*)(void *)  rpl_free,
int(*)(void *)  rpl_complete,
void(*)(struct evbuffer *, void *)  rpl_marshal 
)

Function for registering a generic RPC with the RPC base.

Do not call this function directly, use EVRPC_REGISTER() instead.

See also
EVRPC_REGISTER()

◆ evrpc_register_rpc()

EVENT2_EXPORT_SYMBOL int evrpc_register_rpc ( struct evrpc_base *  ,
struct evrpc *  ,
void(*)(struct evrpc_req_generic *, void *)  ,
void *   
)

Low level function for registering an RPC with a server.

Use EVRPC_REGISTER() instead.

See also
EVRPC_REGISTER()

◆ evrpc_remove_hook()

EVENT2_EXPORT_SYMBOL int evrpc_remove_hook ( void *  vbase,
enum EVRPC_HOOK_TYPE  hook_type,
void *  handle 
)

removes a previously added hook

Parameters
vbasea pointer to either struct evrpc_base or struct evrpc_pool
hook_typeeither INPUT or OUTPUT
handlea handle returned by evrpc_add_hook()
Returns
1 on success or 0 on failure
See also
evrpc_add_hook()

◆ evrpc_resume_request()

EVENT2_EXPORT_SYMBOL int evrpc_resume_request ( void *  vbase,
void *  ctx,
enum EVRPC_HOOK_RESULT  res 
)

resume a paused request

Parameters
vbasea pointer to either struct evrpc_base or struct evrpc_pool
ctxthe context pointer provided to the original hook call

◆ evrpc_send_request_generic()

EVENT2_EXPORT_SYMBOL int evrpc_send_request_generic ( struct evrpc_pool *  pool,
void *  request,
void *  reply,
void(*)(struct evrpc_status *, void *, void *, void *)  cb,
void *  cb_arg,
const char *  rpcname,
void(*)(struct evbuffer *, void *)  req_marshal,
void(*)(void *)  rpl_clear,
int(*)(void *, struct evbuffer *)  rpl_unmarshal 
)

Function for sending a generic RPC request.

Do not call this function directly, use EVRPC_MAKE_REQUEST() instead.

See also
EVRPC_MAKE_REQUEST()
evrpc_make_request_ctx
EVENT2_EXPORT_SYMBOL struct evrpc_request_wrapper * evrpc_make_request_ctx(struct evrpc_pool *pool, void *request, void *reply, const char *rpcname, void(*req_marshal)(struct evbuffer *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct evbuffer *), void(*cb)(struct evrpc_status *, void *, void *, void *), void *cbarg)
use EVRPC_GENERATE instead
evrpc_register_generic
EVENT2_EXPORT_SYMBOL int evrpc_register_generic(struct evrpc_base *base, const char *name, void(*callback)(struct evrpc_req_generic *, void *), void *cbarg, void *(*req_new)(void *), void *req_new_arg, void(*req_free)(void *), int(*req_unmarshal)(void *, struct evbuffer *), void *(*rpl_new)(void *), void *rpl_new_arg, void(*rpl_free)(void *), int(*rpl_complete)(void *), void(*rpl_marshal)(struct evbuffer *, void *))
Function for registering a generic RPC with the RPC base.
evbuffer
An evbuffer is an opaque data type for efficiently buffering data to be sent or received on the netwo...
Definition: buffer.h:97
evrpc_send_request_generic
EVENT2_EXPORT_SYMBOL int evrpc_send_request_generic(struct evrpc_pool *pool, void *request, void *reply, void(*cb)(struct evrpc_status *, void *, void *, void *), void *cb_arg, const char *rpcname, void(*req_marshal)(struct evbuffer *, void *), void(*rpl_clear)(void *), int(*rpl_unmarshal)(void *, struct evbuffer *))
Function for sending a generic RPC request.
EVRPC_STRUCT
#define EVRPC_STRUCT(rpcname)
The type of a specific RPC Message.
Definition: rpc.h:159