netevent.h File Reference

This file contains event notification functions. More...

#include <sys/time.h>
#include "dnscrypt/dnscrypt.h"

Data Structures

struct  comm_base
 A communication point dispatcher. More...
 
struct  comm_reply
 Reply information for a communication point. More...
 
struct  comm_point
 Communication point to the network These behaviours can be accomplished by setting the flags and passing return values from the callback. More...
 
struct  comm_timer
 Structure only for making timeout events. More...
 
struct  comm_signal
 Structure only for signal events. More...
 
struct  http2_session
 HTTP2 session. More...
 
struct  http2_stream
 HTTP stream. More...
 
struct  doq_addr_storage
 DoQ socket address storage for IP4 or IP6 address. More...
 
struct  doq_server_socket
 The DoQ server socket information, for DNS over QUIC. More...
 
struct  doq_pkt_addr
 DoQ packet address information. More...
 

Macros

#define NETEVENT_NOERROR   0
 to pass no_error to callback function
 
#define NETEVENT_CLOSED   -1
 to pass closed connection to callback function
 
#define NETEVENT_TIMEOUT   -2
 to pass timeout happened to callback function
 
#define NETEVENT_CAPSFAIL   -3
 to pass fallback from capsforID to callback function; 0x20 failed
 
#define NETEVENT_DONE   -4
 to pass done transfer to callback function; http file is complete
 
#define NETEVENT_PKT_WRITTEN   -5
 to pass write of the write packet is done to callback function used when tcp_write_and_read is enabled
 
#define NETEVENT_SLOW_ACCEPT_TIME   2000
 timeout to slow accept calls when not possible, in msec.
 
#define SLOW_LOG_TIME   10
 timeout to slow down log print, so it does not spam the logs, in sec
 
#define DOQ_MAX_CIDLEN   24
 for doq, the maximum dcid length, in ngtcp2 it is 20.
 

Typedefs

typedef int comm_point_callback_type(struct comm_point *, void *, int, struct comm_reply *)
 callback from communication point function type
 

Enumerations

enum  http_status {
  HTTP_STATUS_OK = 200 , HTTP_STATUS_BAD_REQUEST = 400 , HTTP_STATUS_NOT_FOUND = 404 , HTTP_STATUS_PAYLOAD_TOO_LARGE = 413 ,
  HTTP_STATUS_URI_TOO_LONG = 414 , HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415 , HTTP_STATUS_NOT_IMPLEMENTED = 501
}
 enum of HTTP status
 

Functions

struct comm_basecomm_base_create (int sigs)
 Create a new comm base. More...
 
struct comm_basecomm_base_create_event (struct ub_event_base *base)
 Create comm base that uses the given ub_event_base (underlying pluggable event mechanism pointer). More...
 
void comm_base_delete_no_base (struct comm_base *b)
 Delete comm base structure but not the underlying lib event base. More...
 
void comm_base_delete (struct comm_base *b)
 Destroy a comm base. More...
 
void comm_base_timept (struct comm_base *b, time_t **tt, struct timeval **tv)
 Obtain two pointers. More...
 
void comm_base_dispatch (struct comm_base *b)
 Dispatch the comm base events. More...
 
void comm_base_exit (struct comm_base *b)
 Exit from dispatch loop. More...
 
void comm_base_set_slow_accept_handlers (struct comm_base *b, void(*stop_accept)(void *), void(*start_accept)(void *), void *arg)
 Set the slow_accept mode handlers. More...
 
struct ub_event_basecomm_base_internal (struct comm_base *b)
 Access internal data structure (for util/tube.c on windows) More...
 
struct comm_pointcomm_point_create_udp (struct comm_base *base, int fd, struct sldns_buffer *buffer, int pp2_enabled, comm_point_callback_type *callback, void *callback_arg, struct unbound_socket *socket)
 Create an UDP comm point. More...
 
struct comm_pointcomm_point_create_udp_ancil (struct comm_base *base, int fd, struct sldns_buffer *buffer, int pp2_enabled, comm_point_callback_type *callback, void *callback_arg, struct unbound_socket *socket)
 Create an UDP with ancillary data comm point. More...
 
struct comm_pointcomm_point_create_doq (struct comm_base *base, int fd, struct sldns_buffer *buffer, comm_point_callback_type *callback, void *callback_arg, struct unbound_socket *socket, struct doq_table *table, struct ub_randstate *rnd, const char *ssl_service_key, const char *ssl_service_pem, struct config_file *cfg)
 Create an UDP comm point for DoQ. More...
 
