unbound 0.1
|
Event service that replays a scenario. More...
#include "config.h"
#include "testcode/fake_event.h"
#include "util/netevent.h"
#include "util/net_help.h"
#include "util/data/msgparse.h"
#include "util/data/msgreply.h"
#include "util/data/msgencode.h"
#include "util/config_file.h"
#include "services/listen_dnsport.h"
#include "services/outside_network.h"
#include "services/cache/infra.h"
#include "testcode/replay.h"
#include "testcode/ldns-testpkts.h"
#include "util/log.h"
#include "util/fptr_wlist.h"
#include <signal.h>
Functions | |
static void | timeval_add (struct timeval *d, const struct timeval *add) |
add timers and the values do not overflow or become negative | |
void | fake_temp_file (const char *adj, const char *id, char *buf, size_t len) |
Get filename to store temporary config stuff. | |
void | fake_event_init (struct replay_scenario *scen) |
Initialise fake event services. | |
void | fake_event_cleanup (void) |
Deinit fake event services. | |
static void | log_pkt (const char *desc, ldns_pkt *pkt) |
helper function that logs a ldns_pkt packet to logfile | |
static const char * | repevt_string (enum replay_event_type t) |
Returns a string describing the event type. | |
static void | delete_fake_pending (struct fake_pending *pend) |
delete a fake pending | |
static void | delete_replay_answer (struct replay_answer *a) |
delete a replay answer | |
static int | pending_matches_current (struct replay_runtime *runtime, struct entry **entry, struct fake_pending **pend) |
return: true if pending query matches the now event. | |
static int | pending_find_match (struct replay_runtime *runtime, struct entry **entry, struct fake_pending *pend) |
Find the range that matches this pending message. | |
static int | pending_matches_range (struct replay_runtime *runtime, struct entry **entry, struct fake_pending **pend) |
See if outgoing pending query matches an entry. | |
static void | pending_list_delete (struct replay_runtime *runtime, struct fake_pending *pend) |
Remove the item from the pending list. | |
static void | fill_buffer_with_reply (ldns_buffer *buffer, struct entry *entry, ldns_pkt *q) |
Fill buffer with reply from the entry. | |
static void | answer_callback_from_entry (struct replay_runtime *runtime, struct entry *entry, struct fake_pending *pend) |
Perform range entry on pending message. | |
static void | answer_check_it (struct replay_runtime *runtime) |
Check the now moment answer check event. | |
static void | fake_front_query (struct replay_runtime *runtime, struct replay_moment *todo) |
Create commpoint (as return address) for a fake incoming query. | |
static void | fake_pending_callback (struct replay_runtime *runtime, struct replay_moment *todo, int error) |
Perform callback for fake pending message. | |
static void | moment_assign (struct replay_runtime *runtime, struct replay_moment *mom) |
pass time | |
static void | time_passes (struct replay_runtime *runtime, struct replay_moment *mom) |
pass time | |
static void | autotrust_check (struct replay_runtime *runtime, struct replay_moment *mom) |
check autotrust file contents | |
static void | do_infra_rtt (struct replay_runtime *runtime) |
Store RTT in infra cache. | |
static void | advance_moment (struct replay_runtime *runtime) |
Advance to the next moment. | |
static void | do_moment_and_advance (struct replay_runtime *runtime) |
Perform actions or checks determined by the moment. | |
static void | run_scenario (struct replay_runtime *runtime) |
run the scenario in event callbacks | |
struct listen_dnsport * | listen_create (struct comm_base *base, struct listen_port *ports, size_t bufsize, int tcp_accept_count, comm_point_callback_t *cb, void *cb_arg) |
Create commpoints with for this thread for the shared ports. | |
void | listen_delete (struct listen_dnsport *listen) |
delete the listening structure | |
struct comm_base * | comm_base_create (int sigs) |
Create a new comm base. | |
void | comm_base_delete (struct comm_base *b) |
Destroy a comm base. | |
void | comm_base_timept (struct comm_base *b, uint32_t **tt, struct timeval **tv) |
Obtain two pointers. | |
void | comm_base_dispatch (struct comm_base *b) |
Dispatch the comm base events. | |
void | comm_base_exit (struct comm_base *b) |
Exit from dispatch loop. | |
struct comm_signal * | comm_signal_create (struct comm_base *base, void(*callback)(int, void *), void *cb_arg) |
Create a signal handler. | |
int | comm_signal_bind (struct comm_signal *comsig, int sig) |
Bind signal struct to catch a signal. | |
void | comm_signal_delete (struct comm_signal *comsig) |
Delete the signal communication point. | |
void | comm_point_send_reply (struct comm_reply *repinfo) |
Send reply. | |
void | comm_point_drop_reply (struct comm_reply *repinfo) |
Drop reply. | |
struct outside_network * | outside_network_create (struct comm_base *base, size_t bufsize, size_t num_ports, char **ifs, int num_ifs, int do_ip4, int do_ip6, size_t num_tcp, struct infra_cache *infra, struct ub_randstate *rnd, int use_caps_for_id, int *availports, int numavailports, size_t unwanted_threshold, void(*unwanted_action)(void *), void *unwanted_param, int do_udp) |
Create outside_network structure with N udp ports. | |
void | outside_network_delete (struct outside_network *outnet) |
Delete outside_network structure. | |
void | outside_network_quit_prepare (struct outside_network *outnet) |
Prepare for quit. | |
struct pending * | pending_udp_query (struct outside_network *outnet, ldns_buffer *packet, struct sockaddr_storage *addr, socklen_t addrlen, int timeout, comm_point_callback_t *callback, void *callback_arg) |
Send UDP query, create pending answer. | |
struct waiting_tcp * | pending_tcp_query (struct outside_network *outnet, ldns_buffer *packet, struct sockaddr_storage *addr, socklen_t addrlen, int timeout, comm_point_callback_t *callback, void *callback_arg) |
Send TCP query. | |
struct serviced_query * | outnet_serviced_query (struct outside_network *outnet, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, int want_dnssec, struct sockaddr_storage *addr, socklen_t addrlen, comm_point_callback_t *callback, void *callback_arg, ldns_buffer *buff, int(*arg_compare)(void *, void *)) |
Perform a serviced query to the authoritative servers. | |
void | outnet_serviced_query_stop (struct serviced_query *sq, void *cb_arg) |
Remove service query callback. | |
struct listen_port * | listening_ports_open (struct config_file *cfg) |
Create shared listening ports Getaddrinfo, create socket, bind and listen to zero or more interfaces for IP4 and/or IP6, for UDP and/or TCP. | |
void | listening_ports_free (struct listen_port *list) |
Close and delete the (list of) listening ports. | |
struct comm_point * | comm_point_create_local (struct comm_base *base, int fd, size_t bufsize, comm_point_callback_t *callback, void *callback_arg) |
Create commpoint to listen to a local domain file descriptor. | |
struct comm_point * | comm_point_create_raw (struct comm_base *base, int fd, int writing, comm_point_callback_t *callback, void *callback_arg) |
Create commpoint to listen to a local domain pipe descriptor. | |
void | comm_point_start_listening (struct comm_point *c, int newfd, int sec) |
Start listening again for input on the comm point. | |
void | comm_point_stop_listening (struct comm_point *c) |
Stop listening for input on the commpoint. | |
void | comm_point_delete (struct comm_point *c) |
Close and deallocate (free) the comm point. | |
size_t | listen_get_mem (struct listen_dnsport *listen) |
get memory size used by the listening structs | |
size_t | outnet_get_mem (struct outside_network *outnet) |
Get memory size in use by outside network. | |
size_t | comm_point_get_mem (struct comm_point *c) |
Get size of memory used by comm point. | |
size_t | serviced_get_mem (struct serviced_query *c) |
Get memory size in use by serviced query while it is servicing callbacks. | |
int | outnet_udp_cb (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
callback for incoming udp answers from the network | |
int | outnet_tcp_cb (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
callback for pending tcp connections | |
void | pending_udp_timer_cb (void *arg) |
callback for udp timeout | |
void | outnet_tcptimer (void *arg) |
callback for outgoing TCP timer event | |
void | comm_point_udp_callback (int fd, short event, void *arg) |
This routine is published for checks and tests, and is only used internally. | |
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. | |
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. | |
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. | |
void | comm_timer_callback (int fd, short event, void *arg) |
This routine is published for checks and tests, and is only used internally. | |
void | comm_signal_callback (int fd, short event, void *arg) |
This routine is published for checks and tests, and is only used internally. | |
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. | |
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. | |
int | serviced_udp_callback (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
callback for serviced query UDP answers | |
int | serviced_tcp_callback (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
TCP reply or error callback for serviced queries. | |
int | pending_cmp (const void *a, const void *b) |
compare function of pending rbtree | |
int | serviced_cmp (const void *a, const void *b) |
compare function of serviced query rbtree | |
struct comm_timer * | comm_timer_create (struct comm_base *base, void(*cb)(void *), void *cb_arg) |
create timer. | |
void | comm_timer_disable (struct comm_timer *timer) |
disable timer. | |
void | comm_timer_set (struct comm_timer *timer, struct timeval *tv) |
reset timevalue for timer. | |
void | comm_timer_delete (struct comm_timer *timer) |
delete timer. | |
struct event_base * | comm_base_internal (struct comm_base *b) |
Access internal data structure (for util/tube.c on windows) | |
void | daemon_remote_exec (struct worker *worker) |
Handle nonthreaded remote cmd execution. | |
Variables | |
static struct replay_scenario * | saved_scenario = NULL |
Global variable: the scenario. |
Event service that replays a scenario.
This implements the same exported symbols as the files: util/netevent.c services/listen_dnsport.c services/outside_network.c But these do not actually access the network or events, instead the scenario is played.
void fake_temp_file | ( | const char * | adj, |
const char * | id, | ||
char * | buf, | ||
size_t | len | ||
) |
Get filename to store temporary config stuff.
The pid is added. in /tmp.
adj,: | adjective, like "_cfg_", "_auto_" |
id,: | identifier, like "example.com". |
buf,: | where to store. |
len,: | length of buf. |
Referenced by autotrust_check(), setup_config(), and spool_auto_file().
void fake_event_init | ( | struct replay_scenario * | scen | ) |
Initialise fake event services.
The fake event services will automatically start when the main program calls netevent.h functions, such as comm_base_dispatch().
scen,: | Set the scenario to use for upcoming event handling. |
Referenced by main().
static int pending_find_match | ( | struct replay_runtime * | runtime, |
struct entry ** | entry, | ||
struct fake_pending * | pend | ||
) | [static] |
Find the range that matches this pending message.
runtime,: | runtime with current moment, and range list. |
entry,: | returns the pointer to entry that matches. |
pend,: | the pending that the entry must match. |
References fake_pending::addr, replay_range::addr, fake_pending::addrlen, replay_range::addrlen, replay_range::end_step, find_match(), log_addr(), log_info(), log_pkt(), replay_range::match, replay_range::next_range, replay_runtime::now, fake_pending::pkt, replay_scenario::range_list, replay_runtime::scenario, sockaddr_cmp(), replay_range::start_step, replay_moment::time_step, and fake_pending::transport.
Referenced by pending_matches_range().
static int pending_matches_range | ( | struct replay_runtime * | runtime, |
struct entry ** | entry, | ||
struct fake_pending ** | pend | ||
) | [static] |
See if outgoing pending query matches an entry.
runtime,: | runtime. |
entry,: | if true, the entry that matches is returned. |
pend,: | if true, the outgoing message that matches is returned. |
References log_info(), fake_pending::next, pending_find_match(), and replay_runtime::pending_list.
Referenced by run_scenario().
static void answer_callback_from_entry | ( | struct replay_runtime * | runtime, |
struct entry * | entry, | ||
struct fake_pending * | pend | ||
) | [static] |
Perform range entry on pending message.
runtime,: | runtime buffer size preference. |
entry,: | entry that codes for the reply to do. |
pend,: | pending query that is answered, callback called. |
References fake_pending::addr, comm_reply::addr, fake_pending::addrlen, comm_reply::addrlen, comm_point::buffer, replay_runtime::bufsize, comm_reply::c, fake_pending::callback, fake_pending::cb_arg, fatal_exit(), comm_point::fd, fill_buffer_with_reply(), NETEVENT_NOERROR, pending_list_delete(), fake_pending::pkt, fake_pending::serviced, fake_pending::transport, and comm_point::type.
Referenced by run_scenario().
static void do_moment_and_advance | ( | struct replay_runtime * | runtime | ) | [static] |
Perform actions or checks determined by the moment.
Also advances the time by one step.
runtime,: | scenario runtime information. |
References advance_moment(), replay_runtime::answer_list, autotrust_check(), do_infra_rtt(), replay_moment::evt_type, fake_front_query(), fake_pending_callback(), fatal_exit(), log_err(), log_info(), moment_assign(), NETEVENT_CLOSED, NETEVENT_NOERROR, NETEVENT_TIMEOUT, replay_runtime::now, replay_moment::repevt_assign, replay_moment::repevt_autotrust_check, replay_moment::repevt_back_query, replay_moment::repevt_back_reply, replay_moment::repevt_error, replay_moment::repevt_front_query, replay_moment::repevt_front_reply, replay_moment::repevt_infra_rtt, replay_moment::repevt_nothing, repevt_string(), replay_moment::repevt_time_passes, replay_moment::repevt_timeout, replay_moment::repevt_traffic, time_passes(), and replay_moment::time_step.
Referenced by run_scenario().
struct listen_dnsport* listen_create | ( | struct comm_base * | base, |
struct listen_port * | ports, | ||
size_t | bufsize, | ||
int | tcp_accept_count, | ||
comm_point_callback_t * | cb, | ||
void * | cb_arg | ||
) | [read] |
Create commpoints with for this thread for the shared ports.
base,: | the comm_base that provides event functionality. for default all ifs. |
ports,: | the list of shared ports. |
bufsize,: | size of datagram buffer. |
tcp_accept_count,: | max number of simultaneous TCP connections from clients. |
cb,: | callback function when a request arrives. It is passed the packet and user argument. Return true to send a reply. |
cb_arg,: | user data argument for callback function. |
References listen_dnsport::base, replay_runtime::bufsize, replay_runtime::callback_query, replay_runtime::cb_arg, comm_point_create_tcp(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), listen_dnsport::cps, comm_point::do_not_close, listen_port::fd, listen_port::ftype, listen_cp_insert(), listen_delete(), listen_type_tcp, listen_type_udp, listen_type_udpancil, log_err(), listen_port::next, and listen_dnsport::udp_buff.
void listen_delete | ( | struct listen_dnsport * | listen | ) |
delete the listening structure
listen,: | listening structure. |
References listen_dnsport::cps, listen_list_delete(), and listen_dnsport::udp_buff.
struct comm_base* comm_base_create | ( | int | sigs | ) | [read] |
Create a new comm base.
sigs,: | if true it attempts to create a default loop for signal handling. |
Referenced by libworker_setup(), and worker_init().
void comm_base_delete | ( | struct comm_base * | b | ) |
Destroy a comm base.
All comm points must have been deleted.
b,: | the base to delete. |
Referenced by libworker_delete(), and worker_delete().
void comm_base_timept | ( | struct comm_base * | b, |
uint32_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.
b,: | the communication base that will update the time values. |
tt,: | pointer to time in seconds is returned. |
tv,: | pointer to time in microseconds is returned. |
Referenced by libworker_setup(), outside_network_create(), and worker_init().
void comm_base_dispatch | ( | struct comm_base * | b | ) |
Dispatch the comm base events.
b,: | the communication to perform. |
Referenced by libworker_dobg(), libworker_fg(), and worker_work().
void comm_base_exit | ( | struct comm_base * | b | ) |
Exit from dispatch loop.
b,: | the communication base that is in dispatch(). |
Referenced by do_reload(), do_stop(), libworker_do_cmd(), libworker_fg_done_cb(), libworker_handle_control_cmd(), worker_handle_control_cmd(), worker_sighandler(), and worker_win_stop_cb().
struct comm_signal* comm_signal_create | ( | struct comm_base * | base, |
void(*)(int, void *) | callback, | ||
void * | cb_arg | ||
) | [read] |
Create a signal handler.
Call signal_bind() later to bind to a signal.
base,: | communication base to use. |
callback,: | called when signal is caught. |
cb_arg,: | user argument to callback |
Referenced by worker_init().
int comm_signal_bind | ( | struct comm_signal * | comsig, |
int | sig | ||
) |
Bind signal struct to catch a signal.
A signle comm_signal can be bound to multiple signals, calling comm_signal_bind multiple times.
comsig,: | the communication point, with callback information. |
sig,: | signal number. |
Referenced by worker_init().
void comm_signal_delete | ( | struct comm_signal * | comsig | ) |
Delete the signal communication point.
comsig,: | to delete. |
Referenced by worker_delete().
void comm_point_send_reply | ( | struct comm_reply * | repinfo | ) |
Send reply.
Put message into commpoint buffer.
repinfo,: | The reply info copied from a commpoint callback call. |
Referenced by fake_front_query(), mesh_new_client(), mesh_send_reply(), and reply_and_prefetch().
void comm_point_drop_reply | ( | struct comm_reply * | repinfo | ) |
Drop reply.
Cleans up.
repinfo,: | The reply info copied from a commpoint callback call. |
Referenced by mesh_new_client(), mesh_state_cleanup(), and worker_handle_request().
struct outside_network* outside_network_create | ( | struct comm_base * | base, |
size_t | bufsize, | ||
size_t | num_ports, | ||
char ** | ifs, | ||
int | num_ifs, | ||
int | do_ip4, | ||
int | do_ip6, | ||
size_t | num_tcp, | ||
struct infra_cache * | infra, | ||
struct ub_randstate * | rnd, | ||
int | use_caps_for_id, | ||
int * | availports, | ||
int | numavailports, | ||
size_t | unwanted_threshold, | ||
void(*)(void *) | unwanted_action, | ||
void * | unwanted_param, | ||
int | do_udp | ||
) | [read] |
Create outside_network structure with N udp ports.
base,: | the communication base to use for event handling. |
bufsize,: | size for network buffers. |
num_ports,: | number of udp ports to open per interface. |
ifs,: | interface names (or NULL for default interface). These interfaces must be able to access all authoritative servers. |
num_ifs,: | number of names in array ifs. |
do_ip4,: | service IP4. |
do_ip6,: | service IP6. |
num_tcp,: | number of outgoing tcp buffers to preallocate. |
infra,: | pointer to infra cached used for serviced queries. |
rnd,: | stored to create random numbers for serviced queries. |
use_caps_for_id,: | enable to use 0x20 bits to encode id randomness. |
availports,: | array of available ports. |
numavailports,: | number of available ports in array. |
unwanted_threshold,: | when to take defensive action. |
unwanted_action,: | the action to take. |
unwanted_param,: | user parameter to action. |
do_udp,: | if udp is done. |
References outside_network::base, calc_num46(), comm_base_timept(), comm_point_create_udp(), port_comm::cp, create_pending_tcp(), outside_network::do_udp, replay_runtime::infra, outside_network::infra, outside_network::ip4_ifs, outside_network::ip6_ifs, log_err(), port_comm::next, outside_network::now_secs, outside_network::now_tv, outside_network::num_ip4, outside_network::num_ip6, outside_network::num_tcp, outnet_udp_cb(), outside_network_delete(), outside_network::pending, pending_cmp(), rbtree_create(), outside_network::rnd, outside_network::serviced, serviced_cmp(), setup_if(), str_is_ip6(), outside_network::svcd_overhead, outside_network::udp_buff, outside_network::unused_fds, outside_network::unwanted_action, outside_network::unwanted_param, outside_network::unwanted_threshold, outside_network::use_caps_for_id, and outside_network::want_to_quit.
void outside_network_delete | ( | struct outside_network * | outnet | ) |
Delete outside_network structure.
outnet,: | object to delete. |
References port_if::avail_ports, pending_tcp::c, comm_point_delete(), port_comm::cp, port_if::inuse, outside_network::ip4_ifs, outside_network::ip6_ifs, port_comm::next, pending::next_waiting, waiting_tcp::next_waiting, outside_network::num_ip4, outside_network::num_ip6, outside_network::num_tcp, port_if::out, outside_network::pending, pending_delete(), pending_node_del(), pending_tcp::query, outside_network::serviced, serviced_node_del(), outside_network::tcp_conns, outside_network::tcp_wait_first, traverse_postorder(), outside_network::udp_buff, outside_network::udp_wait_first, outside_network::unused_fds, waiting_tcp_delete(), and outside_network::want_to_quit.
void outside_network_quit_prepare | ( | struct outside_network * | outnet | ) |
Prepare for quit.
Sends no more queries, even if queued up.
outnet,: | object to prepare for removal |
References outside_network::want_to_quit.
struct pending* pending_udp_query | ( | struct outside_network * | outnet, |
ldns_buffer * | packet, | ||
struct sockaddr_storage * | addr, | ||
socklen_t | addrlen, | ||
int | timeout, | ||
comm_point_callback_t * | callback, | ||
void * | callback_arg | ||
) | [read] |
Send UDP query, create pending answer.
Changes the ID for the query to be random and unique for that destination.
outnet,: | provides the event handling |
packet,: | wireformat query to send to destination. |
addr,: | address to send to. |
addrlen,: | length of addr. |
timeout,: | in milliseconds from now. |
callback,: | function to call on error, timeout or reply. |
callback_arg,: | user argument for callback function. |
References replay_moment::addr, pending::addr, replay_moment::addrlen, pending::addrlen, advance_moment(), outside_network::base, pending::cb, pending::cb_arg, comm_timer_create(), comm_timer_delete(), replay_moment::evt_type, fatal_exit(), find_match(), rbnode_t::key, log_assert, log_err(), log_info(), log_pkt(), replay_moment::match, memdup(), pending::next_waiting, pending::node, replay_runtime::now, pending::outnet, pending_delete(), replay_runtime::pending_list, pending_udp_timer_cb(), pending::pkt, pending::pkt_len, randomize_and_send_udp(), repevt_string(), sockaddr_cmp(), replay_moment::time_step, pending::timeout, pending::timer, outside_network::udp_wait_first, outside_network::udp_wait_last, outside_network::unused_fds, VERB_ALGO, and verbose().
struct waiting_tcp* pending_tcp_query | ( | struct outside_network * | outnet, |
ldns_buffer * | packet, | ||
struct sockaddr_storage * | addr, | ||
socklen_t | addrlen, | ||
int | timeout, | ||
comm_point_callback_t * | callback, | ||
void * | callback_arg | ||
) | [read] |
Send TCP query.
May wait for TCP buffer. Selects ID to be random, and checks id.
outnet,: | provides the event handling. |
packet,: | wireformat query to send to destination. copied from. |
addr,: | address to send to. |
addrlen,: | length of addr. |
timeout,: | in seconds from now. Timer starts running now. Timer may expire if all buffers are used, without any query been sent to the server yet. |
callback,: | function to call on error, timeout or reply. |
callback_arg,: | user argument for callback function. |
References replay_moment::addr, waiting_tcp::addr, replay_moment::addrlen, waiting_tcp::addrlen, advance_moment(), outside_network::base, waiting_tcp::cb, waiting_tcp::cb_arg, comm_timer_create(), comm_timer_set(), replay_moment::evt_type, fatal_exit(), find_match(), log_assert, log_err(), log_info(), log_pkt(), replay_moment::match, waiting_tcp::next_waiting, replay_runtime::now, waiting_tcp::outnet, outnet_tcp_take_into_use(), outnet_tcptimer(), replay_runtime::pending_list, waiting_tcp::pkt, waiting_tcp::pkt_len, repevt_string(), outside_network::rnd, sockaddr_cmp(), outside_network::tcp_free, outside_network::tcp_wait_first, outside_network::tcp_wait_last, replay_moment::time_step, waiting_tcp::timer, ub_random(), and waiting_tcp_delete().
struct serviced_query* outnet_serviced_query | ( | struct outside_network * | outnet, |
uint8_t * | qname, | ||
size_t | qnamelen, | ||
uint16_t | qtype, | ||
uint16_t | qclass, | ||
uint16_t | flags, | ||
int | dnssec, | ||
int | want_dnssec, | ||
struct sockaddr_storage * | addr, | ||
socklen_t | addrlen, | ||
comm_point_callback_t * | callback, | ||
void * | callback_arg, | ||
ldns_buffer * | buff, | ||
int(*)(void *, void *) | arg_compare | ||
) | [read] |
Perform a serviced query to the authoritative servers.
Duplicate efforts are detected, and EDNS, TCP and UDP retry is performed.
outnet,: | outside network, with rbtree of serviced queries. |
qname,: | what qname to query. |
qnamelen,: | length of qname in octets including 0 root label. |
qtype,: | rrset type to query (host format) |
qclass,: | query class. (host format) |
flags,: | flags u16 (host format), includes opcode, CD bit. |
dnssec,: | if set, DO bit is set in EDNS queries. If the value includes BIT_CD, CD bit is set when in EDNS queries. If the value includes BIT_DO, DO bit is set when in EDNS queries. |
want_dnssec,: | signatures are needed, without EDNS the answer is likely to be useless. |
callback,: | callback function. |
callback_arg,: | user argument to callback function. |
addr,: | to which server to send the query. |
addrlen,: | length of addr. |
buff,: | scratch buffer to create query contents in. Empty on exit. |
arg_compare,: | function to compare callback args, return true if identical. It is given the callback_arg and args that are listed. |
References replay_moment::addr, replay_moment::addrlen, advance_moment(), attach_edns_record(), outside_network::base, BIT_CD, BIT_RD, edns_data::bits, callback_list_find(), service_callback::cb, service_callback::cb_arg, serviced_query::cblist, outside_network::do_udp, EDNS_ADVERTISED_SIZE, EDNS_ADVERTISED_VERSION, EDNS_DO, edns_data::edns_present, edns_data::edns_version, replay_moment::evt_type, edns_data::ext_rcode, fatal_exit(), find_match(), log_assert, log_err(), log_info(), log_nametypeclass(), lookup_serviced(), replay_moment::match, service_callback::next, replay_runtime::now, replay_runtime::pending_list, serviced_query::qbuf, rbtree_delete(), repevt_string(), outside_network::serviced, serviced_create(), serviced_gen_query(), serviced_tcp_send(), serviced_udp_send(), sockaddr_cmp(), replay_moment::time_step, UDP_AUTH_QUERY_TIMEOUT, edns_data::udp_size, VERB_OPS, and verbose().
void outnet_serviced_query_stop | ( | struct serviced_query * | sq, |
void * | cb_arg | ||
) |
Remove service query callback.
If that leads to zero callbacks, the query is completely cancelled.
sq,: | serviced query to adjust. |
cb_arg,: | callback argument of callback that needs removal. same as the callback_arg to outnet_serviced_query(). |
References fake_pending::buffer, callback_list_remove(), fake_pending::cb_arg, serviced_query::cblist, log_assert, log_info(), fake_pending::next, serviced_query::outnet, replay_runtime::pending_list, fake_pending::pkt, rbtree_delete(), fake_pending::runtime, outside_network::serviced, serviced_delete(), and serviced_query::to_be_deleted.
struct listen_port* listening_ports_open | ( | struct config_file * | cfg | ) | [read] |
Create shared listening ports Getaddrinfo, create socket, bind and listen to zero or more interfaces for IP4 and/or IP6, for UDP and/or TCP.
On the given port number. It creates the sockets.
cfg,: | settings on what ports to open. |
References config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::if_automatic, config_file::ifs, config_file::incoming_num_tcp, listening_ports_free(), config_file::num_ifs, config_file::port, ports_create_if(), config_file::so_rcvbuf, config_file::so_sndbuf, and str_is_ip6().
struct comm_point* comm_point_create_local | ( | struct comm_base * | base, |
int | fd, | ||
size_t | bufsize, | ||
comm_point_callback_t * | callback, | ||
void * | callback_arg | ||
) | [read] |
Create commpoint to listen to a local domain file descriptor.
base,: | in which base to alloc the commpoint. |
fd,: | file descriptor of open AF_UNIX socket set to listen nonblocking. |
bufsize,: | size of buffer to create for handlers. |
callback,: | callback function pointer for the handler. |
callback_arg,: | will be passed to your callback function. |
struct comm_point* comm_point_create_raw | ( | struct comm_base * | base, |
int | fd, | ||
int | writing, | ||
comm_point_callback_t * | callback, | ||
void * | callback_arg | ||
) | [read] |
Create commpoint to listen to a local domain pipe descriptor.
base,: | in which base to alloc the commpoint. |
fd,: | file descriptor. |
writing,: | true if you want to listen to writes, false for reads. |
callback,: | callback function pointer for the handler. |
callback_arg,: | will be passed to your callback function. |
Referenced by accept_open(), remote_accept_callback(), tube_setup_bg_listen(), and tube_setup_bg_write().
void comm_point_start_listening | ( | struct comm_point * | c, |
int | newfd, | ||
int | sec | ||
) |
Start listening again for input on the comm point.
c,: | commpoint to enable again. |
newfd,: | new fd, or -1 to leave fd be. |
sec,: | timeout in seconds, or -1 for no (change to the) timeout. |
Referenced by comm_point_send_reply(), outnet_tcp_take_into_use(), reclaim_tcp_handler(), remote_accept_callback(), select_ifport(), setup_tcp_handler(), tcp_callback_reader(), tcp_callback_writer(), and tube_queue_item().
void comm_point_stop_listening | ( | struct comm_point * | c | ) |
Stop listening for input on the commpoint.
No callbacks will happen.
c,: | commpoint to disable. The fd is not closed. |
Referenced by comm_point_tcp_accept_callback(), remote_accept_callback(), tcp_callback_reader(), tcp_callback_writer(), and tube_handle_write().
void comm_point_delete | ( | struct comm_point * | c | ) |
Close and deallocate (free) the comm point.
If the comm point is a tcp-accept point, also its tcp-handler points are deleted.
c,: | comm point to delete. |
Referenced by clean_point(), comm_point_create_tcp(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_delete(), daemon_remote_clear(), listen_create(), listen_list_delete(), outside_network_delete(), tube_remove_bg_listen(), and tube_remove_bg_write().
size_t listen_get_mem | ( | struct listen_dnsport * | listen | ) |
get memory size used by the listening structs
listen,: | listening structure. |
References listen_dnsport::base, listen_list::com, comm_point_get_mem(), listen_dnsport::cps, listen_list::next, and listen_dnsport::udp_buff.
size_t outnet_get_mem | ( | struct outside_network * | outnet | ) |
Get memory size in use by outside network.
Counts buffers and outstanding query (serviced queries) malloced data.
outnet,: | outside network structure. |
References outside_network::base, pending_tcp::c, serviced_query::cblist, comm_point_get_mem(), rbtree_t::count, port_comm::cp, if_get_mem(), outside_network::ip4_ifs, outside_network::ip6_ifs, service_callback::next, port_comm::next, waiting_tcp::next_waiting, pending::next_waiting, outside_network::num_ip4, outside_network::num_ip6, outside_network::num_tcp, outside_network::pending, serviced_query::qbuflen, pending_tcp::query, RBTREE_FOR, outside_network::serviced, outside_network::svcd_overhead, outside_network::tcp_conns, outside_network::tcp_wait_first, outside_network::udp_buff, outside_network::udp_wait_first, outside_network::unused_fds, waiting_tcp_get_mem(), and waiting_udp_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.
c,: | commpoint. |
Referenced by comm_point_get_mem(), if_get_mem(), listen_get_mem(), outnet_get_mem(), and worker_mem_report().
size_t serviced_get_mem | ( | struct serviced_query * | sq | ) |
Get memory size in use by serviced query while it is servicing callbacks.
This takes into account the pre-deleted status of it; it will be deleted when the callbacks are done.
sq,: | serviced query. |
References serviced_query::cblist, comm_timer_get_mem(), service_callback::next, serviced_query::qbuflen, and serviced_query::status.
void comm_point_udp_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 comm point.
fd,: | file descriptor. |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_point structure. |
Referenced by comm_point_create_udp(), and fptr_whitelist_event().
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.
fd,: | file descriptor. |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_point structure. |
Referenced by comm_point_create_udp_ancil(), and fptr_whitelist_event().
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.
handle libevent callback for tcp accept comm point
fd,: | file descriptor. |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_point structure. |
Referenced by comm_point_create_tcp(), and fptr_whitelist_event().
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.
handle libevent callback for tcp data comm point
fd,: | file descriptor. |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_point structure. |
Referenced by comm_point_create_tcp_handler(), comm_point_create_tcp_out(), and fptr_whitelist_event().
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.
fd,: | file descriptor (always -1). |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_timer structure. |
Referenced by comm_timer_create(), comm_timer_set(), and fptr_whitelist_event().
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.
fd,: | file descriptor (used for the signal number). |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the internal commsignal structure. |
Referenced by comm_signal_bind(), and fptr_whitelist_event().
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
fd,: | file descriptor. |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_point structure. |
Referenced by comm_point_create_local(), and fptr_whitelist_event().
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.
fd,: | file descriptor. |
event,: | event bits from libevent: EV_READ, EV_WRITE, EV_SIGNAL, EV_TIMEOUT. |
arg,: | the comm_point structure. |
Referenced by comm_point_create_raw(), and fptr_whitelist_event().
struct comm_timer* comm_timer_create | ( | struct comm_base * | base, |
void(*)(void *) | cb, | ||
void * | cb_arg | ||
) | [read] |
create timer.
Not active upon creation.
base,: | event handling base. |
cb,: | callback function: void myfunc(void* myarg); |
cb_arg,: | user callback argument. |
Referenced by pending_tcp_query(), pending_udp_query(), worker_init(), and wsvc_setup_worker().
void comm_timer_disable | ( | struct comm_timer * | timer | ) |
disable timer.
Stops callbacks from happening.
timer,: | to disable. |
Referenced by comm_timer_delete(), comm_timer_set(), and outnet_udp_cb().
void comm_timer_set | ( | struct comm_timer * | timer, |
struct timeval * | tv | ||
) |
reset timevalue for timer.
timer,: | timer to (re)set. |
tv,: | when the timer should activate. if NULL timer is disabled. |
Referenced by pending_tcp_query(), randomize_and_send_udp(), reset_worker_timer(), set_cron_timer(), worker_init(), worker_probe_timer_cb(), and worker_restart_timer().
void comm_timer_delete | ( | struct comm_timer * | timer | ) |
delete timer.
timer,: | to delete. |
Referenced by pending_delete(), pending_udp_query(), waiting_tcp_delete(), worker_delete(), and wsvc_desetup_worker().
struct event_base* comm_base_internal | ( | struct comm_base * | b | ) | [read] |
Access internal data structure (for util/tube.c on windows)
b,: | comm base |
Referenced by wsvc_setup_worker().
void daemon_remote_exec | ( | struct worker * | worker | ) |
Handle nonthreaded remote cmd execution.
worker,: | this worker (the remote worker). |
References worker::cmd, execute_cmd(), log_err(), tube_read_msg(), VERB_ALGO, and verbose().
struct replay_scenario* saved_scenario = NULL [static] |
Global variable: the scenario.
Saved here for when event_init is done.
Referenced by comm_base_create().