unbound: testcode/fake_event.c File Reference

unbound 0.1

Data Structures | Macros | Functions | Variables
fake_event.c File Reference

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/data/dname.h"`
`#include "util/edns.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/testpkts.h"`
`#include "util/log.h"`
`#include "util/fptr_wlist.h"`
`#include "sldns/sbuffer.h"`
`#include "sldns/wire2str.h"`
`#include "sldns/str2wire.h"`
`#include "daemon/remote.h"`
`#include <signal.h>`

## Data Structures
struct | fake_commpoint
| fake commpoint, stores information More...

## Macros
#define | FAKE_COMMPOINT_TYPECODE 97347923
| unique code to check that fake_commpoint is that structure

## 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, uint8_t *pkt, size_t len)
| helper function that logs a sldns_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 int | count_reply_packets (struct entry *entry)
| number of replies in entry
static void | fill_buffer_with_reply (sldns_buffer *buffer, struct entry *entry, uint8_t *q, size_t qlen, int tcp_pkt_counter)
| 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 | tempfile_check (struct replay_runtime *runtime, struct replay_moment *mom)
| check tempfile file contents
static void | do_infra_rtt (struct replay_runtime *runtime)
| Store RTT in infra cache.
static void | expon_timeout_backoff (struct replay_runtime *runtime)
| perform exponential backoff on the timeout
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 *ATTR_UNUSED(ports), size_t bufsize, int ATTR_UNUSED(tcp_accept_count), int ATTR_UNUSED(tcp_idle_timeout), int ATTR_UNUSED(harden_large_queries), uint32_t ATTR_UNUSED(http_max_streams), char *ATTR_UNUSED(http_endpoint), int ATTR_UNUSED(http_notls), struct tcl_list *ATTR_UNUSED(tcp_conn_limit), void *ATTR_UNUSED(sslctx), struct dt_env *ATTR_UNUSED(dtenv), comm_point_callback_type *cb, void *cb_arg)
void | listen_delete (struct listen_dnsport *listen)
| delete the listening structure
struct comm_base * | comm_base_create (int ATTR_UNUSED(sigs))
void | comm_base_delete (struct comm_base *b)
| Destroy a comm base.
void | comm_base_timept (struct comm_base *b, time_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 *ATTR_UNUSED(comsig), int ATTR_UNUSED(sig))
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 ATTR_UNUSED(num_ports), char **ATTR_UNUSED(ifs), int ATTR_UNUSED(num_ifs), int ATTR_UNUSED(do_ip4), int ATTR_UNUSED(do_ip6), size_t ATTR_UNUSED(num_tcp), int ATTR_UNUSED(dscp), struct infra_cache *infra, struct ub_randstate *ATTR_UNUSED(rnd), int ATTR_UNUSED(use_caps_for_id), int *ATTR_UNUSED(availports), int ATTR_UNUSED(numavailports), size_t ATTR_UNUSED(unwanted_threshold), int ATTR_UNUSED(outgoing_tcp_mss), void(*unwanted_action)(void *), void *ATTR_UNUSED(unwanted_param), int ATTR_UNUSED(do_udp), void *ATTR_UNUSED(sslctx), int ATTR_UNUSED(delayclose), int ATTR_UNUSED(tls_use_sni), struct dt_env *ATTR_UNUSED(dtenv), int ATTR_UNUSED(udp_connect), int ATTR_UNUSED(max_reuse_tcp_queries), int ATTR_UNUSED(tcp_reuse_timeout), int ATTR_UNUSED(tcp_auth_query_timeout))
void | outside_network_delete (struct outside_network *outnet)
| Delete outside_network structure.
void | outside_network_quit_prepare (struct outside_network *ATTR_UNUSED(outnet))
struct pending * | pending_udp_query (struct serviced_query *sq, sldns_buffer *packet, int timeout, comm_point_callback_type *callback, void *callback_arg)
| Send UDP query, create pending answer.
struct waiting_tcp * | pending_tcp_query (struct serviced_query *sq, sldns_buffer *packet, int timeout, comm_point_callback_type *callback, void *callback_arg)
| Send TCP query.
struct serviced_query * | outnet_serviced_query (struct outside_network *outnet, struct query_info *qinfo, uint16_t flags, int dnssec, int ATTR_UNUSED(want_dnssec), int ATTR_UNUSED(nocaps), int ATTR_UNUSED(check_ratelimit), int ATTR_UNUSED(tcp_upstream), int ATTR_UNUSED(ssl_upstream), char *ATTR_UNUSED(tls_auth_name), struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *zone, size_t zonelen, struct module_qstate *qstate, comm_point_callback_type *callback, void *callback_arg, sldns_buffer *ATTR_UNUSED(buff), struct module_env *env, int *ATTR_UNUSED(was_ratelimited))
void | outnet_serviced_query_stop (struct serviced_query *sq, void *cb_arg)
| Remove service query callback.
int | resolve_interface_names (char **ATTR_UNUSED(ifs), int ATTR_UNUSED(num_ifs), struct config_strlist *ATTR_UNUSED(list), char ***ATTR_UNUSED(resif), int *ATTR_UNUSED(num_resif))
struct listen_port * | listening_ports_open (struct config_file *ATTR_UNUSED(cfg), char **ATTR_UNUSED(ifs), int ATTR_UNUSED(num_ifs), int *ATTR_UNUSED(reuseport))
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 *ATTR_UNUSED(base), int ATTR_UNUSED(fd), size_t ATTR_UNUSED(bufsize), comm_point_callback_type *ATTR_UNUSED(callback), void *ATTR_UNUSED(callback_arg))
struct comm_point * | comm_point_create_raw (struct comm_base *ATTR_UNUSED(base), int ATTR_UNUSED(fd), int ATTR_UNUSED(writing), comm_point_callback_type *ATTR_UNUSED(callback), void *ATTR_UNUSED(callback_arg))
void | comm_point_start_listening (struct comm_point *ATTR_UNUSED(c), int ATTR_UNUSED(newfd), int ATTR_UNUSED(sec))
void | comm_point_stop_listening (struct comm_point *ATTR_UNUSED(c))
void | comm_point_delete (struct comm_point *c)
| Close and deallocate (free) the comm point.
size_t | listen_get_mem (struct listen_dnsport *ATTR_UNUSED(listen))
size_t | outnet_get_mem (struct outside_network *ATTR_UNUSED(outnet))
size_t | comm_point_get_mem (struct comm_point *ATTR_UNUSED(c))
size_t | serviced_get_mem (struct serviced_query *ATTR_UNUSED(c))
int | outnet_udp_cb (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(reply_info))
int | outnet_tcp_cb (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(reply_info))
void | pending_udp_timer_cb (void *ATTR_UNUSED(arg))
void | serviced_timer_cb (void *ATTR_UNUSED(arg))
void | pending_udp_timer_delay_cb (void *ATTR_UNUSED(arg))
void | outnet_tcptimer (void *ATTR_UNUSED(arg))
void | comm_point_udp_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_point_udp_ancil_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_point_tcp_accept_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_point_tcp_handle_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_timer_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_signal_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_point_http_handle_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_point_local_handle_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_point_raw_handle_callback (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
void | comm_base_handle_slow_accept (int ATTR_UNUSED(fd), short ATTR_UNUSED(event), void *ATTR_UNUSED(arg))
int | serviced_udp_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(reply_info))
int | serviced_tcp_callback (struct comm_point *ATTR_UNUSED(c), void *ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply *ATTR_UNUSED(reply_info))
int | pending_cmp (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b))
int | serviced_cmp (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b))
int | reuse_cmp (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b))
int | reuse_id_cmp (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b))
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.
void | comm_base_set_slow_accept_handlers (struct comm_base *ATTR_UNUSED(b), void(*stop_acc)(void *), void(*start_acc)(void *), void *ATTR_UNUSED(arg))
struct ub_event_base * | comm_base_internal (struct comm_base *ATTR_UNUSED(b))
void | daemon_remote_exec (struct worker *ATTR_UNUSED(worker))
void | listen_start_accept (struct listen_dnsport *ATTR_UNUSED(listen))
void | listen_stop_accept (struct listen_dnsport *ATTR_UNUSED(listen))
void | daemon_remote_start_accept (struct daemon_remote *ATTR_UNUSED(rc))
void | daemon_remote_stop_accept (struct daemon_remote *ATTR_UNUSED(rc))
int | create_udp_sock (int ATTR_UNUSED(family), int ATTR_UNUSED(socktype), struct sockaddr *ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen), int ATTR_UNUSED(v6only), int *ATTR_UNUSED(inuse), int *ATTR_UNUSED(noproto), int ATTR_UNUSED(rcv), int ATTR_UNUSED(snd), int ATTR_UNUSED(listen), int *ATTR_UNUSED(reuseport), int ATTR_UNUSED(transparent), int ATTR_UNUSED(freebind), int ATTR_UNUSED(use_systemd), int ATTR_UNUSED(dscp))
struct comm_point * | comm_point_create_udp (struct comm_base *ATTR_UNUSED(base), int ATTR_UNUSED(fd), sldns_buffer *ATTR_UNUSED(buffer), int ATTR_UNUSED(pp2_enabled), comm_point_callback_type *ATTR_UNUSED(callback), void *ATTR_UNUSED(callback_arg), struct unbound_socket *ATTR_UNUSED(socket))
struct comm_point * | comm_point_create_tcp_out (struct comm_base *ATTR_UNUSED(base), size_t ATTR_UNUSED(bufsize), comm_point_callback_type *ATTR_UNUSED(callback), void *ATTR_UNUSED(callback_arg))
struct comm_point * | outnet_comm_point_for_udp (struct outside_network *outnet, comm_point_callback_type *cb, void *cb_arg, struct sockaddr_storage *ATTR_UNUSED(to_addr), socklen_t ATTR_UNUSED(to_addrlen))
struct comm_point * | outnet_comm_point_for_tcp (struct outside_network *outnet, comm_point_callback_type *cb, void *cb_arg, struct sockaddr_storage *to_addr, socklen_t to_addrlen, struct sldns_buffer *query, int timeout, int ATTR_UNUSED(ssl), char *ATTR_UNUSED(host))
struct comm_point * | outnet_comm_point_for_http (struct outside_network *outnet, comm_point_callback_type *cb, void *cb_arg, struct sockaddr_storage *to_addr, socklen_t to_addrlen, int timeout, int ssl, char *host, char *path, struct config_file *cfg)
| Create http commpoint suitable for communication to the destination.
int | comm_point_send_udp_msg (struct comm_point *c, sldns_buffer *packet, struct sockaddr *addr, socklen_t addrlen, int ATTR_UNUSED(is_connected))
int | outnet_get_tcp_fd (struct sockaddr_storage *ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen), int ATTR_UNUSED(tcp_mss), int ATTR_UNUSED(dscp))
int | outnet_tcp_connect (int ATTR_UNUSED(s), struct sockaddr_storage *ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen))
int | tcp_req_info_add_meshstate (struct tcp_req_info *ATTR_UNUSED(req), struct mesh_area *ATTR_UNUSED(mesh), struct mesh_state *ATTR_UNUSED(m))
void | tcp_req_info_remove_mesh_state (struct tcp_req_info *ATTR_UNUSED(req), struct mesh_state *ATTR_UNUSED(m))
size_t | tcp_req_info_get_stream_buffer_size (void)
| get the size of currently used tcp stream wait buffers (in bytes)
size_t | http2_get_query_buffer_size (void)
| get the size of currently used HTTP2 query buffers (in bytes)
size_t | http2_get_response_buffer_size (void)
| get the size of currently used HTTP2 response buffers (in bytes)
void | http2_stream_add_meshstate (struct http2_stream *ATTR_UNUSED(h2_stream), struct mesh_area *ATTR_UNUSED(mesh), struct mesh_state *ATTR_UNUSED(m))

