|
||||
File indexing completed on 2025-01-18 09:57:12
0001 /* 0002 * Copyright (c) 2006-2007 Niels Provos <provos@citi.umich.edu> 0003 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 0004 * 0005 * Redistribution and use in source and binary forms, with or without 0006 * modification, are permitted provided that the following conditions 0007 * are met: 0008 * 1. Redistributions of source code must retain the above copyright 0009 * notice, this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright 0011 * notice, this list of conditions and the following disclaimer in the 0012 * documentation and/or other materials provided with the distribution. 0013 * 3. The name of the author may not be used to endorse or promote products 0014 * derived from this software without specific prior written permission. 0015 * 0016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 #ifndef EVENT2_RPC_H_INCLUDED_ 0028 #define EVENT2_RPC_H_INCLUDED_ 0029 0030 /* For int types. */ 0031 #include <event2/util.h> 0032 #include <event2/visibility.h> 0033 0034 #ifdef __cplusplus 0035 extern "C" { 0036 #endif 0037 0038 /** @file rpc.h 0039 * 0040 * This header files provides basic support for an RPC server and client. 0041 * 0042 * To support RPCs in a server, every supported RPC command needs to be 0043 * defined and registered. 0044 * 0045 * EVRPC_HEADER(SendCommand, Request, Reply); 0046 * 0047 * SendCommand is the name of the RPC command. 0048 * Request is the name of a structure generated by event_rpcgen.py. 0049 * It contains all parameters relating to the SendCommand RPC. The 0050 * server needs to fill in the Reply structure. 0051 * Reply is the name of a structure generated by event_rpcgen.py. It 0052 * contains the answer to the RPC. 0053 * 0054 * To register an RPC with an HTTP server, you need to first create an RPC 0055 * base with: 0056 * 0057 * struct evrpc_base *base = evrpc_init(http); 0058 * 0059 * A specific RPC can then be registered with 0060 * 0061 * EVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg); 0062 * 0063 * when the server receives an appropriately formatted RPC, the user callback 0064 * is invoked. The callback needs to fill in the reply structure. 0065 * 0066 * void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg); 0067 * 0068 * To send the reply, call EVRPC_REQUEST_DONE(rpc); 0069 * 0070 * See the regression test for an example. 0071 */ 0072 0073 /** 0074 Determines if the member has been set in the message 0075 0076 @param msg the message to inspect 0077 @param member the member variable to test for presences 0078 @return 1 if it's present or 0 otherwise. 0079 */ 0080 #define EVTAG_HAS(msg, member) \ 0081 ((msg)->member##_set == 1) 0082 0083 #ifndef EVENT2_RPC_COMPAT_H_INCLUDED_ 0084 0085 /** 0086 Assigns a value to the member in the message. 0087 0088 @param msg the message to which to assign a value 0089 @param member the name of the member variable 0090 @param value the value to assign 0091 */ 0092 #define EVTAG_ASSIGN(msg, member, value) \ 0093 (*(msg)->base->member##_assign)((msg), (value)) 0094 /** 0095 Assigns a value to the member in the message. 0096 0097 @param msg the message to which to assign a value 0098 @param member the name of the member variable 0099 @param value the value to assign 0100 @param len the length of the value 0101 */ 0102 #define EVTAG_ASSIGN_WITH_LEN(msg, member, value, len) \ 0103 (*(msg)->base->member##_assign)((msg), (value), (len)) 0104 /** 0105 Returns the value for a member. 0106 0107 @param msg the message from which to get the value 0108 @param member the name of the member variable 0109 @param pvalue a pointer to the variable to hold the value 0110 @return 0 on success, -1 otherwise. 0111 */ 0112 #define EVTAG_GET(msg, member, pvalue) \ 0113 (*(msg)->base->member##_get)((msg), (pvalue)) 0114 /** 0115 Returns the value for a member. 0116 0117 @param msg the message from which to get the value 0118 @param member the name of the member variable 0119 @param pvalue a pointer to the variable to hold the value 0120 @param plen a pointer to the length of the value 0121 @return 0 on success, -1 otherwise. 0122 */ 0123 #define EVTAG_GET_WITH_LEN(msg, member, pvalue, plen) \ 0124 (*(msg)->base->member##_get)((msg), (pvalue), (plen)) 0125 0126 #endif /* EVENT2_RPC_COMPAT_H_INCLUDED_ */ 0127 0128 /** 0129 Adds a value to an array. 0130 */ 0131 #define EVTAG_ARRAY_ADD_VALUE(msg, member, value) \ 0132 (*(msg)->base->member##_add)((msg), (value)) 0133 /** 0134 Allocates a new entry in the array and returns it. 0135 */ 0136 #define EVTAG_ARRAY_ADD(msg, member) \ 0137 (*(msg)->base->member##_add)(msg) 0138 /** 0139 Gets a variable at the specified offset from the array. 0140 */ 0141 #define EVTAG_ARRAY_GET(msg, member, offset, pvalue) \ 0142 (*(msg)->base->member##_get)((msg), (offset), (pvalue)) 0143 /** 0144 Returns the number of entries in the array. 0145 */ 0146 #define EVTAG_ARRAY_LEN(msg, member) ((msg)->member##_length) 0147 0148 0149 struct evbuffer; 0150 struct event_base; 0151 struct evrpc_req_generic; 0152 struct evrpc_request_wrapper; 0153 struct evrpc; 0154 0155 /** The type of a specific RPC Message 0156 * 0157 * @param rpcname the name of the RPC message 0158 */ 0159 #define EVRPC_STRUCT(rpcname) struct evrpc_req__##rpcname 0160 0161 struct evhttp_request; 0162 struct evrpc_status; 0163 struct evrpc_hook_meta; 0164 0165 /** Creates the definitions and prototypes for an RPC 0166 * 0167 * You need to use EVRPC_HEADER to create structures and function prototypes 0168 * needed by the server and client implementation. The structures have to be 0169 * defined in an .rpc file and converted to source code via event_rpcgen.py 0170 * 0171 * @param rpcname the name of the RPC 0172 * @param reqstruct the name of the RPC request structure 0173 * @param replystruct the name of the RPC reply structure 0174 * @see EVRPC_GENERATE() 0175 */ 0176 #define EVRPC_HEADER(rpcname, reqstruct, rplystruct) \ 0177 EVRPC_STRUCT(rpcname) { \ 0178 struct evrpc_hook_meta *hook_meta; \ 0179 struct reqstruct* request; \ 0180 struct rplystruct* reply; \ 0181 struct evrpc* rpc; \ 0182 struct evhttp_request* http_req; \ 0183 struct evbuffer* rpc_data; \ 0184 }; \ 0185 EVENT2_EXPORT_SYMBOL \ 0186 int evrpc_send_request_##rpcname(struct evrpc_pool *, \ 0187 struct reqstruct *, struct rplystruct *, \ 0188 void (*)(struct evrpc_status *, \ 0189 struct reqstruct *, struct rplystruct *, void *cbarg), \ 0190 void *); 0191 0192 struct evrpc_pool; 0193 0194 /** use EVRPC_GENERATE instead */ 0195 EVENT2_EXPORT_SYMBOL 0196 struct evrpc_request_wrapper *evrpc_make_request_ctx( 0197 struct evrpc_pool *pool, void *request, void *reply, 0198 const char *rpcname, 0199 void (*req_marshal)(struct evbuffer*, void *), 0200 void (*rpl_clear)(void *), 0201 int (*rpl_unmarshal)(void *, struct evbuffer *), 0202 void (*cb)(struct evrpc_status *, void *, void *, void *), 0203 void *cbarg); 0204 0205 /** Creates a context structure that contains rpc specific information. 0206 * 0207 * EVRPC_MAKE_CTX is used to populate a RPC specific context that 0208 * contains information about marshaling the RPC data types. 0209 * 0210 * @param rpcname the name of the RPC 0211 * @param reqstruct the name of the RPC request structure 0212 * @param replystruct the name of the RPC reply structure 0213 * @param pool the evrpc_pool over which to make the request 0214 * @param request a pointer to the RPC request structure object 0215 * @param reply a pointer to the RPC reply structure object 0216 * @param cb the callback function to call when the RPC has completed 0217 * @param cbarg the argument to supply to the callback 0218 */ 0219 #define EVRPC_MAKE_CTX(rpcname, reqstruct, rplystruct, \ 0220 pool, request, reply, cb, cbarg) \ 0221 evrpc_make_request_ctx(pool, request, reply, \ 0222 #rpcname, \ 0223 (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \ 0224 (void (*)(void *))rplystruct##_clear, \ 0225 (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal, \ 0226 (void (*)(struct evrpc_status *, void *, void *, void *))cb, \ 0227 cbarg) 0228 0229 /** Generates the code for receiving and sending an RPC message 0230 * 0231 * EVRPC_GENERATE is used to create the code corresponding to sending 0232 * and receiving a particular RPC message 0233 * 0234 * @param rpcname the name of the RPC 0235 * @param reqstruct the name of the RPC request structure 0236 * @param replystruct the name of the RPC reply structure 0237 * @see EVRPC_HEADER() 0238 */ 0239 #define EVRPC_GENERATE(rpcname, reqstruct, rplystruct) \ 0240 int evrpc_send_request_##rpcname(struct evrpc_pool *pool, \ 0241 struct reqstruct *request, struct rplystruct *reply, \ 0242 void (*cb)(struct evrpc_status *, \ 0243 struct reqstruct *, struct rplystruct *, void *cbarg), \ 0244 void *cbarg) { \ 0245 return evrpc_send_request_generic(pool, request, reply, \ 0246 (void (*)(struct evrpc_status *, void *, void *, void *))cb, \ 0247 cbarg, \ 0248 #rpcname, \ 0249 (void (*)(struct evbuffer *, void *))reqstruct##_marshal, \ 0250 (void (*)(void *))rplystruct##_clear, \ 0251 (int (*)(void *, struct evbuffer *))rplystruct##_unmarshal); \ 0252 } 0253 0254 /** Provides access to the HTTP request object underlying an RPC 0255 * 0256 * Access to the underlying http object; can be used to look at headers or 0257 * for getting the remote ip address 0258 * 0259 * @param rpc_req the rpc request structure provided to the server callback 0260 * @return an struct evhttp_request object that can be inspected for 0261 * HTTP headers or sender information. 0262 */ 0263 #define EVRPC_REQUEST_HTTP(rpc_req) (rpc_req)->http_req 0264 0265 /** completes the server response to an rpc request */ 0266 EVENT2_EXPORT_SYMBOL 0267 void evrpc_request_done(struct evrpc_req_generic *req); 0268 0269 /** accessors for request and reply */ 0270 EVENT2_EXPORT_SYMBOL 0271 void *evrpc_get_request(struct evrpc_req_generic *req); 0272 EVENT2_EXPORT_SYMBOL 0273 void *evrpc_get_reply(struct evrpc_req_generic *req); 0274 0275 /** Creates the reply to an RPC request 0276 * 0277 * EVRPC_REQUEST_DONE is used to answer a request; the reply is expected 0278 * to have been filled in. The request and reply pointers become invalid 0279 * after this call has finished. 0280 * 0281 * @param rpc_req the rpc request structure provided to the server callback 0282 */ 0283 #define EVRPC_REQUEST_DONE(rpc_req) do { \ 0284 struct evrpc_req_generic *req_ = (struct evrpc_req_generic *)(rpc_req); \ 0285 evrpc_request_done(req_); \ 0286 } while (0) 0287 0288 0289 struct evrpc_base; 0290 struct evhttp; 0291 0292 /* functions to start up the rpc system */ 0293 0294 /** Creates a new rpc base from which RPC requests can be received 0295 * 0296 * @param server a pointer to an existing HTTP server 0297 * @return a newly allocated evrpc_base struct or NULL if an error occurred 0298 * @see evrpc_free() 0299 */ 0300 EVENT2_EXPORT_SYMBOL 0301 struct evrpc_base *evrpc_init(struct evhttp *server); 0302 0303 /** 0304 * Frees the evrpc base 0305 * 0306 * For now, you are responsible for making sure that no rpcs are ongoing. 0307 * 0308 * @param base the evrpc_base object to be freed 0309 * @see evrpc_init 0310 */ 0311 EVENT2_EXPORT_SYMBOL 0312 void evrpc_free(struct evrpc_base *base); 0313 0314 /** register RPCs with the HTTP Server 0315 * 0316 * registers a new RPC with the HTTP server, each RPC needs to have 0317 * a unique name under which it can be identified. 0318 * 0319 * @param base the evrpc_base structure in which the RPC should be 0320 * registered. 0321 * @param name the name of the RPC 0322 * @param request the name of the RPC request structure 0323 * @param reply the name of the RPC reply structure 0324 * @param callback the callback that should be invoked when the RPC 0325 * is received. The callback has the following prototype 0326 * void (*callback)(EVRPC_STRUCT(Message)* rpc, void *arg) 0327 * @param cbarg an additional parameter that can be passed to the callback. 0328 * The parameter can be used to carry around state. 0329 */ 0330 #define EVRPC_REGISTER(base, name, request, reply, callback, cbarg) \ 0331 evrpc_register_generic(base, #name, \ 0332 (void (*)(struct evrpc_req_generic *, void *))callback, cbarg, \ 0333 (void *(*)(void *))request##_new_with_arg, NULL, \ 0334 (void (*)(void *))request##_free, \ 0335 (int (*)(void *, struct evbuffer *))request##_unmarshal, \ 0336 (void *(*)(void *))reply##_new_with_arg, NULL, \ 0337 (void (*)(void *))reply##_free, \ 0338 (int (*)(void *))reply##_complete, \ 0339 (void (*)(struct evbuffer *, void *))reply##_marshal) 0340 0341 /** 0342 Low level function for registering an RPC with a server. 0343 0344 Use EVRPC_REGISTER() instead. 0345 0346 @see EVRPC_REGISTER() 0347 */ 0348 EVENT2_EXPORT_SYMBOL 0349 int evrpc_register_rpc(struct evrpc_base *, struct evrpc *, 0350 void (*)(struct evrpc_req_generic*, void *), void *); 0351 0352 /** 0353 * Unregisters an already registered RPC 0354 * 0355 * @param base the evrpc_base object from which to unregister an RPC 0356 * @param name the name of the rpc to unregister 0357 * @return -1 on error or 0 when successful. 0358 * @see EVRPC_REGISTER() 0359 */ 0360 #define EVRPC_UNREGISTER(base, name) evrpc_unregister_rpc((base), #name) 0361 0362 EVENT2_EXPORT_SYMBOL 0363 int evrpc_unregister_rpc(struct evrpc_base *base, const char *name); 0364 0365 /* 0366 * Client-side RPC support 0367 */ 0368 0369 struct evhttp_connection; 0370 struct evrpc_status; 0371 0372 /** launches an RPC and sends it to the server 0373 * 0374 * EVRPC_MAKE_REQUEST() is used by the client to send an RPC to the server. 0375 * 0376 * @param name the name of the RPC 0377 * @param pool the evrpc_pool that contains the connection objects over which 0378 * the request should be sent. 0379 * @param request a pointer to the RPC request structure - it contains the 0380 * data to be sent to the server. 0381 * @param reply a pointer to the RPC reply structure. It is going to be filled 0382 * if the request was answered successfully 0383 * @param cb the callback to invoke when the RPC request has been answered 0384 * @param cbarg an additional argument to be passed to the client 0385 * @return 0 on success, -1 on failure 0386 */ 0387 #define EVRPC_MAKE_REQUEST(name, pool, request, reply, cb, cbarg) \ 0388 evrpc_send_request_##name((pool), (request), (reply), (cb), (cbarg)) 0389 0390 /** 0391 Makes an RPC request based on the provided context. 0392 0393 This is a low-level function and should not be used directly 0394 unless a custom context object is provided. Use EVRPC_MAKE_REQUEST() 0395 instead. 0396 0397 @param ctx a context from EVRPC_MAKE_CTX() 0398 @returns 0 on success, -1 otherwise. 0399 @see EVRPC_MAKE_REQUEST(), EVRPC_MAKE_CTX() 0400 */ 0401 EVENT2_EXPORT_SYMBOL 0402 int evrpc_make_request(struct evrpc_request_wrapper *ctx); 0403 0404 /** creates an rpc connection pool 0405 * 0406 * a pool has a number of connections associated with it. 0407 * rpc requests are always made via a pool. 0408 * 0409 * @param base a pointer to an struct event_based object; can be left NULL 0410 * in singled-threaded applications 0411 * @return a newly allocated struct evrpc_pool object or NULL if an error 0412 * occurred 0413 * @see evrpc_pool_free() 0414 */ 0415 EVENT2_EXPORT_SYMBOL 0416 struct evrpc_pool *evrpc_pool_new(struct event_base *base); 0417 /** frees an rpc connection pool 0418 * 0419 * @param pool a pointer to an evrpc_pool allocated via evrpc_pool_new() 0420 * @see evrpc_pool_new() 0421 */ 0422 EVENT2_EXPORT_SYMBOL 0423 void evrpc_pool_free(struct evrpc_pool *pool); 0424 0425 /** 0426 * Adds a connection over which rpc can be dispatched to the pool. 0427 * 0428 * The connection object must have been newly created. 0429 * 0430 * @param pool the pool to which to add the connection 0431 * @param evcon the connection to add to the pool. 0432 */ 0433 EVENT2_EXPORT_SYMBOL 0434 void evrpc_pool_add_connection(struct evrpc_pool *pool, 0435 struct evhttp_connection *evcon); 0436 0437 /** 0438 * Removes a connection from the pool. 0439 * 0440 * The connection object must have been newly created. 0441 * 0442 * @param pool the pool from which to remove the connection 0443 * @param evcon the connection to remove from the pool. 0444 */ 0445 EVENT2_EXPORT_SYMBOL 0446 void evrpc_pool_remove_connection(struct evrpc_pool *pool, 0447 struct evhttp_connection *evcon); 0448 0449 /** 0450 * Sets the timeout in secs after which a request has to complete. The 0451 * RPC is completely aborted if it does not complete by then. Setting 0452 * the timeout to 0 means that it never timeouts and can be used to 0453 * implement callback type RPCs. 0454 * 0455 * Any connection already in the pool will be updated with the new 0456 * timeout. Connections added to the pool after set_timeout has be 0457 * called receive the pool timeout only if no timeout has been set 0458 * for the connection itself. 0459 * 0460 * @param pool a pointer to a struct evrpc_pool object 0461 * @param timeout_in_secs the number of seconds after which a request should 0462 * timeout and a failure be returned to the callback. 0463 */ 0464 EVENT2_EXPORT_SYMBOL 0465 void evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs); 0466 0467 /** 0468 * Hooks for changing the input and output of RPCs; this can be used to 0469 * implement compression, authentication, encryption, ... 0470 */ 0471 0472 enum EVRPC_HOOK_TYPE { 0473 EVRPC_INPUT, /**< apply the function to an input hook */ 0474 EVRPC_OUTPUT /**< apply the function to an output hook */ 0475 }; 0476 0477 #ifndef _WIN32 0478 /** Deprecated alias for EVRPC_INPUT. Not available on windows, where it 0479 * conflicts with platform headers. */ 0480 #define INPUT EVRPC_INPUT 0481 /** Deprecated alias for EVRPC_OUTPUT. Not available on windows, where it 0482 * conflicts with platform headers. */ 0483 #define OUTPUT EVRPC_OUTPUT 0484 #endif 0485 0486 /** 0487 * Return value from hook processing functions 0488 */ 0489 0490 enum EVRPC_HOOK_RESULT { 0491 EVRPC_TERMINATE = -1, /**< indicates the rpc should be terminated */ 0492 EVRPC_CONTINUE = 0, /**< continue processing the rpc */ 0493 EVRPC_PAUSE = 1 /**< pause processing request until resumed */ 0494 }; 0495 0496 /** adds a processing hook to either an rpc base or rpc pool 0497 * 0498 * If a hook returns TERMINATE, the processing is aborted. On CONTINUE, 0499 * the request is immediately processed after the hook returns. If the 0500 * hook returns PAUSE, request processing stops until evrpc_resume_request() 0501 * has been called. 0502 * 0503 * The add functions return handles that can be used for removing hooks. 0504 * 0505 * @param vbase a pointer to either struct evrpc_base or struct evrpc_pool 0506 * @param hook_type either INPUT or OUTPUT 0507 * @param cb the callback to call when the hook is activated 0508 * @param cb_arg an additional argument for the callback 0509 * @return a handle to the hook so it can be removed later 0510 * @see evrpc_remove_hook() 0511 */ 0512 EVENT2_EXPORT_SYMBOL 0513 void *evrpc_add_hook(void *vbase, 0514 enum EVRPC_HOOK_TYPE hook_type, 0515 int (*cb)(void *, struct evhttp_request *, struct evbuffer *, void *), 0516 void *cb_arg); 0517 0518 /** removes a previously added hook 0519 * 0520 * @param vbase a pointer to either struct evrpc_base or struct evrpc_pool 0521 * @param hook_type either INPUT or OUTPUT 0522 * @param handle a handle returned by evrpc_add_hook() 0523 * @return 1 on success or 0 on failure 0524 * @see evrpc_add_hook() 0525 */ 0526 EVENT2_EXPORT_SYMBOL 0527 int evrpc_remove_hook(void *vbase, 0528 enum EVRPC_HOOK_TYPE hook_type, 0529 void *handle); 0530 0531 /** resume a paused request 0532 * 0533 * @param vbase a pointer to either struct evrpc_base or struct evrpc_pool 0534 * @param ctx the context pointer provided to the original hook call 0535 */ 0536 EVENT2_EXPORT_SYMBOL 0537 int evrpc_resume_request(void *vbase, void *ctx, enum EVRPC_HOOK_RESULT res); 0538 0539 /** adds meta data to request 0540 * 0541 * evrpc_hook_add_meta() allows hooks to add meta data to a request. for 0542 * a client request, the meta data can be inserted by an outgoing request hook 0543 * and retrieved by the incoming request hook. 0544 * 0545 * @param ctx the context provided to the hook call 0546 * @param key a NUL-terminated c-string 0547 * @param data the data to be associated with the key 0548 * @param data_size the size of the data 0549 */ 0550 EVENT2_EXPORT_SYMBOL 0551 void evrpc_hook_add_meta(void *ctx, const char *key, 0552 const void *data, size_t data_size); 0553 0554 /** retrieves meta data previously associated 0555 * 0556 * evrpc_hook_find_meta() can be used to retrieve meta data associated to a 0557 * request by a previous hook. 0558 * @param ctx the context provided to the hook call 0559 * @param key a NUL-terminated c-string 0560 * @param data pointer to a data pointer that will contain the retrieved data 0561 * @param data_size pointer to the size of the data 0562 * @return 0 on success or -1 on failure 0563 */ 0564 EVENT2_EXPORT_SYMBOL 0565 int evrpc_hook_find_meta(void *ctx, const char *key, 0566 void **data, size_t *data_size); 0567 0568 /** 0569 * returns the connection object associated with the request 0570 * 0571 * @param ctx the context provided to the hook call 0572 * @return a pointer to the evhttp_connection object or NULL if an error 0573 * occurred 0574 */ 0575 EVENT2_EXPORT_SYMBOL 0576 struct evhttp_connection *evrpc_hook_get_connection(void *ctx); 0577 0578 /** 0579 Function for sending a generic RPC request. 0580 0581 Do not call this function directly, use EVRPC_MAKE_REQUEST() instead. 0582 0583 @see EVRPC_MAKE_REQUEST() 0584 */ 0585 EVENT2_EXPORT_SYMBOL 0586 int evrpc_send_request_generic(struct evrpc_pool *pool, 0587 void *request, void *reply, 0588 void (*cb)(struct evrpc_status *, void *, void *, void *), 0589 void *cb_arg, 0590 const char *rpcname, 0591 void (*req_marshal)(struct evbuffer *, void *), 0592 void (*rpl_clear)(void *), 0593 int (*rpl_unmarshal)(void *, struct evbuffer *)); 0594 0595 /** 0596 Function for registering a generic RPC with the RPC base. 0597 0598 Do not call this function directly, use EVRPC_REGISTER() instead. 0599 0600 @see EVRPC_REGISTER() 0601 */ 0602 EVENT2_EXPORT_SYMBOL 0603 int evrpc_register_generic(struct evrpc_base *base, const char *name, 0604 void (*callback)(struct evrpc_req_generic *, void *), void *cbarg, 0605 void *(*req_new)(void *), void *req_new_arg, void (*req_free)(void *), 0606 int (*req_unmarshal)(void *, struct evbuffer *), 0607 void *(*rpl_new)(void *), void *rpl_new_arg, void (*rpl_free)(void *), 0608 int (*rpl_complete)(void *), 0609 void (*rpl_marshal)(struct evbuffer *, void *)); 0610 0611 /** accessors for obscure and undocumented functionality */ 0612 EVENT2_EXPORT_SYMBOL 0613 struct evrpc_pool* evrpc_request_get_pool(struct evrpc_request_wrapper *ctx); 0614 EVENT2_EXPORT_SYMBOL 0615 void evrpc_request_set_pool(struct evrpc_request_wrapper *ctx, 0616 struct evrpc_pool *pool); 0617 EVENT2_EXPORT_SYMBOL 0618 void evrpc_request_set_cb(struct evrpc_request_wrapper *ctx, 0619 void (*cb)(struct evrpc_status*, void *request, void *reply, void *arg), 0620 void *cb_arg); 0621 0622 #ifdef __cplusplus 0623 } 0624 #endif 0625 0626 #endif /* EVENT2_RPC_H_INCLUDED_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |