2 * Copyright (c) 2006-2007 Niels Provos <provos@citi.umich.edu>
3 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef EVENT2_RPC_STRUCT_H_INCLUDED_
28 #define EVENT2_RPC_STRUCT_H_INCLUDED_
34 /** @file event2/rpc_struct.h
36 Structures used by rpc.h. Using these structures directly may harm
37 forward compatibility: be careful!
41 /* Fix so that people don't have to run with <sys/queue.h> */
43 #define EVENT_DEFINED_TQENTRY_
44 #define TAILQ_ENTRY(type) \
46 struct type *tqe_next; /* next element */ \
47 struct type **tqe_prev; /* address of previous next element */ \
49 #endif /* !TAILQ_ENTRY */
52 * provides information about the completed RPC request.
55 #define EVRPC_STATUS_ERR_NONE 0
56 #define EVRPC_STATUS_ERR_TIMEOUT 1
57 #define EVRPC_STATUS_ERR_BADPAYLOAD 2
58 #define EVRPC_STATUS_ERR_UNSTARTED 3
59 #define EVRPC_STATUS_ERR_HOOKABORTED 4
62 /* for looking at headers or other information */
63 struct evhttp_request *http_req;
66 /* the structure below needs to be synchronized with evrpc_req_generic */
68 /* Encapsulates a request */
70 TAILQ_ENTRY(evrpc) next;
72 /* the URI at which the request handler lives */
75 /* creates a new request structure */
76 void *(*request_new)(void *);
77 void *request_new_arg;
79 /* frees the request structure */
80 void (*request_free)(void *);
82 /* unmarshals the buffer into the proper request structure */
83 int (*request_unmarshal)(void *, struct evbuffer *);
85 /* creates a new reply structure */
86 void *(*reply_new)(void *);
89 /* frees the reply structure */
90 void (*reply_free)(void *);
92 /* verifies that the reply is valid */
93 int (*reply_complete)(void *);
95 /* marshals the reply into a buffer */
96 void (*reply_marshal)(struct evbuffer*, void *);
98 /* the callback invoked for each received rpc */
99 void (*cb)(struct evrpc_req_generic *, void *);
102 /* reference for further configuration */
103 struct evrpc_base *base;
106 #ifdef EVENT_DEFINED_TQENTRY_
114 #endif /* EVENT2_RPC_STRUCT_H_INCLUDED_ */