2 * util/netevent.h - event notification
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
6 * This software is open source.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
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.
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.
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.
39 * This file contains event notification functions.
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.
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.
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.
63 #include "dnscrypt/dnscrypt.h"
71 /* internal event notification data storage structure. */
72 struct internal_event;
74 struct internal_timer; /* A sub struct of the comm_timer super struct */
76 /** callback from communication point function type */
77 typedef int comm_point_callback_type(struct comm_point*, void*, int,
80 /** to pass no_error to callback function */
81 #define NETEVENT_NOERROR 0
82 /** to pass closed connection to callback function */
83 #define NETEVENT_CLOSED -1
84 /** to pass timeout happened to callback function */
85 #define NETEVENT_TIMEOUT -2
86 /** to pass fallback from capsforID to callback function; 0x20 failed */
87 #define NETEVENT_CAPSFAIL -3
88 /** to pass done transfer to callback function; http file is complete */
89 #define NETEVENT_DONE -4
91 /** timeout to slow accept calls when not possible, in msec. */
92 #define NETEVENT_SLOW_ACCEPT_TIME 2000
95 * A communication point dispatcher. Thread specific.
98 /** behind the scenes structure. with say libevent info. alloced */
99 struct internal_base* eb;
100 /** callback to stop listening on accept sockets,
101 * performed when accept() will not function properly */
102 void (*stop_accept)(void*);
103 /** callback to start listening on accept sockets, performed
104 * after stop_accept() then a timeout has passed. */
105 void (*start_accept)(void*);
106 /** user argument for stop_accept and start_accept functions */
111 * Reply information for a communication point.
114 /** the comm_point with fd to send reply on to. */
115 struct comm_point* c;
116 /** the address (for UDP based communication) */
117 struct sockaddr_storage addr;
118 /** length of address */
120 /** return type 0 (none), 4(IP4), 6(IP6) */
122 /* DnsCrypt context */
124 uint8_t client_nonce[crypto_box_HALF_NONCEBYTES];
125 uint8_t nmkey[crypto_box_BEFORENMBYTES];
126 const dnsccert *dnsc_cert;
129 /** the return source interface data */
132 struct in6_pktinfo v6info;
135 struct in_pktinfo v4info;
136 #elif defined(IP_RECVDSTADDR)
137 struct in_addr v4addr;
140 /** variable with return source data */
142 /** max udp size for udp packets */
147 * Communication point to the network
148 * These behaviours can be accomplished by setting the flags
149 * and passing return values from the callback.
150 * udp frontside: called after readdone. sendafter.
151 * tcp frontside: called readdone, sendafter. close.
152 * udp behind: called after readdone. No send after.
153 * tcp behind: write done, read done, then called. No send after.
156 /** behind the scenes structure, with say libevent info. alloced. */
157 struct internal_event* ev;
159 /** file descriptor for communication point */
162 /** timeout (NULL if it does not). Malloced. */
163 struct timeval* timeout;
165 /** buffer pointer. Either to perthread, or own buffer or NULL */
166 struct sldns_buffer* buffer;
168 /* -------- TCP Handler -------- */
169 /** Read/Write state for TCP */
171 /** The current read/write count for TCP */
172 size_t tcp_byte_count;
173 /** parent communication point (for TCP sockets) */
174 struct comm_point* tcp_parent;
175 /** sockaddr from peer, for TCP handlers */
176 struct comm_reply repinfo;
178 /* -------- TCP Accept -------- */
179 /** the number of TCP handlers for this tcp-accept socket */
181 /** current number of tcp handler in-use for this accept socket */
183 /** malloced array of tcp handlers for a tcp-accept,
184 of size max_tcp_count. */
185 struct comm_point** tcp_handlers;
186 /** linked list of free tcp_handlers to use for new queries.
187 For tcp_accept the first entry, for tcp_handlers the next one. */
188 struct comm_point* tcp_free;
190 /* -------- SSL TCP DNS ------- */
191 /** the SSL object with rw bio (owned) or for commaccept ctx ref */
193 /** handshake state for init and renegotiate */
195 /** no handshake, it has been done */
196 comm_ssl_shake_none = 0,
197 /** ssl initial handshake wants to read */
199 /** ssl initial handshake wants to write */
200 comm_ssl_shake_write,
201 /** ssl_write wants to read */
202 comm_ssl_shake_hs_read,
203 /** ssl_read wants to write */
204 comm_ssl_shake_hs_write
207 /* -------- HTTP ------- */
208 /** Currently reading in http headers */
210 /** Currently reading in chunk headers, 0=not, 1=firstline, 2=unused
211 * (more lines), 3=trailer headers after chunk */
212 int http_in_chunk_headers;
213 /** chunked transfer */
215 /** http temp buffer (shared buffer for temporary work) */
216 struct sldns_buffer* http_temp;
217 /** http stored content in buffer */
220 /* -------- dnstap ------- */
221 /** the dnstap environment */
222 struct dt_env* dtenv;
224 /** is this a UDP, TCP-accept or TCP socket. */
225 enum comm_point_type {
226 /** UDP socket - handle datagrams. */
228 /** TCP accept socket - only creates handlers if readable. */
230 /** TCP handler socket - handle byteperbyte readwrite. */
232 /** HTTP handler socket */
234 /** AF_UNIX socket - for internal commands. */
236 /** raw - not DNS format - for pipe readers and writers */
239 /** variable with type of socket, UDP,TCP-accept,TCP,pipe */
242 /* ---------- Behaviour ----------- */
243 /** if set the connection is NOT closed on delete. */
246 /** if set, the connection is closed on error, on timeout,
247 and after read/write completes. No callback is done. */
250 /** if set, read/write completes:
251 read/write state of tcp is toggled.
252 buffer reset/bytecount reset.
254 So that when that is done the callback is called. */
255 int tcp_do_toggle_rw;
257 /** timeout in msec for TCP wait times for this connection */
258 int tcp_timeout_msec;
260 /** if set, tcp keepalive is enabled on this connection */
263 /** if set, checks for pending error from nonblocking connect() call.*/
264 int tcp_check_nb_connect;
266 /** if set, check for connection limit on tcp accept. */
267 struct tcl_list* tcp_conn_limit;
268 /** the entry for the connection. */
269 struct tcl_addr* tcl_addr;
271 #ifdef USE_MSG_FASTOPEN
272 /** used to track if the sendto() call should be done when using TFO. */
277 /** Is this a dnscrypt channel */
279 /** encrypted buffer pointer. Either to perthread, or own buffer or NULL */
280 struct sldns_buffer* dnscrypt_buffer;
282 /** number of queries outstanding on this socket, used by
283 * outside network for udp ports */
286 /** callback when done.
287 tcp_accept does not get called back, is NULL then.
288 If a timeout happens, callback with timeout=1 is called.
289 If an error happens, callback is called with error set
290 nonzero. If not NETEVENT_NOERROR, it is an errno value.
291 If the connection is closed (by remote end) then the
292 callback is called with error set to NETEVENT_CLOSED=-1.
293 If a timeout happens on the connection, the error is set to
295 The reply_info can be copied if the reply needs to happen at a
296 later time. It consists of a struct with commpoint and address.
297 It can be passed to a msg send routine some time later.
298 Note the reply information is temporary and must be copied.
299 NULL is passed for_reply info, in cases where error happened.
302 int my_callback(struct comm_point* c, void* my_arg, int error,
303 struct comm_reply *reply_info);
305 if the routine returns 0, nothing is done.
306 Notzero, the buffer will be sent back to client.
307 For UDP this is done without changing the commpoint.
308 In TCP it sets write state.
310 comm_point_callback_type* callback;
311 /** argument to pass to callback. */
316 * Structure only for making timeout events.
319 /** the internal event stuff (derived) */
320 struct internal_timer* ev_timer;
322 /** callback function, takes user arg only */
323 void (*callback)(void*);
325 /** callback user argument */
330 * Structure only for signal events.
333 /** the communication base */
334 struct comm_base* base;
336 /** the internal event stuff */
337 struct internal_signal* ev_signal;
339 /** callback function, takes signal number and user arg */
340 void (*callback)(int, void*);
342 /** callback user argument */
347 * Create a new comm base.
348 * @param sigs: if true it attempts to create a default loop for
350 * @return: the new comm base. NULL on error.
352 struct comm_base* comm_base_create(int sigs);
355 * Create comm base that uses the given ub_event_base (underlying pluggable
356 * event mechanism pointer).
357 * @param base: underlying pluggable event base.
358 * @return: the new comm base. NULL on error.
360 struct comm_base* comm_base_create_event(struct ub_event_base* base);
363 * Delete comm base structure but not the underlying lib event base.
364 * All comm points must have been deleted.
365 * @param b: the base to delete.
367 void comm_base_delete_no_base(struct comm_base* b);
370 * Destroy a comm base.
371 * All comm points must have been deleted.
372 * @param b: the base to delete.
374 void comm_base_delete(struct comm_base* b);
377 * Obtain two pointers. The pointers never change (until base_delete()).
378 * The pointers point to time values that are updated regularly.
379 * @param b: the communication base that will update the time values.
380 * @param tt: pointer to time in seconds is returned.
381 * @param tv: pointer to time in microseconds is returned.
383 void comm_base_timept(struct comm_base* b, time_t** tt, struct timeval** tv);
386 * Dispatch the comm base events.
387 * @param b: the communication to perform.
389 void comm_base_dispatch(struct comm_base* b);
392 * Exit from dispatch loop.
393 * @param b: the communication base that is in dispatch().
395 void comm_base_exit(struct comm_base* b);
398 * Set the slow_accept mode handlers. You can not provide these if you do
399 * not perform accept() calls.
400 * @param b: comm base
401 * @param stop_accept: function that stops listening to accept fds.
402 * @param start_accept: function that resumes listening to accept fds.
403 * @param arg: callback arg to pass to the functions.
405 void comm_base_set_slow_accept_handlers(struct comm_base* b,
406 void (*stop_accept)(void*), void (*start_accept)(void*), void* arg);
409 * Access internal data structure (for util/tube.c on windows)
410 * @param b: comm base
411 * @return ub_event_base.
413 struct ub_event_base* comm_base_internal(struct comm_base* b);
416 * Create an UDP comm point. Calls malloc.
417 * setups the structure with the parameters you provide.
418 * @param base: in which base to alloc the commpoint.
419 * @param fd : file descriptor of open UDP socket.
420 * @param buffer: shared buffer by UDP sockets from this thread.
421 * @param callback: callback function pointer.
422 * @param callback_arg: will be passed to your callback function.
423 * @return: returns the allocated communication point. NULL on error.
424 * Sets timeout to NULL. Turns off TCP options.
426 struct comm_point* comm_point_create_udp(struct comm_base* base,
427 int fd, struct sldns_buffer* buffer,
428 comm_point_callback_type* callback, void* callback_arg);
431 * Create an UDP with ancillary data comm point. Calls malloc.
432 * Uses recvmsg instead of recv to get udp message.
433 * setups the structure with the parameters you provide.
434 * @param base: in which base to alloc the commpoint.
435 * @param fd : file descriptor of open UDP socket.
436 * @param buffer: shared buffer by UDP sockets from this thread.
437 * @param callback: callback function pointer.
438 * @param callback_arg: will be passed to your callback function.
439 * @return: returns the allocated communication point. NULL on error.
440 * Sets timeout to NULL. Turns off TCP options.
442 struct comm_point* comm_point_create_udp_ancil(struct comm_base* base,
443 int fd, struct sldns_buffer* buffer,
444 comm_point_callback_type* callback, void* callback_arg);
447 * Create a TCP listener comm point. Calls malloc.
448 * Setups the structure with the parameters you provide.
449 * Also Creates TCP Handlers, pre allocated for you.
450 * Uses the parameters you provide.
451 * @param base: in which base to alloc the commpoint.
452 * @param fd: file descriptor of open TCP socket set to listen nonblocking.
453 * @param num: becomes max_tcp_count, the routine allocates that
454 * many tcp handler commpoints.
455 * @param idle_timeout: TCP idle timeout in ms.
456 * @param tcp_conn_limit: TCP connection limit info.
457 * @param bufsize: size of buffer to create for handlers.
458 * @param callback: callback function pointer for TCP handlers.
459 * @param callback_arg: will be passed to your callback function.
460 * @return: returns the TCP listener commpoint. You can find the
461 * TCP handlers in the array inside the listener commpoint.
462 * returns NULL on error.
463 * Inits timeout to NULL. All handlers are on the free list.
465 struct comm_point* comm_point_create_tcp(struct comm_base* base,
466 int fd, int num, int idle_timeout, struct tcl_list* tcp_conn_limit,
467 size_t bufsize, comm_point_callback_type* callback, void* callback_arg);
470 * Create an outgoing TCP commpoint. No file descriptor is opened, left at -1.
471 * @param base: in which base to alloc the commpoint.
472 * @param bufsize: size of buffer to create for handlers.
473 * @param callback: callback function pointer for the handler.
474 * @param callback_arg: will be passed to your callback function.
475 * @return: the commpoint or NULL on error.
477 struct comm_point* comm_point_create_tcp_out(struct comm_base* base,
478 size_t bufsize, comm_point_callback_type* callback, void* callback_arg);
481 * Create an outgoing HTTP commpoint. No file descriptor is opened, left at -1.
482 * @param base: in which base to alloc the commpoint.
483 * @param bufsize: size of buffer to create for handlers.
484 * @param callback: callback function pointer for the handler.
485 * @param callback_arg: will be passed to your callback function.
486 * @param temp: sldns buffer, shared between other http_out commpoints, for
487 * temporary data when performing callbacks.
488 * @return: the commpoint or NULL on error.
490 struct comm_point* comm_point_create_http_out(struct comm_base* base,
491 size_t bufsize, comm_point_callback_type* callback,
492 void* callback_arg, struct sldns_buffer* temp);
495 * Create commpoint to listen to a local domain file descriptor.
496 * @param base: in which base to alloc the commpoint.
497 * @param fd: file descriptor of open AF_UNIX socket set to listen nonblocking.
498 * @param bufsize: size of buffer to create for handlers.
499 * @param callback: callback function pointer for the handler.
500 * @param callback_arg: will be passed to your callback function.
501 * @return: the commpoint or NULL on error.
503 struct comm_point* comm_point_create_local(struct comm_base* base,
504 int fd, size_t bufsize,
505 comm_point_callback_type* callback, void* callback_arg);
508 * Create commpoint to listen to a local domain pipe descriptor.
509 * @param base: in which base to alloc the commpoint.
510 * @param fd: file descriptor.
511 * @param writing: true if you want to listen to writes, false for reads.
512 * @param callback: callback function pointer for the handler.
513 * @param callback_arg: will be passed to your callback function.
514 * @return: the commpoint or NULL on error.
516 struct comm_point* comm_point_create_raw(struct comm_base* base,
518 comm_point_callback_type* callback, void* callback_arg);
521 * Close a comm point fd.
522 * @param c: comm point to close.
524 void comm_point_close(struct comm_point* c);
527 * Close and deallocate (free) the comm point. If the comm point is
528 * a tcp-accept point, also its tcp-handler points are deleted.
529 * @param c: comm point to delete.
531 void comm_point_delete(struct comm_point* c);
534 * Send reply. Put message into commpoint buffer.
535 * @param repinfo: The reply info copied from a commpoint callback call.
537 void comm_point_send_reply(struct comm_reply* repinfo);
540 * Drop reply. Cleans up.
541 * @param repinfo: The reply info copied from a commpoint callback call.
543 void comm_point_drop_reply(struct comm_reply* repinfo);
546 * Send an udp message over a commpoint.
547 * @param c: commpoint to send it from.
548 * @param packet: what to send.
549 * @param addr: where to send it to.
550 * @param addrlen: length of addr.
551 * @return: false on a failure.
553 int comm_point_send_udp_msg(struct comm_point* c, struct sldns_buffer* packet,
554 struct sockaddr* addr, socklen_t addrlen);
557 * Stop listening for input on the commpoint. No callbacks will happen.
558 * @param c: commpoint to disable. The fd is not closed.
560 void comm_point_stop_listening(struct comm_point* c);
563 * Start listening again for input on the comm point.
564 * @param c: commpoint to enable again.
565 * @param newfd: new fd, or -1 to leave fd be.
566 * @param msec: timeout in milliseconds, or -1 for no (change to the) timeout.
569 void comm_point_start_listening(struct comm_point* c, int newfd, int msec);
572 * Stop listening and start listening again for reading or writing.
573 * @param c: commpoint
574 * @param rd: if true, listens for reading.
575 * @param wr: if true, listens for writing.
577 void comm_point_listen_for_rw(struct comm_point* c, int rd, int wr);
580 * Get size of memory used by comm point.
581 * For TCP handlers this includes subhandlers.
582 * For UDP handlers, this does not include the (shared) UDP buffer.
583 * @param c: commpoint.
584 * @return size in bytes.
586 size_t comm_point_get_mem(struct comm_point* c);
589 * create timer. Not active upon creation.
590 * @param base: event handling base.
591 * @param cb: callback function: void myfunc(void* myarg);
592 * @param cb_arg: user callback argument.
593 * @return: the new timer or NULL on error.
595 struct comm_timer* comm_timer_create(struct comm_base* base,
596 void (*cb)(void*), void* cb_arg);
599 * disable timer. Stops callbacks from happening.
600 * @param timer: to disable.
602 void comm_timer_disable(struct comm_timer* timer);
605 * reset timevalue for timer.
606 * @param timer: timer to (re)set.
607 * @param tv: when the timer should activate. if NULL timer is disabled.
609 void comm_timer_set(struct comm_timer* timer, struct timeval* tv);
613 * @param timer: to delete.
615 void comm_timer_delete(struct comm_timer* timer);
618 * see if timeout has been set to a value.
619 * @param timer: the timer to examine.
620 * @return: false if disabled or not set.
622 int comm_timer_is_set(struct comm_timer* timer);
625 * Get size of memory used by comm timer.
626 * @param timer: the timer to examine.
627 * @return size in bytes.
629 size_t comm_timer_get_mem(struct comm_timer* timer);
632 * Create a signal handler. Call signal_bind() later to bind to a signal.
633 * @param base: communication base to use.
634 * @param callback: called when signal is caught.
635 * @param cb_arg: user argument to callback
636 * @return: the signal struct or NULL on error.
638 struct comm_signal* comm_signal_create(struct comm_base* base,
639 void (*callback)(int, void*), void* cb_arg);
642 * Bind signal struct to catch a signal. A signle comm_signal can be bound
643 * to multiple signals, calling comm_signal_bind multiple times.
644 * @param comsig: the communication point, with callback information.
645 * @param sig: signal number.
646 * @return: true on success. false on error.
648 int comm_signal_bind(struct comm_signal* comsig, int sig);
651 * Delete the signal communication point.
652 * @param comsig: to delete.
654 void comm_signal_delete(struct comm_signal* comsig);
657 * perform accept(2) with error checking.
658 * @param c: commpoint with accept fd.
659 * @param addr: remote end returned here.
660 * @param addrlen: length of remote end returned here.
661 * @return new fd, or -1 on error.
662 * if -1, error message has been printed if necessary, simply drop
663 * out of the reading handler.
665 int comm_point_perform_accept(struct comm_point* c,
666 struct sockaddr_storage* addr, socklen_t* addrlen);
668 /**** internal routines ****/
671 * This routine is published for checks and tests, and is only used internally.
672 * handle libevent callback for udp comm point.
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.
678 void comm_point_udp_callback(int fd, short event, void* arg);
681 * This routine is published for checks and tests, and is only used internally.
682 * handle libevent callback for udp ancillary data comm point.
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.
688 void comm_point_udp_ancil_callback(int fd, short event, void* arg);
691 * This routine is published for checks and tests, and is only used internally.
692 * handle libevent callback for tcp accept comm point
693 * @param fd: file descriptor.
694 * @param event: event bits from libevent:
695 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
696 * @param arg: the comm_point structure.
698 void comm_point_tcp_accept_callback(int fd, short event, void* arg);
701 * This routine is published for checks and tests, and is only used internally.
702 * handle libevent callback for tcp data comm point
703 * @param fd: file descriptor.
704 * @param event: event bits from libevent:
705 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
706 * @param arg: the comm_point structure.
708 void comm_point_tcp_handle_callback(int fd, short event, void* arg);
711 * This routine is published for checks and tests, and is only used internally.
712 * handle libevent callback for tcp data comm point
713 * @param fd: file descriptor.
714 * @param event: event bits from libevent:
715 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
716 * @param arg: the comm_point structure.
718 void comm_point_http_handle_callback(int fd, short event, void* arg);
721 * This routine is published for checks and tests, and is only used internally.
722 * handle libevent callback for timer comm.
723 * @param fd: file descriptor (always -1).
724 * @param event: event bits from libevent:
725 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
726 * @param arg: the comm_timer structure.
728 void comm_timer_callback(int fd, short event, void* arg);
731 * This routine is published for checks and tests, and is only used internally.
732 * handle libevent callback for signal comm.
733 * @param fd: file descriptor (used for the signal number).
734 * @param event: event bits from libevent:
735 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
736 * @param arg: the internal commsignal structure.
738 void comm_signal_callback(int fd, short event, void* arg);
741 * This routine is published for checks and tests, and is only used internally.
742 * libevent callback for AF_UNIX fds
743 * @param fd: file descriptor.
744 * @param event: event bits from libevent:
745 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
746 * @param arg: the comm_point structure.
748 void comm_point_local_handle_callback(int fd, short event, void* arg);
751 * This routine is published for checks and tests, and is only used internally.
752 * libevent callback for raw fd access.
753 * @param fd: file descriptor.
754 * @param event: event bits from libevent:
755 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
756 * @param arg: the comm_point structure.
758 void comm_point_raw_handle_callback(int fd, short event, void* arg);
761 * This routine is published for checks and tests, and is only used internally.
762 * libevent callback for timeout on slow accept.
763 * @param fd: file descriptor.
764 * @param event: event bits from libevent:
765 * EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
766 * @param arg: the comm_point structure.
768 void comm_base_handle_slow_accept(int fd, short event, void* arg);
772 * Callback for openssl BIO to on windows detect WSAEWOULDBLOCK and notify
773 * the winsock_event of this for proper TCP nonblocking implementation.
774 * @param c: comm_point, fd must be set its struct event is registered.
775 * @param ssl: openssl SSL, fd must be set so it has a bio.
777 void comm_point_tcp_win_bio_cb(struct comm_point* c, void* ssl);
780 /** see if errno for tcp connect has to be logged or not. This uses errno */
781 int tcp_connect_errno_needs_log(struct sockaddr* addr, socklen_t addrlen);
783 #endif /* NET_EVENT_H */