Electroneum
unbound-event.h
Go to the documentation of this file.
1 /*
2  * unbound-event.h - unbound validating resolver public API with events
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
55 #ifndef _UB_UNBOUND_EVENT_H
56 #define _UB_UNBOUND_EVENT_H
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 struct ub_ctx;
63 struct ub_result;
64 struct event_base;
65 
67 #define UB_EV_TIMEOUT 0x01
68 
69 #define UB_EV_READ 0x02
70 
71 #define UB_EV_WRITE 0x04
72 
73 #define UB_EV_SIGNAL 0x08
74 
75 #define UB_EV_PERSIST 0x10
76 
78 #define UB_EVENT_MAGIC 0x44d74d78
79 
80 struct ub_event;
81 struct ub_event_base;
82 struct timeval;
83 
90  void (*free)(struct ub_event_base*);
93  int (*dispatch)(struct ub_event_base*);
95  int (*loopexit)(struct ub_event_base*, struct timeval*);
97  struct ub_event* (*new_event)(struct ub_event_base*,
98  int fd, short bits, void (*cb)(int, short, void*), void* arg);
101  struct ub_event* (*new_signal)(struct ub_event_base*, int fd,
102  void (*cb)(int, short, void*), void* arg);
105  struct ub_event* (*winsock_register_wsaevent)(struct ub_event_base*,
106  void* wsaevent, void (*cb)(int, short, void*), void* arg);
107 };
108 
117  unsigned long magic;
120 };
121 
125 struct ub_event_vmt {
128  void (*add_bits)(struct ub_event*, short);
131  void (*del_bits)(struct ub_event*, short);
134  void (*set_fd)(struct ub_event*, int);
136  void (*free)(struct ub_event*);
138  int (*add)(struct ub_event*, struct timeval*);
140  int (*del)(struct ub_event*);
142  int (*add_timer)(struct ub_event*, struct ub_event_base*,
143  void (*cb)(int, short, void*), void* arg, struct timeval*);
145  int (*del_timer)(struct ub_event*);
147  int (*add_signal)(struct ub_event*, struct timeval*);
149  int (*del_signal)(struct ub_event*);
158  void (*winsock_tcp_wouldblock)(struct ub_event*, int eventbit);
159 };
160 
166 struct ub_event {
168  unsigned long magic;
170  struct ub_event_vmt* vmt;
171 };
172 
173 typedef void (*ub_event_callback_type)(void*, int, void*, int, int, char*);
174 
187 struct ub_ctx* ub_ctx_create_ub_event(struct ub_event_base* base);
188 
204 struct ub_ctx* ub_ctx_create_event(struct event_base* base);
205 
216 int ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base);
217 
256 int ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype,
257  int rrclass, void* mydata, ub_event_callback_type callback,
258  int* async_id);
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* _UB_UNBOUND_H */
struct ub_event_base * event_base
Definition: context.h:118
struct ub_ctx * ub_ctx_create_event(struct event_base *base)
unsigned long magic
int ub_ctx_set_event(struct ub_ctx *ctx, struct event_base *base)
int(* dispatch)(struct ub_event_base *)
Definition: unbound-event.h:93
struct ub_event_vmt * vmt
void(* ub_event_callback_type)(void *, int, void *, int, int, char *)
const char * name
int(* loopexit)(struct ub_event_base *, struct timeval *)
Definition: unbound-event.h:95
void(* free)(struct ub_event_base *)
Definition: unbound-event.h:90
int(* del_timer)(struct ub_event *)
void(* del_bits)(struct ub_event *, short)
unsigned long magic
struct ub_event_base_vmt * vmt
void(* winsock_tcp_wouldblock)(struct ub_event *, int eventbit)
int(* add_signal)(struct ub_event *, struct timeval *)
void(* winsock_unregister_wsaevent)(struct ub_event *ev)
void(* set_fd)(struct ub_event *, int)
int ub_resolve_event(struct ub_ctx *ctx, const char *name, int rrtype, int rrclass, void *mydata, ub_event_callback_type callback, int *async_id)
int(* del_signal)(struct ub_event *)
int(* add_timer)(struct ub_event *, struct ub_event_base *, void(*cb)(int, short, void *), void *arg, struct timeval *)
void(* add_bits)(struct ub_event *, short)
struct ub_ctx * ub_ctx_create_ub_event(struct ub_event_base *base)
void(* free)(struct ub_event *)
int(* add)(struct ub_event *, struct timeval *)
unsigned int bits[ATOMS]
Definition: rctTypes.h:136
int(* del)(struct ub_event *)
Definition: context.h:62