struct comm_pointcomm_point_create_tcp (struct comm_base *base, int fd, int num, int idle_timeout, int harden_large_queries, uint32_t http_max_streams, char *http_endpoint, struct tcl_list *tcp_conn_limit, size_t bufsize, struct sldns_buffer *spoolbuf, enum listen_type port_type, int pp2_enabled, comm_point_callback_type *callback, void *callback_arg, struct unbound_socket *socket)
 Create a TCP listener comm point. More...
 
struct comm_pointcomm_point_create_tcp_out (struct comm_base *base, size_t bufsize, comm_point_callback_type *callback, void *callback_arg)
 Create an outgoing TCP commpoint. More...
 
struct comm_pointcomm_point_create_http_out (struct comm_base *base, size_t bufsize, comm_point_callback_type *callback, void *callback_arg, struct sldns_buffer *temp)
 Create an outgoing HTTP commpoint. More...
 
struct comm_pointcomm_point_create_local (struct comm_base *base, int fd, size_t bufsize, comm_point_callback_type *callback, void *callback_arg)
 Create commpoint to listen to a local domain file descriptor. More...
 
struct comm_pointcomm_point_create_raw (struct comm_base *base, int fd, int writing, comm_point_callback_type *callback, void *callback_arg)
 Create commpoint to listen to a local domain pipe descriptor. More...
 
void comm_point_close (struct comm_point *c)
 Close a comm point fd. More...
 
void comm_point_delete (struct comm_point *c)
 Close and deallocate (free) the comm point. More...
 
void comm_point_send_reply (struct comm_reply *repinfo)
 Send reply. More...
 
void comm_point_drop_reply (struct comm_reply *repinfo)
 Drop reply. More...
 
int comm_point_send_udp_msg (struct comm_point *c, struct sldns_buffer *packet, struct sockaddr *addr, socklen_t addrlen, int is_connected)
 Send an udp message over a commpoint. More...
 
void comm_point_stop_listening (struct comm_point *c)
 Stop listening for input on the commpoint. More...
 
void comm_point_start_listening (struct comm_point *c, int newfd, int msec)
 Start listening again for input on the comm point. More...
 
void comm_point_listen_for_rw (struct comm_point *c, int rd, int wr)
 Stop listening and start listening again for reading or writing. More...
 
int adjusted_tcp_timeout (struct comm_point *c)
 For TCP handlers that use c->tcp_timeout_msec, this routine adjusts it with the minimum. More...
 
size_t comm_point_get_mem (struct comm_point *c)
 Get size of memory used by comm point. More...
 
struct comm_timercomm_timer_create (struct comm_base *base, void(*cb)(void *), void *cb_arg)
 create timer. More...
 
void comm_timer_disable (struct comm_timer *timer)
 disable timer. More...
 
void comm_timer_set (struct comm_timer *timer, struct timeval *tv)
 reset timevalue for timer. More...
 
void comm_timer_delete (struct comm_timer *timer)
 delete timer. More...
 
int comm_timer_is_set (struct comm_timer *timer)
 see if timeout has been set to a value. More...
 
size_t comm_timer_get_mem (struct comm_timer *timer)
 Get size of memory used by comm timer. More...
 
struct comm_signalcomm_signal_create (struct comm_base *base, void(*callback)(int, void *), void *cb_arg)
 Create a signal handler. More...
 
int comm_signal_bind (struct comm_signal *comsig, int sig)
 Bind signal struct to catch a signal. More...
 
void comm_signal_delete (struct comm_signal *comsig)
 Delete the signal communication point. More...
 
int comm_point_perform_accept (struct comm_point *c, struct sockaddr_storage *addr, socklen_t *addrlen)
 perform accept(2) with error checking. More...
 
void comm_point_udp_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_udp_ancil_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_doq_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_tcp_accept_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_tcp_handle_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_http_handle_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
struct http2_streamhttp2_stream_create (int32_t stream_id)
 Create new http2 stream. More...
 
void http2_session_add_stream (struct http2_session *h2_session, struct http2_stream *h2_stream)
 Add new stream to session linked list. More...
 
void http2_stream_add_meshstate (struct http2_stream *h2_stream, struct mesh_area *mesh, struct mesh_state *m)
 Add mesh state to stream. More...
 
void http2_stream_remove_mesh_state (struct http2_stream *h2_stream)
 Remove mesh state from stream. More...
 
