Back to home page

EIC code displayed by LXR

 
 

    


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_STRUCT_H_INCLUDED_
0028 #define EVENT2_RPC_STRUCT_H_INCLUDED_
0029 
0030 #ifdef __cplusplus
0031 extern "C" {
0032 #endif
0033 
0034 /** @file event2/rpc_struct.h
0035 
0036   Structures used by rpc.h.  Using these structures directly may harm
0037   forward compatibility: be careful!
0038 
0039  */
0040 
0041 /* Fix so that people don't have to run with <sys/queue.h> */
0042 #ifndef TAILQ_ENTRY
0043 #define EVENT_DEFINED_TQENTRY_
0044 #define TAILQ_ENTRY(type)                       \
0045 struct {                                \
0046     struct type *tqe_next;  /* next element */          \
0047     struct type **tqe_prev; /* address of previous next element */  \
0048 }
0049 #endif /* !TAILQ_ENTRY */
0050 
0051 /**
0052  * provides information about the completed RPC request.
0053  */
0054 struct evrpc_status {
0055 #define EVRPC_STATUS_ERR_NONE       0
0056 #define EVRPC_STATUS_ERR_TIMEOUT    1
0057 #define EVRPC_STATUS_ERR_BADPAYLOAD 2
0058 #define EVRPC_STATUS_ERR_UNSTARTED  3
0059 #define EVRPC_STATUS_ERR_HOOKABORTED    4
0060     int error;
0061 
0062     /* for looking at headers or other information */
0063     struct evhttp_request *http_req;
0064 };
0065 
0066 /* the structure below needs to be synchronized with evrpc_req_generic */
0067 
0068 /* Encapsulates a request */
0069 struct evrpc {
0070     TAILQ_ENTRY(evrpc) next;
0071 
0072     /* the URI at which the request handler lives */
0073     const char* uri;
0074 
0075     /* creates a new request structure */
0076     void *(*request_new)(void *);
0077     void *request_new_arg;
0078 
0079     /* frees the request structure */
0080     void (*request_free)(void *);
0081 
0082     /* unmarshals the buffer into the proper request structure */
0083     int (*request_unmarshal)(void *, struct evbuffer *);
0084 
0085     /* creates a new reply structure */
0086     void *(*reply_new)(void *);
0087     void *reply_new_arg;
0088 
0089     /* frees the reply structure */
0090     void (*reply_free)(void *);
0091 
0092     /* verifies that the reply is valid */
0093     int (*reply_complete)(void *);
0094 
0095     /* marshals the reply into a buffer */
0096     void (*reply_marshal)(struct evbuffer*, void *);
0097 
0098     /* the callback invoked for each received rpc */
0099     void (*cb)(struct evrpc_req_generic *, void *);
0100     void *cb_arg;
0101 
0102     /* reference for further configuration */
0103     struct evrpc_base *base;
0104 };
0105 
0106 #ifdef EVENT_DEFINED_TQENTRY_
0107 #undef TAILQ_ENTRY
0108 #endif
0109 
0110 #ifdef __cplusplus
0111 }
0112 #endif
0113 
0114 #endif /* EVENT2_RPC_STRUCT_H_INCLUDED_ */