xref: /freebsd/contrib/unbound/testcode/fake_event.c (revision b2efd602aea8b3cbc3fb215b9611946d04fceb10)
1 /*
2  * testcode/fake_event.c - fake event handling that replays existing scenario.
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 /**
37  * \file
38  * Event service that replays a scenario.
39  * This implements the same exported symbols as the files:
40  * util/netevent.c
41  * services/listen_dnsport.c
42  * services/outside_network.c
43  * But these do not actually access the network or events, instead
44  * the scenario is played.
45  */
46 
47 #include "config.h"
48 #include "testcode/fake_event.h"
49 #include "util/netevent.h"
50 #include "util/net_help.h"
51 #include "util/data/msgparse.h"
52 #include "util/data/msgreply.h"
53 #include "util/data/msgencode.h"
54 #include "util/data/dname.h"
55 #include "util/storage/slabhash.h"
56 #include "util/edns.h"
57 #include "util/config_file.h"
58 #include "services/listen_dnsport.h"
59 #include "services/outside_network.h"
60 #include "services/cache/infra.h"
61 #include "testcode/replay.h"
62 #include "testcode/testpkts.h"
63 #include "util/log.h"
64 #include "util/fptr_wlist.h"
65 #include "sldns/sbuffer.h"
66 #include "sldns/wire2str.h"
67 #include "sldns/str2wire.h"
68 #include "daemon/remote.h"
69 #include "daemon/daemon.h"
70 #include "util/timeval_func.h"
71 #include <signal.h>
72 struct worker;
73 struct daemon_remote;
74 
75 /** unique code to check that fake_commpoint is that structure */
76 #define FAKE_COMMPOINT_TYPECODE 97347923
77 /** fake commpoint, stores information */
78 struct fake_commpoint {
79 	/** typecode */
80 	int typecode;
81 	/** if this is a udp outgoing type of commpoint */
82 	int type_udp_out;
83 	/** if this is a tcp outgoing type of commpoint */
84 	int type_tcp_out;
85 	/** if this is a http outgoing type of commpoint. */
86 	int type_http_out;
87 
88 	/** the callback, stored for usage */
89 	comm_point_callback_type* cb;
90 	/** the callback userarg, stored for usage */
91 	void* cb_arg;
92 	/** runtime ptr */
93 	struct replay_runtime* runtime;
94 	/** the pending entry for this commpoint (if any) */
95 	struct fake_pending* pending;
96 };
97 
98 /** Global variable: the scenario. Saved here for when event_init is done. */
99 static struct replay_scenario* saved_scenario = NULL;
100 
101 void
fake_temp_file(const char * adj,const char * id,char * buf,size_t len)102 fake_temp_file(const char* adj, const char* id, char* buf, size_t len)
103 {
104 #ifdef USE_WINSOCK
105 	snprintf(buf, len, "testbound_%u%s%s.tmp",
106 		(unsigned)getpid(), adj, id);
107 #else
108 	snprintf(buf, len, "/tmp/testbound_%u%s%s.tmp",
109 		(unsigned)getpid(), adj, id);
110 #endif
111 }
112 
113 void
fake_event_init(struct replay_scenario * scen)114 fake_event_init(struct replay_scenario* scen)
115 {
116 	saved_scenario = scen;
117 }
118 
119 void
fake_event_cleanup(void)120 fake_event_cleanup(void)
121 {
122 	replay_scenario_delete(saved_scenario);
123 	saved_scenario = NULL;
124 }
125 
126 /** helper function that logs a sldns_pkt packet to logfile */
127 static void
log_pkt(const char * desc,uint8_t * pkt,size_t len)128 log_pkt(const char* desc, uint8_t* pkt, size_t len)
129 {
130 	char* str = sldns_wire2str_pkt(pkt, len);
131 	if(!str)
132 		fatal_exit("%s: (failed out of memory wire2str_pkt)", desc);
133 	else {
134 		log_info("%s%s", desc, str);
135 		free(str);
136 	}
137 }
138 
139 /**
140  * Returns a string describing the event type.
141  */
142 static const char*
repevt_string(enum replay_event_type t)143 repevt_string(enum replay_event_type t)
144 {
145 	switch(t) {
146 	case repevt_nothing:	 return "NOTHING";
147 	case repevt_front_query: return "QUERY";
148 	case repevt_front_reply: return "CHECK_ANSWER";
149 	case repevt_timeout:	 return "TIMEOUT";
150 	case repevt_time_passes: return "TIME_PASSES";
151 	case repevt_back_reply:  return "REPLY";
152 	case repevt_back_query:  return "CHECK_OUT_QUERY";
153 	case repevt_autotrust_check: return "CHECK_AUTOTRUST";
154 	case repevt_tempfile_check: return "CHECK_TEMPFILE";
155 	case repevt_error:	 return "ERROR";
156 	case repevt_assign:	 return "ASSIGN";
157 	case repevt_traffic:	 return "TRAFFIC";
158 	case repevt_infra_rtt:	 return "INFRA_RTT";
159 	case repevt_flush_message: return "FLUSH_MESSAGE";
160 	case repevt_expire_message: return "EXPIRE_MESSAGE";
161 	default:		 return "UNKNOWN";
162 	}
163 }
164 
165 /** delete a fake pending */
166 static void
delete_fake_pending(struct fake_pending * pend)167 delete_fake_pending(struct fake_pending* pend)
168 {
169 	if(!pend)
170 		return;
171 	free(pend->zone);
172 	sldns_buffer_free(pend->buffer);
173 	free(pend->pkt);
174 	free(pend);
175 }
176 
177 /** delete a replay answer */
178 static void
delete_replay_answer(struct replay_answer * a)179 delete_replay_answer(struct replay_answer* a)
180 {
181 	if(!a)
182 		return;
183 	if(a->repinfo.c) {
184 		sldns_buffer_free(a->repinfo.c->buffer);
185 		free(a->repinfo.c);
186 	}
187 	free(a->pkt);
188 	free(a);
189 }
190 
191 /** Log the packet for a reply_packet from testpkts. */
192 static void
log_testpkt_reply_pkt(const char * txt,struct reply_packet * reppkt)193 log_testpkt_reply_pkt(const char* txt, struct reply_packet* reppkt)
194 {
195 	if(!reppkt) {
196 		log_info("%s <null>", txt);
197 		return;
198 	}
199 	if(reppkt->reply_from_hex) {
200 		log_pkt(txt, sldns_buffer_begin(reppkt->reply_from_hex),
201 			sldns_buffer_limit(reppkt->reply_from_hex));
202 		return;
203 	}
204 	log_pkt(txt, reppkt->reply_pkt, reppkt->reply_len);
205 }
206 
207 /**
208  * return: true if pending query matches the now event.
209  */
210 static int
pending_matches_current(struct replay_runtime * runtime,struct entry ** entry,struct fake_pending ** pend)211 pending_matches_current(struct replay_runtime* runtime,
212 	struct entry** entry, struct fake_pending **pend)
213 {
214 	struct fake_pending* p;
215 	struct entry* e;
216 	if(!runtime->now || runtime->now->evt_type != repevt_back_query
217 		|| !runtime->pending_list)
218 		return 0;
219 	/* see if any of the pending queries matches */
220 	for(p = runtime->pending_list; p; p = p->next) {
221 		if(runtime->now->addrlen != 0 &&
222 			sockaddr_cmp(&p->addr, p->addrlen, &runtime->now->addr,
223 			runtime->now->addrlen) != 0)
224 			continue;
225 		if((e=find_match(runtime->now->match, p->pkt, p->pkt_len,
226 			p->transport))) {
227 			*entry = e;
228 			*pend = p;
229 			return 1;
230 		}
231 	}
232 	return 0;
233 }
234 
235 /**
236  * Find the range that matches this pending message.
237  * @param runtime: runtime with current moment, and range list.
238  * @param entry: returns the pointer to entry that matches.
239  * @param pend: the pending that the entry must match.
240  * @return: true if a match is found.
241  */
242 static int
pending_find_match(struct replay_runtime * runtime,struct entry ** entry,struct fake_pending * pend)243 pending_find_match(struct replay_runtime* runtime, struct entry** entry,
244 	struct fake_pending* pend)
245 {
246 	int timenow = runtime->now->time_step;
247 	struct replay_range* p = runtime->scenario->range_list;
248 	while(p) {
249 		if(p->start_step <= timenow && timenow <= p->end_step &&
250 		  (p->addrlen == 0 || sockaddr_cmp(&p->addr, p->addrlen,
251 		  	&pend->addr, pend->addrlen) == 0) &&
252 		  (*entry = find_match(p->match, pend->pkt, pend->pkt_len,
253 		 	 pend->transport))) {
254 			log_info("matched query time %d in range [%d, %d] "
255 				"with entry line %d", timenow,
256 				p->start_step, p->end_step, (*entry)->lineno);
257 			if(p->addrlen != 0)
258 				log_addr(0, "matched ip", &p->addr, p->addrlen);
259 			log_testpkt_reply_pkt("matched pkt: ",
260 				(*entry)->reply_list);
261 			return 1;
262 		}
263 		p = p->next_range;
264 	}
265 	return 0;
266 }
267 
268 /**
269  * See if outgoing pending query matches an entry.
270  * @param runtime: runtime.
271  * @param entry: if true, the entry that matches is returned.
272  * @param pend: if true, the outgoing message that matches is returned.
273  * @return: true if pending query matches the now event.
274  */
275 static int
pending_matches_range(struct replay_runtime * runtime,struct entry ** entry,struct fake_pending ** pend)276 pending_matches_range(struct replay_runtime* runtime,
277 	struct entry** entry, struct fake_pending** pend)
278 {
279 	struct fake_pending* p = runtime->pending_list;
280 	/* slow, O(N*N), but it works as advertised with weird matching */
281 	while(p) {
282 		if(p->tcp_pkt_counter != 0) {
283 			/* continue tcp transfer */
284 			*pend = p;
285 			return 1;
286 		}
287 		if(pending_find_match(runtime, entry, p)) {
288 			*pend = p;
289 			return 1;
290 		}
291 		p = p->next;
292 	}
293 	return 0;
294 }
295 
296 /**
297  * Remove the item from the pending list.
298  */
299 static void
pending_list_delete(struct replay_runtime * runtime,struct fake_pending * pend)300 pending_list_delete(struct replay_runtime* runtime, struct fake_pending* pend)
301 {
302 	struct fake_pending** prev = &runtime->pending_list;
303 	struct fake_pending* p = runtime->pending_list;
304 
305 	while(p) {
306 		if(p == pend) {
307 			*prev = p->next;
308 			delete_fake_pending(pend);
309 			return;
310 		}
311 
312 		prev = &p->next;
313 		p = p->next;
314 	}
315 }
316 
317 /** number of replies in entry */
318 static int
count_reply_packets(struct entry * entry)319 count_reply_packets(struct entry* entry)
320 {
321 	int count = 0;
322 	struct reply_packet* reppkt = entry->reply_list;
323 	while(reppkt) {
324 		count++;
325 		reppkt = reppkt->next;
326 	}
327 	return count;
328 }
329 
330 /**
331  * Fill buffer with reply from the entry.
332  */
333 static void
fill_buffer_with_reply(sldns_buffer * buffer,struct entry * entry,uint8_t * q,size_t qlen,int tcp_pkt_counter)334 fill_buffer_with_reply(sldns_buffer* buffer, struct entry* entry, uint8_t* q,
335 	size_t qlen, int tcp_pkt_counter)
336 {
337 	struct reply_packet* reppkt;
338 	uint8_t* c;
339 	size_t clen;
340 	log_assert(entry && entry->reply_list);
341 	sldns_buffer_clear(buffer);
342 	reppkt = entry->reply_list;
343 	if(tcp_pkt_counter > 0) {
344 		int i = tcp_pkt_counter;
345 		while(reppkt && i--)
346 			reppkt = reppkt->next;
347 		if(!reppkt) fatal_exit("extra packet read from TCP stream but none is available");
348 		log_testpkt_reply_pkt("extra packet ", reppkt);
349 	}
350 	if(reppkt->reply_from_hex) {
351 		c = sldns_buffer_begin(reppkt->reply_from_hex);
352 		clen = sldns_buffer_limit(reppkt->reply_from_hex);
353 		if(!c) fatal_exit("out of memory");
354 	} else {
355 		c = reppkt->reply_pkt;
356 		clen = reppkt->reply_len;
357 	}
358 	if(c) {
359 		if(q) adjust_packet(entry, &c, &clen, q, qlen);
360 		sldns_buffer_write(buffer, c, clen);
361 		if(q) free(c);
362 	}
363 	sldns_buffer_flip(buffer);
364 }
365 
366 /**
367  * Perform range entry on pending message.
368  * @param runtime: runtime buffer size preference.
369  * @param entry: entry that codes for the reply to do.
370  * @param pend: pending query that is answered, callback called.
371  */
372 static void
answer_callback_from_entry(struct replay_runtime * runtime,struct entry * entry,struct fake_pending * pend)373 answer_callback_from_entry(struct replay_runtime* runtime,
374         struct entry* entry, struct fake_pending* pend)
375 {
376 	struct comm_point c;
377 	struct comm_reply repinfo;
378 	void* cb_arg = pend->cb_arg;
379 	comm_point_callback_type* cb = pend->callback;
380 
381 	memset(&c, 0, sizeof(c));
382 	c.fd = -1;
383 	c.buffer = sldns_buffer_new(runtime->bufsize);
384 	c.type = comm_udp;
385 	if(pend->transport == transport_tcp) {
386 		c.type = comm_tcp;
387 		c.tcp_timeout_msec = 30000;
388 		c.tcp_keepalive = runtime->tcp_seen_keepalive;
389 	}
390 	fill_buffer_with_reply(c.buffer, entry, pend->pkt, pend->pkt_len,
391 		pend->tcp_pkt_counter);
392 	repinfo.c = &c;
393 	repinfo.remote_addrlen = pend->addrlen;
394 	memcpy(&repinfo.remote_addr, &pend->addr, pend->addrlen);
395 	if(!pend->serviced) {
396 		if(entry && entry->reply_list->next &&
397 			pend->tcp_pkt_counter < count_reply_packets(entry)) {
398 			/* go to next packet next time */
399 			pend->tcp_pkt_counter++;
400 		} else {
401 			pending_list_delete(runtime, pend);
402 		}
403 	}
404 	if((*cb)(&c, cb_arg, NETEVENT_NOERROR, &repinfo)) {
405 		fatal_exit("testbound: unexpected: callback returned 1");
406 	}
407 	sldns_buffer_free(c.buffer);
408 }
409 
410 /** Check the now moment answer check event */
411 static void
answer_check_it(struct replay_runtime * runtime)412 answer_check_it(struct replay_runtime* runtime)
413 {
414 	struct replay_answer* ans = runtime->answer_list,
415 		*prev = NULL;
416 	log_assert(runtime && runtime->now &&
417 		runtime->now->evt_type == repevt_front_reply);
418 	while(ans) {
419 		enum transport_type tr = transport_tcp;
420 		if(ans->repinfo.c->type == comm_udp)
421 			tr = transport_udp;
422 		if((runtime->now->addrlen == 0 || sockaddr_cmp(
423 			&runtime->now->addr, runtime->now->addrlen,
424 			&ans->repinfo.remote_addr, ans->repinfo.remote_addrlen) == 0) &&
425 			find_match(runtime->now->match, ans->pkt,
426 				ans->pkt_len, tr)) {
427 			log_info("testbound matched event entry from line %d",
428 				runtime->now->match->lineno);
429 			log_info("testbound: do STEP %d %s",
430 				runtime->now->time_step,
431 				repevt_string(runtime->now->evt_type));
432 			if(prev)
433 				prev->next = ans->next;
434 			else 	runtime->answer_list = ans->next;
435 			if(!ans->next)
436 				runtime->answer_last = prev;
437 			if(ans->repinfo.c->tcp_keepalive)
438 				runtime->tcp_seen_keepalive = 1;
439 			delete_replay_answer(ans);
440 			return;
441 		} else {
442 			prev = ans;
443 			ans = ans->next;
444 		}
445 	}
446 	log_info("testbound: do STEP %d %s", runtime->now->time_step,
447 		repevt_string(runtime->now->evt_type));
448 	fatal_exit("testbound: not matched");
449 }
450 
451 /**
452  * Create commpoint (as return address) for a fake incoming query.
453  */
454 static void
fake_front_query(struct replay_runtime * runtime,struct replay_moment * todo)455 fake_front_query(struct replay_runtime* runtime, struct replay_moment *todo)
456 {
457 	struct comm_reply repinfo;
458 	memset(&repinfo, 0, sizeof(repinfo));
459 	repinfo.c = (struct comm_point*)calloc(1, sizeof(struct comm_point));
460 	if(!repinfo.c)
461 		fatal_exit("out of memory in fake_front_query");
462 	repinfo.remote_addrlen = (socklen_t)sizeof(struct sockaddr_in);
463 	if(todo->addrlen != 0) {
464 		repinfo.remote_addrlen = todo->addrlen;
465 		memcpy(&repinfo.remote_addr, &todo->addr, todo->addrlen);
466 		repinfo.client_addrlen = todo->addrlen;
467 		memcpy(&repinfo.client_addr, &todo->addr, todo->addrlen);
468 	}
469 	repinfo.c->fd = -1;
470 	repinfo.c->ev = (struct internal_event*)runtime;
471 	repinfo.c->buffer = sldns_buffer_new(runtime->bufsize);
472 	if(todo->match->match_transport == transport_tcp) {
473 		repinfo.c->type = comm_tcp;
474 		repinfo.c->tcp_timeout_msec = 30000;
475 		repinfo.c->tcp_keepalive = runtime->tcp_seen_keepalive;
476 	} else
477 		repinfo.c->type = comm_udp;
478 	fill_buffer_with_reply(repinfo.c->buffer, todo->match, NULL, 0, 0);
479 	log_info("testbound: incoming QUERY");
480 	log_testpkt_reply_pkt("query pkt ", todo->match->reply_list);
481 	/* call the callback for incoming queries */
482 	if((*runtime->callback_query)(repinfo.c, runtime->cb_arg,
483 		NETEVENT_NOERROR, &repinfo)) {
484 		/* send immediate reply */
485 		comm_point_send_reply(&repinfo);
486 	}
487 	/* clear it again, in case copy not done properly */
488 	memset(&repinfo, 0, sizeof(repinfo));
489 }
490 
491 /**
492  * Perform callback for fake pending message.
493  */
494 static void
fake_pending_callback(struct replay_runtime * runtime,struct replay_moment * todo,int error)495 fake_pending_callback(struct replay_runtime* runtime,
496 	struct replay_moment* todo, int error)
497 {
498 	struct fake_pending* p = runtime->pending_list;
499 	struct comm_reply repinfo;
500 	struct comm_point c;
501 	void* cb_arg;
502 	comm_point_callback_type* cb;
503 
504 	memset(&c, 0, sizeof(c));
505 	if(!p) fatal_exit("No pending queries.");
506 	cb_arg = p->cb_arg;
507 	cb = p->callback;
508 	c.buffer = sldns_buffer_new(runtime->bufsize);
509 	c.type = comm_udp;
510 	if(p->transport == transport_tcp) {
511 		c.type = comm_tcp;
512 		c.tcp_timeout_msec = 30000;
513 		c.tcp_keepalive = runtime->tcp_seen_keepalive;
514 	}
515 	if(todo->evt_type == repevt_back_reply && todo->match) {
516 		fill_buffer_with_reply(c.buffer, todo->match, p->pkt,
517 			p->pkt_len, p->tcp_pkt_counter);
518 	}
519 	repinfo.c = &c;
520 	repinfo.remote_addrlen = p->addrlen;
521 	memcpy(&repinfo.remote_addr, &p->addr, p->addrlen);
522 	if(!p->serviced) {
523 		if(todo->match && todo->match->reply_list->next && !error &&
524 			p->tcp_pkt_counter < count_reply_packets(todo->match)) {
525 			/* go to next packet next time */
526 			p->tcp_pkt_counter++;
527 		} else {
528 			pending_list_delete(runtime, p);
529 		}
530 	}
531 	if((*cb)(&c, cb_arg, error, &repinfo)) {
532 		fatal_exit("unexpected: pending callback returned 1");
533 	}
534 	/* delete the pending item. */
535 	sldns_buffer_free(c.buffer);
536 }
537 
538 /** pass time */
539 static void
moment_assign(struct replay_runtime * runtime,struct replay_moment * mom)540 moment_assign(struct replay_runtime* runtime, struct replay_moment* mom)
541 {
542 	char* value = macro_process(runtime->vars, runtime, mom->string);
543 	if(!value)
544 		fatal_exit("could not process macro step %d", mom->time_step);
545 	log_info("assign %s = %s", mom->variable, value);
546 	if(!macro_assign(runtime->vars, mom->variable, value))
547 		fatal_exit("out of memory storing macro");
548 	free(value);
549 	if(verbosity >= VERB_ALGO)
550 		macro_print_debug(runtime->vars);
551 }
552 
553 /** pass time */
554 static void
time_passes(struct replay_runtime * runtime,struct replay_moment * mom)555 time_passes(struct replay_runtime* runtime, struct replay_moment* mom)
556 {
557 	struct fake_timer *t;
558 	struct timeval tv = mom->elapse;
559 	if(mom->string) {
560 		char* xp = macro_process(runtime->vars, runtime, mom->string);
561 		double sec;
562 		if(!xp) fatal_exit("could not macro expand %s", mom->string);
563 		verbose(VERB_ALGO, "EVAL %s", mom->string);
564 		sec = atof(xp);
565 		free(xp);
566 #ifndef S_SPLINT_S
567 		tv.tv_sec = sec;
568 		tv.tv_usec = (int)((sec - (double)tv.tv_sec) *1000000. + 0.5);
569 #endif
570 	}
571 	timeval_add(&runtime->now_tv, &tv);
572 	runtime->now_secs = (time_t)runtime->now_tv.tv_sec;
573 #ifndef S_SPLINT_S
574 	log_info("elapsed %d.%6.6d  now %d.%6.6d",
575 		(int)tv.tv_sec, (int)tv.tv_usec,
576 		(int)runtime->now_tv.tv_sec, (int)runtime->now_tv.tv_usec);
577 #endif
578 	/* see if any timers have fired; and run them */
579 	while( (t=replay_get_oldest_timer(runtime)) ) {
580 		t->enabled = 0;
581 		log_info("fake_timer callback");
582 		fptr_ok(fptr_whitelist_comm_timer(t->cb));
583 		(*t->cb)(t->cb_arg);
584 	}
585 }
586 
587 /** check autotrust file contents */
588 static void
autotrust_check(struct replay_runtime * runtime,struct replay_moment * mom)589 autotrust_check(struct replay_runtime* runtime, struct replay_moment* mom)
590 {
591 	char name[1024], line[1024];
592 	FILE *in;
593 	int lineno = 0, oke=1;
594 	char* expanded;
595 	struct config_strlist* p;
596 	line[sizeof(line)-1] = 0;
597 	log_assert(mom->autotrust_id);
598 	fake_temp_file("_auto_", mom->autotrust_id, name, sizeof(name));
599 	in = fopen(name, "r");
600 	if(!in) fatal_exit("could not open %s: %s", name, strerror(errno));
601 	for(p=mom->file_content; p; p=p->next) {
602 		lineno++;
603 		if(!fgets(line, (int)sizeof(line)-1, in)) {
604 			log_err("autotrust check failed, could not read line");
605 			log_err("file %s, line %d", name, lineno);
606 			log_err("should be: %s", p->str);
607 			fatal_exit("autotrust_check failed");
608 		}
609 		strip_end_white(line);
610 		expanded = macro_process(runtime->vars, runtime, p->str);
611 		if(!expanded)
612 			fatal_exit("could not expand macro line %d", lineno);
613 		if(verbosity >= 7 && strcmp(p->str, expanded) != 0)
614 			log_info("expanded '%s' to '%s'", p->str, expanded);
615 		if(strcmp(expanded, line) != 0) {
616 			log_err("mismatch in file %s, line %d", name, lineno);
617 			log_err("file has : %s", line);
618 			log_err("should be: %s", expanded);
619 			free(expanded);
620 			oke = 0;
621 			continue;
622 		}
623 		free(expanded);
624 		fprintf(stderr, "%s:%2d ok : %s\n", name, lineno, line);
625 	}
626 	if(fgets(line, (int)sizeof(line)-1, in)) {
627 		log_err("autotrust check failed, extra lines in %s after %d",
628 			name, lineno);
629 		do {
630 			fprintf(stderr, "file has: %s", line);
631 		} while(fgets(line, (int)sizeof(line)-1, in));
632 		oke = 0;
633 	}
634 	fclose(in);
635 	if(!oke)
636 		fatal_exit("autotrust_check STEP %d failed", mom->time_step);
637 	log_info("autotrust %s is OK", mom->autotrust_id);
638 }
639 
640 /** check tempfile file contents */
641 static void
tempfile_check(struct replay_runtime * runtime,struct replay_moment * mom)642 tempfile_check(struct replay_runtime* runtime, struct replay_moment* mom)
643 {
644 	char name[1024], line[1024];
645 	FILE *in;
646 	int lineno = 0, oke=1;
647 	char* expanded;
648 	struct config_strlist* p;
649 	line[sizeof(line)-1] = 0;
650 	log_assert(mom->autotrust_id);
651 	fake_temp_file("_temp_", mom->autotrust_id, name, sizeof(name));
652 	in = fopen(name, "r");
653 	if(!in) fatal_exit("could not open %s: %s", name, strerror(errno));
654 	for(p=mom->file_content; p; p=p->next) {
655 		lineno++;
656 		if(!fgets(line, (int)sizeof(line)-1, in)) {
657 			log_err("tempfile check failed, could not read line");
658 			log_err("file %s, line %d", name, lineno);
659 			log_err("should be: %s", p->str);
660 			fatal_exit("tempfile_check failed");
661 		}
662 		strip_end_white(line);
663 		expanded = macro_process(runtime->vars, runtime, p->str);
664 		if(!expanded)
665 			fatal_exit("could not expand macro line %d", lineno);
666 		if(verbosity >= 7 && strcmp(p->str, expanded) != 0)
667 			log_info("expanded '%s' to '%s'", p->str, expanded);
668 		if(strcmp(expanded, line) != 0) {
669 			log_err("mismatch in file %s, line %d", name, lineno);
670 			log_err("file has : %s", line);
671 			log_err("should be: %s", expanded);
672 			free(expanded);
673 			oke = 0;
674 			continue;
675 		}
676 		free(expanded);
677 		fprintf(stderr, "%s:%2d ok : %s\n", name, lineno, line);
678 	}
679 	if(fgets(line, (int)sizeof(line)-1, in)) {
680 		log_err("tempfile check failed, extra lines in %s after %d",
681 			name, lineno);
682 		do {
683 			fprintf(stderr, "file has: %s", line);
684 		} while(fgets(line, (int)sizeof(line)-1, in));
685 		oke = 0;
686 	}
687 	fclose(in);
688 	if(!oke)
689 		fatal_exit("tempfile_check STEP %d failed", mom->time_step);
690 	log_info("tempfile %s is OK", mom->autotrust_id);
691 }
692 
693 /** Store RTT in infra cache */
694 static void
do_infra_rtt(struct replay_runtime * runtime)695 do_infra_rtt(struct replay_runtime* runtime)
696 {
697 	struct replay_moment* now = runtime->now;
698 	int rto;
699 	size_t dplen = 0;
700 	uint8_t* dp = sldns_str2wire_dname(now->variable, &dplen);
701 	if(!dp) fatal_exit("cannot parse %s", now->variable);
702 	rto = infra_rtt_update(runtime->infra, &now->addr, now->addrlen,
703 		dp, dplen, LDNS_RR_TYPE_A, atoi(now->string),
704 		-1, runtime->now_secs);
705 	log_addr(0, "INFRA_RTT for", &now->addr, now->addrlen);
706 	log_info("INFRA_RTT(%s roundtrip %d): rto of %d", now->variable,
707 		atoi(now->string), rto);
708 	if(rto == 0) fatal_exit("infra_rtt_update failed");
709 	free(dp);
710 }
711 
712 /** Flush message from message cache. */
713 static void
do_flush_message(struct replay_runtime * runtime)714 do_flush_message(struct replay_runtime* runtime)
715 {
716 	struct replay_moment* now = runtime->now;
717 	uint8_t rr[1024];
718 	size_t rr_len = sizeof(rr), dname_len = 0;
719 	hashvalue_type h;
720 	struct query_info k;
721 
722 	if(sldns_str2wire_rr_question_buf(now->string, rr, &rr_len,
723 		&dname_len, NULL, 0, NULL, 0) != 0)
724 		fatal_exit("could not parse '%s'", now->string);
725 
726 	log_info("remove message %s", now->string);
727 	k.qname = rr;
728 	k.qname_len = dname_len;
729 	k.qtype = sldns_wirerr_get_type(rr, rr_len, dname_len);
730 	k.qclass = sldns_wirerr_get_class(rr, rr_len, dname_len);
731 	k.local_alias = NULL;
732 	h = query_info_hash(&k, 0);
733 	slabhash_remove(runtime->daemon->env->msg_cache, h, &k);
734 }
735 
736 /** Expire message from message cache. */
737 static void
do_expire_message(struct replay_runtime * runtime)738 do_expire_message(struct replay_runtime* runtime)
739 {
740 	struct replay_moment* now = runtime->now;
741 	uint8_t rr[1024];
742 	size_t rr_len = sizeof(rr), dname_len = 0;
743 	hashvalue_type h;
744 	struct query_info k;
745 	struct lruhash_entry* e;
746 
747 	if(sldns_str2wire_rr_question_buf(now->string, rr, &rr_len,
748 		&dname_len, NULL, 0, NULL, 0) != 0)
749 		fatal_exit("could not parse '%s'", now->string);
750 
751 	log_info("expire message %s", now->string);
752 	k.qname = rr;
753 	k.qname_len = dname_len;
754 	k.qtype = sldns_wirerr_get_type(rr, rr_len, dname_len);
755 	k.qclass = sldns_wirerr_get_class(rr, rr_len, dname_len);
756 	k.local_alias = NULL;
757 	h = query_info_hash(&k, 0);
758 
759 	e = slabhash_lookup(runtime->daemon->env->msg_cache, h, &k, 0);
760 	if(e) {
761 		struct msgreply_entry* msg = (struct msgreply_entry*)e->key;
762 		struct reply_info* rep = (struct reply_info*)msg->entry.data;
763 		time_t expired = runtime->now_secs;
764 		expired -= 3;
765 		rep->ttl = expired;
766 		rep->prefetch_ttl = expired;
767 		rep->serve_expired_ttl = expired;
768 		lock_rw_unlock(&msg->entry.lock);
769 	}
770 }
771 
772 /** perform exponential backoff on the timeout */
773 static void
expon_timeout_backoff(struct replay_runtime * runtime)774 expon_timeout_backoff(struct replay_runtime* runtime)
775 {
776 	struct fake_pending* p = runtime->pending_list;
777 	int rtt, vs;
778 	uint8_t edns_lame_known;
779 	int last_rtt, rto;
780 	if(!p) return; /* no pending packet to backoff */
781 	if(!infra_host(runtime->infra, &p->addr, p->addrlen, p->zone,
782 		p->zonelen, runtime->now_secs, &vs, &edns_lame_known, &rtt))
783 		return;
784 	last_rtt = rtt;
785 	rto = infra_rtt_update(runtime->infra, &p->addr, p->addrlen, p->zone,
786 		p->zonelen, p->qtype, -1, last_rtt, runtime->now_secs);
787 	log_info("infra_rtt_update returned rto %d", rto);
788 }
789 
790 /**
791  * Advance to the next moment.
792  */
793 static void
advance_moment(struct replay_runtime * runtime)794 advance_moment(struct replay_runtime* runtime)
795 {
796 	if(!runtime->now)
797 		runtime->now = runtime->scenario->mom_first;
798 	else 	runtime->now = runtime->now->mom_next;
799 }
800 
801 /**
802  * Perform actions or checks determined by the moment.
803  * Also advances the time by one step.
804  * @param runtime: scenario runtime information.
805  */
806 static void
do_moment_and_advance(struct replay_runtime * runtime)807 do_moment_and_advance(struct replay_runtime* runtime)
808 {
809 	struct replay_moment* mom;
810 	if(!runtime->now) {
811 		advance_moment(runtime);
812 		return;
813 	}
814 	log_info("testbound: do STEP %d %s", runtime->now->time_step,
815 		repevt_string(runtime->now->evt_type));
816 	switch(runtime->now->evt_type) {
817 	case repevt_nothing:
818 		advance_moment(runtime);
819 		break;
820 	case repevt_front_query:
821 		/* advance moment before doing the step, so that the next
822 		   moment which may check some result of the mom step
823 		   can catch those results. */
824 		mom = runtime->now;
825 		advance_moment(runtime);
826 		fake_front_query(runtime, mom);
827 		break;
828 	case repevt_front_reply:
829 		if(runtime->answer_list)
830 			log_err("testbound: There are unmatched answers.");
831 		fatal_exit("testbound: query answer not matched");
832 		break;
833 	case repevt_timeout:
834 		mom = runtime->now;
835 		advance_moment(runtime);
836 		expon_timeout_backoff(runtime);
837 		fake_pending_callback(runtime, mom, NETEVENT_TIMEOUT);
838 		break;
839 	case repevt_back_reply:
840 		mom = runtime->now;
841 		advance_moment(runtime);
842 		fake_pending_callback(runtime, mom, NETEVENT_NOERROR);
843 		break;
844 	case repevt_back_query:
845 		/* Back queries are matched when they are sent out. */
846 		log_err("No query matching the current moment was sent.");
847 		fatal_exit("testbound: back query not matched");
848 		break;
849 	case repevt_error:
850 		mom = runtime->now;
851 		advance_moment(runtime);
852 		fake_pending_callback(runtime, mom, NETEVENT_CLOSED);
853 		break;
854 	case repevt_time_passes:
855 		time_passes(runtime, runtime->now);
856 		advance_moment(runtime);
857 		break;
858 	case repevt_autotrust_check:
859 		autotrust_check(runtime, runtime->now);
860 		advance_moment(runtime);
861 		break;
862 	case repevt_tempfile_check:
863 		tempfile_check(runtime, runtime->now);
864 		advance_moment(runtime);
865 		break;
866 	case repevt_assign:
867 		moment_assign(runtime, runtime->now);
868 		advance_moment(runtime);
869 		break;
870 	case repevt_traffic:
871 		advance_moment(runtime);
872 		break;
873 	case repevt_infra_rtt:
874 		do_infra_rtt(runtime);
875 		advance_moment(runtime);
876 		break;
877 	case repevt_flush_message:
878 		do_flush_message(runtime);
879 		advance_moment(runtime);
880 		break;
881 	case repevt_expire_message:
882 		do_expire_message(runtime);
883 		advance_moment(runtime);
884 		break;
885 	default:
886 		fatal_exit("testbound: unknown event type %d",
887 			runtime->now->evt_type);
888 	}
889 }
890 
891 /** run the scenario in event callbacks */
892 static void
run_scenario(struct replay_runtime * runtime)893 run_scenario(struct replay_runtime* runtime)
894 {
895 	struct entry* entry = NULL;
896 	struct fake_pending* pending = NULL;
897 	int max_rounds = 5000;
898 	int rounds = 0;
899 	runtime->now = runtime->scenario->mom_first;
900 	log_info("testbound: entering fake runloop");
901 	do {
902 		/* if moment matches pending query do it. */
903 		/* else if moment matches given answer, do it */
904 		/* else if precoded_range matches pending, do it */
905 		/* else do the current moment */
906 		if(pending_matches_current(runtime, &entry, &pending)) {
907 			log_info("testbound: do STEP %d CHECK_OUT_QUERY",
908 				runtime->now->time_step);
909 			advance_moment(runtime);
910 			if(entry->copy_id)
911 				answer_callback_from_entry(runtime, entry,
912 				pending);
913 		} else if(runtime->answer_list && runtime->now &&
914 			runtime->now->evt_type == repevt_front_reply) {
915 			answer_check_it(runtime);
916 			advance_moment(runtime);
917 		} else if(runtime->now && pending_matches_range(runtime,
918 			&entry, &pending)) {
919 			if(entry)
920 				answer_callback_from_entry(runtime, entry, pending);
921 		} else {
922 			do_moment_and_advance(runtime);
923 		}
924 		log_info("testbound: end of event stage");
925 		rounds++;
926 		if(rounds > max_rounds)
927 			fatal_exit("testbound: too many rounds, it loops.");
928 	} while(runtime->now);
929 
930 	if(runtime->pending_list) {
931 		struct fake_pending* p;
932 		log_err("testbound: there are still messages pending.");
933 		for(p = runtime->pending_list; p; p=p->next) {
934 			log_pkt("pending msg", p->pkt, p->pkt_len);
935 			log_addr(0, "pending to", &p->addr, p->addrlen);
936 		}
937 		fatal_exit("testbound: there are still messages pending.");
938 	}
939 	if(runtime->answer_list) {
940 		fatal_exit("testbound: there are unmatched answers.");
941 	}
942 	log_info("testbound: exiting fake runloop.");
943 	runtime->exit_cleanly = 1;
944 }
945 
946 /*********** Dummy routines ***********/
947 
948 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 (dot_sslctx),void * ATTR_UNUSED (doh_sslctx),void * ATTR_UNUSED (quic_ssl),struct dt_env * ATTR_UNUSED (dtenv),struct doq_table * ATTR_UNUSED (table),struct ub_randstate * ATTR_UNUSED (rnd),struct config_file * ATTR_UNUSED (cfg),comm_point_callback_type * cb,void * cb_arg)949 listen_create(struct comm_base* base, struct listen_port* ATTR_UNUSED(ports),
950 	size_t bufsize, int ATTR_UNUSED(tcp_accept_count),
951 	int ATTR_UNUSED(tcp_idle_timeout),
952 	int ATTR_UNUSED(harden_large_queries),
953 	uint32_t ATTR_UNUSED(http_max_streams),
954 	char* ATTR_UNUSED(http_endpoint),
955 	int ATTR_UNUSED(http_notls),
956 	struct tcl_list* ATTR_UNUSED(tcp_conn_limit),
957 	void* ATTR_UNUSED(dot_sslctx), void* ATTR_UNUSED(doh_sslctx),
958 	void* ATTR_UNUSED(quic_ssl),
959 	struct dt_env* ATTR_UNUSED(dtenv),
960 	struct doq_table* ATTR_UNUSED(table),
961 	struct ub_randstate* ATTR_UNUSED(rnd),
962 	struct config_file* ATTR_UNUSED(cfg),
963 	comm_point_callback_type* cb, void *cb_arg)
964 {
965 	struct replay_runtime* runtime = (struct replay_runtime*)base;
966 	struct listen_dnsport* l= calloc(1, sizeof(struct listen_dnsport));
967 	if(!l)
968 		return NULL;
969 	l->base = base;
970 	l->udp_buff = sldns_buffer_new(bufsize);
971 	if(!l->udp_buff) {
972 		free(l);
973 		return NULL;
974 	}
975 	runtime->callback_query = cb;
976 	runtime->cb_arg = cb_arg;
977 	runtime->bufsize = bufsize;
978 	return l;
979 }
980 
981 void
listen_delete(struct listen_dnsport * listen)982 listen_delete(struct listen_dnsport* listen)
983 {
984 	if(!listen)
985 		return;
986 	sldns_buffer_free(listen->udp_buff);
987 	free(listen);
988 }
989 
990 struct comm_base*
comm_base_create(int ATTR_UNUSED (sigs))991 comm_base_create(int ATTR_UNUSED(sigs))
992 {
993 	/* we return the runtime structure instead. */
994 	struct replay_runtime* runtime = (struct replay_runtime*)
995 		calloc(1, sizeof(struct replay_runtime));
996 	if(!runtime)
997 		fatal_exit("out of memory in fake_event.c:comm_base_create");
998 	runtime->scenario = saved_scenario;
999 	runtime->vars = macro_store_create();
1000 	if(!runtime->vars) fatal_exit("out of memory");
1001 	return (struct comm_base*)runtime;
1002 }
1003 
1004 void
comm_base_delete(struct comm_base * b)1005 comm_base_delete(struct comm_base* b)
1006 {
1007 	struct replay_runtime* runtime = (struct replay_runtime*)b;
1008 	struct fake_pending* p, *np;
1009 	struct replay_answer* a, *na;
1010 	struct fake_timer* t, *nt;
1011 	if(!runtime)
1012 		return;
1013 	runtime->scenario= NULL;
1014 	p = runtime->pending_list;
1015 	while(p) {
1016 		np = p->next;
1017 		delete_fake_pending(p);
1018 		p = np;
1019 	}
1020 	a = runtime->answer_list;
1021 	while(a) {
1022 		na = a->next;
1023 		delete_replay_answer(a);
1024 		a = na;
1025 	}
1026 	t = runtime->timer_list;
1027 	while(t) {
1028 		nt = t->next;
1029 		free(t);
1030 		t = nt;
1031 	}
1032 	macro_store_delete(runtime->vars);
1033 	free(runtime);
1034 }
1035 
1036 void
comm_base_timept(struct comm_base * b,time_t ** tt,struct timeval ** tv)1037 comm_base_timept(struct comm_base* b, time_t** tt, struct timeval** tv)
1038 {
1039 	struct replay_runtime* runtime = (struct replay_runtime*)b;
1040 	*tt = &runtime->now_secs;
1041 	*tv = &runtime->now_tv;
1042 }
1043 
1044 void
comm_base_dispatch(struct comm_base * b)1045 comm_base_dispatch(struct comm_base* b)
1046 {
1047 	struct replay_runtime* runtime = (struct replay_runtime*)b;
1048 	run_scenario(runtime);
1049 	if(runtime->sig_cb)
1050 		(*runtime->sig_cb)(SIGTERM, runtime->sig_cb_arg);
1051 	else	exit(0); /* OK exit when LIBEVENT_SIGNAL_PROBLEM exists */
1052 }
1053 
1054 void
comm_base_exit(struct comm_base * b)1055 comm_base_exit(struct comm_base* b)
1056 {
1057 	struct replay_runtime* runtime = (struct replay_runtime*)b;
1058 	if(!runtime->exit_cleanly) {
1059 		/* some sort of failure */
1060 		fatal_exit("testbound: comm_base_exit was called.");
1061 	}
1062 }
1063 
1064 struct comm_signal*
comm_signal_create(struct comm_base * base,void (* callback)(int,void *),void * cb_arg)1065 comm_signal_create(struct comm_base* base,
1066         void (*callback)(int, void*), void* cb_arg)
1067 {
1068 	struct replay_runtime* runtime = (struct replay_runtime*)base;
1069 	runtime->sig_cb = callback;
1070 	runtime->sig_cb_arg = cb_arg;
1071 	return calloc(1, sizeof(struct comm_signal));
1072 }
1073 
1074 int
comm_signal_bind(struct comm_signal * ATTR_UNUSED (comsig),int ATTR_UNUSED (sig))1075 comm_signal_bind(struct comm_signal* ATTR_UNUSED(comsig), int
1076 	ATTR_UNUSED(sig))
1077 {
1078 	return 1;
1079 }
1080 
1081 void
comm_signal_delete(struct comm_signal * comsig)1082 comm_signal_delete(struct comm_signal* comsig)
1083 {
1084 	free(comsig);
1085 }
1086 
1087 void
comm_point_send_reply(struct comm_reply * repinfo)1088 comm_point_send_reply(struct comm_reply* repinfo)
1089 {
1090 	struct replay_answer* ans = (struct replay_answer*)calloc(1,
1091 		sizeof(struct replay_answer));
1092 	struct replay_runtime* runtime = (struct replay_runtime*)repinfo->c->ev;
1093 	log_info("testbound: comm_point_send_reply fake");
1094 	/* dump it into the todo list */
1095 	log_assert(ans);
1096 	memcpy(&ans->repinfo, repinfo, sizeof(struct comm_reply));
1097 	ans->next = NULL;
1098 	if(runtime->answer_last)
1099 		runtime->answer_last->next = ans;
1100 	else 	runtime->answer_list = ans;
1101 	runtime->answer_last = ans;
1102 
1103 	/* try to parse packet */
1104 	ans->pkt = memdup(sldns_buffer_begin(ans->repinfo.c->buffer),
1105 		sldns_buffer_limit(ans->repinfo.c->buffer));
1106 	ans->pkt_len = sldns_buffer_limit(ans->repinfo.c->buffer);
1107 	if(!ans->pkt) fatal_exit("out of memory");
1108 	log_pkt("reply pkt: ", ans->pkt, ans->pkt_len);
1109 }
1110 
1111 void
comm_point_drop_reply(struct comm_reply * repinfo)1112 comm_point_drop_reply(struct comm_reply* repinfo)
1113 {
1114 	log_info("comm_point_drop_reply fake");
1115 	if(repinfo->c) {
1116 		sldns_buffer_free(repinfo->c->buffer);
1117 		free(repinfo->c);
1118 	}
1119 }
1120 
1121 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))1122 outside_network_create(struct comm_base* base, size_t bufsize,
1123 	size_t ATTR_UNUSED(num_ports), char** ATTR_UNUSED(ifs),
1124 	int ATTR_UNUSED(num_ifs), int ATTR_UNUSED(do_ip4),
1125 	int ATTR_UNUSED(do_ip6), size_t ATTR_UNUSED(num_tcp),
1126 	int ATTR_UNUSED(dscp),
1127 	struct infra_cache* infra,
1128 	struct ub_randstate* ATTR_UNUSED(rnd),
1129 	int ATTR_UNUSED(use_caps_for_id), int* ATTR_UNUSED(availports),
1130 	int ATTR_UNUSED(numavailports), size_t ATTR_UNUSED(unwanted_threshold),
1131 	int ATTR_UNUSED(outgoing_tcp_mss),
1132 	void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param),
1133 	int ATTR_UNUSED(do_udp), void* ATTR_UNUSED(sslctx),
1134 	int ATTR_UNUSED(delayclose), int ATTR_UNUSED(tls_use_sni),
1135 	struct dt_env* ATTR_UNUSED(dtenv), int ATTR_UNUSED(udp_connect),
1136 	int ATTR_UNUSED(max_reuse_tcp_queries), int ATTR_UNUSED(tcp_reuse_timeout),
1137 	int ATTR_UNUSED(tcp_auth_query_timeout))
1138 {
1139 	struct replay_runtime* runtime = (struct replay_runtime*)base;
1140 	struct outside_network* outnet =  calloc(1,
1141 		sizeof(struct outside_network));
1142 	(void)unwanted_action;
1143 	if(!outnet)
1144 		return NULL;
1145 	runtime->infra = infra;
1146 	outnet->base = base;
1147 	outnet->udp_buff = sldns_buffer_new(bufsize);
1148 	if(!outnet->udp_buff) {
1149 		free(outnet);
1150 		return NULL;
1151 	}
1152 	return outnet;
1153 }
1154 
1155 void
outside_network_delete(struct outside_network * outnet)1156 outside_network_delete(struct outside_network* outnet)
1157 {
1158 	if(!outnet)
1159 		return;
1160 	sldns_buffer_free(outnet->udp_buff);
1161 	free(outnet);
1162 }
1163 
1164 void
outside_network_quit_prepare(struct outside_network * ATTR_UNUSED (outnet))1165 outside_network_quit_prepare(struct outside_network* ATTR_UNUSED(outnet))
1166 {
1167 }
1168 
1169 struct pending*
pending_udp_query(struct serviced_query * sq,sldns_buffer * packet,int timeout,comm_point_callback_type * callback,void * callback_arg)1170 pending_udp_query(struct serviced_query* sq, sldns_buffer* packet,
1171 	int timeout, comm_point_callback_type* callback, void* callback_arg)
1172 {
1173 	struct replay_runtime* runtime = (struct replay_runtime*)
1174 		sq->outnet->base;
1175 	struct fake_pending* pend = (struct fake_pending*)calloc(1,
1176 		sizeof(struct fake_pending));
1177 	log_assert(pend);
1178 	pend->buffer = sldns_buffer_new(sldns_buffer_capacity(packet));
1179 	log_assert(pend->buffer);
1180 	sldns_buffer_write(pend->buffer, sldns_buffer_begin(packet),
1181 		sldns_buffer_limit(packet));
1182 	sldns_buffer_flip(pend->buffer);
1183 	memcpy(&pend->addr, &sq->addr, sq->addrlen);
1184 	pend->addrlen = sq->addrlen;
1185 	pend->callback = callback;
1186 	pend->cb_arg = callback_arg;
1187 	pend->timeout = timeout/1000;
1188 	pend->transport = transport_udp;
1189 	pend->pkt = NULL;
1190 	pend->zone = NULL;
1191 	pend->serviced = 0;
1192 	pend->runtime = runtime;
1193 	pend->pkt_len = sldns_buffer_limit(packet);
1194 	pend->pkt = memdup(sldns_buffer_begin(packet), pend->pkt_len);
1195 	if(!pend->pkt) fatal_exit("out of memory");
1196 	log_pkt("pending udp pkt: ", pend->pkt, pend->pkt_len);
1197 
1198 	/* see if it matches the current moment */
1199 	if(runtime->now && runtime->now->evt_type == repevt_back_query &&
1200 		(runtime->now->addrlen == 0 || sockaddr_cmp(
1201 			&runtime->now->addr, runtime->now->addrlen,
1202 			&pend->addr, pend->addrlen) == 0) &&
1203 		find_match(runtime->now->match, pend->pkt, pend->pkt_len,
1204 			pend->transport)) {
1205 		log_info("testbound: matched pending to event. "
1206 			"advance time between events.");
1207 		log_info("testbound: do STEP %d %s", runtime->now->time_step,
1208 			repevt_string(runtime->now->evt_type));
1209 		advance_moment(runtime);
1210 		/* still create the pending, because we need it to callback */
1211 	}
1212 	log_info("testbound: created fake pending");
1213 	/* add to list */
1214 	pend->next = runtime->pending_list;
1215 	runtime->pending_list = pend;
1216 	return (struct pending*)pend;
1217 }
1218 
1219 struct waiting_tcp*
pending_tcp_query(struct serviced_query * sq,sldns_buffer * packet,int timeout,comm_point_callback_type * callback,void * callback_arg)1220 pending_tcp_query(struct serviced_query* sq, sldns_buffer* packet,
1221 	int timeout, comm_point_callback_type* callback, void* callback_arg)
1222 {
1223 	struct replay_runtime* runtime = (struct replay_runtime*)
1224 		sq->outnet->base;
1225 	struct fake_pending* pend = (struct fake_pending*)calloc(1,
1226 		sizeof(struct fake_pending));
1227 	log_assert(pend);
1228 	pend->buffer = sldns_buffer_new(sldns_buffer_capacity(packet));
1229 	log_assert(pend->buffer);
1230 	sldns_buffer_write(pend->buffer, sldns_buffer_begin(packet),
1231 		sldns_buffer_limit(packet));
1232 	sldns_buffer_flip(pend->buffer);
1233 	memcpy(&pend->addr, &sq->addr, sq->addrlen);
1234 	pend->addrlen = sq->addrlen;
1235 	pend->callback = callback;
1236 	pend->cb_arg = callback_arg;
1237 	pend->timeout = timeout/1000;
1238 	pend->transport = transport_tcp;
1239 	pend->pkt = NULL;
1240 	pend->zone = NULL;
1241 	pend->runtime = runtime;
1242 	pend->serviced = 0;
1243 	pend->pkt_len = sldns_buffer_limit(packet);
1244 	pend->pkt = memdup(sldns_buffer_begin(packet), pend->pkt_len);
1245 	if(!pend->pkt) fatal_exit("out of memory");
1246 	log_pkt("pending tcp pkt: ", pend->pkt, pend->pkt_len);
1247 
1248 	/* see if it matches the current moment */
1249 	if(runtime->now && runtime->now->evt_type == repevt_back_query &&
1250 		(runtime->now->addrlen == 0 || sockaddr_cmp(
1251 			&runtime->now->addr, runtime->now->addrlen,
1252 			&pend->addr, pend->addrlen) == 0) &&
1253 		find_match(runtime->now->match, pend->pkt, pend->pkt_len,
1254 			pend->transport)) {
1255 		log_info("testbound: matched pending to event. "
1256 			"advance time between events.");
1257 		log_info("testbound: do STEP %d %s", runtime->now->time_step,
1258 			repevt_string(runtime->now->evt_type));
1259 		advance_moment(runtime);
1260 		/* still create the pending, because we need it to callback */
1261 	}
1262 	log_info("testbound: created fake pending");
1263 	/* add to list */
1264 	pend->next = runtime->pending_list;
1265 	runtime->pending_list = pend;
1266 	return (struct waiting_tcp*)pend;
1267 }
1268 
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 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))1269 struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
1270 	struct query_info* qinfo, uint16_t flags, int dnssec,
1271 	int ATTR_UNUSED(want_dnssec), int ATTR_UNUSED(nocaps),
1272 	int ATTR_UNUSED(check_ratelimit),
1273 	int tcp_upstream, int ATTR_UNUSED(ssl_upstream),
1274 	char* ATTR_UNUSED(tls_auth_name), struct sockaddr_storage* addr,
1275 	socklen_t addrlen, uint8_t* zone, size_t zonelen,
1276 	struct module_qstate* qstate, comm_point_callback_type* callback,
1277 	void* callback_arg, sldns_buffer* ATTR_UNUSED(buff),
1278 	struct module_env* env, int* ATTR_UNUSED(was_ratelimited))
1279 {
1280 	struct replay_runtime* runtime = (struct replay_runtime*)outnet->base;
1281 	struct fake_pending* pend = (struct fake_pending*)calloc(1,
1282 		sizeof(struct fake_pending));
1283 	char z[LDNS_MAX_DOMAINLEN];
1284 	log_assert(pend);
1285 	log_nametypeclass(VERB_OPS, "pending serviced query",
1286 		qinfo->qname, qinfo->qtype, qinfo->qclass);
1287 	dname_str(zone, z);
1288 	verbose(VERB_OPS, "pending serviced query zone %s flags%s%s%s%s",
1289 		z, (flags&BIT_RD)?" RD":"", (flags&BIT_CD)?" CD":"",
1290 		(flags&~(BIT_RD|BIT_CD))?" MORE":"", (dnssec)?" DO":"");
1291 
1292 	/* create packet with EDNS */
1293 	pend->buffer = sldns_buffer_new(4096);
1294 	log_assert(pend->buffer);
1295 	sldns_buffer_write_u16(pend->buffer, 0); /* id */
1296 	sldns_buffer_write_u16(pend->buffer, flags);
1297 	sldns_buffer_write_u16(pend->buffer, 1); /* qdcount */
1298 	sldns_buffer_write_u16(pend->buffer, 0); /* ancount */
1299 	sldns_buffer_write_u16(pend->buffer, 0); /* nscount */
1300 	sldns_buffer_write_u16(pend->buffer, 0); /* arcount */
1301 	sldns_buffer_write(pend->buffer, qinfo->qname, qinfo->qname_len);
1302 	sldns_buffer_write_u16(pend->buffer, qinfo->qtype);
1303 	sldns_buffer_write_u16(pend->buffer, qinfo->qclass);
1304 	sldns_buffer_flip(pend->buffer);
1305 	if(1) {
1306 		struct edns_data edns;
1307 		struct edns_string_addr* client_string_addr;
1308 		struct edns_option* backed_up_opt_list =
1309 			qstate->edns_opts_back_out;
1310 		struct edns_option* per_upstream_opt_list = NULL;
1311 		/* If we have an already populated EDNS option list make a copy
1312 		 * since we may now add upstream specific EDNS options. */
1313 		if(qstate->edns_opts_back_out) {
1314 			per_upstream_opt_list = edns_opt_copy_region(
1315 				qstate->edns_opts_back_out, qstate->region);
1316 			if(!per_upstream_opt_list) {
1317 				free(pend);
1318 				fatal_exit("out of memory");
1319 			}
1320 			qstate->edns_opts_back_out = per_upstream_opt_list;
1321 		}
1322 		if(!inplace_cb_query_call(env, qinfo, flags, addr, addrlen,
1323 			zone, zonelen, qstate, qstate->region)) {
1324 			free(pend);
1325 			return NULL;
1326 		}
1327 		/* Restore the option list; we can explicitly use the copied
1328 		 * one from now on. */
1329 		per_upstream_opt_list = qstate->edns_opts_back_out;
1330 		qstate->edns_opts_back_out = backed_up_opt_list;
1331 		if((client_string_addr = edns_string_addr_lookup(
1332 			&env->edns_strings->client_strings,
1333 			addr, addrlen))) {
1334 			edns_opt_list_append(&per_upstream_opt_list,
1335 				env->edns_strings->client_string_opcode,
1336 				client_string_addr->string_len,
1337 				client_string_addr->string, qstate->region);
1338 		}
1339 		/* add edns */
1340 		edns.edns_present = 1;
1341 		edns.ext_rcode = 0;
1342 		edns.edns_version = EDNS_ADVERTISED_VERSION;
1343 		edns.udp_size = EDNS_ADVERTISED_SIZE;
1344 		edns.bits = 0;
1345 		if((dnssec & EDNS_DO))
1346 			edns.bits = EDNS_DO;
1347 		edns.padding_block_size = 0;
1348 		edns.cookie_present = 0;
1349 		edns.cookie_valid = 0;
1350 		edns.opt_list_in = NULL;
1351 		edns.opt_list_out = per_upstream_opt_list;
1352 		edns.opt_list_inplace_cb_out = NULL;
1353 		if(sldns_buffer_capacity(pend->buffer) >=
1354 			sldns_buffer_limit(pend->buffer)
1355 			+calc_edns_field_size(&edns)) {
1356 			attach_edns_record(pend->buffer, &edns);
1357 		} else {
1358 			verbose(VERB_ALGO, "edns field too large to fit");
1359 		}
1360 	}
1361 	memcpy(&pend->addr, addr, addrlen);
1362 	pend->addrlen = addrlen;
1363 	pend->zone = memdup(zone, zonelen);
1364 	pend->zonelen = zonelen;
1365 	pend->qtype = (int)qinfo->qtype;
1366 	log_assert(pend->zone);
1367 	pend->callback = callback;
1368 	pend->cb_arg = callback_arg;
1369 	pend->timeout = UDP_AUTH_QUERY_TIMEOUT/1000;
1370 	pend->transport = tcp_upstream?transport_tcp:transport_udp;
1371 	pend->pkt = NULL;
1372 	pend->runtime = runtime;
1373 	pend->serviced = 1;
1374 	pend->pkt_len = sldns_buffer_limit(pend->buffer);
1375 	pend->pkt = memdup(sldns_buffer_begin(pend->buffer), pend->pkt_len);
1376 	if(!pend->pkt) fatal_exit("out of memory");
1377 	/*log_pkt("pending serviced query: ", pend->pkt, pend->pkt_len);*/
1378 
1379 	/* see if it matches the current moment */
1380 	if(runtime->now && runtime->now->evt_type == repevt_back_query &&
1381 		(runtime->now->addrlen == 0 || sockaddr_cmp(
1382 			&runtime->now->addr, runtime->now->addrlen,
1383 			&pend->addr, pend->addrlen) == 0) &&
1384 		find_match(runtime->now->match, pend->pkt, pend->pkt_len,
1385 			pend->transport)) {
1386 		log_info("testbound: matched pending to event. "
1387 			"advance time between events.");
1388 		log_info("testbound: do STEP %d %s", runtime->now->time_step,
1389 			repevt_string(runtime->now->evt_type));
1390 		advance_moment(runtime);
1391 		/* still create the pending, because we need it to callback */
1392 	}
1393 	log_info("testbound: created fake pending");
1394 	/* add to list */
1395 	pend->next = runtime->pending_list;
1396 	runtime->pending_list = pend;
1397 	return (struct serviced_query*)pend;
1398 }
1399 
outnet_serviced_query_stop(struct serviced_query * sq,void * cb_arg)1400 void outnet_serviced_query_stop(struct serviced_query* sq, void* cb_arg)
1401 {
1402 	struct fake_pending* pend = (struct fake_pending*)sq;
1403 	struct replay_runtime* runtime = pend->runtime;
1404 	/* delete from the list */
1405 	struct fake_pending* p = runtime->pending_list, *prev=NULL;
1406 	while(p) {
1407 		if(p == pend) {
1408 			log_assert(p->cb_arg == cb_arg);
1409 			(void)cb_arg;
1410 			log_info("serviced pending delete");
1411 			if(prev)
1412 				prev->next = p->next;
1413 			else 	runtime->pending_list = p->next;
1414 			sldns_buffer_free(p->buffer);
1415 			free(p->pkt);
1416 			free(p->zone);
1417 			free(p);
1418 			return;
1419 		}
1420 		prev = p;
1421 		p = p->next;
1422 	}
1423 	log_info("double delete of pending serviced query");
1424 }
1425 
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))1426 int resolve_interface_names(char** ATTR_UNUSED(ifs), int ATTR_UNUSED(num_ifs),
1427 	struct config_strlist* ATTR_UNUSED(list), char*** ATTR_UNUSED(resif),
1428 	int* ATTR_UNUSED(num_resif))
1429 {
1430 	return 1;
1431 }
1432 
listening_ports_open(struct config_file * ATTR_UNUSED (cfg),char ** ATTR_UNUSED (ifs),int ATTR_UNUSED (num_ifs),int * ATTR_UNUSED (reuseport))1433 struct listen_port* listening_ports_open(struct config_file* ATTR_UNUSED(cfg),
1434 	char** ATTR_UNUSED(ifs), int ATTR_UNUSED(num_ifs),
1435 	int* ATTR_UNUSED(reuseport))
1436 {
1437 	return calloc(1, sizeof(struct listen_port));
1438 }
1439 
listening_ports_free(struct listen_port * list)1440 void listening_ports_free(struct listen_port* list)
1441 {
1442 	free(list);
1443 }
1444 
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))1445 struct comm_point* comm_point_create_local(struct comm_base* ATTR_UNUSED(base),
1446         int ATTR_UNUSED(fd), size_t ATTR_UNUSED(bufsize),
1447         comm_point_callback_type* ATTR_UNUSED(callback),
1448 	void* ATTR_UNUSED(callback_arg))
1449 {
1450 	struct fake_commpoint* fc = (struct fake_commpoint*)calloc(1,
1451 		sizeof(*fc));
1452 	if(!fc) return NULL;
1453 	fc->typecode = FAKE_COMMPOINT_TYPECODE;
1454 	return (struct comm_point*)fc;
1455 }
1456 
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))1457 struct comm_point* comm_point_create_raw(struct comm_base* ATTR_UNUSED(base),
1458         int ATTR_UNUSED(fd), int ATTR_UNUSED(writing),
1459         comm_point_callback_type* ATTR_UNUSED(callback),
1460 	void* ATTR_UNUSED(callback_arg))
1461 {
1462 	/* no pipe comm possible */
1463 	struct fake_commpoint* fc = (struct fake_commpoint*)calloc(1,
1464 		sizeof(*fc));
1465 	if(!fc) return NULL;
1466 	fc->typecode = FAKE_COMMPOINT_TYPECODE;
1467 	return (struct comm_point*)fc;
1468 }
1469 
comm_point_start_listening(struct comm_point * ATTR_UNUSED (c),int ATTR_UNUSED (newfd),int ATTR_UNUSED (sec))1470 void comm_point_start_listening(struct comm_point* ATTR_UNUSED(c),
1471 	int ATTR_UNUSED(newfd), int ATTR_UNUSED(sec))
1472 {
1473 	/* no bg write pipe comm possible */
1474 }
1475 
comm_point_stop_listening(struct comm_point * ATTR_UNUSED (c))1476 void comm_point_stop_listening(struct comm_point* ATTR_UNUSED(c))
1477 {
1478 	/* no bg write pipe comm possible */
1479 }
1480 
1481 /* only cmd com _local gets deleted */
comm_point_delete(struct comm_point * c)1482 void comm_point_delete(struct comm_point* c)
1483 {
1484 	struct fake_commpoint* fc = (struct fake_commpoint*)c;
1485 	if(c == NULL) return;
1486 	log_assert(fc->typecode == FAKE_COMMPOINT_TYPECODE);
1487 	if(fc->type_tcp_out) {
1488 		/* remove tcp pending, so no more callbacks to it */
1489 		pending_list_delete(fc->runtime, fc->pending);
1490 	}
1491 	free(c);
1492 }
1493 
listen_get_mem(struct listen_dnsport * ATTR_UNUSED (listen))1494 size_t listen_get_mem(struct listen_dnsport* ATTR_UNUSED(listen))
1495 {
1496 	return 0;
1497 }
1498 
outnet_get_mem(struct outside_network * ATTR_UNUSED (outnet))1499 size_t outnet_get_mem(struct outside_network* ATTR_UNUSED(outnet))
1500 {
1501 	return 0;
1502 }
1503 
comm_point_get_mem(struct comm_point * ATTR_UNUSED (c))1504 size_t comm_point_get_mem(struct comm_point* ATTR_UNUSED(c))
1505 {
1506 	return 0;
1507 }
1508 
comm_timer_get_mem(struct comm_timer * ATTR_UNUSED (timer))1509 size_t comm_timer_get_mem(struct comm_timer* ATTR_UNUSED(timer))
1510 {
1511 	return 0;
1512 }
1513 
serviced_get_mem(struct serviced_query * ATTR_UNUSED (c))1514 size_t serviced_get_mem(struct serviced_query* ATTR_UNUSED(c))
1515 {
1516 	return 0;
1517 }
1518 
1519 /* fake for fptr wlist */
outnet_udp_cb(struct comm_point * ATTR_UNUSED (c),void * ATTR_UNUSED (arg),int ATTR_UNUSED (error),struct comm_reply * ATTR_UNUSED (reply_info))1520 int outnet_udp_cb(struct comm_point* ATTR_UNUSED(c),
1521 	void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
1522         struct comm_reply *ATTR_UNUSED(reply_info))
1523 {
1524 	log_assert(0);
1525 	return 0;
1526 }
1527 
outnet_tcp_cb(struct comm_point * ATTR_UNUSED (c),void * ATTR_UNUSED (arg),int ATTR_UNUSED (error),struct comm_reply * ATTR_UNUSED (reply_info))1528 int outnet_tcp_cb(struct comm_point* ATTR_UNUSED(c),
1529 	void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
1530         struct comm_reply *ATTR_UNUSED(reply_info))
1531 {
1532 	log_assert(0);
1533 	return 0;
1534 }
1535 
pending_udp_timer_cb(void * ATTR_UNUSED (arg))1536 void pending_udp_timer_cb(void *ATTR_UNUSED(arg))
1537 {
1538 	log_assert(0);
1539 }
1540 
serviced_timer_cb(void * ATTR_UNUSED (arg))1541 void serviced_timer_cb(void *ATTR_UNUSED(arg))
1542 {
1543 	log_assert(0);
1544 }
1545 
pending_udp_timer_delay_cb(void * ATTR_UNUSED (arg))1546 void pending_udp_timer_delay_cb(void *ATTR_UNUSED(arg))
1547 {
1548 	log_assert(0);
1549 }
1550 
outnet_tcptimer(void * ATTR_UNUSED (arg))1551 void outnet_tcptimer(void* ATTR_UNUSED(arg))
1552 {
1553 	log_assert(0);
1554 }
1555 
comm_point_udp_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1556 void comm_point_udp_callback(int ATTR_UNUSED(fd), short ATTR_UNUSED(event),
1557 	void* ATTR_UNUSED(arg))
1558 {
1559 	log_assert(0);
1560 }
1561 
comm_point_udp_ancil_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1562 void comm_point_udp_ancil_callback(int ATTR_UNUSED(fd),
1563 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1564 {
1565 	log_assert(0);
1566 }
1567 
comm_point_tcp_accept_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1568 void comm_point_tcp_accept_callback(int ATTR_UNUSED(fd),
1569 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1570 {
1571 	log_assert(0);
1572 }
1573 
comm_point_tcp_handle_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1574 void comm_point_tcp_handle_callback(int ATTR_UNUSED(fd),
1575 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1576 {
1577 	log_assert(0);
1578 }
1579 
comm_timer_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1580 void comm_timer_callback(int ATTR_UNUSED(fd),
1581 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1582 {
1583 	log_assert(0);
1584 }
1585 
comm_signal_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1586 void comm_signal_callback(int ATTR_UNUSED(fd),
1587 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1588 {
1589 	log_assert(0);
1590 }
1591 
comm_point_http_handle_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1592 void comm_point_http_handle_callback(int ATTR_UNUSED(fd),
1593 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1594 {
1595 	log_assert(0);
1596 }
1597 
comm_point_local_handle_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1598 void comm_point_local_handle_callback(int ATTR_UNUSED(fd),
1599 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1600 {
1601 	log_assert(0);
1602 }
1603 
comm_point_raw_handle_callback(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1604 void comm_point_raw_handle_callback(int ATTR_UNUSED(fd),
1605 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1606 {
1607 	log_assert(0);
1608 }
1609 
comm_base_handle_slow_accept(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))1610 void comm_base_handle_slow_accept(int ATTR_UNUSED(fd),
1611 	short ATTR_UNUSED(event), void* ATTR_UNUSED(arg))
1612 {
1613 	log_assert(0);
1614 }
1615 
serviced_udp_callback(struct comm_point * ATTR_UNUSED (c),void * ATTR_UNUSED (arg),int ATTR_UNUSED (error),struct comm_reply * ATTR_UNUSED (reply_info))1616 int serviced_udp_callback(struct comm_point* ATTR_UNUSED(c),
1617 	void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
1618         struct comm_reply* ATTR_UNUSED(reply_info))
1619 {
1620 	log_assert(0);
1621 	return 0;
1622 }
1623 
serviced_tcp_callback(struct comm_point * ATTR_UNUSED (c),void * ATTR_UNUSED (arg),int ATTR_UNUSED (error),struct comm_reply * ATTR_UNUSED (reply_info))1624 int serviced_tcp_callback(struct comm_point* ATTR_UNUSED(c),
1625 	void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
1626         struct comm_reply* ATTR_UNUSED(reply_info))
1627 {
1628 	log_assert(0);
1629 	return 0;
1630 }
1631 
pending_cmp(const void * ATTR_UNUSED (a),const void * ATTR_UNUSED (b))1632 int pending_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
1633 {
1634 	log_assert(0);
1635 	return 0;
1636 }
1637 
serviced_cmp(const void * ATTR_UNUSED (a),const void * ATTR_UNUSED (b))1638 int serviced_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
1639 {
1640 	log_assert(0);
1641 	return 0;
1642 }
1643 
reuse_cmp(const void * ATTR_UNUSED (a),const void * ATTR_UNUSED (b))1644 int reuse_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
1645 {
1646 	log_assert(0);
1647 	return 0;
1648 }
1649 
reuse_id_cmp(const void * ATTR_UNUSED (a),const void * ATTR_UNUSED (b))1650 int reuse_id_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
1651 {
1652 	log_assert(0);
1653 	return 0;
1654 }
1655 
1656 /* timers in testbound for autotrust. statistics tested in tdir. */
comm_timer_create(struct comm_base * base,void (* cb)(void *),void * cb_arg)1657 struct comm_timer* comm_timer_create(struct comm_base* base,
1658 	void (*cb)(void*), void* cb_arg)
1659 {
1660 	struct replay_runtime* runtime = (struct replay_runtime*)base;
1661 	struct fake_timer* t = (struct fake_timer*)calloc(1, sizeof(*t));
1662 	if(!t)
1663 		fatal_exit("out of memory in fake_event.c:comm_timer_create");
1664 	t->cb = cb;
1665 	t->cb_arg = cb_arg;
1666 	fptr_ok(fptr_whitelist_comm_timer(t->cb)); /* check in advance */
1667 	t->runtime = runtime;
1668 	t->next = runtime->timer_list;
1669 	runtime->timer_list = t;
1670 	return (struct comm_timer*)t;
1671 }
1672 
comm_timer_disable(struct comm_timer * timer)1673 void comm_timer_disable(struct comm_timer* timer)
1674 {
1675 	struct fake_timer* t = (struct fake_timer*)timer;
1676 	log_info("fake timer disabled");
1677 	t->enabled = 0;
1678 }
1679 
comm_timer_set(struct comm_timer * timer,struct timeval * tv)1680 void comm_timer_set(struct comm_timer* timer, struct timeval* tv)
1681 {
1682 	struct fake_timer* t = (struct fake_timer*)timer;
1683 	t->enabled = 1;
1684 	t->tv = *tv;
1685 	log_info("fake timer set %d.%6.6d",
1686 		(int)t->tv.tv_sec, (int)t->tv.tv_usec);
1687 	timeval_add(&t->tv, &t->runtime->now_tv);
1688 }
1689 
comm_timer_is_set(struct comm_timer * timer)1690 int comm_timer_is_set(struct comm_timer* timer)
1691 {
1692 	struct fake_timer* t = (struct fake_timer*)timer;
1693 	return t->enabled;
1694 }
1695 
comm_timer_delete(struct comm_timer * timer)1696 void comm_timer_delete(struct comm_timer* timer)
1697 {
1698 	struct fake_timer* t = (struct fake_timer*)timer;
1699 	struct fake_timer** pp, *p;
1700 	if(!t) return;
1701 
1702 	/* remove from linked list */
1703 	pp = &t->runtime->timer_list;
1704 	p = t->runtime->timer_list;
1705 	while(p) {
1706 		if(p == t) {
1707 			/* snip from list */
1708 			*pp = p->next;
1709 			break;
1710 		}
1711 		pp = &p->next;
1712 		p = p->next;
1713 	}
1714 
1715 	free(timer);
1716 }
1717 
comm_base_set_slow_accept_handlers(struct comm_base * ATTR_UNUSED (b),void (* stop_acc)(void *),void (* start_acc)(void *),void * ATTR_UNUSED (arg))1718 void comm_base_set_slow_accept_handlers(struct comm_base* ATTR_UNUSED(b),
1719 	void (*stop_acc)(void*), void (*start_acc)(void*),
1720 	void* ATTR_UNUSED(arg))
1721 {
1722 	/* ignore this */
1723 	(void)stop_acc;
1724 	(void)start_acc;
1725 }
1726 
comm_base_internal(struct comm_base * ATTR_UNUSED (b))1727 struct ub_event_base* comm_base_internal(struct comm_base* ATTR_UNUSED(b))
1728 {
1729 	/* no pipe comm possible in testbound */
1730 	return NULL;
1731 }
1732 
daemon_remote_exec(struct worker * ATTR_UNUSED (worker))1733 void daemon_remote_exec(struct worker* ATTR_UNUSED(worker))
1734 {
1735 }
1736 
listen_start_accept(struct listen_dnsport * ATTR_UNUSED (listen))1737 void listen_start_accept(struct listen_dnsport* ATTR_UNUSED(listen))
1738 {
1739 }
1740 
listen_stop_accept(struct listen_dnsport * ATTR_UNUSED (listen))1741 void listen_stop_accept(struct listen_dnsport* ATTR_UNUSED(listen))
1742 {
1743 }
1744 
daemon_remote_start_accept(struct daemon_remote * ATTR_UNUSED (rc))1745 void daemon_remote_start_accept(struct daemon_remote* ATTR_UNUSED(rc))
1746 {
1747 }
1748 
daemon_remote_stop_accept(struct daemon_remote * ATTR_UNUSED (rc))1749 void daemon_remote_stop_accept(struct daemon_remote* ATTR_UNUSED(rc))
1750 {
1751 }
1752 
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))1753 int create_udp_sock(int ATTR_UNUSED(family), int ATTR_UNUSED(socktype),
1754 	struct sockaddr* ATTR_UNUSED(addr), socklen_t ATTR_UNUSED(addrlen),
1755 	int ATTR_UNUSED(v6only), int* ATTR_UNUSED(inuse),
1756 	int* ATTR_UNUSED(noproto), int ATTR_UNUSED(rcv), int ATTR_UNUSED(snd),
1757 	int ATTR_UNUSED(listen), int* ATTR_UNUSED(reuseport),
1758 	int ATTR_UNUSED(transparent), int ATTR_UNUSED(freebind),
1759 	int ATTR_UNUSED(use_systemd), int ATTR_UNUSED(dscp))
1760 {
1761 	/* if you actually print to this, it'll be stdout during test */
1762 	return 1;
1763 }
1764 
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))1765 struct comm_point* comm_point_create_udp(struct comm_base *ATTR_UNUSED(base),
1766 	int ATTR_UNUSED(fd), sldns_buffer* ATTR_UNUSED(buffer),
1767 	int ATTR_UNUSED(pp2_enabled),
1768 	comm_point_callback_type* ATTR_UNUSED(callback),
1769 	void* ATTR_UNUSED(callback_arg),
1770 	struct unbound_socket* ATTR_UNUSED(socket))
1771 {
1772 	log_assert(0);
1773 	return NULL;
1774 }
1775 
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))1776 struct comm_point* comm_point_create_tcp_out(struct comm_base*
1777 	ATTR_UNUSED(base), size_t ATTR_UNUSED(bufsize),
1778 	comm_point_callback_type* ATTR_UNUSED(callback),
1779 	void* ATTR_UNUSED(callback_arg))
1780 {
1781 	log_assert(0);
1782 	return NULL;
1783 }
1784 
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))1785 struct comm_point* outnet_comm_point_for_udp(struct outside_network* outnet,
1786 	comm_point_callback_type* cb, void* cb_arg,
1787 	struct sockaddr_storage* ATTR_UNUSED(to_addr),
1788 	socklen_t ATTR_UNUSED(to_addrlen))
1789 {
1790 	struct replay_runtime* runtime = (struct replay_runtime*)
1791 		outnet->base;
1792 	struct fake_commpoint* fc = (struct fake_commpoint*)calloc(1,
1793 		sizeof(*fc));
1794 	if(!fc) return NULL;
1795 	fc->typecode = FAKE_COMMPOINT_TYPECODE;
1796 	fc->type_udp_out = 1;
1797 	fc->cb = cb;
1798 	fc->cb_arg = cb_arg;
1799 	fc->runtime = runtime;
1800 	/* used by authzone transfers */
1801 	return (struct comm_point*)fc;
1802 }
1803 
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))1804 struct comm_point* outnet_comm_point_for_tcp(struct outside_network* outnet,
1805 	comm_point_callback_type* cb, void* cb_arg,
1806 	struct sockaddr_storage* to_addr, socklen_t to_addrlen,
1807 	struct sldns_buffer* query, int timeout, int ATTR_UNUSED(ssl),
1808 	char* ATTR_UNUSED(host))
1809 {
1810 	struct replay_runtime* runtime = (struct replay_runtime*)
1811 		outnet->base;
1812 	struct fake_commpoint* fc = (struct fake_commpoint*)calloc(1,
1813 		sizeof(*fc));
1814 	struct fake_pending* pend = (struct fake_pending*)calloc(1,
1815 		sizeof(struct fake_pending));
1816 	if(!fc || !pend) {
1817 		free(fc);
1818 		free(pend);
1819 		return NULL;
1820 	}
1821 	fc->typecode = FAKE_COMMPOINT_TYPECODE;
1822 	fc->type_tcp_out = 1;
1823 	fc->cb = cb;
1824 	fc->cb_arg = cb_arg;
1825 	fc->runtime = runtime;
1826 	fc->pending = pend;
1827 
1828 	/* used by authzone transfers */
1829 	/* create pending item */
1830 	pend->buffer = sldns_buffer_new(sldns_buffer_limit(query)+10);
1831 	if(!pend->buffer) {
1832 		free(fc);
1833 		free(pend);
1834 		return NULL;
1835 	}
1836 	sldns_buffer_copy(pend->buffer, query);
1837 	memcpy(&pend->addr, to_addr, to_addrlen);
1838 	pend->addrlen = to_addrlen;
1839 	pend->zone = NULL;
1840 	pend->zonelen = 0;
1841 	if(LDNS_QDCOUNT(sldns_buffer_begin(query)) > 0) {
1842 		char buf[512];
1843 		char addrbuf[128];
1844 		(void)sldns_wire2str_rrquestion_buf(sldns_buffer_at(query, LDNS_HEADER_SIZE), sldns_buffer_limit(query)-LDNS_HEADER_SIZE, buf, sizeof(buf));
1845 		addr_to_str((struct sockaddr_storage*)to_addr, to_addrlen,
1846 			addrbuf, sizeof(addrbuf));
1847 		if(verbosity >= VERB_ALGO) {
1848 			strip_end_white(buf);
1849 			log_info("tcp to %s: %s", addrbuf, buf);
1850 		}
1851 		log_assert(sldns_buffer_limit(query)-LDNS_HEADER_SIZE >= 2);
1852 		pend->qtype = (int)sldns_buffer_read_u16_at(query,
1853 			LDNS_HEADER_SIZE+
1854 			dname_valid(sldns_buffer_at(query, LDNS_HEADER_SIZE),
1855 				sldns_buffer_limit(query)-LDNS_HEADER_SIZE));
1856 	}
1857 	pend->callback = cb;
1858 	pend->cb_arg = cb_arg;
1859 	pend->timeout = timeout;
1860 	pend->transport = transport_tcp;
1861 	pend->pkt = NULL;
1862 	pend->runtime = runtime;
1863 	pend->serviced = 0;
1864 	pend->pkt_len = sldns_buffer_limit(pend->buffer);
1865 	pend->pkt = memdup(sldns_buffer_begin(pend->buffer), pend->pkt_len);
1866 	if(!pend->pkt) fatal_exit("out of memory");
1867 
1868 	log_info("testbound: created fake pending for tcp_out");
1869 
1870 	/* add to list */
1871 	pend->next = runtime->pending_list;
1872 	runtime->pending_list = pend;
1873 
1874 	return (struct comm_point*)fc;
1875 }
1876 
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)1877 struct comm_point* outnet_comm_point_for_http(struct outside_network* outnet,
1878 	comm_point_callback_type* cb, void* cb_arg,
1879 	struct sockaddr_storage* to_addr, socklen_t to_addrlen, int timeout,
1880 	int ssl, char* host, char* path, struct config_file* cfg)
1881 {
1882 	struct replay_runtime* runtime = (struct replay_runtime*)
1883 		outnet->base;
1884 	struct fake_commpoint* fc = (struct fake_commpoint*)calloc(1,
1885 		sizeof(*fc));
1886 	if(!fc) {
1887 		return NULL;
1888 	}
1889 	fc->typecode = FAKE_COMMPOINT_TYPECODE;
1890 	fc->type_http_out = 1;
1891 	fc->cb = cb;
1892 	fc->cb_arg = cb_arg;
1893 	fc->runtime = runtime;
1894 
1895 	(void)to_addr;
1896 	(void)to_addrlen;
1897 	(void)timeout;
1898 
1899 	(void)ssl;
1900 	(void)host;
1901 	(void)path;
1902 	(void)cfg;
1903 
1904 	/* handle http comm point and return contents from test script */
1905 	return (struct comm_point*)fc;
1906 }
1907 
comm_point_send_udp_msg(struct comm_point * c,sldns_buffer * packet,struct sockaddr * addr,socklen_t addrlen,int ATTR_UNUSED (is_connected))1908 int comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
1909 	struct sockaddr* addr, socklen_t addrlen, int ATTR_UNUSED(is_connected))
1910 {
1911 	struct fake_commpoint* fc = (struct fake_commpoint*)c;
1912 	struct replay_runtime* runtime = fc->runtime;
1913 	struct fake_pending* pend = (struct fake_pending*)calloc(1,
1914 		sizeof(struct fake_pending));
1915 	if(!pend) {
1916 		log_err("malloc failure");
1917 		return 0;
1918 	}
1919 	fc->pending = pend;
1920 	/* used by authzone transfers */
1921 	/* create pending item */
1922 	pend->buffer = sldns_buffer_new(sldns_buffer_limit(packet) + 10);
1923 	if(!pend->buffer) {
1924 		free(pend);
1925 		return 0;
1926 	}
1927 	sldns_buffer_copy(pend->buffer, packet);
1928 	memcpy(&pend->addr, addr, addrlen);
1929 	pend->addrlen = addrlen;
1930 	pend->zone = NULL;
1931 	pend->zonelen = 0;
1932 	if(LDNS_QDCOUNT(sldns_buffer_begin(packet)) > 0) {
1933 		char buf[512];
1934 		char addrbuf[128];
1935 		(void)sldns_wire2str_rrquestion_buf(sldns_buffer_at(packet, LDNS_HEADER_SIZE), sldns_buffer_limit(packet)-LDNS_HEADER_SIZE, buf, sizeof(buf));
1936 		addr_to_str((struct sockaddr_storage*)addr, addrlen,
1937 			addrbuf, sizeof(addrbuf));
1938 		if(verbosity >= VERB_ALGO) {
1939 			strip_end_white(buf);
1940 			log_info("udp to %s: %s", addrbuf, buf);
1941 		}
1942 		log_assert(sldns_buffer_limit(packet)-LDNS_HEADER_SIZE >= 2);
1943 		pend->qtype = (int)sldns_buffer_read_u16_at(packet,
1944 			LDNS_HEADER_SIZE+
1945 			dname_valid(sldns_buffer_at(packet, LDNS_HEADER_SIZE),
1946 				sldns_buffer_limit(packet)-LDNS_HEADER_SIZE));
1947 	}
1948 	pend->callback = fc->cb;
1949 	pend->cb_arg = fc->cb_arg;
1950 	pend->timeout = UDP_AUTH_QUERY_TIMEOUT/1000;
1951 	pend->transport = transport_udp;
1952 	pend->pkt = NULL;
1953 	pend->runtime = runtime;
1954 	pend->serviced = 0;
1955 	pend->pkt_len = sldns_buffer_limit(pend->buffer);
1956 	pend->pkt = memdup(sldns_buffer_begin(pend->buffer), pend->pkt_len);
1957 	if(!pend->pkt) fatal_exit("out of memory");
1958 
1959 	log_info("testbound: created fake pending for send_udp_msg");
1960 
1961 	/* add to list */
1962 	pend->next = runtime->pending_list;
1963 	runtime->pending_list = pend;
1964 
1965 	return 1;
1966 }
1967 
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 ATTR_UNUSED (nodelay))1968 int outnet_get_tcp_fd(struct sockaddr_storage* ATTR_UNUSED(addr),
1969 	socklen_t ATTR_UNUSED(addrlen), int ATTR_UNUSED(tcp_mss),
1970 	int ATTR_UNUSED(dscp), int ATTR_UNUSED(nodelay))
1971 {
1972 	log_assert(0);
1973 	return -1;
1974 }
1975 
outnet_tcp_connect(int ATTR_UNUSED (s),struct sockaddr_storage * ATTR_UNUSED (addr),socklen_t ATTR_UNUSED (addrlen))1976 int outnet_tcp_connect(int ATTR_UNUSED(s), struct sockaddr_storage* ATTR_UNUSED(addr),
1977 	socklen_t ATTR_UNUSED(addrlen))
1978 {
1979 	log_assert(0);
1980 	return 0;
1981 }
1982 
tcp_req_info_add_meshstate(struct tcp_req_info * ATTR_UNUSED (req),struct mesh_area * ATTR_UNUSED (mesh),struct mesh_state * ATTR_UNUSED (m))1983 int tcp_req_info_add_meshstate(struct tcp_req_info* ATTR_UNUSED(req),
1984         struct mesh_area* ATTR_UNUSED(mesh), struct mesh_state* ATTR_UNUSED(m))
1985 {
1986 	log_assert(0);
1987 	return 0;
1988 }
1989 
1990 void
tcp_req_info_remove_mesh_state(struct tcp_req_info * ATTR_UNUSED (req),struct mesh_state * ATTR_UNUSED (m))1991 tcp_req_info_remove_mesh_state(struct tcp_req_info* ATTR_UNUSED(req),
1992 	struct mesh_state* ATTR_UNUSED(m))
1993 {
1994 	log_assert(0);
1995 }
1996 
1997 size_t
tcp_req_info_get_stream_buffer_size(void)1998 tcp_req_info_get_stream_buffer_size(void)
1999 {
2000 	return 0;
2001 }
2002 
2003 size_t
http2_get_query_buffer_size(void)2004 http2_get_query_buffer_size(void)
2005 {
2006 	return 0;
2007 }
2008 
2009 size_t
http2_get_response_buffer_size(void)2010 http2_get_response_buffer_size(void)
2011 {
2012 	return 0;
2013 }
2014 
http2_stream_add_meshstate(struct http2_stream * ATTR_UNUSED (h2_stream),struct mesh_area * ATTR_UNUSED (mesh),struct mesh_state * ATTR_UNUSED (m))2015 void http2_stream_add_meshstate(struct http2_stream* ATTR_UNUSED(h2_stream),
2016 	struct mesh_area* ATTR_UNUSED(mesh), struct mesh_state* ATTR_UNUSED(m))
2017 {
2018 }
2019 
http2_stream_remove_mesh_state(struct http2_stream * ATTR_UNUSED (h2_stream))2020 void http2_stream_remove_mesh_state(struct http2_stream* ATTR_UNUSED(h2_stream))
2021 {
2022 }
2023 
fast_reload_service_cb(int ATTR_UNUSED (fd),short ATTR_UNUSED (event),void * ATTR_UNUSED (arg))2024 void fast_reload_service_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(event),
2025 	void* ATTR_UNUSED(arg))
2026 {
2027 	log_assert(0);
2028 }
2029 
fast_reload_thread_stop(struct fast_reload_thread * ATTR_UNUSED (fast_reload_thread))2030 void fast_reload_thread_stop(
2031 	struct fast_reload_thread* ATTR_UNUSED(fast_reload_thread))
2032 {
2033 	/* nothing */
2034 }
2035 
fast_reload_client_callback(struct comm_point * ATTR_UNUSED (c),void * ATTR_UNUSED (arg),int ATTR_UNUSED (error),struct comm_reply * ATTR_UNUSED (repinfo))2036 int fast_reload_client_callback(struct comm_point* ATTR_UNUSED(c),
2037 	void* ATTR_UNUSED(arg), int ATTR_UNUSED(error),
2038         struct comm_reply* ATTR_UNUSED(repinfo))
2039 {
2040 	log_assert(0);
2041 	return 0;
2042 }
2043 
2044 /*********** End of Dummy routines ***********/
2045