## Variables
static struct replay_scenario * | saved_scenario = NULL
| Global variable: the scenario.

## Detailed Description

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.

## Function Documentation

## ◆ fake_temp_file()

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.

Parameters

  adj | adjective, like "_cfg_", "_auto_"
  id | identifier, like "example.com".
  buf | where to store.
  len | length of buf.

Referenced by autotrust_check(), setup_config(), spool_auto_file(), spool_temp_file(), spool_temp_file_name(), and tempfile_check().

## ◆ fake_event_init()

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().

Parameters

  scen | Set the scenario to use for upcoming event handling.

References saved_scenario.

Referenced by main().

## ◆ pending_find_match()

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.

Parameters

  runtime | runtime with current moment, and range list.
  entry | returns the pointer to entry that matches.
  pend | the pending that the entry must match.

Returns
  : true if a match is found.

References replay_range::addr, fake_pending::addr, replay_range::addrlen, fake_pending::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().

## ◆ 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.

Parameters

  runtime | runtime.
  entry | if true, the entry that matches is returned.
  pend | if true, the outgoing message that matches is returned.

Returns
  : true if pending query matches the now event.

References fake_pending::next, pending_find_match(), replay_runtime::pending_list, fake_pending::runtime, and fake_pending::tcp_pkt_counter.

