1 /* 2 * testcode/testbound.c - test program for unbound. 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 * Exits with code 1 on a failure. 0 if all unit tests are successful. 39 */ 40 41 #include "config.h" 42 #ifdef HAVE_TIME_H 43 # include <time.h> 44 #endif 45 #include <ctype.h> 46 #include "testcode/testpkts.h" 47 #include "testcode/replay.h" 48 #include "testcode/fake_event.h" 49 #include "daemon/remote.h" 50 #include "libunbound/worker.h" 51 #include "daemon/worker.h" 52 #include "util/config_file.h" 53 #include "sldns/keyraw.h" 54 #ifdef UB_ON_WINDOWS 55 #include "winrc/win_svc.h" 56 #endif 57 58 /** signal that this is a testbound compile */ 59 #define unbound_testbound 1 60 /** renamed main routine */ 61 int daemon_main(int argc, char* argv[]); 62 /** 63 * include the main program from the unbound daemon. 64 * rename main to daemon_main to call it 65 */ 66 #define main daemon_main 67 #include "daemon/unbound.c" 68 #undef main 69 70 /** maximum line length for lines in the replay file. */ 71 #define MAX_LINE_LEN 1024 72 /** config files (removed at exit) */ 73 static struct config_strlist* cfgfiles = NULL; 74 75 /** give commandline usage for testbound. */ 76 static void 77 testbound_usage(void) 78 { 79 printf("usage: testbound [options]\n"); 80 printf("\ttest the unbound daemon.\n"); 81 printf("-h this help\n"); 82 printf("-p file playback text file\n"); 83 printf("-1 detect SHA1 support (exit code 0 or 1)\n"); 84 printf("-2 detect SHA256 support (exit code 0 or 1)\n"); 85 printf("-g detect GOST support (exit code 0 or 1)\n"); 86 printf("-e detect ECDSA support (exit code 0 or 1)\n"); 87 printf("-c detect CLIENT_SUBNET support (exit code 0 or 1)\n"); 88 printf("-i detect IPSECMOD support (exit code 0 or 1)\n"); 89 printf("-s testbound self-test - unit test of testbound parts.\n"); 90 printf("-o str unbound commandline options separated by spaces.\n"); 91 printf("Version %s\n", PACKAGE_VERSION); 92 printf("BSD licensed, see LICENSE file in source package.\n"); 93 printf("Report bugs to %s.\n", PACKAGE_BUGREPORT); 94 } 95 96 /** Max number of arguments to pass to unbound. */ 97 #define MAXARG 100 98 99 /** 100 * Add options from string to passed argc. splits on whitespace. 101 * @param args: the option argument, "-v -p 12345" or so. 102 * @param pass_argc: ptr to the argc for unbound. Modified. 103 * @param pass_argv: the argv to pass to unbound. Modified. 104 */ 105 static void 106 add_opts(const char* args, int* pass_argc, char* pass_argv[]) 107 { 108 const char *p = args, *np; 109 size_t len; 110 while(p && isspace((unsigned char)*p)) 111 p++; 112 while(p && *p) { 113 /* find location of next string and length of this one */ 114 if((np = strchr(p, ' '))) 115 len = (size_t)(np-p); 116 else len = strlen(p); 117 /* allocate and copy option */ 118 if(*pass_argc >= MAXARG-1) 119 fatal_exit("too many arguments: '%s'", p); 120 pass_argv[*pass_argc] = (char*)malloc(len+1); 121 if(!pass_argv[*pass_argc]) 122 fatal_exit("add_opts: out of memory"); 123 memcpy(pass_argv[*pass_argc], p, len); 124 pass_argv[*pass_argc][len] = 0; 125 (*pass_argc)++; 126 /* go to next option */ 127 p = np; 128 while(p && isspace((unsigned char)*p)) 129 p++; 130 } 131 } 132 133 /** pretty print commandline for unbound in this test */ 134 static void 135 echo_cmdline(int argc, char* argv[]) 136 { 137 int i; 138 fprintf(stderr, "testbound is starting:"); 139 for(i=0; i<argc; i++) { 140 fprintf(stderr, " [%s]", argv[i]); 141 } 142 fprintf(stderr, "\n"); 143 } 144 145 /** spool temp file name */ 146 static void 147 spool_temp_file_name(int* lineno, FILE* cfg, char* id) 148 { 149 char line[MAX_LINE_LEN]; 150 /* find filename for new file */ 151 while(isspace((unsigned char)*id)) 152 id++; 153 if(*id == '\0') 154 fatal_exit("TEMPFILE_NAME must have id, line %d", *lineno); 155 strip_end_white(id); 156 fake_temp_file("_temp_", id, line, sizeof(line)); 157 fprintf(cfg, "\"%s\"\n", line); 158 } 159 160 /** spool temp file */ 161 static void 162 spool_temp_file(FILE* in, int* lineno, char* id) 163 { 164 char line[MAX_LINE_LEN]; 165 char* parse; 166 FILE* spool; 167 /* find filename for new file */ 168 while(isspace((unsigned char)*id)) 169 id++; 170 if(*id == '\0') 171 fatal_exit("TEMPFILE_CONTENTS must have id, line %d", *lineno); 172 strip_end_white(id); 173 fake_temp_file("_temp_", id, line, sizeof(line)); 174 /* open file and spool to it */ 175 spool = fopen(line, "w"); 176 if(!spool) fatal_exit("could not open %s: %s", line, strerror(errno)); 177 fprintf(stderr, "testbound is spooling temp file: %s\n", line); 178 if(!cfg_strlist_insert(&cfgfiles, strdup(line))) 179 fatal_exit("out of memory"); 180 line[sizeof(line)-1] = 0; 181 while(fgets(line, MAX_LINE_LEN-1, in)) { 182 parse = line; 183 (*lineno)++; 184 while(isspace((unsigned char)*parse)) 185 parse++; 186 if(strncmp(parse, "$INCLUDE_TEMPFILE", 17) == 0) { 187 char l2[MAX_LINE_LEN-30]; /* -30 makes it fit with 188 a preceding $INCLUDE in the buf line[] */ 189 char* tid = parse+17; 190 while(isspace((unsigned char)*tid)) 191 tid++; 192 strip_end_white(tid); 193 fake_temp_file("_temp_", tid, l2, sizeof(l2)); 194 snprintf(line, sizeof(line), "$INCLUDE %s\n", l2); 195 } 196 if(strncmp(parse, "TEMPFILE_END", 12) == 0) { 197 fclose(spool); 198 return; 199 } 200 fputs(line, spool); 201 } 202 fatal_exit("no TEMPFILE_END in input file"); 203 } 204 205 /** spool autotrust file */ 206 static void 207 spool_auto_file(FILE* in, int* lineno, FILE* cfg, char* id) 208 { 209 char line[MAX_LINE_LEN]; 210 char* parse; 211 FILE* spool; 212 /* find filename for new file */ 213 while(isspace((unsigned char)*id)) 214 id++; 215 if(*id == '\0') 216 fatal_exit("AUTROTRUST_FILE must have id, line %d", *lineno); 217 strip_end_white(id); 218 fake_temp_file("_auto_", id, line, sizeof(line)); 219 /* add option for the file */ 220 fprintf(cfg, "server: auto-trust-anchor-file: \"%s\"\n", line); 221 /* open file and spool to it */ 222 spool = fopen(line, "w"); 223 if(!spool) fatal_exit("could not open %s: %s", line, strerror(errno)); 224 fprintf(stderr, "testbound is spooling key file: %s\n", line); 225 if(!cfg_strlist_insert(&cfgfiles, strdup(line))) 226 fatal_exit("out of memory"); 227 line[sizeof(line)-1] = 0; 228 while(fgets(line, MAX_LINE_LEN-1, in)) { 229 parse = line; 230 (*lineno)++; 231 while(isspace((unsigned char)*parse)) 232 parse++; 233 if(strncmp(parse, "AUTOTRUST_END", 13) == 0) { 234 fclose(spool); 235 return; 236 } 237 fputs(line, spool); 238 } 239 fatal_exit("no AUTOTRUST_END in input file"); 240 } 241 242 /** process config elements */ 243 static void 244 setup_config(FILE* in, int* lineno, int* pass_argc, char* pass_argv[]) 245 { 246 char configfile[MAX_LINE_LEN]; 247 char line[MAX_LINE_LEN]; 248 char* parse; 249 FILE* cfg; 250 fake_temp_file("_cfg", "", configfile, sizeof(configfile)); 251 add_opts("-c", pass_argc, pass_argv); 252 add_opts(configfile, pass_argc, pass_argv); 253 cfg = fopen(configfile, "w"); 254 if(!cfg) fatal_exit("could not open %s: %s", 255 configfile, strerror(errno)); 256 if(!cfg_strlist_insert(&cfgfiles, strdup(configfile))) 257 fatal_exit("out of memory"); 258 line[sizeof(line)-1] = 0; 259 /* some basic settings to not pollute the host system */ 260 fprintf(cfg, "server: use-syslog: no\n"); 261 fprintf(cfg, " directory: \"\"\n"); 262 fprintf(cfg, " chroot: \"\"\n"); 263 fprintf(cfg, " username: \"\"\n"); 264 fprintf(cfg, " pidfile: \"\"\n"); 265 fprintf(cfg, " val-log-level: 2\n"); 266 fprintf(cfg, " log-servfail: yes\n"); 267 fprintf(cfg, "remote-control: control-enable: no\n"); 268 while(fgets(line, MAX_LINE_LEN-1, in)) { 269 parse = line; 270 (*lineno)++; 271 while(isspace((unsigned char)*parse)) 272 parse++; 273 if(!*parse || parse[0] == ';') 274 continue; 275 if(strncmp(parse, "COMMANDLINE", 11) == 0) { 276 parse[strlen(parse)-1] = 0; /* strip off \n */ 277 add_opts(parse+11, pass_argc, pass_argv); 278 continue; 279 } 280 if(strncmp(parse, "AUTOTRUST_FILE", 14) == 0) { 281 spool_auto_file(in, lineno, cfg, parse+14); 282 continue; 283 } 284 if(strncmp(parse, "TEMPFILE_NAME", 13) == 0) { 285 spool_temp_file_name(lineno, cfg, parse+13); 286 continue; 287 } 288 if(strncmp(parse, "TEMPFILE_CONTENTS", 17) == 0) { 289 spool_temp_file(in, lineno, parse+17); 290 continue; 291 } 292 if(strncmp(parse, "CONFIG_END", 10) == 0) { 293 fclose(cfg); 294 return; 295 } 296 if(strncmp(parse, "fake-sha1: yes", 14) == 0) { 297 /* Allow the use of SHA1 signatures for the test, 298 * in case that OpenSSL disallows use of RSASHA1 299 * with rh-allow-sha1-signatures disabled. */ 300 #ifndef UB_ON_WINDOWS 301 setenv("OPENSSL_ENABLE_SHA1_SIGNATURES", "1", 0); 302 #else 303 _putenv("OPENSSL_ENABLE_SHA1_SIGNATURES=1"); 304 #endif 305 } 306 fputs(line, cfg); 307 } 308 fatal_exit("No CONFIG_END in input file"); 309 310 } 311 312 /** read playback file */ 313 static struct replay_scenario* 314 setup_playback(const char* filename, int* pass_argc, char* pass_argv[]) 315 { 316 struct replay_scenario* scen = NULL; 317 int lineno = 0; 318 319 if(filename) { 320 FILE *in = fopen(filename, "rb"); 321 if(!in) { 322 perror(filename); 323 exit(1); 324 } 325 setup_config(in, &lineno, pass_argc, pass_argv); 326 scen = replay_scenario_read(in, filename, &lineno); 327 fclose(in); 328 if(!scen) 329 fatal_exit("Could not read: %s", filename); 330 } 331 else fatal_exit("need a playback file (-p)"); 332 log_info("Scenario: %s", scen->title); 333 return scen; 334 } 335 336 /** remove config file at exit */ 337 static void remove_configfile(void) 338 { 339 struct config_strlist* p; 340 for(p=cfgfiles; p; p=p->next) 341 unlink(p->str); 342 config_delstrlist(cfgfiles); 343 cfgfiles = NULL; 344 } 345 346 /** perform the playback on the playback_file with the args. */ 347 static int 348 perform_playback(char* playback_file, int pass_argc, char** pass_argv) 349 { 350 struct replay_scenario* scen = NULL; 351 int c, res; 352 353 /* setup test environment */ 354 scen = setup_playback(playback_file, &pass_argc, pass_argv); 355 /* init fake event backend */ 356 fake_event_init(scen); 357 358 pass_argv[pass_argc] = NULL; 359 echo_cmdline(pass_argc, pass_argv); 360 361 /* run the normal daemon */ 362 res = daemon_main(pass_argc, pass_argv); 363 364 fake_event_cleanup(); 365 for(c=1; c<pass_argc; c++) 366 free(pass_argv[c]); 367 return res; 368 } 369 370 /* For fuzzing the main routine is replaced with 371 * LLVMFuzzerTestOneInput. */ 372 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 373 #define main dummy_main 374 #endif 375 /** 376 * Main fake event test program. Setup, teardown and report errors. 377 * @param argc: arg count. 378 * @param argv: array of commandline arguments. 379 * @return program failure if test fails. 380 */ 381 int 382 main(int argc, char* argv[]) 383 { 384 int c, res; 385 int pass_argc = 0; 386 char* pass_argv[MAXARG]; 387 char* playback_file = NULL; 388 int init_optind = optind; 389 char* init_optarg = optarg; 390 391 /* we do not want the test to depend on the timezone */ 392 (void)putenv("TZ=UTC"); 393 memset(pass_argv, 0, sizeof(pass_argv)); 394 #ifdef HAVE_SYSTEMD 395 /* we do not want the test to use systemd daemon startup notification*/ 396 (void)unsetenv("NOTIFY_SOCKET"); 397 #endif /* HAVE_SYSTEMD */ 398 399 checklock_start(); 400 log_init(NULL, 0, NULL); 401 /* determine commandline options for the daemon */ 402 pass_argc = 1; 403 pass_argv[0] = "unbound"; 404 add_opts("-d", &pass_argc, pass_argv); 405 while( (c=getopt(argc, argv, "12egciho:p:s")) != -1) { 406 switch(c) { 407 case 's': 408 free(pass_argv[1]); 409 testbound_selftest(); 410 checklock_stop(); 411 if(log_get_lock()) { 412 lock_basic_destroy((lock_basic_type*)log_get_lock()); 413 } 414 exit(0); 415 case '1': 416 #ifdef USE_SHA1 417 printf("SHA1 supported\n"); 418 exit(0); 419 #else 420 printf("SHA1 not supported\n"); 421 exit(1); 422 #endif 423 break; 424 case '2': 425 #if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS) || defined(HAVE_NETTLE)) && defined(USE_SHA2) 426 printf("SHA256 supported\n"); 427 exit(0); 428 #else 429 printf("SHA256 not supported\n"); 430 exit(1); 431 #endif 432 break; 433 case 'e': 434 #if defined(USE_ECDSA) 435 printf("ECDSA supported\n"); 436 exit(0); 437 #else 438 printf("ECDSA not supported\n"); 439 exit(1); 440 #endif 441 break; 442 case 'g': 443 #ifdef USE_GOST 444 if(sldns_key_EVP_load_gost_id()) { 445 printf("GOST supported\n"); 446 exit(0); 447 } else { 448 printf("GOST not supported\n"); 449 exit(1); 450 } 451 #else 452 printf("GOST not supported\n"); 453 exit(1); 454 #endif 455 break; 456 case 'c': 457 #ifdef CLIENT_SUBNET 458 printf("CLIENT_SUBNET supported\n"); 459 exit(0); 460 #else 461 printf("CLIENT_SUBNET not supported\n"); 462 exit(1); 463 #endif 464 break; 465 case 'i': 466 #ifdef USE_IPSECMOD 467 printf("IPSECMOD supported\n"); 468 exit(0); 469 #else 470 printf("IPSECMOD not supported\n"); 471 exit(1); 472 #endif 473 break; 474 case 'p': 475 playback_file = optarg; 476 break; 477 case 'o': 478 add_opts(optarg, &pass_argc, pass_argv); 479 break; 480 case '?': 481 case 'h': 482 default: 483 testbound_usage(); 484 exit(1); 485 } 486 } 487 argc -= optind; 488 /* argv += optind; not using further arguments */ 489 if(argc != 0) { 490 testbound_usage(); 491 exit(1); 492 } 493 log_info("Start of %s testbound program.", PACKAGE_STRING); 494 if(atexit(&remove_configfile) != 0) 495 fatal_exit("atexit() failed: %s", strerror(errno)); 496 497 /* reset getopt processing */ 498 optind = init_optind; 499 optarg = init_optarg; 500 501 res = perform_playback(playback_file, pass_argc, pass_argv); 502 if(res == 0) { 503 log_info("Testbound Exit Success\n"); 504 /* remove configfile from here, the atexit() is for when 505 * there is a crash to remove the tmpdir file. 506 * This one removes the file while alloc and log locks are 507 * still valid, and can be logged (for memory calculation), 508 * it leaves the ptr NULL so the atexit does nothing. */ 509 remove_configfile(); 510 if(log_get_lock()) { 511 lock_basic_destroy((lock_basic_type*)log_get_lock()); 512 } 513 #ifdef HAVE_PTHREAD 514 /* dlopen frees its thread state (dlopen of gost engine) */ 515 pthread_exit(NULL); 516 #endif 517 } 518 return res; 519 } 520 521 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 522 static int delete_file(const char *pathname) { 523 int ret = unlink(pathname); 524 free((void *)pathname); 525 return ret; 526 } 527 528 static char *buf_to_file(const uint8_t *buf, size_t size) { 529 int fd; 530 size_t pos; 531 char *pathname = strdup("/tmp/fuzz-XXXXXX"); 532 if (pathname == NULL) 533 return NULL; 534 535 fd = mkstemp(pathname); 536 if (fd == -1) { 537 log_err("mkstemp of file %s failed: %s", pathname, strerror(errno)); 538 free(pathname); 539 return NULL; 540 } 541 pos = 0; 542 while (pos < size) { 543 int nbytes = write(fd, &buf[pos], size - pos); 544 if (nbytes <= 0) { 545 if (nbytes == -1 && errno == EINTR) 546 continue; 547 log_err("write to file %s failed: %s", pathname, strerror(errno)); 548 goto err; 549 } 550 pos += nbytes; 551 } 552 553 if (close(fd) == -1) { 554 log_err("close of file %s failed: %s", pathname, strerror(errno)); 555 goto err; 556 } 557 558 return pathname; 559 err: 560 delete_file(pathname); 561 return NULL; 562 } 563 564 /* based on main() above, but with: hard-coded passed args, file created from fuzz input */ 565 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) 566 { 567 int c, res; 568 int pass_argc = 0; 569 char* pass_argv[MAXARG]; 570 char* playback_file = NULL; 571 572 /* we do not want the test to depend on the timezone */ 573 (void)putenv("TZ=UTC"); 574 memset(pass_argv, 0, sizeof(pass_argv)); 575 #ifdef HAVE_SYSTEMD 576 /* we do not want the test to use systemd daemon startup notification*/ 577 (void)unsetenv("NOTIFY_SOCKET"); 578 #endif /* HAVE_SYSTEMD */ 579 580 checklock_start(); 581 log_init(NULL, 0, NULL); 582 /* determine commandline options for the daemon */ 583 pass_argc = 1; 584 pass_argv[0] = "unbound"; 585 add_opts("-d", &pass_argc, pass_argv); 586 587 playback_file = buf_to_file(Data, Size); 588 if (playback_file) { 589 log_info("Start of %s testbound program.", PACKAGE_STRING); 590 591 res = perform_playback(playback_file, pass_argc, pass_argv); 592 if(res == 0) { 593 log_info("Testbound Exit Success\n"); 594 /* remove configfile from here, the atexit() is for when 595 * there is a crash to remove the tmpdir file. 596 * This one removes the file while alloc and log locks are 597 * still valid, and can be logged (for memory calculation), 598 * it leaves the ptr NULL so the atexit does nothing. */ 599 remove_configfile(); 600 #ifdef HAVE_PTHREAD 601 /* dlopen frees its thread state (dlopen of gost engine) */ 602 pthread_exit(NULL); 603 #endif 604 } 605 606 delete_file(playback_file); 607 } 608 609 if(log_get_lock()) { 610 lock_basic_destroy((lock_basic_type*)log_get_lock()); 611 } 612 return res; 613 } 614 #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ 615 616 /* fake remote control */ 617 struct listen_port* daemon_remote_open_ports(struct config_file* 618 ATTR_UNUSED(cfg)) 619 { 620 return NULL; 621 } 622 623 struct daemon_remote* daemon_remote_create(struct config_file* ATTR_UNUSED(cfg)) 624 { 625 return (struct daemon_remote*)calloc(1, sizeof(struct daemon_remote)); 626 } 627 628 void daemon_remote_delete(struct daemon_remote* rc) 629 { 630 free(rc); 631 } 632 633 void daemon_remote_clear(struct daemon_remote* ATTR_UNUSED(rc)) 634 { 635 /* nothing */ 636 } 637 638 int daemon_remote_open_accept(struct daemon_remote* ATTR_UNUSED(rc), 639 struct listen_port* ATTR_UNUSED(ports), struct worker* worker) 640 { 641 struct replay_runtime* runtime = (struct replay_runtime*)worker->base; 642 runtime->daemon = worker->daemon; 643 return 1; 644 } 645 646 int remote_accept_callback(struct comm_point* ATTR_UNUSED(c), 647 void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), 648 struct comm_reply* ATTR_UNUSED(repinfo)) 649 { 650 log_assert(0); 651 return 0; 652 } 653 654 int remote_control_callback(struct comm_point* ATTR_UNUSED(c), 655 void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), 656 struct comm_reply* ATTR_UNUSED(repinfo)) 657 { 658 log_assert(0); 659 return 0; 660 } 661 662 void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg)) 663 { 664 log_assert(0); 665 } 666 667 #ifdef UB_ON_WINDOWS 668 void wsvc_command_option(const char* ATTR_UNUSED(wopt), 669 const char* ATTR_UNUSED(cfgfile), int ATTR_UNUSED(v), 670 int ATTR_UNUSED(c)) 671 { 672 log_assert(0); 673 } 674 #endif 675 676 #ifdef UB_ON_WINDOWS 677 void wsvc_setup_worker(struct worker* ATTR_UNUSED(worker)) 678 { 679 /* do nothing */ 680 } 681 #endif 682 683 #ifdef UB_ON_WINDOWS 684 void wsvc_desetup_worker(struct worker* ATTR_UNUSED(worker)) 685 { 686 /* do nothing */ 687 } 688 #endif 689 690 #ifdef UB_ON_WINDOWS 691 void worker_win_stop_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev), 692 void* ATTR_UNUSED(arg)) 693 { 694 log_assert(0); 695 } 696 697 void wsvc_cron_cb(void* ATTR_UNUSED(arg)) 698 { 699 log_assert(0); 700 } 701 #endif /* UB_ON_WINDOWS */ 702 703 int tcp_connect_errno_needs_log(struct sockaddr* ATTR_UNUSED(addr), 704 socklen_t ATTR_UNUSED(addrlen)) 705 { 706 return 1; 707 } 708 709 int squelch_err_ssl_handshake(unsigned long ATTR_UNUSED(err)) 710 { 711 return 0; 712 } 713 714 void listen_setup_locks(void) 715 { 716 /* nothing */ 717 } 718 719 void listen_desetup_locks(void) 720 { 721 /* nothing */ 722 } 723 724 void fast_reload_printq_list_delete( 725 struct fast_reload_printq* ATTR_UNUSED(list)) 726 { 727 /* nothing */ 728 } 729 730 void fast_reload_worker_pickup_changes(struct worker* ATTR_UNUSED(worker)) 731 { 732 /* nothing */ 733 } 734 735 #ifdef HAVE_NGTCP2 736 void* quic_sslctx_create(char* ATTR_UNUSED(key), char* ATTR_UNUSED(pem), 737 char* ATTR_UNUSED(verifypem)) 738 { 739 return NULL; 740 } 741 742 void comm_point_doq_callback(int ATTR_UNUSED(fd), short ATTR_UNUSED(event), 743 void* ATTR_UNUSED(arg)) 744 { 745 /* nothing */ 746 } 747 748 int doq_conn_cmp(const void* ATTR_UNUSED(key1), const void* ATTR_UNUSED(key2)) 749 { 750 return 0; 751 } 752 753 int doq_conid_cmp(const void* ATTR_UNUSED(key1), const void* ATTR_UNUSED(key2)) 754 { 755 return 0; 756 } 757 758 int doq_timer_cmp(const void* ATTR_UNUSED(key1), const void* ATTR_UNUSED(key2)) 759 { 760 return 0; 761 } 762 763 int doq_stream_cmp(const void* ATTR_UNUSED(key1), const void* ATTR_UNUSED(key2)) 764 { 765 return 0; 766 } 767 768 struct doq_table* doq_table_create(struct config_file* ATTR_UNUSED(cfg), 769 struct ub_randstate* ATTR_UNUSED(rnd)) 770 { 771 return calloc(1, sizeof(struct doq_table)); 772 } 773 774 void doq_table_delete(struct doq_table* table) 775 { 776 free(table); 777 } 778 779 void doq_timer_cb(void* ATTR_UNUSED(arg)) 780 { 781 /* nothing */ 782 } 783 784 size_t doq_table_quic_size_get(struct doq_table* ATTR_UNUSED(table)) 785 { 786 return 0; 787 } 788 #endif 789