]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/util/netevent.h
network_cmds-596.100.2.tar.gz
[apple/network_cmds.git] / unbound / util / netevent.h
1 /*
2 * util/netevent.h - event notification
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
36 /**
37 * \file
38 *
39 * This file contains event notification functions.
40 *
41 * There are three types of communication points
42 * o UDP socket - perthread buffer.
43 * o TCP-accept socket - array of TCP-sockets, socketcount.
44 * o TCP socket - own buffer, parent-TCPaccept, read/write state,
45 * number of bytes read/written, timeout.
46 *
47 * There are sockets aimed towards our clients and towards the internet.
48 * o frontside - aimed towards our clients, queries come in, answers back.
49 * o behind - aimed towards internet, to the authoritative DNS servers.
50 *
51 * Several event types are available:
52 * o comm_base - for thread safety of the comm points, one per thread.
53 * o comm_point - udp and tcp networking, with callbacks.
54 * o comm_timer - a timeout with callback.
55 * o comm_signal - callbacks when signal is caught.
56 * o comm_reply - holds reply info during networking callback.
57 *
58 */
59
60 #ifndef NET_EVENT_H
61 #define NET_EVENT_H
62
63 struct sldns_buffer;
64 struct comm_point;
65 struct comm_reply;
66 struct event_base;
67
68 /* internal event notification data storage structure. */
69 struct internal_event;
70 struct internal_base;
71 struct internal_timer;
72
73 /** callback from communication point function type */
74 typedef int comm_point_callback_t(struct comm_point*, void*, int,
75 struct comm_reply*);
76
77 /** to pass no_error to callback function */
78 #define NETEVENT_NOERROR 0
79 /** to pass closed connection to callback function */
80 #define NETEVENT_CLOSED -1
81 /** to pass timeout happened to callback function */
82 #define NETEVENT_TIMEOUT -2
83 /** to pass fallback from capsforID to callback function; 0x20 failed */
84 #define NETEVENT_CAPSFAIL -3
85
86 /** timeout to slow accept calls when not possible, in msec. */
87 #define NETEVENT_SLOW_ACCEPT_TIME 2000
88
89 /**
90 * A communication point dispatcher. Thread specific.
91 */
92 struct comm_base {
93 /** behind the scenes structure. with say libevent info. alloced */
94 struct internal_base* eb;
95 /** callback to stop listening on accept sockets,
96 * performed when accept() will not function properly */
97 void (*stop_accept)(void*);
98 /** callback to start listening on accept sockets, performed
99 * after stop_accept() then a timeout has passed. */
100 void (*start_accept)(void*);
101 /** user argument for stop_accept and start_accept functions */
102 void* cb_arg;
103 };
104
105 /**
106 * Reply information for a communication point.
107 */
108 struct comm_reply {
109 /** the comm_point with fd to send reply on to. */
110 struct comm_point* c;
111 /** the address (for UDP based communication) */
112 struct sockaddr_storage addr;
113 /** length of address */
114 socklen_t addrlen;
115 /** return type 0 (none), 4(IP4), 6(IP6) */
116 int srctype;
117 /** the return source interface data */
118 union {
119 #ifdef IPV6_PKTINFO
120 struct in6_pktinfo v6info;
121 #endif
122 #ifdef IP_PKTINFO
123 struct in_pktinfo v4info;
124 #elif defined(IP_RECVDSTADDR)
125 struct in_addr v4addr;
126 #endif
127 }
128 /** variable with return source data */
129 pktinfo;
130 };
131
132 /**
133 * Communication point to the network
134 * These behaviours can be accomplished by setting the flags
135 * and passing return values from the callback.
136 * udp frontside: called after readdone. sendafter.
137 * tcp frontside: called readdone, sendafter. close.
138 * udp behind: called after readdone. No send after.
139 * tcp behind: write done, read done, then called. No send after.
140 */
141 struct comm_point {
142 /** behind the scenes structure, with say libevent info. alloced. */
143 struct internal_event* ev;
144
145 /** file descriptor for communication point */
146 int fd;
147
148 /** timeout (NULL if it does not). Malloced. */
149 struct timeval* timeout;
150
151 /** buffer pointer. Either to perthread, or own buffer or NULL */
152 struct sldns_buffer* buffer;
153
154 /* -------- TCP Handler -------- */
155 /** Read/Write state for TCP */
156 int tcp_is_reading;
157 /** The current read/write count for TCP */
158 size_t tcp_byte_count;
159 /** parent communication point (for TCP sockets) */
160 struct comm_point* tcp_parent;
161 /** sockaddr from peer, for TCP handlers */
162 struct comm_reply repinfo;
163
164 /* -------- TCP Accept -------- */
165 /** the number of TCP handlers for this tcp-accept socket */
166 int max_tcp_count;
167 /** malloced array of tcp handlers for a tcp-accept,
168 of size max_tcp_count. */
169 struct comm_point** tcp_handlers;
170 /** linked list of free tcp_handlers to use for new queries.
171 For tcp_accept the first entry, for tcp_handlers the next one. */
172 struct comm_point* tcp_free;
173
174 /* -------- SSL TCP DNS ------- */
175 /** the SSL object with rw bio (owned) or for commaccept ctx ref */
176 void* ssl;
177 /** handshake state for init and renegotiate */
178 enum {
179 /** no handshake, it has been done */
180 comm_ssl_shake_none = 0,
181 /** ssl initial handshake wants to read */
182 comm_ssl_shake_read,
183 /** ssl initial handshake wants to write */
184 comm_ssl_shake_write,
185 /** ssl_write wants to read */
186 comm_ssl_shake_hs_read,
187 /** ssl_read wants to write */
188 comm_ssl_shake_hs_write
189 } ssl_shake_state;
190
191 /* -------- dnstap ------- */
192 /** the dnstap environment */
193 struct dt_env* dtenv;
194
195 /** is this a UDP, TCP-accept or TCP socket. */
196 enum comm_point_type {
197 /** UDP socket - handle datagrams. */
198 comm_udp,
199 /** TCP accept socket - only creates handlers if readable. */
200 comm_tcp_accept,
201 /** TCP handler socket - handle byteperbyte readwrite. */
202 comm_tcp,
203 /** AF_UNIX socket - for internal commands. */
204 comm_local,
205 /** raw - not DNS format - for pipe readers and writers */
206 comm_raw
207 }
208 /** variable with type of socket, UDP,TCP-accept,TCP,pipe */
209 type;
210
211 /* ---------- Behaviour ----------- */
212 /** if set the connection is NOT closed on delete. */
213 int do_not_close;
214
215 /** if set, the connection is closed on error, on timeout,
216 and after read/write completes. No callback is done. */
217 int tcp_do_close;
218
219 /** if set, read/write completes:
220 read/write state of tcp is toggled.
221 buffer reset/bytecount reset.
222 this flag cleared.
223 So that when that is done the callback is called. */
224 int tcp_do_toggle_rw;
225
226 /** if set, checks for pending error from nonblocking connect() call.*/
227 int tcp_check_nb_connect;
228
229 /** number of queries outstanding on this socket, used by
230 * outside network for udp ports */
231 int inuse;
232
233 /** callback when done.
234 tcp_accept does not get called back, is NULL then.
235 If a timeout happens, callback with timeout=1 is called.
236 If an error happens, callback is called with error set
237 nonzero. If not NETEVENT_NOERROR, it is an errno value.
238 If the connection is closed (by remote end) then the
239 callback is called with error set to NETEVENT_CLOSED=-1.
240 If a timeout happens on the connection, the error is set to
241 NETEVENT_TIMEOUT=-2.
242 The reply_info can be copied if the reply needs to happen at a
243 later time. It consists of a struct with commpoint and address.
244 It can be passed to a msg send routine some time later.
245 Note the reply information is temporary and must be copied.
246 NULL is passed for_reply info, in cases where error happened.
247
248 declare as:
249 int my_callback(struct comm_point* c, void* my_arg, int error,
250 struct comm_reply *reply_info);
251
252 if the routine returns 0, nothing is done.
253 Notzero, the buffer will be sent back to client.
254 For UDP this is done without changing the commpoint.
255 In TCP it sets write state.
256 */
257 comm_point_callback_t* callback;
258 /** argument to pass to callback. */
259 void *cb_arg;
260 };
261
262 /**
263 * Structure only for making timeout events.
264 */
265 struct comm_timer {
266 /** the internal event stuff */
267 struct internal_timer* ev_timer;
268
269 /** callback function, takes user arg only */
270 void (*callback)(void*);
271
272 /** callback user argument */
273 void* cb_arg;
274 };
275
276 /**
277 * Structure only for signal events.
278 */
279 struct comm_signal {
280 /** the communication base */
281 struct comm_base* base;
282
283 /** the internal event stuff */
284 struct internal_signal* ev_signal;
285
286 /** callback function, takes signal number and user arg */
287 void (*callback)(int, void*);
288
289 /** callback user argument */
290 void* cb_arg;
291 };
292
293 /**
294 * Create a new comm base.
295 * @param sigs: if true it attempts to create a default loop for
296 * signal handling.
297 * @return: the new comm base. NULL on error.
298 */
299 struct comm_base* comm_base_create(int sigs);
300
301 /**
302 * Create comm base that uses the given event_base (underlying event
303 * mechanism pointer).
304 * @param base: underlying lib event base.
305 * @return: the new comm base. NULL on error.
306 */
307 struct comm_base* comm_base_create_event(struct event_base* base);
308
309 /**
310 * Delete comm base structure but not the underlying lib event base.
311 * All comm points must have been deleted.
312 * @param b: the base to delete.
313 */
314 void comm_base_delete_no_base(struct comm_base* b);
315
316 /**
317 * Destroy a comm base.
318 * All comm points must have been deleted.
319 * @param b: the base to delete.
320 */
321 void comm_base_delete(struct comm_base* b);
322
323 /**
324 * Obtain two pointers. The pointers never change (until base_delete()).
325 * The pointers point to time values that are updated regularly.
326 * @param b: the communication base that will update the time values.
327 * @param tt: pointer to time in seconds is returned.
328 * @param tv: pointer to time in microseconds is returned.
329 */
330 void comm_base_timept(struct comm_base* b, time_t** tt, struct timeval** tv);
331
332 /**
333 * Dispatch the comm base events.
334 * @param b: the communication to perform.
335 */
336 void comm_base_dispatch(struct comm_base* b);
337
338 /**
339 * Exit from dispatch loop.
340 * @param b: the communication base that is in dispatch().
341 */
342 void comm_base_exit(struct comm_base* b);
343
344 /**
345 * Set the slow_accept mode handlers. You can not provide these if you do
346 * not perform accept() calls.
347 * @param b: comm base
348 * @param stop_accept: function that stops listening to accept fds.
349 * @param start_accept: function that resumes listening to accept fds.
350 * @param arg: callback arg to pass to the functions.
351 */
352 void comm_base_set_slow_accept_handlers(struct comm_base* b,
353 void (*stop_accept)(void*), void (*start_accept)(void*), void* arg);
354
355 /**
356 * Access internal data structure (for util/tube.c on windows)
357 * @param b: comm base
358 * @return event_base. Could be libevent, or internal event handler.
359 */
360 struct event_base* comm_base_internal(struct comm_base* b);
361
362 /**
363 * Create an UDP comm point. Calls malloc.
364 * setups the structure with the parameters you provide.
365 * @param base: in which base to alloc the commpoint.
366 * @param fd : file descriptor of open UDP socket.
367 * @param buffer: shared buffer by UDP sockets from this thread.
368 * @param callback: callback function pointer.
369 * @param callback_arg: will be passed to your callback function.
370 * @return: returns the allocated communication point. NULL on error.
371 * Sets timeout to NULL. Turns off TCP options.
372 */
373 struct comm_point* comm_point_create_udp(struct comm_base* base,
374 int fd, struct sldns_buffer* buffer,
375 comm_point_callback_t* callback, void* callback_arg);
376
377 /**
378 * Create an UDP with ancillary data comm point. Calls malloc.
379 * Uses recvmsg instead of recv to get udp message.
380 * setups the structure with the parameters you provide.
381 * @param base: in which base to alloc the commpoint.
382 * @param fd : file descriptor of open UDP socket.
383 * @param buffer: shared buffer by UDP sockets from this thread.
384 * @param callback: callback function pointer.
385 * @param callback_arg: will be passed to your callback function.
386 * @return: returns the allocated communication point. NULL on error.
387 * Sets timeout to NULL. Turns off TCP options.
388 */
389 struct comm_point* comm_point_create_udp_ancil(struct comm_base* base,
390 int fd, struct sldns_buffer* buffer,
391 comm_point_callback_t* callback, void* callback_arg);
392
393 /**
394 * Create a TCP listener comm point. Calls malloc.
395 * Setups the structure with the parameters you provide.
396 * Also Creates TCP Handlers, pre allocated for you.
397 * Uses the parameters you provide.
398 * @param base: in which base to alloc the commpoint.
399 * @param fd: file descriptor of open TCP socket set to listen nonblocking.
400 * @param num: becomes max_tcp_count, the routine allocates that
401 * many tcp handler commpoints.
402 * @param bufsize: size of buffer to create for handlers.
403 * @param callback: callback function pointer for TCP handlers.
404 * @param callback_arg: will be passed to your callback function.
405 * @return: returns the TCP listener commpoint. You can find the
406 * TCP handlers in the array inside the listener commpoint.
407 * returns NULL on error.
408 * Inits timeout to NULL. All handlers are on the free list.
409 */
410 struct comm_point* comm_point_create_tcp(struct comm_base* base,
411 int fd, int num, size_t bufsize,
412 comm_point_callback_t* callback, void* callback_arg);
413
414 /**
415 * Create an outgoing TCP commpoint. No file descriptor is opened, left at -1.
416 * @param base: in which base to alloc the commpoint.
417 * @param bufsize: size of buffer to create for handlers.
418 * @param callback: callback function pointer for the handler.
419 * @param callback_arg: will be passed to your callback function.
420 * @return: the commpoint or NULL on error.
421 */
422 struct comm_point* comm_point_create_tcp_out(struct comm_base* base,
423 size_t bufsize, comm_point_callback_t* callback, void* callback_arg);
424
425 /**
426 * Create commpoint to listen to a local domain file descriptor.
427 * @param base: in which base to alloc the commpoint.
428 * @param fd: file descriptor of open AF_UNIX socket set to listen nonblocking.
429 * @param bufsize: size of buffer to create for handlers.
430 * @param callback: callback function pointer for the handler.
431 * @param callback_arg: will be passed to your callback function.
432 * @return: the commpoint or NULL on error.
433 */
434 struct comm_point* comm_point_create_local(struct comm_base* base,
435 int fd, size_t bufsize,
436 comm_point_callback_t* callback, void* callback_arg);
437
438 /**
439 * Create commpoint to listen to a local domain pipe descriptor.
440 * @param base: in which base to alloc the commpoint.
441 * @param fd: file descriptor.
442 * @param writing: true if you want to listen to writes, false for reads.
443 * @param callback: callback function pointer for the handler.
444 * @param callback_arg: will be passed to your callback function.
445 * @return: the commpoint or NULL on error.
446 */
447 struct comm_point* comm_point_create_raw(struct comm_base* base,
448 int fd, int writing,
449 comm_point_callback_t* callback, void* callback_arg);
450
451 /**
452 * Close a comm point fd.
453 * @param c: comm point to close.
454 */
455 void comm_point_close(struct comm_point* c);
456
457 /**
458 * Close and deallocate (free) the comm point. If the comm point is
459 * a tcp-accept point, also its tcp-handler points are deleted.
460 * @param c: comm point to delete.
461 */
462 void comm_point_delete(struct comm_point* c);
463
464 /**
465 * Send reply. Put message into commpoint buffer.
466 * @param repinfo: The reply info copied from a commpoint callback call.
467 */
468 void comm_point_send_reply(struct comm_reply* repinfo);
469
470 /**
471 * Drop reply. Cleans up.
472 * @param repinfo: The reply info copied from a commpoint callback call.
473 */
474 void comm_point_drop_reply(struct comm_reply* repinfo);
475
476 /**
477 * Send an udp message over a commpoint.
478 * @param c: commpoint to send it from.
479 * @param packet: what to send.
480 * @param addr: where to send it to.
481 * @param addrlen: length of addr.
482 * @return: false on a failure.
483 */
484 int comm_point_send_udp_msg(struct comm_point* c, struct sldns_buffer* packet,
485 struct sockaddr* addr, socklen_t addrlen);
486
487 /**
488 * Stop listening for input on the commpoint. No callbacks will happen.
489 * @param c: commpoint to disable. The fd is not closed.
490 */
491 void comm_point_stop_listening(struct comm_point* c);
492
493 /**
494 * Start listening again for input on the comm point.
495 * @param c: commpoint to enable again.
496 * @param newfd: new fd, or -1 to leave fd be.
497 * @param sec: timeout in seconds, or -1 for no (change to the) timeout.
498 */
499 void comm_point_start_listening(struct comm_point* c, int newfd, int sec);
500
501 /**
502 * Stop listening and start listening again for reading or writing.
503 * @param c: commpoint
504 * @param rd: if true, listens for reading.
505 * @param wr: if true, listens for writing.
506 */
507 void comm_point_listen_for_rw(struct comm_point* c, int rd, int wr);
508
509 /**
510 * Get size of memory used by comm point.
511 * For TCP handlers this includes subhandlers.
512 * For UDP handlers, this does not include the (shared) UDP buffer.
513 * @param c: commpoint.
514 * @return size in bytes.
515 */
516 size_t comm_point_get_mem(struct comm_point* c);
517
518 /**
519 * create timer. Not active upon creation.
520 * @param base: event handling base.
521 * @param cb: callback function: void myfunc(void* myarg);
522 * @param cb_arg: user callback argument.
523 * @return: the new timer or NULL on error.
524 */
525 struct comm_timer* comm_timer_create(struct comm_base* base,
526 void (*cb)(void*), void* cb_arg);
527
528 /**
529 * disable timer. Stops callbacks from happening.
530 * @param timer: to disable.
531 */
532 void comm_timer_disable(struct comm_timer* timer);
533
534 /**
535 * reset timevalue for timer.
536 * @param timer: timer to (re)set.
537 * @param tv: when the timer should activate. if NULL timer is disabled.
538 */
539 void comm_timer_set(struct comm_timer* timer, struct timeval* tv);
540
541 /**
542 * delete timer.
543 * @param timer: to delete.
544 */
545 void comm_timer_delete(struct comm_timer* timer);
546
547 /**
548 * see if timeout has been set to a value.
549 * @param timer: the timer to examine.
550 * @return: false if disabled or not set.
551 */
552 int comm_timer_is_set(struct comm_timer* timer);
553
554 /**
555 * Get size of memory used by comm timer.
556 * @param timer: the timer to examine.
557 * @return size in bytes.
558 */
559 size_t comm_timer_get_mem(struct comm_timer* timer);
560
561 /**
562 * Create a signal handler. Call signal_bind() later to bind to a signal.
563 * @param base: communication base to use.
564 * @param callback: called when signal is caught.
565 * @param cb_arg: user argument to callback
566 * @return: the signal struct or NULL on error.
567 */
568 struct comm_signal* comm_signal_create(struct comm_base* base,
569 void (*callback)(int, void*), void* cb_arg);
570
571 /**
572 * Bind signal struct to catch a signal. A signle comm_signal can be bound
573 * to multiple signals, calling comm_signal_bind multiple times.
574 * @param comsig: the communication point, with callback information.
575 * @param sig: signal number.
576 * @return: true on success. false on error.
577 */
578 int comm_signal_bind(struct comm_signal* comsig, int sig);
579
580 /**
581 * Delete the signal communication point.
582 * @param comsig: to delete.
583 */
584 void comm_signal_delete(struct comm_signal* comsig);
585
586 /**
587 * perform accept(2) with error checking.
588 * @param c: commpoint with accept fd.
589 * @param addr: remote end returned here.
590 * @param addrlen: length of remote end returned here.
591 * @return new fd, or -1 on error.
592 * if -1, error message has been printed if necessary, simply drop
593 * out of the reading handler.
594 */
595 int comm_point_perform_accept(struct comm_point* c,
596 struct sockaddr_storage* addr, socklen_t* addrlen);
597
598 /**** internal routines ****/
599
600 /**
601 * This routine is published for checks and tests, and is only used internally.
602 * handle libevent callback for udp comm point.
603 * @param fd: file descriptor.
604 * @param event: event bits from libevent:
605 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
606 * @param arg: the comm_point structure.
607 */
608 void comm_point_udp_callback(int fd, short event, void* arg);
609
610 /**
611 * This routine is published for checks and tests, and is only used internally.
612 * handle libevent callback for udp ancillary data comm point.
613 * @param fd: file descriptor.
614 * @param event: event bits from libevent:
615 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
616 * @param arg: the comm_point structure.
617 */
618 void comm_point_udp_ancil_callback(int fd, short event, void* arg);
619
620 /**
621 * This routine is published for checks and tests, and is only used internally.
622 * handle libevent callback for tcp accept comm point
623 * @param fd: file descriptor.
624 * @param event: event bits from libevent:
625 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
626 * @param arg: the comm_point structure.
627 */
628 void comm_point_tcp_accept_callback(int fd, short event, void* arg);
629
630 /**
631 * This routine is published for checks and tests, and is only used internally.
632 * handle libevent callback for tcp data comm point
633 * @param fd: file descriptor.
634 * @param event: event bits from libevent:
635 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
636 * @param arg: the comm_point structure.
637 */
638 void comm_point_tcp_handle_callback(int fd, short event, void* arg);
639
640 /**
641 * This routine is published for checks and tests, and is only used internally.
642 * handle libevent callback for timer comm.
643 * @param fd: file descriptor (always -1).
644 * @param event: event bits from libevent:
645 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
646 * @param arg: the comm_timer structure.
647 */
648 void comm_timer_callback(int fd, short event, void* arg);
649
650 /**
651 * This routine is published for checks and tests, and is only used internally.
652 * handle libevent callback for signal comm.
653 * @param fd: file descriptor (used for the signal number).
654 * @param event: event bits from libevent:
655 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
656 * @param arg: the internal commsignal structure.
657 */
658 void comm_signal_callback(int fd, short event, void* arg);
659
660 /**
661 * This routine is published for checks and tests, and is only used internally.
662 * libevent callback for AF_UNIX fds
663 * @param fd: file descriptor.
664 * @param event: event bits from libevent:
665 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
666 * @param arg: the comm_point structure.
667 */
668 void comm_point_local_handle_callback(int fd, short event, void* arg);
669
670 /**
671 * This routine is published for checks and tests, and is only used internally.
672 * libevent callback for raw fd access.
673 * @param fd: file descriptor.
674 * @param event: event bits from libevent:
675 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
676 * @param arg: the comm_point structure.
677 */
678 void comm_point_raw_handle_callback(int fd, short event, void* arg);
679
680 /**
681 * This routine is published for checks and tests, and is only used internally.
682 * libevent callback for timeout on slow accept.
683 * @param fd: file descriptor.
684 * @param event: event bits from libevent:
685 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
686 * @param arg: the comm_point structure.
687 */
688 void comm_base_handle_slow_accept(int fd, short event, void* arg);
689
690 #ifdef USE_WINSOCK
691 /**
692 * Callback for openssl BIO to on windows detect WSAEWOULDBLOCK and notify
693 * the winsock_event of this for proper TCP nonblocking implementation.
694 * @param c: comm_point, fd must be set its struct event is registered.
695 * @param ssl: openssl SSL, fd must be set so it has a bio.
696 */
697 void comm_point_tcp_win_bio_cb(struct comm_point* c, void* ssl);
698 #endif
699
700 /** see if errno for tcp connect has to be logged or not. This uses errno */
701 int tcp_connect_errno_needs_log(struct sockaddr* addr, socklen_t addrlen);
702
703 #endif /* NET_EVENT_H */