Referenced by run_scenario().

## ◆ answer_callback_from_entry()

static void answer_callback_from_entry | ( | struct replay_runtime * | runtime,
|  | struct entry * | entry,
|  | struct fake_pending * | pend
| ) |  |
| static

Perform range entry on pending message.

Parameters

  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, fake_pending::addrlen, comm_point::buffer, replay_runtime::bufsize, comm_reply::c, fake_pending::callback, fake_pending::cb_arg, count_reply_packets(), fatal_exit(), comm_point::fd, fill_buffer_with_reply(), NETEVENT_NOERROR, reply_packet::next, pending_list_delete(), fake_pending::pkt, comm_reply::remote_addr, comm_reply::remote_addrlen, entry::reply_list, fake_pending::serviced, sldns_buffer_free(), sldns_buffer_new(), comm_point::tcp_keepalive, fake_pending::tcp_pkt_counter, replay_runtime::tcp_seen_keepalive, comm_point::tcp_timeout_msec, fake_pending::transport, and comm_point::type.

Referenced by run_scenario().

## ◆ do_moment_and_advance()

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.

Parameters

  runtime | scenario runtime information.

References advance_moment(), replay_runtime::answer_list, autotrust_check(), do_infra_rtt(), replay_moment::evt_type, expon_timeout_backoff(), 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_tempfile_check, replay_moment::repevt_time_passes, replay_moment::repevt_timeout, replay_moment::repevt_traffic, tempfile_check(), time_passes(), and replay_moment::time_step.