void doq_pkt_addr_init (struct doq_pkt_addr *paddr)
 Initialize the pkt addr with lengths set to sizeof. More...
 
void doq_send_pkt (struct comm_point *c, struct doq_pkt_addr *paddr, uint32_t ecn)
 send doq packet over UDP.
 
void doq_timer_cb (void *arg)
 doq timer callback function.
 
void comm_timer_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_signal_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_local_handle_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_point_raw_handle_callback (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
void comm_base_handle_slow_accept (int fd, short event, void *arg)
 This routine is published for checks and tests, and is only used internally. More...
 
int tcp_connect_errno_needs_log (struct sockaddr *addr, socklen_t addrlen)
 See if errno for tcp connect has to be logged or not. More...
 

Detailed Description

This file contains event notification functions.

There are three types of communication points o UDP socket - perthread buffer. o TCP-accept socket - array of TCP-sockets, socketcount. o TCP socket - own buffer, parent-TCPaccept, read/write state, number of bytes read/written, timeout.

There are sockets aimed towards our clients and towards the internet. o frontside - aimed towards our clients, queries come in, answers back. o behind - aimed towards internet, to the authoritative DNS servers.

Several event types are available: o comm_base - for thread safety of the comm points, one per thread. o comm_point - udp and tcp networking, with callbacks. o comm_timer - a timeout with callback. o comm_signal - callbacks when signal is caught. o comm_reply - holds reply info during networking callback.

Function Documentation

◆ comm_base_create()

struct comm_base* comm_base_create ( int  sigs)

Create a new comm base.

Parameters
sigsif true it attempts to create a default loop for signal handling.
Returns
: the new comm base. NULL on error.

References internal_base::base, comm_base::eb, internal_base::now, internal_base::secs, ub_comm_base_now(), ub_default_event_base(), ub_get_event_sys(), VERB_ALGO, and verbose().

◆ comm_base_create_event()

struct comm_base* comm_base_create_event ( struct ub_event_base base)

Create comm base that uses the given ub_event_base (underlying pluggable event mechanism pointer).

Parameters
baseunderlying pluggable event base.
Returns
: the new comm base. NULL on error.

References internal_base::base, comm_base::eb, and ub_comm_base_now().

Referenced by libworker_setup().

◆ comm_base_delete_no_base()

void comm_base_delete_no_base ( struct comm_base b)

Delete comm base structure but not the underlying lib event base.

All comm points must have been deleted.

Parameters
bthe base to delete.

References internal_base::base, comm_base::eb, log_err(), internal_base::slow_accept, internal_base::slow_accept_enabled, ub_event_del(), and ub_event_free().

Referenced by libworker_delete_event().

◆ comm_base_delete()

◆ comm_base_timept()

void comm_base_timept ( struct comm_base b,
time_t **  tt,
struct timeval **  tv 
)

Obtain two pointers.

The pointers never change (until base_delete()). The pointers point to time values that are updated regularly.

Parameters
bthe communication base that will update the time values.
ttpointer to time in seconds is returned.
tvpointer to time in microseconds is returned.

References comm_base::eb, internal_base::now, replay_runtime::now_secs, replay_runtime::now_tv, and internal_base::secs.

Referenced by outside_network_create(), and ub_comm_base_now().

◆ comm_base_dispatch()

void comm_base_dispatch ( struct comm_base b)

Dispatch the comm base events.

Parameters
bthe communication to perform.

References internal_base::base, comm_base::eb, run_scenario(), replay_runtime::sig_cb, replay_runtime::sig_cb_arg, and ub_event_base_dispatch().

Referenced by libworker_dobg(), and worker_work().

◆ comm_base_exit()

void comm_base_exit ( struct comm_base b)

Exit from dispatch loop.

Parameters
bthe communication base that is in dispatch().

References internal_base::base, comm_base::eb, replay_runtime::exit_cleanly, log_err(), and ub_event_base_loopexit().

Referenced by do_reload(), do_stop(), libworker_do_cmd(), libworker_fg_done_cb(), and worker_sighandler().

◆ comm_base_set_slow_accept_handlers()

void comm_base_set_slow_accept_handlers ( struct comm_base b,
void(*)(void *)  stop_accept,
void(*)(void *)  start_accept,
void *  arg 
)

Set the slow_accept mode handlers.

You can not provide these if you do not perform accept() calls.

Parameters
bcomm base
stop_acceptfunction that stops listening to accept fds.
start_acceptfunction that resumes listening to accept fds.
argcallback arg to pass to the functions.

References comm_base::cb_arg, comm_base::start_accept, and comm_base::stop_accept.

◆ comm_base_internal()

struct ub_event_base* comm_base_internal ( struct comm_base b)

Access internal data structure (for util/tube.c on windows)

Parameters
bcomm base
Returns
ub_event_base.

References internal_base::base, and comm_base::eb.

◆ comm_point_create_udp()

struct comm_point* comm_point_create_udp ( struct comm_base base,
int  fd,
struct sldns_buffer buffer,
int  pp2_enabled,
comm_point_callback_type callback,
void *  callback_arg,
struct unbound_socket socket 
)

Create an UDP comm point.

Calls malloc. setups the structure with the parameters you provide.

Parameters
basein which base to alloc the commpoint.
fdfile descriptor of open UDP socket.
buffershared buffer by UDP sockets from this thread.
pp2_enabledif the comm point will support PROXYv2.
callbackcallback function pointer.
callback_argwill be passed to your callback function.
socketand opened socket properties will be passed to your callback function.
Returns
: returns the allocated communication point. NULL on error. Sets timeout to NULL. Turns off TCP options.

References internal_event::base, internal_base::base, comm_point::buffer, comm_point::callback, comm_point::cb_arg, comm_point_delete(), comm_point_udp_callback(), comm_point::cur_tcp_count, comm_point::do_not_close, comm_base::eb, internal_event::ev, comm_point::ev, comm_point::event_added, comm_point::fd, comm_point::inuse, log_err(), comm_point::max_tcp_count, comm_point::pp2_enabled, comm_point::pp2_header_state, comm_point::socket, comm_point::tcp_byte_count, comm_point::tcp_check_nb_connect, comm_point::tcp_do_close, comm_point::tcp_do_toggle_rw, comm_point::tcp_free, comm_point::tcp_handlers, comm_point::tcp_is_reading, comm_point::tcp_parent, comm_point::timeout, comm_point::type, UB_EV_PERSIST, UB_EV_READ, ub_event_add(), and ub_event_new().

◆ comm_point_create_udp_ancil()

struct comm_point* comm_point_create_udp_ancil ( struct comm_base base,
int  fd,
struct sldns_buffer buffer,
int  pp2_enabled,
comm_point_callback_type callback,
void *  callback_arg,
struct unbound_socket socket 
)

Create an UDP with ancillary data comm point.

Calls malloc. Uses recvmsg instead of recv to get udp message. setups the structure with the parameters you provide.

Parameters
basein which base to alloc the commpoint.
fdfile descriptor of open UDP socket.
buffershared buffer by UDP sockets from this thread.
pp2_enabledif the comm point will support PROXYv2.
callbackcallback function pointer.
callback_argwill be passed to your callback function.
socketand opened socket properties will be passed to your callback function.
Returns
: returns the allocated communication point. NULL on error. Sets timeout to NULL. Turns off TCP options.

◆ comm_point_create_doq()

struct comm_point* comm_point_create_doq ( struct comm_base base,
int  fd,
struct sldns_buffer buffer,
comm_point_callback_type callback,
void *  callback_arg,
struct unbound_socket socket,
struct doq_table *  table,
struct ub_randstate *  rnd,
const char *  ssl_service_key,
const char *  ssl_service_pem,
struct config_file cfg 
)

Create an UDP comm point for DoQ.

Calls malloc. setups the structure with the parameters you provide.

Parameters
basein which base to alloc the commpoint.
fd: file descriptor of open UDP socket.
buffershared buffer by UDP sockets from this thread.
callbackcallback function pointer.
callback_argwill be passed to your callback function.
socketand opened socket properties will be passed to your callback function.
tablethe doq connection table for the host.
rndrandom generator to use.
ssl_service_keythe ssl service key file.
ssl_service_pemthe ssl service pem file.
cfgconfig file struct.
Returns
: returns the allocated communication point. NULL on error. Sets timeout to NULL. Turns off TCP options.

References internal_event::base, internal_base::base, comm_point::buffer, comm_point::callback, comm_point::cb_arg, comm_point_delete(), comm_point_doq_callback(), comm_point::cur_tcp_count, comm_point::do_not_close, comm_base::eb, internal_event::ev, comm_point::ev, comm_point::event_added, comm_point::fd, comm_point::inuse, log_err(), comm_point::max_tcp_count, comm_point::pp2_enabled, comm_point::pp2_header_state, sock_close(), comm_point::socket, comm_point::tcp_byte_count, comm_point::tcp_check_nb_connect, comm_point::tcp_do_close, comm_point::tcp_do_toggle_rw, comm_point::tcp_free, comm_point::tcp_handlers, comm_point::tcp_is_reading, comm_point::tcp_parent, comm_point::timeout, comm_point::type, UB_EV_PERSIST, UB_EV_READ, ub_event_add(), and ub_event_new().

◆ comm_point_create_tcp()

struct comm_point* comm_point_create_tcp ( struct comm_base base,
int  fd,
int  num,
int  idle_timeout,
int  harden_large_queries,
uint32_t  http_max_streams,
char *  http_endpoint,
struct tcl_list tcp_conn_limit,
size_t  bufsize,
struct sldns_buffer spoolbuf,
enum listen_type  port_type,
int  pp2_enabled,
comm_point_callback_type callback,
void *  callback_arg,
struct unbound_socket socket 
)

Create a TCP listener comm point.

Calls malloc. Setups the structure with the parameters you provide. Also Creates TCP Handlers, pre allocated for you. Uses the parameters you provide.

Parameters
basein which base to alloc the commpoint.
fdfile descriptor of open TCP socket set to listen nonblocking.
numbecomes max_tcp_count, the routine allocates that many tcp handler commpoints.
idle_timeoutTCP idle timeout in ms.
harden_large_querieswhether query size should be limited.
http_max_streamsmaximum number of HTTP/2 streams per connection.
http_endpointHTTP endpoint to service queries on
tcp_conn_limitTCP connection limit info.
bufsizesize of buffer to create for handlers.
spoolbufshared spool buffer for tcp_req_info structures. or NULL to not create those structures in the tcp handlers.
port_typethe type of port we are creating a TCP listener for. Used to select handler type to use.
pp2_enabledif the comm point will support PROXYv2.
callbackcallback function pointer for TCP handlers.
callback_argwill be passed to your callback function.
socketand opened socket properties will be passed to your callback function.
Returns
: returns the TCP listener commpoint. You can find the TCP handlers in the array inside the listener commpoint. returns NULL on error. Inits timeout to NULL. All handlers are on the free list.

References internal_event::base, internal_base::base, comm_point::buffer, comm_point::callback, comm_point::cb_arg, comm_point_create_tcp_handler(), comm_point_delete(), comm_point_tcp_accept_callback(), comm_point::comm_tcp_accept, comm_point::cur_tcp_count, comm_point::do_not_close, comm_base::eb, internal_event::ev, comm_point::ev, comm_point::event_added, comm_point::fd, listen_type_http, listen_type_ssl, listen_type_tcp, listen_type_tcp_dnscrypt, log_err(), comm_point::max_tcp_count, comm_point::pp2_enabled, comm_point::pp2_header_none, comm_point::pp2_header_state, comm_point::socket, comm_point::tcl_addr, comm_point::tcp_byte_count, comm_point::tcp_check_nb_connect, comm_point::tcp_conn_limit, comm_point::tcp_do_close, comm_point::tcp_do_toggle_rw, comm_point::tcp_free, comm_point::tcp_handlers, comm_point::tcp_is_reading, comm_point::tcp_keepalive, comm_point::tcp_parent, comm_point::tcp_timeout_msec, comm_point::timeout, comm_point::type, UB_EV_PERSIST, UB_EV_READ, ub_event_add(), and ub_event_new().

◆ comm_point_create_tcp_out()

◆ comm_point_create_http_out()

struct comm_point* comm_point_create_http_out ( struct comm_base base,
size_t  bufsize,
comm_point_callback_type callback,
void *  callback_arg,
struct sldns_buffer temp 
)

◆ comm_point_create_local()

struct comm_point* comm_point_create_local ( struct comm_base base,
int  fd,
size_t  bufsize,
comm_point_callback_type callback,
void *  callback_arg 
)

Create commpoint to listen to a local domain file descriptor.

Parameters
basein which base to alloc the commpoint.
fdfile descriptor of open AF_UNIX socket set to listen nonblocking.
bufsizesize of buffer to create for handlers.
callbackcallback function pointer for the handler.
callback_argwill be passed to your callback function.
Returns
: the commpoint or NULL on error.

References internal_event::base, internal_base::base, comm_point::buffer, comm_point::callback, comm_point::cb_arg, comm_point_local_handle_callback(), comm_point::cur_tcp_count, comm_point::do_not_close, comm_base::eb, internal_event::ev, comm_point::ev, comm_point::event_added, comm_point::fd, log_err(), comm_point::max_tcp_count, comm_point::pp2_enabled, comm_point::pp2_header_state, sldns_buffer_new(), comm_point::tcp_byte_count, comm_point::tcp_check_nb_connect, comm_point::tcp_do_close, comm_point::tcp_do_toggle_rw, comm_point::tcp_free, comm_point::tcp_handlers, comm_point::tcp_is_reading, comm_point::tcp_parent, comm_point::timeout, comm_point::type, UB_EV_PERSIST, UB_EV_READ, ub_event_add(), ub_event_free(), and ub_event_new().

◆ comm_point_create_raw()

struct comm_point* comm_point_create_raw ( struct comm_base base,
int  fd,
int  writing,
comm_point_callback_type callback,
void *  callback_arg 
)

◆ comm_point_close()

◆ comm_point_delete()

◆ comm_point_send_reply()

void comm_point_send_reply ( struct comm_reply repinfo)

Send reply.

Put message into commpoint buffer.

Parameters
repinfoThe reply info copied from a commpoint callback call.

References replay_runtime::answer_last, replay_runtime::answer_list, comm_point::buffer, comm_reply::c, comm_point::ev, log_assert, log_info(), memdup(), replay_answer::next, replay_answer::pkt, replay_answer::repinfo, sldns_buffer_begin(), and sldns_buffer_limit().

Referenced by reply_and_prefetch().

◆ comm_point_drop_reply()

◆ comm_point_send_udp_msg()

int comm_point_send_udp_msg ( struct comm_point c,
struct sldns_buffer packet,
struct sockaddr *  addr,
socklen_t  addrlen,
int  is_connected 
)

Send an udp message over a commpoint.

Parameters
ccommpoint to send it from.
packetwhat to send.
addrwhere to send it to. If NULL, send is performed, for connected sockets, to the connected address.
addrlenlength of addr.
is_connectedif the UDP socket is connect()ed.
Returns
: false on a failure.

References internal_event::base, comm_base::eb, comm_point::ev, comm_point::fd, internal_base::last_writewait_log, log_addr(), log_assert, log_err(), internal_base::secs, SEND_BLOCKED_MAX_RETRY, SEND_BLOCKED_WAIT_TIMEOUT, sldns_buffer_begin(), sldns_buffer_remaining(), SLOW_LOG_TIME, sock_strerror(), udp_send_errno_needs_log(), VERB_OPS, and verbose().

Referenced by comm_point_udp_callback().

◆ comm_point_stop_listening()

void comm_point_stop_listening ( struct comm_point c)

Stop listening for input on the commpoint.

No callbacks will happen.

Parameters
ccommpoint to disable. The fd is not closed.

References internal_event::ev, comm_point::ev, comm_point::event_added, comm_point::fd, log_err(), ub_event_del(), VERB_ALGO, and verbose().

Referenced by comm_point_http_handle_write(), comm_point_tcp_accept_callback(), tcp_callback_reader(), and tcp_callback_writer().

◆ comm_point_start_listening()

void comm_point_start_listening ( struct comm_point c,
int  newfd,
int  msec 
)

◆ comm_point_listen_for_rw()

void comm_point_listen_for_rw ( struct comm_point c,
int  rd,
int  wr 
)

Stop listening and start listening again for reading or writing.

Parameters
ccommpoint
rdif true, listens for reading.
wrif true, listens for writing.

References internal_event::ev, comm_point::ev, comm_point::event_added, comm_point::fd, log_err(), comm_point::timeout, UB_EV_READ, UB_EV_TIMEOUT, UB_EV_WRITE, ub_event_add(), ub_event_add_bits(), ub_event_del(), ub_event_del_bits(), VERB_ALGO, and verbose().

Referenced by remote_handshake_later(), ssl_handle_read(), ssl_handle_write(), ssl_http_read_more(), and ssl_http_write_more().

◆ adjusted_tcp_timeout()

int adjusted_tcp_timeout ( struct comm_point c)

For TCP handlers that use c->tcp_timeout_msec, this routine adjusts it with the minimum.

Otherwise, a 0 value advertised without the minimum applied moves to a 0 in comm_point_start_listening and that routine treats it as no timeout, listen forever, which is not wanted.

Parameters
ccomm point to use the tcp_timeout_msec of.
Returns
adjusted tcp_timeout_msec value with the minimum if smaller.

References TCP_QUERY_TIMEOUT_MINIMUM, and comm_point::tcp_timeout_msec.

Referenced by setup_tcp_handler(), tcp_callback_reader(), and tcp_callback_writer().

◆ comm_point_get_mem()

size_t comm_point_get_mem ( struct comm_point c)

Get size of memory used by comm point.

For TCP handlers this includes subhandlers. For UDP handlers, this does not include the (shared) UDP buffer.

Parameters
ccommpoint.
Returns
size in bytes.

References comm_point::buffer, comm_point::ev, comm_point::max_tcp_count, sldns_buffer_capacity(), comm_point::tcp_handlers, comm_point::timeout, and comm_point::type.

◆ comm_timer_create()

struct comm_timer* comm_timer_create ( struct comm_base base,
void(*)(void *)  cb,
void *  cb_arg 
)

create timer.

Not active upon creation.

Parameters
baseevent handling base.
cbcallback function: void myfunc(void* myarg);
cb_arguser callback argument.
Returns
: the new timer or NULL on error.

References internal_base::base, internal_timer::base, comm_timer::callback, comm_timer::cb_arg, comm_timer_callback(), comm_base::eb, internal_timer::ev, comm_timer::ev_timer, log_err(), internal_timer::super, UB_EV_TIMEOUT, and ub_event_new().

Referenced by dt_msg_queue_create(), mesh_serve_expired_init(), pending_tcp_query(), pending_udp_query(), serviced_create(), validate_suspend_setup_timer(), xfr_probe_send_probe(), and xfr_transfer_init_fetch().

◆ comm_timer_disable()

void comm_timer_disable ( struct comm_timer timer)

◆ comm_timer_set()

◆ comm_timer_delete()

◆ comm_timer_is_set()

int comm_timer_is_set ( struct comm_timer timer)

see if timeout has been set to a value.

Parameters
timerthe timer to examine.
Returns
: false if disabled or not set.

References fake_timer::enabled, internal_timer::enabled, and comm_timer::ev_timer.

Referenced by dt_msg_queue_start_timer().

◆ comm_timer_get_mem()

size_t comm_timer_get_mem ( struct comm_timer timer)

Get size of memory used by comm timer.

Parameters
timerthe timer to examine.
Returns
size in bytes.

Referenced by serviced_get_mem(), waiting_tcp_get_mem(), and waiting_udp_get_mem().

◆ comm_signal_create()

struct comm_signal* comm_signal_create ( struct comm_base base,
void(*)(int, void *)  callback,
void *  cb_arg 
)

Create a signal handler.

Call signal_bind() later to bind to a signal.

Parameters
basecommunication base to use.
callbackcalled when signal is caught.
cb_arguser argument to callback
Returns
: the signal struct or NULL on error.

References comm_signal::base, comm_signal::callback, replay_runtime::cb_arg, comm_signal::cb_arg, comm_signal::ev_signal, log_err(), replay_runtime::sig_cb, and replay_runtime::sig_cb_arg.

◆ comm_signal_bind()

int comm_signal_bind ( struct comm_signal comsig,
int  sig 
)

Bind signal struct to catch a signal.

A single comm_signal can be bound to multiple signals, calling comm_signal_bind multiple times.

Parameters
comsigthe communication point, with callback information.
sigsignal number.
Returns
: true on success. false on error.

References internal_base::base, comm_signal::base, comm_signal_callback(), comm_base::eb, comm_signal::ev_signal, log_assert, log_err(), entry::next, ub_event_free(), ub_signal_add(), and ub_signal_new().

◆ comm_signal_delete()

void comm_signal_delete ( struct comm_signal comsig)

Delete the signal communication point.

Parameters
comsigto delete.

References internal_signal::ev, comm_signal::ev_signal, internal_signal::next, ub_event_free(), and ub_signal_del().

Referenced by worker_delete().

◆ comm_point_perform_accept()

int comm_point_perform_accept ( struct comm_point c,
struct sockaddr_storage *  addr,
socklen_t *  addrlen 
)

◆ comm_point_udp_callback()

◆ comm_point_udp_ancil_callback()

void comm_point_udp_ancil_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

handle libevent callback for udp ancillary data comm point.

Parameters
fdfile descriptor.
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_point structure.

◆ comm_point_doq_callback()

void comm_point_doq_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

handle libevent callback for doq comm point.

Parameters
fdfile descriptor.
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_point structure.

Referenced by comm_point_create_doq().

◆ comm_point_tcp_accept_callback()

◆ comm_point_tcp_handle_callback()

◆ comm_point_http_handle_callback()

void comm_point_http_handle_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

handle libevent callback for tcp data comm point

Parameters
fdfile descriptor.
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_point structure.

References internal_event::base, comm_point::callback, comm_point::cb_arg, comm_point::comm_http, comm_point_http_handle_read(), comm_point_http_handle_write(), comm_point::ev, comm_point::fd, fptr_ok, fptr_whitelist_comm_point(), log_assert, log_err(), NETEVENT_CLOSED, NETEVENT_TIMEOUT, reclaim_http_handler(), comm_point::tcp_do_close, comm_point::type, ub_comm_base_now(), UB_EV_READ, UB_EV_TIMEOUT, UB_EV_WRITE, VERB_QUERY, and verbose().

Referenced by comm_point_create_http_out(), and comm_point_tcp_accept_callback().

◆ http2_stream_create()

struct http2_stream* http2_stream_create ( int32_t  stream_id)

Create new http2 stream.

Parameters
stream_idID for stream to create.
Returns
malloc'ed stream, NULL on error

◆ http2_session_add_stream()

void http2_session_add_stream ( struct http2_session h2_session,
struct http2_stream h2_stream 
)

Add new stream to session linked list.

Parameters
h2_sessionhttp2 session to add stream to
h2_streamstream to add to session list

◆ http2_stream_add_meshstate()

void http2_stream_add_meshstate ( struct http2_stream h2_stream,
struct mesh_area mesh,
struct mesh_state m 
)

Add mesh state to stream.

To be able to remove mesh reply on stream closure

References http2_stream::mesh, and http2_stream::mesh_state.

◆ http2_stream_remove_mesh_state()

void http2_stream_remove_mesh_state ( struct http2_stream h2_stream)

Remove mesh state from stream.

When the mesh state has been removed.

References http2_stream::mesh_state.

◆ doq_pkt_addr_init()

void doq_pkt_addr_init ( struct doq_pkt_addr paddr)

Initialize the pkt addr with lengths set to sizeof.

That is ready for a call to recv.

◆ comm_timer_callback()

void comm_timer_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

handle libevent callback for timer comm.

Parameters
fdfile descriptor (always -1).
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_timer structure.

Referenced by comm_timer_create(), and comm_timer_set().

◆ comm_signal_callback()

void comm_signal_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

handle libevent callback for signal comm.

Parameters
fdfile descriptor (used for the signal number).
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe internal commsignal structure.

References comm_signal::base, comm_signal::callback, comm_signal::cb_arg, fptr_ok, fptr_whitelist_comm_signal(), ub_comm_base_now(), and UB_EV_SIGNAL.

Referenced by comm_signal_bind().

◆ comm_point_local_handle_callback()

void comm_point_local_handle_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

libevent callback for AF_UNIX fds

Parameters
fdfile descriptor.
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_point structure.

References internal_event::base, comm_point::callback, comm_point::cb_arg, comm_point::comm_local, comm_point_tcp_handle_read(), comm_point::ev, comm_point::fd, fptr_ok, fptr_whitelist_comm_point(), log_assert, log_err(), NETEVENT_CLOSED, comm_point::type, ub_comm_base_now(), and UB_EV_READ.

Referenced by comm_point_create_local().

◆ comm_point_raw_handle_callback()

void comm_point_raw_handle_callback ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

libevent callback for raw fd access.

Parameters
fdfile descriptor.
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_point structure.

Referenced by comm_point_create_raw().

◆ comm_base_handle_slow_accept()

void comm_base_handle_slow_accept ( int  fd,
short  event,
void *  arg 
)

This routine is published for checks and tests, and is only used internally.

libevent callback for timeout on slow accept.

Parameters
fdfile descriptor.
eventevent bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT.
argthe comm_point structure.

Referenced by comm_point_perform_accept().

◆ tcp_connect_errno_needs_log()

int tcp_connect_errno_needs_log ( struct sockaddr *  addr,
socklen_t  addrlen 
)

See if errno for tcp connect has to be logged or not.

This uses errno

Parameters
addrapart from checking errno, the addr is checked for ip4mapped and broadcast type, hence passed.
addrlenlength of the addr parameter.
Returns
true if it needs to be logged.

References udp_send_errno_needs_log().

Referenced by comm_point_tcp_handle_write().