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