Referenced by run_scenario().

## ◆ listen_delete()

void listen_delete | ( | struct listen_dnsport * | listen | ) |

delete the listening structure

Parameters

  listen | listening structure.

References sldns_buffer_free(), and listen_dnsport::udp_buff.

## ◆ comm_base_delete()

void comm_base_delete | ( | struct comm_base * | b | ) |

Destroy a comm base.

All comm points must have been deleted.

Parameters

  b | the base to delete.

References replay_runtime::answer_list, delete_fake_pending(), delete_replay_answer(), macro_store_delete(), fake_pending::next, replay_answer::next, fake_timer::next, replay_runtime::pending_list, fake_timer::runtime, replay_runtime::scenario, replay_runtime::timer_list, and replay_runtime::vars.

Referenced by libworker_delete(), and worker_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

  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.

References replay_runtime::now_secs, and replay_runtime::now_tv.

Referenced by libworker_setup(), outside_network_create(), ub_comm_base_now(), and worker_init().

## ◆ comm_base_dispatch()

void comm_base_dispatch | ( | struct comm_base * | b | ) |

Dispatch the comm base events.

Parameters

  b | the communication to perform.

References run_scenario(), replay_runtime::sig_cb, and replay_runtime::sig_cb_arg.

Referenced by libworker_dobg(), libworker_fg(), and worker_work().

## ◆ comm_base_exit()

void comm_base_exit | ( | struct comm_base * | b | ) |

Exit from dispatch loop.

Parameters

  b | the communication base that is in dispatch().

References replay_runtime::exit_cleanly, and fatal_exit().

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

## ◆ 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

  base | communication base to use.
  callback | called when signal is caught.
  cb_arg | user argument to callback

Returns
  : the signal struct or NULL on error.

References replay_runtime::cb_arg, replay_runtime::sig_cb, and replay_runtime::sig_cb_arg.

Referenced by worker_init().

## ◆ comm_signal_delete()

void comm_signal_delete | ( | struct comm_signal * | comsig | ) |

Delete the signal communication point.

Parameters

  comsig | to delete.

Referenced by worker_delete().

## ◆ comm_point_send_reply()

void comm_point_send_reply | ( | struct comm_reply * | repinfo | ) |

Send reply.

Put message into commpoint buffer.

Parameters

  repinfo | The 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, fatal_exit(), log_assert, log_info(), log_pkt(), memdup(), replay_answer::next, replay_answer::pkt, replay_answer::repinfo, sldns_buffer_begin(), and sldns_buffer_limit().

Referenced by fake_front_query(), mesh_new_client(), mesh_send_reply(), and reply_and_prefetch().

## ◆ comm_point_drop_reply()

void comm_point_drop_reply | ( | struct comm_reply * | repinfo | ) |

Drop reply.

Cleans up.

Parameters

  repinfo | The reply info copied from a commpoint callback call.

References comm_point::buffer, comm_reply::c, log_info(), and sldns_buffer_free().

Referenced by dnsc_handle_curved_request(), mesh_new_client(), mesh_query_done(), mesh_state_cleanup(), tcp_req_info_handle_writedone(), tcp_req_info_send_reply(), and worker_handle_request().

## ◆ outside_network_delete()

void outside_network_delete | ( | struct outside_network * | outnet | ) |

Delete outside_network structure.

Parameters

  outnet | object to delete.

References sldns_buffer_free(), and outside_network::udp_buff.

## ◆ pending_udp_query()

struct pending * pending_udp_query | ( | struct serviced_query * | sq,
|  | struct sldns_buffer * | packet,
|  | int | timeout,
|  | comm_point_callback_type * | callback,
|  | void * | callback_arg
| ) |  |

Send UDP query, create pending answer.

Changes the ID for the query to be random and unique for that destination.

Parameters

  sq | serviced query.
  packet | wireformat query to send to destination.
  timeout | in milliseconds from now.
  callback | function to call on error, timeout or reply.
  callback_arg | user argument for callback function.

Returns
  : NULL on error for malloc or socket. Else the pending query object.

References serviced_query::addr, replay_moment::addr, serviced_query::addrlen, replay_moment::addrlen, advance_moment(), outside_network::base, replay_moment::evt_type, fatal_exit(), find_match(), log_assert, log_info(), log_pkt(), replay_moment::match, memdup(), replay_runtime::now, serviced_query::outnet, replay_runtime::pending_list, repevt_string(), sldns_buffer_begin(), sldns_buffer_capacity(), sldns_buffer_flip(), sldns_buffer_limit(), sldns_buffer_new(), sldns_buffer_write(), sockaddr_cmp(), and replay_moment::time_step.

## ◆ pending_tcp_query()

struct waiting_tcp * pending_tcp_query | ( | struct serviced_query * | sq,
|  | struct sldns_buffer * | packet,
|  | int | timeout,
|  | comm_point_callback_type * | callback,
|  | void * | callback_arg
| ) |  |

Send TCP query.

May wait for TCP buffer. Selects ID to be random, and checks id.

Parameters

  sq | serviced query.
  packet | wireformat query to send to destination. copied from.
  timeout | in milliseconds 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.

Returns
  : false on error for malloc or socket. Else the pending TCP object.

References serviced_query::addr, replay_moment::addr, serviced_query::addrlen, replay_moment::addrlen, advance_moment(), outside_network::base, replay_moment::evt_type, fatal_exit(), find_match(), log_assert, log_info(), log_pkt(), replay_moment::match, memdup(), replay_runtime::now, serviced_query::outnet, replay_runtime::pending_list, repevt_string(), sldns_buffer_begin(), sldns_buffer_capacity(), sldns_buffer_flip(), sldns_buffer_limit(), sldns_buffer_new(), sldns_buffer_write(), sockaddr_cmp(), and replay_moment::time_step.

## ◆ outnet_serviced_query_stop()

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.

Parameters

  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, fake_pending::cb_arg, log_assert, log_info(), fake_pending::next, replay_runtime::pending_list, fake_pending::pkt, fake_pending::runtime, sldns_buffer_free(), and fake_pending::zone.

## ◆ comm_point_delete()

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.

Parameters

  c | comm point to delete.

References FAKE_COMMPOINT_TYPECODE, log_assert, fake_commpoint::pending, pending_list_delete(), fake_commpoint::runtime, fake_commpoint::type_tcp_out, and fake_commpoint::typecode.

Referenced by auth_xfer_delete(), auth_xfer_probe_timer_callback(), auth_xfer_probe_udp_callback(), auth_xfer_transfer_http_callback(), auth_xfer_transfer_tcp_callback(), auth_xfer_transfer_timer_callback(), clean_point(), daemon_remote_clear(), listen_create(), listen_list_delete(), outnet_comm_point_for_http(), outnet_comm_point_for_tcp(), outside_network_delete(), tube_remove_bg_listen(), tube_remove_bg_write(), xfr_probe_disown(), xfr_probe_send_probe(), xfr_transfer_disown(), and xfr_transfer_init_fetch().

## ◆ 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

  base | event handling base.
  cb | callback function: void myfunc(void* myarg);
  cb_arg | user callback argument.

Returns
  : the new timer or NULL on error.

References fake_timer::cb, fake_timer::cb_arg, fatal_exit(), fptr_ok, fptr_whitelist_comm_timer(), fake_timer::next, fake_timer::runtime, and replay_runtime::timer_list.

Referenced by dt_msg_queue_create(), mesh_serve_expired_init(), pending_tcp_query(), pending_udp_query(), serviced_create(), worker_init(), wsvc_setup_worker(), xfr_probe_send_probe(), xfr_set_timeout(), and xfr_transfer_init_fetch().

## ◆ comm_timer_disable()

void comm_timer_disable | ( | struct comm_timer * | timer | ) |

disable timer.

Stops callbacks from happening.

Parameters

  timer | to disable.

References fake_timer::enabled, and log_info().

Referenced by auth_xfer_probe_udp_callback(), auth_xfer_transfer_http_callback(), auth_xfer_transfer_tcp_callback(), outnet_udp_cb(), and use_free_buffer().

## ◆ comm_timer_set()

void comm_timer_set | ( | struct comm_timer * | timer,
|  | struct timeval * | tv
| ) |  |

reset timevalue for timer.

Parameters

  timer | timer to (re)set.
  tv | when the timer should activate. if NULL timer is disabled.

References fake_timer::enabled, log_info(), replay_runtime::now_tv, fake_timer::runtime, timeval_add(), and fake_timer::tv.

Referenced by dt_msg_queue_start_timer(), mesh_serve_expired_init(), outnet_tcp_take_query_setup(), outnet_waiting_tcp_list_add(), outnet_waiting_tcp_list_add_first(), pending_udp_timer_cb(), randomize_and_send_udp(), reset_worker_timer(), serviced_create(), set_cron_timer(), worker_init(), worker_probe_timer_cb(), worker_restart_timer(), xfr_probe_send_probe(), xfr_set_timeout(), and xfr_transfer_init_fetch().

## ◆ comm_timer_delete()

void comm_timer_delete | ( | struct comm_timer * | timer | ) |

delete timer.

Parameters

  timer | to delete.

References fake_timer::next, fake_timer::runtime, and replay_runtime::timer_list.

Referenced by auth_xfer_delete(), dt_msg_queue_delete(), mesh_query_done(), mesh_serve_expired_callback(), mesh_state_cleanup(), pending_delete(), pending_udp_query(), serviced_node_del(), waiting_tcp_delete(), worker_delete(), wsvc_desetup_worker(), xfr_nextprobe_disown(), xfr_probe_disown(), and xfr_transfer_disown().

## ◆ outnet_comm_point_for_http()

struct comm_point * outnet_comm_point_for_http | ( | struct outside_network * | outnet,
|  | comm_point_callback_type * | cb,
|  | void * | cb_arg,
|  | struct sockaddr_storage * | to_addr,
|  | socklen_t | to_addrlen,
|  | int | timeout,
|  | int | ssl,
|  | char * | host,
|  | char * | path,
|  | struct config_file * | cfg
| ) |  |

Create http commpoint suitable for communication to the destination.

Creates the http request buffer. It also performs connect() to the to_addr.

Parameters

  outnet | outside_network with the comm_base it is attached to, and the tcp_mss.
  cb | callback function for the commpoint.
  cb_arg | callback argument for cb.
  to_addr | intended destination.
  to_addrlen | length of to_addr.
  timeout | timeout for the TCP connection. timeout in milliseconds, or -1 for no (change to the) timeout. So seconds*1000.
  ssl | set to true for https.
  host | hostname to use for the destination. part of http request.
  path | pathname to lookup, eg. name of the file on the destination.
  cfg | running configuration for User-Agent setup.

Returns
  http_out commpoint, or NULL.

References outside_network::base, fake_commpoint::cb, fake_commpoint::cb_arg, replay_runtime::cb_arg, FAKE_COMMPOINT_TYPECODE, fake_commpoint::runtime, fake_commpoint::type_http_out, and fake_commpoint::typecode.

## Variable Documentation

## ◆ saved_scenario

struct replay_scenario* saved_scenario = NULL
| static

Global variable: the scenario.

Saved here for when event_init is done.

Referenced by fake_event_cleanup(), and fake_event_init().