microhttpd2_generated_daemon_options.h (94879B)
1 /** 2 * The options (parameters) for MHD daemon 3 */ 4 enum MHD_FIXED_ENUM_APP_SET_ MHD_DaemonOption 5 { /** 6 * Not a real option. 7 * Should not be used directly. 8 * This value indicates the end of the list of the options. 9 */ 10 MHD_D_O_END = 0 11 , 12 13 /** 14 * Set MHD work (threading and polling) mode. 15 * Consider use of #MHD_D_OPTION_WM_EXTERNAL_PERIODIC(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH(), #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() instead of direct use of this parameter. 16 */ 17 MHD_D_O_WORK_MODE = 40 18 , 19 20 /** 21 * Select a sockets watch system call used for internal polling. 22 */ 23 MHD_D_O_POLL_SYSCALL = 41 24 , 25 26 /** 27 * Instruct MHD to register all sockets every processing round. 28 * 29 By default (this options is not enabled) every processing round (every time 30 * when #MHD_daemon_event_update() is called) MHD calls 31 * #MHD_SocketRegistrationUpdateCallback only for the new sockets, for 32 * the removed sockets and for the updated sockets. 33 * Some sockets are registered when #MHD_daemon_start() is called. 34 * 35 If this options is enabled, then #MHD_SocketRegistrationUpdateCallback is 36 * called for every socket each processing round. No sockets are registered when 37 * the daemon is being started. 38 */ 39 MHD_D_O_REREGISTER_ALL = 45 40 , 41 42 /** 43 * Set a callback to use for logging 44 */ 45 MHD_D_O_LOG_CALLBACK = 60 46 , 47 48 /** 49 * Bind to the given TCP port and address family. 50 * 51 Does not work with #MHD_D_OPTION_BIND_SA() or #MHD_D_OPTION_LISTEN_SOCKET(). 52 * 53 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 54 */ 55 MHD_D_O_BIND_PORT = 80 56 , 57 58 /** 59 * Bind to the given socket address. 60 * 61 Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_LISTEN_SOCKET(). 62 * 63 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 64 */ 65 MHD_D_O_BIND_SA = 81 66 , 67 68 /** 69 * Accept connections from the given socket. Socket 70 * must be a TCP or UNIX domain (SOCK_STREAM) socket. 71 * 72 Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA(). 73 * 74 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 75 */ 76 MHD_D_O_LISTEN_SOCKET = 82 77 , 78 79 /** 80 * Select mode of reusing address:port listen address. 81 * 82 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 83 */ 84 MHD_D_O_LISTEN_ADDR_REUSE = 100 85 , 86 87 /** 88 * Configure TCP_FASTOPEN option, including setting a 89 * custom @a queue_length. 90 * 91 Note that having a larger queue size can cause resource exhaustion 92 * attack as the TCP stack has to now allocate resources for the SYN 93 * packet along with its DATA. 94 * 95 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 96 */ 97 MHD_D_O_TCP_FASTOPEN = 101 98 , 99 100 /** 101 * Use the given backlog for the listen() call. 102 * 103 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 104 * Zero parameter treated as MHD/system default. 105 */ 106 MHD_D_O_LISTEN_BACKLOG = 102 107 , 108 109 /** 110 * Inform that SIGPIPE is suppressed or handled by application. 111 * If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`. 112 * Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically. 113 */ 114 MHD_D_O_SIGPIPE_SUPPRESSED = 103 115 , 116 117 /** 118 * Enable TLS (HTTPS) and select TLS backend 119 */ 120 MHD_D_O_TLS = 120 121 , 122 123 /** 124 * Provide TLS key and certificate data in-memory. 125 * Works only if TLS mode is enabled. 126 */ 127 MHD_D_O_TLS_CERT_KEY = 121 128 , 129 130 /** 131 * Provide the certificate of the certificate authority (CA) to be used by the MHD daemon for client authentication. 132 * Works only if TLS mode is enabled. 133 */ 134 MHD_D_O_TLS_CLIENT_CA = 122 135 , 136 137 /** 138 * Configure PSK to use for the TLS key exchange. 139 */ 140 MHD_D_O_TLS_PSK_CALLBACK = 130 141 , 142 143 /** 144 * Control ALPN for TLS connection. 145 * Silently ignored for non-TLS. 146 * By default ALPN is automatically used for TLS connections. 147 */ 148 MHD_D_O_NO_ALPN = 140 149 , 150 151 /** 152 * Require ACME ALPN challenge support in TLS backend. 153 * If this option is enabled then TLS backends without ACME ALPN challenge 154 * support will not be selected automatically. The daemon will fail to start 155 * if no TLS backend with ACME ALPN is available. 156 */ 157 MHD_D_O_ACME_ALPN_REQUIRED = 141 158 , 159 160 /** 161 * Provide application name to load dedicated section in TLS backend's configuration file. 162 * Search for "System-wide configuration of the library" for GnuTLS documentation or 163 * for "config, OPENSSL LIBRARY CONFIGURATION" for OpenSSL documentation. 164 * If not specified the default backend configuration is used: 165 * "@LIBMICROHTTPD" (if available), then "@SYSTEM" (if available) then default priorities, then "NORMAL" for GnuTLS; 166 * "libmicrohttpd" (if available), then default name ("openssl_conf") for OpenSSL. 167 * Ignored when MbedTLS is used as daemon's TLS backend. 168 */ 169 MHD_D_O_TLS_APP_NAME = 142 170 , 171 172 /** 173 * Set the configuration pathname for OpenSSL configuration file 174 * Ignored OpenSSL is not used as daemon's TLS backend. 175 */ 176 MHD_D_O_TLS_OPENSSL_DEF_FILE = 144 177 , 178 179 /** 180 * Specify the inactivity timeout for a connection in milliseconds. 181 * If a connection remains idle (no activity) for this many 182 * milliseconds, it is closed automatically. 183 * Use zero for no timeout; this is also the (unsafe!) 184 * default. 185 * Values larger than 1209600000 (two weeks) are silently 186 * clamped to 1209600000. 187 * Precise closing time is not guaranteed and depends on 188 * system clock granularity and amount of time spent on 189 * processing other connections. Typical precision is 190 * within +/- 30 milliseconds, while the worst case could 191 * be greater than +/- 1 second. 192 * Values below 1500 milliseconds are risky as they 193 * may cause valid connections to be aborted and may 194 * increase load the server load due to clients' repetitive 195 * automatic retries. 196 */ 197 MHD_D_O_DEFAULT_TIMEOUT_MILSEC = 160 198 , 199 200 /** 201 * Maximum number of (concurrent) network connections served by daemon. 202 * @note The real maximum number of network connections could be smaller 203 * than requested due to the system limitations, like FD_SETSIZE when 204 * polling by select() is used. 205 */ 206 MHD_D_O_GLOBAL_CONNECTION_LIMIT = 161 207 , 208 209 /** 210 * Limit on the number of (concurrent) network connections made to the server from the same IP address. 211 * Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. 212 */ 213 MHD_D_O_PER_IP_LIMIT = 162 214 , 215 216 /** 217 * Set a policy callback that accepts/rejects connections based on the client's IP address. The callbeck function will be called before servicing any new incoming connection. 218 */ 219 MHD_D_O_ACCEPT_POLICY = 163 220 , 221 222 /** 223 * Set mode of connection memory buffer zeroing 224 */ 225 MHD_D_O_CONN_BUFF_ZEROING = 164 226 , 227 228 /** 229 * Set how strictly MHD will enforce the HTTP protocol. 230 */ 231 MHD_D_O_PROTOCOL_STRICT_LEVEL = 200 232 , 233 234 /** 235 * Set a callback to be called first for every request when the request line is received (before any parsing of the header). 236 * This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place. 237 * Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs. 238 */ 239 MHD_D_O_EARLY_URI_LOGGER = 201 240 , 241 242 /** 243 * Disable converting plus ('+') character to space in GET parameters (URI part after '?'). 244 * Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details. 245 * By default plus is converted to space in the query part of URI. 246 */ 247 MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE = 202 248 , 249 250 /** 251 * Suppresse use of 'Date:' header. 252 * According to RFC should be suppressed only if the system has no RTC. 253 * The 'Date:' is not suppressed (the header is enabled) by default. 254 */ 255 MHD_D_O_SUPPRESS_DATE_HEADER = 240 256 , 257 258 /** 259 * Use SHOUTcast for responses. 260 * This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'. 261 */ 262 MHD_D_O_ENABLE_SHOUTCAST = 241 263 , 264 265 /** 266 * Maximum memory size per connection. 267 * Default is 32kb. 268 * Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems. 269 * The size should be large enough to fit all request headers (together with internal parsing information). 270 */ 271 MHD_D_O_CONN_MEMORY_LIMIT = 280 272 , 273 274 /** 275 * The size of the shared memory pool for accamulated upload processing. 276 * The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application. 277 * Default is 8Mb. 278 * Can be set to zero to disable share pool. 279 */ 280 MHD_D_O_LARGE_POOL_SIZE = 281 281 , 282 283 /** 284 * Desired size of the stack for the threads started by MHD. 285 * Use 0 for system default, which is also MHD default. 286 * Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION(). 287 */ 288 MHD_D_O_STACK_SIZE = 282 289 , 290 291 /** 292 * The the maximum FD value. 293 * The limit is applied to all sockets used by MHD. 294 * If listen socket FD is equal or higher that specified value, the daemon fail to start. 295 * If new connection FD is equal or higher that specified value, the connection is rejected. 296 * Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case. 297 * Silently ignored on W32 (WinSock sockets). 298 */ 299 MHD_D_O_FD_NUMBER_LIMIT = 283 300 , 301 302 /** 303 * Enable `turbo`. 304 * Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations. 305 * Most effects only happen with internal threads with epoll. 306 * The 'turbo' mode is not enabled (mode is disabled) by default. 307 */ 308 MHD_D_O_TURBO = 320 309 , 310 311 /** 312 * Disable some internal thread safety. 313 * Indicates that MHD daemon will be used by application in single-threaded mode only. When this flag is set then application must call any MHD function only within a single thread. 314 * This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment. 315 * Not compatible with any internal threads modes. 316 * If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory. 317 * Thread safety is not disabled (safety is enabled) by default. 318 */ 319 MHD_D_O_DISABLE_THREAD_SAFETY = 321 320 , 321 322 /** 323 * You need to set this option if you want to disable use of HTTP Upgrade. 324 * Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used. 325 * You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving. 326 * The upgrade is not disallowed (upgrade is allowed) by default. 327 */ 328 MHD_D_O_DISALLOW_UPGRADE = 322 329 , 330 331 /** 332 * Disable #MHD_action_suspend() functionality. 333 * 334 You should only use this function if you do not use suspend functionality and need a generally minor boost in performance. 335 * The suspend is not disallowed (suspend is allowed) by default. 336 */ 337 MHD_D_O_DISALLOW_SUSPEND_RESUME = 323 338 , 339 340 /** 341 * Disable cookies parsing. 342 * 343 Disable automatic cookies processing if cookies are not used. 344 * Cookies are automatically parsed by default. 345 */ 346 MHD_D_O_DISABLE_COOKIES = 324 347 , 348 349 /** 350 * Set a callback to be called for pre-start finalisation. 351 * 352 The specified callback will be called one time, after network initialisation, TLS pre-initialisation, but before the start of the internal threads (if allowed) 353 */ 354 MHD_D_O_DAEMON_READY_CALLBACK = 360 355 , 356 357 /** 358 * Set a function that should be called whenever a connection is started or closed. 359 */ 360 MHD_D_O_NOTIFY_CONNECTION = 361 361 , 362 363 /** 364 * Register a function that should be called whenever a stream is started or closed. 365 * For HTTP/1.1 this callback is called one time for every connection. 366 */ 367 MHD_D_O_NOTIFY_STREAM = 362 368 , 369 370 /** 371 * Set strong random data to be used by MHD. 372 * Currently the data is only needed for Digest Auth module. 373 * Daemon support for Digest Auth is enabled automatically if this option is used. 374 * The recommended size is between 8 and 32 bytes. Security can be lower for sizes less or equal four. 375 * Sizes larger then 32 (or, probably, larger than 16 - debatable) will not increase the security. 376 */ 377 MHD_D_O_RANDOM_ENTROPY = 400 378 , 379 380 /** 381 * Specify the size of the internal hash map array that tracks generated digest nonces usage. 382 * When the size of the map is too small then need to handle concurrent DAuth requests, a lot of stale nonce results will be produced. 383 * By default the size is 1000 entries. 384 */ 385 MHD_D_O_AUTH_DIGEST_MAP_SIZE = 401 386 , 387 388 /** 389 * Nonce validity time (in seconds) used for Digest Auth. 390 * If followed by zero value the value is silently ignored. 391 * @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest() 392 */ 393 MHD_D_O_AUTH_DIGEST_NONCE_TIMEOUT = 403 394 , 395 396 /** 397 * Default maximum nc (nonce count) value used for Digest Auth. 398 * If followed by zero value the value is silently ignored. 399 * @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest() 400 */ 401 MHD_D_O_AUTH_DIGEST_DEF_MAX_NC = 404 402 , 403 404 /** 405 * The sentinel value. 406 * This value enforces specific underlying integer type for the enum. 407 * Do not use. 408 */ 409 MHD_D_O_SENTINEL = 65535 410 411 }; 412 413 /** 414 * Data for #MHD_D_O_LOG_CALLBACK 415 */ 416 struct MHD_DaemonOptionValueLog 417 { 418 /** 419 * the callback to use for logging, 420 * NULL to disable logging. 421 * The logging to stderr is enabled by default. 422 */ 423 MHD_LoggingCallback v_log_cb; 424 425 /** 426 * the closure for the logging callback 427 */ 428 void *v_log_cb_cls; 429 430 }; 431 432 /** 433 * Data for #MHD_D_O_BIND_PORT 434 */ 435 struct MHD_DaemonOptionValueBind 436 { 437 /** 438 * the address family to use, 439 * the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used) 440 */ 441 enum MHD_AddressFamily v_af; 442 443 /** 444 * port to use, 0 to let system assign any free port, 445 * ignored if @a af is #MHD_AF_NONE 446 */ 447 uint_least16_t v_port; 448 449 }; 450 451 /** 452 * Data for #MHD_D_O_BIND_SA 453 */ 454 struct MHD_DaemonOptionValueSA 455 { 456 /** 457 * the size of the socket address pointed by @a sa. 458 */ 459 size_t v_sa_len; 460 461 /** 462 * the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX) 463 */ 464 /* const */ struct sockaddr *v_sa; 465 466 /** 467 * When a previous version of the protocol exist (like IPv4 when @a v_sa is IPv6) bind to both protocols (IPv6 and IPv4). 468 */ 469 enum MHD_Bool v_dual; 470 471 }; 472 473 /** 474 * Data for #MHD_D_O_TCP_FASTOPEN 475 */ 476 struct MHD_DaemonOptionValueTFO 477 { 478 /** 479 * the type use of of TCP FastOpen 480 */ 481 enum MHD_TCPFastOpenType v_option; 482 483 /** 484 * the length of the queue, zero to use system or MHD default, 485 * silently ignored on platforms without support for custom queue size 486 */ 487 unsigned int v_queue_length; 488 489 }; 490 491 /** 492 * Data for #MHD_D_O_TLS_CERT_KEY 493 */ 494 struct MHD_DaemonOptionValueTlsCert 495 { 496 /** 497 * The X.509 certificates chain in PEM format loaded into memory (not a filename). 498 * The first certificate must be the server certificate, following by the chain of signing 499 * certificates up to (but not including) CA root certificate. 500 */ 501 /* const */ char *v_mem_cert; 502 503 /** 504 * the private key in PEM format loaded into memory (not a filename) 505 */ 506 const char *v_mem_key; 507 508 /** 509 * the option passphrase phrase to decrypt the private key, 510 * could be NULL if private key does not need a password 511 */ 512 const char *v_mem_pass; 513 514 }; 515 516 /** 517 * Data for #MHD_D_O_TLS_PSK_CALLBACK 518 */ 519 struct MHD_DaemonOptionValueTlsPskCB 520 { 521 /** 522 * the function to call to obtain pre-shared key 523 */ 524 MHD_PskServerCredentialsCallback v_psk_cb; 525 526 /** 527 * the closure for @a psk_cb 528 */ 529 void *v_psk_cb_cls; 530 531 }; 532 533 /** 534 * Data for #MHD_D_O_TLS_APP_NAME 535 */ 536 struct MHD_DaemonOptionValueTlsAppName 537 { 538 /** 539 * the name of the application, used as converted to 540 * uppercase (with '@'-prefixed) for GnuTLS and as converted to 541 * lowercase for OpenSSL; must not be longer than 127 characters 542 */ 543 char *v_app_name; 544 545 /** 546 * forbid use fallback/default configuration if specified 547 * configuration is not found; also forbid ignoring errors in the 548 * configuration on TLS backends, which may ignoring configuration 549 * errors 550 */ 551 enum MHD_Bool v_disable_fallback; 552 553 }; 554 555 /** 556 * Data for #MHD_D_O_TLS_OPENSSL_DEF_FILE 557 */ 558 struct MHD_DaemonOptionValueTlsOsslDefFile 559 { 560 /** 561 * the path and the name of the OpenSSL configuration file, 562 * if only the name is provided then standard path for 563 * configuration files is used, 564 * could be NULL to use default configuration file pathname 565 * or an empty (zero-size) string to disable file loading 566 */ 567 char *v_pathname; 568 569 /** 570 * forbid use of fallback/default location and name of 571 * the OpenSSL configuration file; also forbid initialisation without 572 * configuration file 573 */ 574 enum MHD_Bool v_disable_fallback; 575 576 }; 577 578 /** 579 * Data for #MHD_D_O_ACCEPT_POLICY 580 */ 581 struct MHD_DaemonOptionValueAcceptPol 582 { 583 /** 584 * the accept policy callback 585 */ 586 MHD_AcceptPolicyCallback v_apc; 587 588 /** 589 * the closure for the callback 590 */ 591 void *v_apc_cls; 592 593 }; 594 595 /** 596 * Data for #MHD_D_O_PROTOCOL_STRICT_LEVEL 597 */ 598 struct MHD_DaemonOptionValueStrctLvl 599 { 600 /** 601 * the level of strictness 602 */ 603 enum MHD_ProtocolStrictLevel v_sl; 604 605 /** 606 * the way how to use the requested level 607 */ 608 enum MHD_UseStictLevel v_how; 609 610 }; 611 612 /** 613 * Data for #MHD_D_O_EARLY_URI_LOGGER 614 */ 615 struct MHD_DaemonOptionValueUriCB 616 { 617 /** 618 * the early URI callback 619 */ 620 MHD_EarlyUriLogCallback v_cb; 621 622 /** 623 * the closure for the callback 624 */ 625 void *v_cls; 626 627 }; 628 629 /** 630 * Data for #MHD_D_O_DAEMON_READY_CALLBACK 631 */ 632 struct MHD_DaemonOptionValueReadyCB 633 { 634 /** 635 * the pre-start callback 636 */ 637 MHD_DaemonReadyCallback v_cb; 638 639 /** 640 * the closure for the callback 641 */ 642 void *v_cb_cls; 643 644 }; 645 646 /** 647 * Data for #MHD_D_O_NOTIFY_CONNECTION 648 */ 649 struct MHD_DaemonOptionValueNotifConnCB 650 { 651 /** 652 * the callback for notifications 653 */ 654 MHD_NotifyConnectionCallback v_ncc; 655 656 /** 657 * the closure for the callback 658 */ 659 void *v_cls; 660 661 }; 662 663 /** 664 * Data for #MHD_D_O_NOTIFY_STREAM 665 */ 666 struct MHD_DaemonOptionValueNotifStreamCB 667 { 668 /** 669 * the callback for notifications 670 */ 671 MHD_NotifyStreamCallback v_nsc; 672 673 /** 674 * the closure for the callback 675 */ 676 void *v_cls; 677 678 }; 679 680 /** 681 * Data for #MHD_D_O_RANDOM_ENTROPY 682 */ 683 struct MHD_DaemonOptionEntropySeed 684 { 685 /** 686 * the size of the buffer 687 */ 688 size_t v_buf_size; 689 690 /** 691 * the buffer with strong random data, the content will be copied by MHD 692 */ 693 /* const */ void *v_buf; 694 695 }; 696 697 /** 698 * Parameters for MHD daemon options 699 */ 700 union MHD_DaemonOptionValue 701 { 702 /** 703 * Value for #MHD_D_O_WORK_MODE. 704 * the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION() 705 */ 706 struct MHD_WorkModeWithParam work_mode; 707 708 /** 709 * Value for #MHD_D_O_POLL_SYSCALL. 710 * FIXME 711 */ 712 enum MHD_SockPollSyscall poll_syscall; 713 714 /** 715 * Value for #MHD_D_O_REREGISTER_ALL. 716 */ 717 enum MHD_Bool reregister_all; 718 719 /** 720 * Value for #MHD_D_O_LOG_CALLBACK. 721 * the callback to use for logging, 722 * NULL to disable logging. 723 * The logging to stderr is enabled by default. 724 */ 725 struct MHD_DaemonOptionValueLog log_callback; 726 727 /** 728 * Value for #MHD_D_O_BIND_PORT. 729 * the address family to use, 730 * the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used) 731 */ 732 struct MHD_DaemonOptionValueBind bind_port; 733 734 /** 735 * Value for #MHD_D_O_BIND_SA. 736 * the size of the socket address pointed by @a sa. 737 */ 738 struct MHD_DaemonOptionValueSA bind_sa; 739 740 /** 741 * Value for #MHD_D_O_LISTEN_SOCKET. 742 * the listen socket to use, ignored if set to #MHD_INVALID_SOCKET 743 */ 744 MHD_Socket listen_socket; 745 746 /** 747 * Value for #MHD_D_O_LISTEN_ADDR_REUSE. 748 * FIXME 749 */ 750 enum MHD_DaemonOptionBindType listen_addr_reuse; 751 752 /** 753 * Value for #MHD_D_O_TCP_FASTOPEN. 754 * the type use of of TCP FastOpen 755 */ 756 struct MHD_DaemonOptionValueTFO tcp_fastopen; 757 758 /** 759 * Value for #MHD_D_O_LISTEN_BACKLOG. 760 * FIXME 761 */ 762 unsigned int listen_backlog; 763 764 /** 765 * Value for #MHD_D_O_SIGPIPE_SUPPRESSED. 766 */ 767 enum MHD_Bool sigpipe_suppressed; 768 769 /** 770 * Value for #MHD_D_O_TLS. 771 * the TLS backend to use, 772 * #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections 773 */ 774 enum MHD_TlsBackend tls; 775 776 /** 777 * Value for #MHD_D_O_TLS_CERT_KEY. 778 * The X.509 certificates chain in PEM format loaded into memory (not a filename). 779 * The first certificate must be the server certificate, following by the chain of signing 780 * certificates up to (but not including) CA root certificate. 781 */ 782 struct MHD_DaemonOptionValueTlsCert tls_cert_key; 783 784 /** 785 * Value for #MHD_D_O_TLS_CLIENT_CA. 786 * the CA certificate in memory (not a filename) 787 */ 788 const char *tls_client_ca; 789 790 /** 791 * Value for #MHD_D_O_TLS_PSK_CALLBACK. 792 * the function to call to obtain pre-shared key 793 */ 794 struct MHD_DaemonOptionValueTlsPskCB tls_psk_callback; 795 796 /** 797 * Value for #MHD_D_O_NO_ALPN. 798 */ 799 enum MHD_Bool no_alpn; 800 801 /** 802 * Value for #MHD_D_O_ACME_ALPN_REQUIRED. 803 */ 804 enum MHD_Bool acme_alpn_required; 805 806 /** 807 * Value for #MHD_D_O_TLS_APP_NAME. 808 * the name of the application, used as converted to 809 * uppercase (with '@'-prefixed) for GnuTLS and as converted to 810 * lowercase for OpenSSL; must not be longer than 127 characters 811 */ 812 struct MHD_DaemonOptionValueTlsAppName tls_app_name; 813 814 /** 815 * Value for #MHD_D_O_TLS_OPENSSL_DEF_FILE. 816 * the path and the name of the OpenSSL configuration file, 817 * if only the name is provided then standard path for 818 * configuration files is used, 819 * could be NULL to use default configuration file pathname 820 * or an empty (zero-size) string to disable file loading 821 */ 822 struct MHD_DaemonOptionValueTlsOsslDefFile tls_openssl_def_file; 823 824 /** 825 * Value for #MHD_D_O_DEFAULT_TIMEOUT_MILSEC. 826 * the timeout in milliseconds, zero for no timeout 827 */ 828 uint_fast32_t default_timeout_milsec; 829 830 /** 831 * Value for #MHD_D_O_GLOBAL_CONNECTION_LIMIT. 832 * FIXME 833 */ 834 unsigned int global_connection_limit; 835 836 /** 837 * Value for #MHD_D_O_PER_IP_LIMIT. 838 * FIXME 839 */ 840 unsigned int per_ip_limit; 841 842 /** 843 * Value for #MHD_D_O_ACCEPT_POLICY. 844 * the accept policy callback 845 */ 846 struct MHD_DaemonOptionValueAcceptPol accept_policy; 847 848 /** 849 * Value for #MHD_D_O_CONN_BUFF_ZEROING. 850 * buffer zeroing mode 851 */ 852 enum MHD_ConnBufferZeroingMode conn_buff_zeroing; 853 854 /** 855 * Value for #MHD_D_O_PROTOCOL_STRICT_LEVEL. 856 * the level of strictness 857 */ 858 struct MHD_DaemonOptionValueStrctLvl protocol_strict_level; 859 860 /** 861 * Value for #MHD_D_O_EARLY_URI_LOGGER. 862 * the early URI callback 863 */ 864 struct MHD_DaemonOptionValueUriCB early_uri_logger; 865 866 /** 867 * Value for #MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE. 868 */ 869 enum MHD_Bool disable_uri_query_plus_as_space; 870 871 /** 872 * Value for #MHD_D_O_SUPPRESS_DATE_HEADER. 873 */ 874 enum MHD_Bool suppress_date_header; 875 876 /** 877 * Value for #MHD_D_O_ENABLE_SHOUTCAST. 878 */ 879 enum MHD_Bool enable_shoutcast; 880 881 /** 882 * Value for #MHD_D_O_CONN_MEMORY_LIMIT. 883 */ 884 size_t conn_memory_limit; 885 886 /** 887 * Value for #MHD_D_O_LARGE_POOL_SIZE. 888 */ 889 size_t large_pool_size; 890 891 /** 892 * Value for #MHD_D_O_STACK_SIZE. 893 */ 894 size_t stack_size; 895 896 /** 897 * Value for #MHD_D_O_FD_NUMBER_LIMIT. 898 * FIXME 899 */ 900 MHD_Socket fd_number_limit; 901 902 /** 903 * Value for #MHD_D_O_TURBO. 904 */ 905 enum MHD_Bool turbo; 906 907 /** 908 * Value for #MHD_D_O_DISABLE_THREAD_SAFETY. 909 */ 910 enum MHD_Bool disable_thread_safety; 911 912 /** 913 * Value for #MHD_D_O_DISALLOW_UPGRADE. 914 */ 915 enum MHD_Bool disallow_upgrade; 916 917 /** 918 * Value for #MHD_D_O_DISALLOW_SUSPEND_RESUME. 919 */ 920 enum MHD_Bool disallow_suspend_resume; 921 922 /** 923 * Value for #MHD_D_O_DISABLE_COOKIES. 924 */ 925 enum MHD_Bool disable_cookies; 926 927 /** 928 * Value for #MHD_D_O_DAEMON_READY_CALLBACK. 929 * the pre-start callback 930 */ 931 struct MHD_DaemonOptionValueReadyCB daemon_ready_callback; 932 933 /** 934 * Value for #MHD_D_O_NOTIFY_CONNECTION. 935 * the callback for notifications 936 */ 937 struct MHD_DaemonOptionValueNotifConnCB notify_connection; 938 939 /** 940 * Value for #MHD_D_O_NOTIFY_STREAM. 941 * the callback for notifications 942 */ 943 struct MHD_DaemonOptionValueNotifStreamCB notify_stream; 944 945 /** 946 * Value for #MHD_D_O_RANDOM_ENTROPY. 947 * the size of the buffer 948 */ 949 struct MHD_DaemonOptionEntropySeed random_entropy; 950 951 /** 952 * Value for #MHD_D_O_AUTH_DIGEST_MAP_SIZE. 953 * the size of the map array 954 */ 955 size_t auth_digest_map_size; 956 957 /** 958 * Value for #MHD_D_O_AUTH_DIGEST_NONCE_TIMEOUT. 959 * FIXME 960 */ 961 unsigned int auth_digest_nonce_timeout; 962 963 /** 964 * Value for #MHD_D_O_AUTH_DIGEST_DEF_MAX_NC. 965 * FIXME 966 */ 967 uint_fast32_t auth_digest_def_max_nc; 968 969 }; 970 971 972 struct MHD_DaemonOptionAndValue 973 { 974 /** 975 * The daemon configuration option 976 */ 977 enum MHD_DaemonOption opt; 978 979 /** 980 * The value for the @a opt option 981 */ 982 union MHD_DaemonOptionValue val; 983 }; 984 985 #if defined(MHD_USE_COMPOUND_LITERALS) && defined(MHD_USE_DESIG_NEST_INIT) 986 /** 987 * Set MHD work (threading and polling) mode. 988 * Consider use of #MHD_D_OPTION_WM_EXTERNAL_PERIODIC(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH(), #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() instead of direct use of this parameter. 989 * @param wmp the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION() 990 * @return structure with the requested setting 991 */ 992 # define MHD_D_OPTION_WORK_MODE(wmp) \ 993 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 994 (const struct MHD_DaemonOptionAndValue) \ 995 { \ 996 .opt = MHD_D_O_WORK_MODE, \ 997 .val.work_mode = (wmp) \ 998 } \ 999 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1000 /** 1001 * Select a sockets watch system call used for internal polling. 1002 * @param els FIXME 1003 * @return structure with the requested setting 1004 */ 1005 # define MHD_D_OPTION_POLL_SYSCALL(els) \ 1006 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1007 (const struct MHD_DaemonOptionAndValue) \ 1008 { \ 1009 .opt = MHD_D_O_POLL_SYSCALL, \ 1010 .val.poll_syscall = (els) \ 1011 } \ 1012 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1013 /** 1014 * Instruct MHD to register all sockets every processing round. 1015 * 1016 By default (this options is not enabled) every processing round (every time 1017 * when #MHD_daemon_event_update() is called) MHD calls 1018 * #MHD_SocketRegistrationUpdateCallback only for the new sockets, for 1019 * the removed sockets and for the updated sockets. 1020 * Some sockets are registered when #MHD_daemon_start() is called. 1021 * 1022 If this options is enabled, then #MHD_SocketRegistrationUpdateCallback is 1023 * called for every socket each processing round. No sockets are registered when 1024 * the daemon is being started. 1025 * @param value the value of the parameter * @return structure with the requested setting 1026 */ 1027 # define MHD_D_OPTION_REREGISTER_ALL(value) \ 1028 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1029 (const struct MHD_DaemonOptionAndValue) \ 1030 { \ 1031 .opt = MHD_D_O_REREGISTER_ALL, \ 1032 .val.reregister_all = (value) \ 1033 } \ 1034 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1035 /** 1036 * Set a callback to use for logging 1037 * @param log_cb the callback to use for logging, 1038 * NULL to disable logging. 1039 * The logging to stderr is enabled by default. 1040 * @param log_cb_cls the closure for the logging callback 1041 * @return structure with the requested setting 1042 */ 1043 # define MHD_D_OPTION_LOG_CALLBACK(log_cb, log_cb_cls) \ 1044 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1045 (const struct MHD_DaemonOptionAndValue) \ 1046 { \ 1047 .opt = MHD_D_O_LOG_CALLBACK, \ 1048 .val.log_callback.v_log_cb = (log_cb), \ 1049 .val.log_callback.v_log_cb_cls = (log_cb_cls) \ 1050 } \ 1051 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1052 /** 1053 * Bind to the given TCP port and address family. 1054 * 1055 Does not work with #MHD_D_OPTION_BIND_SA() or #MHD_D_OPTION_LISTEN_SOCKET(). 1056 * 1057 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 1058 * @param af the address family to use, 1059 * the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used) 1060 * @param port port to use, 0 to let system assign any free port, 1061 * ignored if @a af is #MHD_AF_NONE 1062 * @return structure with the requested setting 1063 */ 1064 # define MHD_D_OPTION_BIND_PORT(af, port) \ 1065 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1066 (const struct MHD_DaemonOptionAndValue) \ 1067 { \ 1068 .opt = MHD_D_O_BIND_PORT, \ 1069 .val.bind_port.v_af = (af), \ 1070 .val.bind_port.v_port = (port) \ 1071 } \ 1072 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1073 /** 1074 * Bind to the given socket address. 1075 * 1076 Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_LISTEN_SOCKET(). 1077 * 1078 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 1079 * @param sa_len the size of the socket address pointed by @a sa. 1080 * @param sa the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX) 1081 * @param dual When a previous version of the protocol exist (like IPv4 when @a v_sa is IPv6) bind to both protocols (IPv6 and IPv4). 1082 * @return structure with the requested setting 1083 */ 1084 # define MHD_D_OPTION_BIND_SA(sa_len, sa, dual) \ 1085 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1086 (const struct MHD_DaemonOptionAndValue) \ 1087 { \ 1088 .opt = MHD_D_O_BIND_SA, \ 1089 .val.bind_sa.v_sa_len = (sa_len), \ 1090 .val.bind_sa.v_sa = (sa), \ 1091 .val.bind_sa.v_dual = (dual) \ 1092 } \ 1093 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1094 /** 1095 * Accept connections from the given socket. Socket 1096 * must be a TCP or UNIX domain (SOCK_STREAM) socket. 1097 * 1098 Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA(). 1099 * 1100 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 1101 * @param listen_fd the listen socket to use, ignored if set to #MHD_INVALID_SOCKET 1102 * @return structure with the requested setting 1103 */ 1104 # define MHD_D_OPTION_LISTEN_SOCKET(listen_fd) \ 1105 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1106 (const struct MHD_DaemonOptionAndValue) \ 1107 { \ 1108 .opt = MHD_D_O_LISTEN_SOCKET, \ 1109 .val.listen_socket = (listen_fd) \ 1110 } \ 1111 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1112 /** 1113 * Select mode of reusing address:port listen address. 1114 * 1115 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 1116 * @param reuse_type FIXME 1117 * @return structure with the requested setting 1118 */ 1119 # define MHD_D_OPTION_LISTEN_ADDR_REUSE(reuse_type) \ 1120 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1121 (const struct MHD_DaemonOptionAndValue) \ 1122 { \ 1123 .opt = MHD_D_O_LISTEN_ADDR_REUSE, \ 1124 .val.listen_addr_reuse = (reuse_type) \ 1125 } \ 1126 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1127 /** 1128 * Configure TCP_FASTOPEN option, including setting a 1129 * custom @a queue_length. 1130 * 1131 Note that having a larger queue size can cause resource exhaustion 1132 * attack as the TCP stack has to now allocate resources for the SYN 1133 * packet along with its DATA. 1134 * 1135 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 1136 * @param option the type use of of TCP FastOpen 1137 * @param queue_length the length of the queue, zero to use system or MHD default, 1138 * silently ignored on platforms without support for custom queue size 1139 * @return structure with the requested setting 1140 */ 1141 # define MHD_D_OPTION_TCP_FASTOPEN(option, queue_length) \ 1142 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1143 (const struct MHD_DaemonOptionAndValue) \ 1144 { \ 1145 .opt = MHD_D_O_TCP_FASTOPEN, \ 1146 .val.tcp_fastopen.v_option = (option), \ 1147 .val.tcp_fastopen.v_queue_length = (queue_length) \ 1148 } \ 1149 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1150 /** 1151 * Use the given backlog for the listen() call. 1152 * 1153 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 1154 * Zero parameter treated as MHD/system default. 1155 * @param backlog_size FIXME 1156 * @return structure with the requested setting 1157 */ 1158 # define MHD_D_OPTION_LISTEN_BACKLOG(backlog_size) \ 1159 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1160 (const struct MHD_DaemonOptionAndValue) \ 1161 { \ 1162 .opt = MHD_D_O_LISTEN_BACKLOG, \ 1163 .val.listen_backlog = (backlog_size) \ 1164 } \ 1165 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1166 /** 1167 * Inform that SIGPIPE is suppressed or handled by application. 1168 * If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`. 1169 * Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically. 1170 * @param value the value of the parameter * @return structure with the requested setting 1171 */ 1172 # define MHD_D_OPTION_SIGPIPE_SUPPRESSED(value) \ 1173 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1174 (const struct MHD_DaemonOptionAndValue) \ 1175 { \ 1176 .opt = MHD_D_O_SIGPIPE_SUPPRESSED, \ 1177 .val.sigpipe_suppressed = (value) \ 1178 } \ 1179 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1180 /** 1181 * Enable TLS (HTTPS) and select TLS backend 1182 * @param backend the TLS backend to use, 1183 * #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections 1184 * @return structure with the requested setting 1185 */ 1186 # define MHD_D_OPTION_TLS(backend) \ 1187 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1188 (const struct MHD_DaemonOptionAndValue) \ 1189 { \ 1190 .opt = MHD_D_O_TLS, \ 1191 .val.tls = (backend) \ 1192 } \ 1193 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1194 /** 1195 * Provide TLS key and certificate data in-memory. 1196 * Works only if TLS mode is enabled. 1197 * @param mem_cert The X.509 certificates chain in PEM format loaded into memory (not a filename). 1198 * The first certificate must be the server certificate, following by the chain of signing 1199 * certificates up to (but not including) CA root certificate. 1200 * @param mem_key the private key in PEM format loaded into memory (not a filename) 1201 * @param mem_pass the option passphrase phrase to decrypt the private key, 1202 * could be NULL if private key does not need a password 1203 * @return structure with the requested setting 1204 */ 1205 # define MHD_D_OPTION_TLS_CERT_KEY(mem_cert, mem_key, mem_pass) \ 1206 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1207 (const struct MHD_DaemonOptionAndValue) \ 1208 { \ 1209 .opt = MHD_D_O_TLS_CERT_KEY, \ 1210 .val.tls_cert_key.v_mem_cert = (mem_cert), \ 1211 .val.tls_cert_key.v_mem_key = (mem_key), \ 1212 .val.tls_cert_key.v_mem_pass = (mem_pass) \ 1213 } \ 1214 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1215 /** 1216 * Provide the certificate of the certificate authority (CA) to be used by the MHD daemon for client authentication. 1217 * Works only if TLS mode is enabled. 1218 * @param mem_client_ca the CA certificate in memory (not a filename) 1219 * @return structure with the requested setting 1220 */ 1221 # define MHD_D_OPTION_TLS_CLIENT_CA(mem_client_ca) \ 1222 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1223 (const struct MHD_DaemonOptionAndValue) \ 1224 { \ 1225 .opt = MHD_D_O_TLS_CLIENT_CA, \ 1226 .val.tls_client_ca = (mem_client_ca) \ 1227 } \ 1228 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1229 /** 1230 * Configure PSK to use for the TLS key exchange. 1231 * @param psk_cb the function to call to obtain pre-shared key 1232 * @param psk_cb_cls the closure for @a psk_cb 1233 * @return structure with the requested setting 1234 */ 1235 # define MHD_D_OPTION_TLS_PSK_CALLBACK(psk_cb, psk_cb_cls) \ 1236 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1237 (const struct MHD_DaemonOptionAndValue) \ 1238 { \ 1239 .opt = MHD_D_O_TLS_PSK_CALLBACK, \ 1240 .val.tls_psk_callback.v_psk_cb = (psk_cb), \ 1241 .val.tls_psk_callback.v_psk_cb_cls = (psk_cb_cls) \ 1242 } \ 1243 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1244 /** 1245 * Control ALPN for TLS connection. 1246 * Silently ignored for non-TLS. 1247 * By default ALPN is automatically used for TLS connections. 1248 * @param value the value of the parameter * @return structure with the requested setting 1249 */ 1250 # define MHD_D_OPTION_NO_ALPN(value) \ 1251 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1252 (const struct MHD_DaemonOptionAndValue) \ 1253 { \ 1254 .opt = MHD_D_O_NO_ALPN, \ 1255 .val.no_alpn = (value) \ 1256 } \ 1257 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1258 /** 1259 * Require ACME ALPN challenge support in TLS backend. 1260 * If this option is enabled then TLS backends without ACME ALPN challenge 1261 * support will not be selected automatically. The daemon will fail to start 1262 * if no TLS backend with ACME ALPN is available. 1263 * @param value the value of the parameter * @return structure with the requested setting 1264 */ 1265 # define MHD_D_OPTION_ACME_ALPN_REQUIRED(value) \ 1266 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1267 (const struct MHD_DaemonOptionAndValue) \ 1268 { \ 1269 .opt = MHD_D_O_ACME_ALPN_REQUIRED, \ 1270 .val.acme_alpn_required = (value) \ 1271 } \ 1272 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1273 /** 1274 * Provide application name to load dedicated section in TLS backend's configuration file. 1275 * Search for "System-wide configuration of the library" for GnuTLS documentation or 1276 * for "config, OPENSSL LIBRARY CONFIGURATION" for OpenSSL documentation. 1277 * If not specified the default backend configuration is used: 1278 * "@LIBMICROHTTPD" (if available), then "@SYSTEM" (if available) then default priorities, then "NORMAL" for GnuTLS; 1279 * "libmicrohttpd" (if available), then default name ("openssl_conf") for OpenSSL. 1280 * Ignored when MbedTLS is used as daemon's TLS backend. 1281 * @param app_name the name of the application, used as converted to 1282 * uppercase (with '@'-prefixed) for GnuTLS and as converted to 1283 * lowercase for OpenSSL; must not be longer than 127 characters 1284 * @param disable_fallback forbid use fallback/default configuration if specified 1285 * configuration is not found; also forbid ignoring errors in the 1286 * configuration on TLS backends, which may ignoring configuration 1287 * errors 1288 * @return structure with the requested setting 1289 */ 1290 # define MHD_D_OPTION_TLS_APP_NAME(app_name, disable_fallback) \ 1291 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1292 (const struct MHD_DaemonOptionAndValue) \ 1293 { \ 1294 .opt = MHD_D_O_TLS_APP_NAME, \ 1295 .val.tls_app_name.v_app_name = (app_name), \ 1296 .val.tls_app_name.v_disable_fallback = (disable_fallback) \ 1297 } \ 1298 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1299 /** 1300 * Set the configuration pathname for OpenSSL configuration file 1301 * Ignored OpenSSL is not used as daemon's TLS backend. 1302 * @param pathname the path and the name of the OpenSSL configuration file, 1303 * if only the name is provided then standard path for 1304 * configuration files is used, 1305 * could be NULL to use default configuration file pathname 1306 * or an empty (zero-size) string to disable file loading 1307 * @param disable_fallback forbid use of fallback/default location and name of 1308 * the OpenSSL configuration file; also forbid initialisation without 1309 * configuration file 1310 * @return structure with the requested setting 1311 */ 1312 # define MHD_D_OPTION_TLS_OPENSSL_DEF_FILE(pathname, disable_fallback) \ 1313 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1314 (const struct MHD_DaemonOptionAndValue) \ 1315 { \ 1316 .opt = MHD_D_O_TLS_OPENSSL_DEF_FILE, \ 1317 .val.tls_openssl_def_file.v_pathname = (pathname), \ 1318 .val.tls_openssl_def_file.v_disable_fallback = (disable_fallback) \ 1319 } \ 1320 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1321 /** 1322 * Specify the inactivity timeout for a connection in milliseconds. 1323 * If a connection remains idle (no activity) for this many 1324 * milliseconds, it is closed automatically. 1325 * Use zero for no timeout; this is also the (unsafe!) 1326 * default. 1327 * Values larger than 1209600000 (two weeks) are silently 1328 * clamped to 1209600000. 1329 * Precise closing time is not guaranteed and depends on 1330 * system clock granularity and amount of time spent on 1331 * processing other connections. Typical precision is 1332 * within +/- 30 milliseconds, while the worst case could 1333 * be greater than +/- 1 second. 1334 * Values below 1500 milliseconds are risky as they 1335 * may cause valid connections to be aborted and may 1336 * increase load the server load due to clients' repetitive 1337 * automatic retries. 1338 * @param timeout the timeout in milliseconds, zero for no timeout 1339 * @return structure with the requested setting 1340 */ 1341 # define MHD_D_OPTION_DEFAULT_TIMEOUT_MILSEC(timeout) \ 1342 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1343 (const struct MHD_DaemonOptionAndValue) \ 1344 { \ 1345 .opt = MHD_D_O_DEFAULT_TIMEOUT_MILSEC, \ 1346 .val.default_timeout_milsec = (timeout) \ 1347 } \ 1348 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1349 /** 1350 * Maximum number of (concurrent) network connections served by daemon. 1351 * @note The real maximum number of network connections could be smaller 1352 * than requested due to the system limitations, like FD_SETSIZE when 1353 * polling by select() is used. 1354 * @param glob_limit FIXME 1355 * @return structure with the requested setting 1356 */ 1357 # define MHD_D_OPTION_GLOBAL_CONNECTION_LIMIT(glob_limit) \ 1358 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1359 (const struct MHD_DaemonOptionAndValue) \ 1360 { \ 1361 .opt = MHD_D_O_GLOBAL_CONNECTION_LIMIT, \ 1362 .val.global_connection_limit = (glob_limit) \ 1363 } \ 1364 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1365 /** 1366 * Limit on the number of (concurrent) network connections made to the server from the same IP address. 1367 * Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. 1368 * @param limit FIXME 1369 * @return structure with the requested setting 1370 */ 1371 # define MHD_D_OPTION_PER_IP_LIMIT(limit) \ 1372 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1373 (const struct MHD_DaemonOptionAndValue) \ 1374 { \ 1375 .opt = MHD_D_O_PER_IP_LIMIT, \ 1376 .val.per_ip_limit = (limit) \ 1377 } \ 1378 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1379 /** 1380 * Set a policy callback that accepts/rejects connections based on the client's IP address. The callbeck function will be called before servicing any new incoming connection. 1381 * @param apc the accept policy callback 1382 * @param apc_cls the closure for the callback 1383 * @return structure with the requested setting 1384 */ 1385 # define MHD_D_OPTION_ACCEPT_POLICY(apc, apc_cls) \ 1386 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1387 (const struct MHD_DaemonOptionAndValue) \ 1388 { \ 1389 .opt = MHD_D_O_ACCEPT_POLICY, \ 1390 .val.accept_policy.v_apc = (apc), \ 1391 .val.accept_policy.v_apc_cls = (apc_cls) \ 1392 } \ 1393 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1394 /** 1395 * Set mode of connection memory buffer zeroing 1396 * @param buff_zeroing buffer zeroing mode 1397 * @return structure with the requested setting 1398 */ 1399 # define MHD_D_OPTION_CONN_BUFF_ZEROING(buff_zeroing) \ 1400 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1401 (const struct MHD_DaemonOptionAndValue) \ 1402 { \ 1403 .opt = MHD_D_O_CONN_BUFF_ZEROING, \ 1404 .val.conn_buff_zeroing = (buff_zeroing) \ 1405 } \ 1406 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1407 /** 1408 * Set how strictly MHD will enforce the HTTP protocol. 1409 * @param sl the level of strictness 1410 * @param how the way how to use the requested level 1411 * @return structure with the requested setting 1412 */ 1413 # define MHD_D_OPTION_PROTOCOL_STRICT_LEVEL(sl, how) \ 1414 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1415 (const struct MHD_DaemonOptionAndValue) \ 1416 { \ 1417 .opt = MHD_D_O_PROTOCOL_STRICT_LEVEL, \ 1418 .val.protocol_strict_level.v_sl = (sl), \ 1419 .val.protocol_strict_level.v_how = (how) \ 1420 } \ 1421 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1422 /** 1423 * Set a callback to be called first for every request when the request line is received (before any parsing of the header). 1424 * This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place. 1425 * Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs. 1426 * @param cb the early URI callback 1427 * @param cls the closure for the callback 1428 * @return structure with the requested setting 1429 */ 1430 # define MHD_D_OPTION_EARLY_URI_LOGGER(cb, cls) \ 1431 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1432 (const struct MHD_DaemonOptionAndValue) \ 1433 { \ 1434 .opt = MHD_D_O_EARLY_URI_LOGGER, \ 1435 .val.early_uri_logger.v_cb = (cb), \ 1436 .val.early_uri_logger.v_cls = (cls) \ 1437 } \ 1438 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1439 /** 1440 * Disable converting plus ('+') character to space in GET parameters (URI part after '?'). 1441 * Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details. 1442 * By default plus is converted to space in the query part of URI. 1443 * @param value the value of the parameter * @return structure with the requested setting 1444 */ 1445 # define MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE(value) \ 1446 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1447 (const struct MHD_DaemonOptionAndValue) \ 1448 { \ 1449 .opt = MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE, \ 1450 .val.disable_uri_query_plus_as_space = (value) \ 1451 } \ 1452 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1453 /** 1454 * Suppresse use of 'Date:' header. 1455 * According to RFC should be suppressed only if the system has no RTC. 1456 * The 'Date:' is not suppressed (the header is enabled) by default. 1457 * @param value the value of the parameter * @return structure with the requested setting 1458 */ 1459 # define MHD_D_OPTION_SUPPRESS_DATE_HEADER(value) \ 1460 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1461 (const struct MHD_DaemonOptionAndValue) \ 1462 { \ 1463 .opt = MHD_D_O_SUPPRESS_DATE_HEADER, \ 1464 .val.suppress_date_header = (value) \ 1465 } \ 1466 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1467 /** 1468 * Use SHOUTcast for responses. 1469 * This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'. 1470 * @param value the value of the parameter * @return structure with the requested setting 1471 */ 1472 # define MHD_D_OPTION_ENABLE_SHOUTCAST(value) \ 1473 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1474 (const struct MHD_DaemonOptionAndValue) \ 1475 { \ 1476 .opt = MHD_D_O_ENABLE_SHOUTCAST, \ 1477 .val.enable_shoutcast = (value) \ 1478 } \ 1479 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1480 /** 1481 * Maximum memory size per connection. 1482 * Default is 32kb. 1483 * Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems. 1484 * The size should be large enough to fit all request headers (together with internal parsing information). 1485 * @param value the value of the parameter * @return structure with the requested setting 1486 */ 1487 # define MHD_D_OPTION_CONN_MEMORY_LIMIT(value) \ 1488 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1489 (const struct MHD_DaemonOptionAndValue) \ 1490 { \ 1491 .opt = MHD_D_O_CONN_MEMORY_LIMIT, \ 1492 .val.conn_memory_limit = (value) \ 1493 } \ 1494 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1495 /** 1496 * The size of the shared memory pool for accamulated upload processing. 1497 * The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application. 1498 * Default is 8Mb. 1499 * Can be set to zero to disable share pool. 1500 * @param value the value of the parameter * @return structure with the requested setting 1501 */ 1502 # define MHD_D_OPTION_LARGE_POOL_SIZE(value) \ 1503 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1504 (const struct MHD_DaemonOptionAndValue) \ 1505 { \ 1506 .opt = MHD_D_O_LARGE_POOL_SIZE, \ 1507 .val.large_pool_size = (value) \ 1508 } \ 1509 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1510 /** 1511 * Desired size of the stack for the threads started by MHD. 1512 * Use 0 for system default, which is also MHD default. 1513 * Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION(). 1514 * @param value the value of the parameter * @return structure with the requested setting 1515 */ 1516 # define MHD_D_OPTION_STACK_SIZE(value) \ 1517 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1518 (const struct MHD_DaemonOptionAndValue) \ 1519 { \ 1520 .opt = MHD_D_O_STACK_SIZE, \ 1521 .val.stack_size = (value) \ 1522 } \ 1523 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1524 /** 1525 * The the maximum FD value. 1526 * The limit is applied to all sockets used by MHD. 1527 * If listen socket FD is equal or higher that specified value, the daemon fail to start. 1528 * If new connection FD is equal or higher that specified value, the connection is rejected. 1529 * Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case. 1530 * Silently ignored on W32 (WinSock sockets). 1531 * @param max_fd FIXME 1532 * @return structure with the requested setting 1533 */ 1534 # define MHD_D_OPTION_FD_NUMBER_LIMIT(max_fd) \ 1535 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1536 (const struct MHD_DaemonOptionAndValue) \ 1537 { \ 1538 .opt = MHD_D_O_FD_NUMBER_LIMIT, \ 1539 .val.fd_number_limit = (max_fd) \ 1540 } \ 1541 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1542 /** 1543 * Enable `turbo`. 1544 * Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations. 1545 * Most effects only happen with internal threads with epoll. 1546 * The 'turbo' mode is not enabled (mode is disabled) by default. 1547 * @param value the value of the parameter * @return structure with the requested setting 1548 */ 1549 # define MHD_D_OPTION_TURBO(value) \ 1550 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1551 (const struct MHD_DaemonOptionAndValue) \ 1552 { \ 1553 .opt = MHD_D_O_TURBO, \ 1554 .val.turbo = (value) \ 1555 } \ 1556 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1557 /** 1558 * Disable some internal thread safety. 1559 * Indicates that MHD daemon will be used by application in single-threaded mode only. When this flag is set then application must call any MHD function only within a single thread. 1560 * This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment. 1561 * Not compatible with any internal threads modes. 1562 * If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory. 1563 * Thread safety is not disabled (safety is enabled) by default. 1564 * @param value the value of the parameter * @return structure with the requested setting 1565 */ 1566 # define MHD_D_OPTION_DISABLE_THREAD_SAFETY(value) \ 1567 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1568 (const struct MHD_DaemonOptionAndValue) \ 1569 { \ 1570 .opt = MHD_D_O_DISABLE_THREAD_SAFETY, \ 1571 .val.disable_thread_safety = (value) \ 1572 } \ 1573 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1574 /** 1575 * You need to set this option if you want to disable use of HTTP Upgrade. 1576 * Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used. 1577 * You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving. 1578 * The upgrade is not disallowed (upgrade is allowed) by default. 1579 * @param value the value of the parameter * @return structure with the requested setting 1580 */ 1581 # define MHD_D_OPTION_DISALLOW_UPGRADE(value) \ 1582 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1583 (const struct MHD_DaemonOptionAndValue) \ 1584 { \ 1585 .opt = MHD_D_O_DISALLOW_UPGRADE, \ 1586 .val.disallow_upgrade = (value) \ 1587 } \ 1588 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1589 /** 1590 * Disable #MHD_action_suspend() functionality. 1591 * 1592 You should only use this function if you do not use suspend functionality and need a generally minor boost in performance. 1593 * The suspend is not disallowed (suspend is allowed) by default. 1594 * @param value the value of the parameter * @return structure with the requested setting 1595 */ 1596 # define MHD_D_OPTION_DISALLOW_SUSPEND_RESUME(value) \ 1597 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1598 (const struct MHD_DaemonOptionAndValue) \ 1599 { \ 1600 .opt = MHD_D_O_DISALLOW_SUSPEND_RESUME, \ 1601 .val.disallow_suspend_resume = (value) \ 1602 } \ 1603 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1604 /** 1605 * Disable cookies parsing. 1606 * 1607 Disable automatic cookies processing if cookies are not used. 1608 * Cookies are automatically parsed by default. 1609 * @param value the value of the parameter * @return structure with the requested setting 1610 */ 1611 # define MHD_D_OPTION_DISABLE_COOKIES(value) \ 1612 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1613 (const struct MHD_DaemonOptionAndValue) \ 1614 { \ 1615 .opt = MHD_D_O_DISABLE_COOKIES, \ 1616 .val.disable_cookies = (value) \ 1617 } \ 1618 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1619 /** 1620 * Set a callback to be called for pre-start finalisation. 1621 * 1622 The specified callback will be called one time, after network initialisation, TLS pre-initialisation, but before the start of the internal threads (if allowed) 1623 * @param cb the pre-start callback 1624 * @param cb_cls the closure for the callback 1625 * @return structure with the requested setting 1626 */ 1627 # define MHD_D_OPTION_DAEMON_READY_CALLBACK(cb, cb_cls) \ 1628 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1629 (const struct MHD_DaemonOptionAndValue) \ 1630 { \ 1631 .opt = MHD_D_O_DAEMON_READY_CALLBACK, \ 1632 .val.daemon_ready_callback.v_cb = (cb), \ 1633 .val.daemon_ready_callback.v_cb_cls = (cb_cls) \ 1634 } \ 1635 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1636 /** 1637 * Set a function that should be called whenever a connection is started or closed. 1638 * @param ncc the callback for notifications 1639 * @param cls the closure for the callback 1640 * @return structure with the requested setting 1641 */ 1642 # define MHD_D_OPTION_NOTIFY_CONNECTION(ncc, cls) \ 1643 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1644 (const struct MHD_DaemonOptionAndValue) \ 1645 { \ 1646 .opt = MHD_D_O_NOTIFY_CONNECTION, \ 1647 .val.notify_connection.v_ncc = (ncc), \ 1648 .val.notify_connection.v_cls = (cls) \ 1649 } \ 1650 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1651 /** 1652 * Register a function that should be called whenever a stream is started or closed. 1653 * For HTTP/1.1 this callback is called one time for every connection. 1654 * @param nsc the callback for notifications 1655 * @param cls the closure for the callback 1656 * @return structure with the requested setting 1657 */ 1658 # define MHD_D_OPTION_NOTIFY_STREAM(nsc, cls) \ 1659 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1660 (const struct MHD_DaemonOptionAndValue) \ 1661 { \ 1662 .opt = MHD_D_O_NOTIFY_STREAM, \ 1663 .val.notify_stream.v_nsc = (nsc), \ 1664 .val.notify_stream.v_cls = (cls) \ 1665 } \ 1666 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1667 /** 1668 * Set strong random data to be used by MHD. 1669 * Currently the data is only needed for Digest Auth module. 1670 * Daemon support for Digest Auth is enabled automatically if this option is used. 1671 * The recommended size is between 8 and 32 bytes. Security can be lower for sizes less or equal four. 1672 * Sizes larger then 32 (or, probably, larger than 16 - debatable) will not increase the security. 1673 * @param buf_size the size of the buffer 1674 * @param buf the buffer with strong random data, the content will be copied by MHD 1675 * @return structure with the requested setting 1676 */ 1677 # define MHD_D_OPTION_RANDOM_ENTROPY(buf_size, buf) \ 1678 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1679 (const struct MHD_DaemonOptionAndValue) \ 1680 { \ 1681 .opt = MHD_D_O_RANDOM_ENTROPY, \ 1682 .val.random_entropy.v_buf_size = (buf_size), \ 1683 .val.random_entropy.v_buf = (buf) \ 1684 } \ 1685 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1686 /** 1687 * Specify the size of the internal hash map array that tracks generated digest nonces usage. 1688 * When the size of the map is too small then need to handle concurrent DAuth requests, a lot of stale nonce results will be produced. 1689 * By default the size is 1000 entries. 1690 * @param size the size of the map array 1691 * @return structure with the requested setting 1692 */ 1693 # define MHD_D_OPTION_AUTH_DIGEST_MAP_SIZE(size) \ 1694 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1695 (const struct MHD_DaemonOptionAndValue) \ 1696 { \ 1697 .opt = MHD_D_O_AUTH_DIGEST_MAP_SIZE, \ 1698 .val.auth_digest_map_size = (size) \ 1699 } \ 1700 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1701 /** 1702 * Nonce validity time (in seconds) used for Digest Auth. 1703 * If followed by zero value the value is silently ignored. 1704 * @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest() 1705 * @param timeout FIXME 1706 * @return structure with the requested setting 1707 */ 1708 # define MHD_D_OPTION_AUTH_DIGEST_NONCE_TIMEOUT(timeout) \ 1709 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1710 (const struct MHD_DaemonOptionAndValue) \ 1711 { \ 1712 .opt = MHD_D_O_AUTH_DIGEST_NONCE_TIMEOUT, \ 1713 .val.auth_digest_nonce_timeout = (timeout) \ 1714 } \ 1715 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1716 /** 1717 * Default maximum nc (nonce count) value used for Digest Auth. 1718 * If followed by zero value the value is silently ignored. 1719 * @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest() 1720 * @param max_nc FIXME 1721 * @return structure with the requested setting 1722 */ 1723 # define MHD_D_OPTION_AUTH_DIGEST_DEF_MAX_NC(max_nc) \ 1724 MHD_NOWARN_COMPOUND_LITERALS_ MHD_NOWARN_AGGR_DYN_INIT_ \ 1725 (const struct MHD_DaemonOptionAndValue) \ 1726 { \ 1727 .opt = MHD_D_O_AUTH_DIGEST_DEF_MAX_NC, \ 1728 .val.auth_digest_def_max_nc = (max_nc) \ 1729 } \ 1730 MHD_RESTORE_WARN_COMPOUND_LITERALS_ MHD_RESTORE_WARN_AGGR_DYN_INIT_ 1731 1732 /** 1733 * Terminate the list of the options 1734 * @return the terminating object of struct MHD_DaemonOptionAndValue 1735 */ 1736 # define MHD_D_OPTION_TERMINATE() \ 1737 MHD_NOWARN_COMPOUND_LITERALS_ \ 1738 (const struct MHD_DaemonOptionAndValue) \ 1739 { \ 1740 .opt = (MHD_D_O_END) \ 1741 } \ 1742 MHD_RESTORE_WARN_COMPOUND_LITERALS_ 1743 1744 #else /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */ 1745 MHD_NOWARN_UNUSED_FUNC_ 1746 /** 1747 * Set MHD work (threading and polling) mode. 1748 * Consider use of #MHD_D_OPTION_WM_EXTERNAL_PERIODIC(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_D_OPTION_WM_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_D_OPTION_WM_EXTERNAL_SINGLE_FD_WATCH(), #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION() instead of direct use of this parameter. 1749 * @param wmp the object created by one of the next functions/macros: #MHD_WM_OPTION_EXTERNAL_PERIODIC(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_LEVEL(), #MHD_WM_OPTION_EXTERNAL_EVENT_LOOP_CB_EDGE(), #MHD_WM_OPTION_EXTERNAL_SINGLE_FD_WATCH(), #MHD_WM_OPTION_WORKER_THREADS(), #MHD_WM_OPTION_THREAD_PER_CONNECTION() 1750 * @return structure with the requested setting 1751 */ 1752 static MHD_INLINE struct MHD_DaemonOptionAndValue 1753 MHD_D_OPTION_WORK_MODE ( 1754 struct MHD_WorkModeWithParam wmp 1755 ) 1756 { 1757 struct MHD_DaemonOptionAndValue opt_val; 1758 1759 opt_val.opt = MHD_D_O_WORK_MODE; 1760 opt_val.val.work_mode = wmp; 1761 1762 return opt_val; 1763 } 1764 1765 1766 /** 1767 * Select a sockets watch system call used for internal polling. 1768 * @param els FIXME 1769 * @return structure with the requested setting 1770 */ 1771 static MHD_INLINE struct MHD_DaemonOptionAndValue 1772 MHD_D_OPTION_POLL_SYSCALL ( 1773 enum MHD_SockPollSyscall els 1774 ) 1775 { 1776 struct MHD_DaemonOptionAndValue opt_val; 1777 1778 opt_val.opt = MHD_D_O_POLL_SYSCALL; 1779 opt_val.val.poll_syscall = els; 1780 1781 return opt_val; 1782 } 1783 1784 1785 /** 1786 * Instruct MHD to register all sockets every processing round. 1787 * 1788 By default (this options is not enabled) every processing round (every time 1789 * when #MHD_daemon_event_update() is called) MHD calls 1790 * #MHD_SocketRegistrationUpdateCallback only for the new sockets, for 1791 * the removed sockets and for the updated sockets. 1792 * Some sockets are registered when #MHD_daemon_start() is called. 1793 * 1794 If this options is enabled, then #MHD_SocketRegistrationUpdateCallback is 1795 * called for every socket each processing round. No sockets are registered when 1796 * the daemon is being started. 1797 * @param value the value of the parameter * @return structure with the requested setting 1798 */ 1799 static MHD_INLINE struct MHD_DaemonOptionAndValue 1800 MHD_D_OPTION_REREGISTER_ALL ( 1801 enum MHD_Bool value 1802 ) 1803 { 1804 struct MHD_DaemonOptionAndValue opt_val; 1805 1806 opt_val.opt = MHD_D_O_REREGISTER_ALL; 1807 opt_val.val.reregister_all = (value); 1808 1809 return opt_val; 1810 } 1811 1812 1813 /** 1814 * Set a callback to use for logging 1815 * @param log_cb the callback to use for logging, 1816 * NULL to disable logging. 1817 * The logging to stderr is enabled by default. 1818 * @param log_cb_cls the closure for the logging callback 1819 * @return structure with the requested setting 1820 */ 1821 static MHD_INLINE struct MHD_DaemonOptionAndValue 1822 MHD_D_OPTION_LOG_CALLBACK ( 1823 MHD_LoggingCallback log_cb, 1824 void *log_cb_cls 1825 ) 1826 { 1827 struct MHD_DaemonOptionAndValue opt_val; 1828 1829 opt_val.opt = MHD_D_O_LOG_CALLBACK; 1830 opt_val.val.log_callback.v_log_cb = log_cb; 1831 opt_val.val.log_callback.v_log_cb_cls = log_cb_cls; 1832 1833 return opt_val; 1834 } 1835 1836 1837 /** 1838 * Bind to the given TCP port and address family. 1839 * 1840 Does not work with #MHD_D_OPTION_BIND_SA() or #MHD_D_OPTION_LISTEN_SOCKET(). 1841 * 1842 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 1843 * @param af the address family to use, 1844 * the #MHD_AF_NONE to disable listen socket (the same effect as if this option is not used) 1845 * @param port port to use, 0 to let system assign any free port, 1846 * ignored if @a af is #MHD_AF_NONE 1847 * @return structure with the requested setting 1848 */ 1849 static MHD_INLINE struct MHD_DaemonOptionAndValue 1850 MHD_D_OPTION_BIND_PORT ( 1851 enum MHD_AddressFamily af, 1852 uint_least16_t port 1853 ) 1854 { 1855 struct MHD_DaemonOptionAndValue opt_val; 1856 1857 opt_val.opt = MHD_D_O_BIND_PORT; 1858 opt_val.val.bind_port.v_af = af; 1859 opt_val.val.bind_port.v_port = port; 1860 1861 return opt_val; 1862 } 1863 1864 1865 /** 1866 * Bind to the given socket address. 1867 * 1868 Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_LISTEN_SOCKET(). 1869 * 1870 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 1871 * @param sa_len the size of the socket address pointed by @a sa. 1872 * @param sa the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX) 1873 * @param dual When a previous version of the protocol exist (like IPv4 when @a v_sa is IPv6) bind to both protocols (IPv6 and IPv4). 1874 * @return structure with the requested setting 1875 */ 1876 static MHD_INLINE struct MHD_DaemonOptionAndValue 1877 MHD_D_OPTION_BIND_SA ( 1878 size_t sa_len, 1879 /* const */ struct sockaddr *sa, 1880 enum MHD_Bool dual 1881 ) 1882 { 1883 struct MHD_DaemonOptionAndValue opt_val; 1884 1885 opt_val.opt = MHD_D_O_BIND_SA; 1886 opt_val.val.bind_sa.v_sa_len = sa_len; 1887 opt_val.val.bind_sa.v_sa = sa; 1888 opt_val.val.bind_sa.v_dual = dual; 1889 1890 return opt_val; 1891 } 1892 1893 1894 /** 1895 * Accept connections from the given socket. Socket 1896 * must be a TCP or UNIX domain (SOCK_STREAM) socket. 1897 * 1898 Does not work with #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA(). 1899 * 1900 If no listen socket optins (#MHD_D_OPTION_BIND_PORT(), #MHD_D_OPTION_BIND_SA(), #MHD_D_OPTION_LISTEN_SOCKET()) are used, MHD does not listen for incoming connection. 1901 * @param listen_fd the listen socket to use, ignored if set to #MHD_INVALID_SOCKET 1902 * @return structure with the requested setting 1903 */ 1904 static MHD_INLINE struct MHD_DaemonOptionAndValue 1905 MHD_D_OPTION_LISTEN_SOCKET ( 1906 MHD_Socket listen_fd 1907 ) 1908 { 1909 struct MHD_DaemonOptionAndValue opt_val; 1910 1911 opt_val.opt = MHD_D_O_LISTEN_SOCKET; 1912 opt_val.val.listen_socket = listen_fd; 1913 1914 return opt_val; 1915 } 1916 1917 1918 /** 1919 * Select mode of reusing address:port listen address. 1920 * 1921 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 1922 * @param reuse_type FIXME 1923 * @return structure with the requested setting 1924 */ 1925 static MHD_INLINE struct MHD_DaemonOptionAndValue 1926 MHD_D_OPTION_LISTEN_ADDR_REUSE ( 1927 enum MHD_DaemonOptionBindType reuse_type 1928 ) 1929 { 1930 struct MHD_DaemonOptionAndValue opt_val; 1931 1932 opt_val.opt = MHD_D_O_LISTEN_ADDR_REUSE; 1933 opt_val.val.listen_addr_reuse = reuse_type; 1934 1935 return opt_val; 1936 } 1937 1938 1939 /** 1940 * Configure TCP_FASTOPEN option, including setting a 1941 * custom @a queue_length. 1942 * 1943 Note that having a larger queue size can cause resource exhaustion 1944 * attack as the TCP stack has to now allocate resources for the SYN 1945 * packet along with its DATA. 1946 * 1947 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 1948 * @param option the type use of of TCP FastOpen 1949 * @param queue_length the length of the queue, zero to use system or MHD default, 1950 * silently ignored on platforms without support for custom queue size 1951 * @return structure with the requested setting 1952 */ 1953 static MHD_INLINE struct MHD_DaemonOptionAndValue 1954 MHD_D_OPTION_TCP_FASTOPEN ( 1955 enum MHD_TCPFastOpenType option, 1956 unsigned int queue_length 1957 ) 1958 { 1959 struct MHD_DaemonOptionAndValue opt_val; 1960 1961 opt_val.opt = MHD_D_O_TCP_FASTOPEN; 1962 opt_val.val.tcp_fastopen.v_option = option; 1963 opt_val.val.tcp_fastopen.v_queue_length = queue_length; 1964 1965 return opt_val; 1966 } 1967 1968 1969 /** 1970 * Use the given backlog for the listen() call. 1971 * 1972 Works only when #MHD_D_OPTION_BIND_PORT() or #MHD_D_OPTION_BIND_SA() are used. 1973 * Zero parameter treated as MHD/system default. 1974 * @param backlog_size FIXME 1975 * @return structure with the requested setting 1976 */ 1977 static MHD_INLINE struct MHD_DaemonOptionAndValue 1978 MHD_D_OPTION_LISTEN_BACKLOG ( 1979 unsigned int backlog_size 1980 ) 1981 { 1982 struct MHD_DaemonOptionAndValue opt_val; 1983 1984 opt_val.opt = MHD_D_O_LISTEN_BACKLOG; 1985 opt_val.val.listen_backlog = backlog_size; 1986 1987 return opt_val; 1988 } 1989 1990 1991 /** 1992 * Inform that SIGPIPE is suppressed or handled by application. 1993 * If suppressed/handled, MHD uses network functions that could generate SIGPIPE, like `sendfile()`. 1994 * Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically. 1995 * @param value the value of the parameter * @return structure with the requested setting 1996 */ 1997 static MHD_INLINE struct MHD_DaemonOptionAndValue 1998 MHD_D_OPTION_SIGPIPE_SUPPRESSED ( 1999 enum MHD_Bool value 2000 ) 2001 { 2002 struct MHD_DaemonOptionAndValue opt_val; 2003 2004 opt_val.opt = MHD_D_O_SIGPIPE_SUPPRESSED; 2005 opt_val.val.sigpipe_suppressed = (value); 2006 2007 return opt_val; 2008 } 2009 2010 2011 /** 2012 * Enable TLS (HTTPS) and select TLS backend 2013 * @param backend the TLS backend to use, 2014 * #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections 2015 * @return structure with the requested setting 2016 */ 2017 static MHD_INLINE struct MHD_DaemonOptionAndValue 2018 MHD_D_OPTION_TLS ( 2019 enum MHD_TlsBackend backend 2020 ) 2021 { 2022 struct MHD_DaemonOptionAndValue opt_val; 2023 2024 opt_val.opt = MHD_D_O_TLS; 2025 opt_val.val.tls = backend; 2026 2027 return opt_val; 2028 } 2029 2030 2031 /** 2032 * Provide TLS key and certificate data in-memory. 2033 * Works only if TLS mode is enabled. 2034 * @param mem_cert The X.509 certificates chain in PEM format loaded into memory (not a filename). 2035 * The first certificate must be the server certificate, following by the chain of signing 2036 * certificates up to (but not including) CA root certificate. 2037 * @param mem_key the private key in PEM format loaded into memory (not a filename) 2038 * @param mem_pass the option passphrase phrase to decrypt the private key, 2039 * could be NULL if private key does not need a password 2040 * @return structure with the requested setting 2041 */ 2042 static MHD_INLINE struct MHD_DaemonOptionAndValue 2043 MHD_D_OPTION_TLS_CERT_KEY ( 2044 /* const */ char *mem_cert, 2045 const char *mem_key, 2046 const char *mem_pass 2047 ) 2048 { 2049 struct MHD_DaemonOptionAndValue opt_val; 2050 2051 opt_val.opt = MHD_D_O_TLS_CERT_KEY; 2052 opt_val.val.tls_cert_key.v_mem_cert = mem_cert; 2053 opt_val.val.tls_cert_key.v_mem_key = mem_key; 2054 opt_val.val.tls_cert_key.v_mem_pass = mem_pass; 2055 2056 return opt_val; 2057 } 2058 2059 2060 /** 2061 * Provide the certificate of the certificate authority (CA) to be used by the MHD daemon for client authentication. 2062 * Works only if TLS mode is enabled. 2063 * @param mem_client_ca the CA certificate in memory (not a filename) 2064 * @return structure with the requested setting 2065 */ 2066 static MHD_INLINE struct MHD_DaemonOptionAndValue 2067 MHD_D_OPTION_TLS_CLIENT_CA ( 2068 const char *mem_client_ca 2069 ) 2070 { 2071 struct MHD_DaemonOptionAndValue opt_val; 2072 2073 opt_val.opt = MHD_D_O_TLS_CLIENT_CA; 2074 opt_val.val.tls_client_ca = mem_client_ca; 2075 2076 return opt_val; 2077 } 2078 2079 2080 /** 2081 * Configure PSK to use for the TLS key exchange. 2082 * @param psk_cb the function to call to obtain pre-shared key 2083 * @param psk_cb_cls the closure for @a psk_cb 2084 * @return structure with the requested setting 2085 */ 2086 static MHD_INLINE struct MHD_DaemonOptionAndValue 2087 MHD_D_OPTION_TLS_PSK_CALLBACK ( 2088 MHD_PskServerCredentialsCallback psk_cb, 2089 void *psk_cb_cls 2090 ) 2091 { 2092 struct MHD_DaemonOptionAndValue opt_val; 2093 2094 opt_val.opt = MHD_D_O_TLS_PSK_CALLBACK; 2095 opt_val.val.tls_psk_callback.v_psk_cb = psk_cb; 2096 opt_val.val.tls_psk_callback.v_psk_cb_cls = psk_cb_cls; 2097 2098 return opt_val; 2099 } 2100 2101 2102 /** 2103 * Control ALPN for TLS connection. 2104 * Silently ignored for non-TLS. 2105 * By default ALPN is automatically used for TLS connections. 2106 * @param value the value of the parameter * @return structure with the requested setting 2107 */ 2108 static MHD_INLINE struct MHD_DaemonOptionAndValue 2109 MHD_D_OPTION_NO_ALPN ( 2110 enum MHD_Bool value 2111 ) 2112 { 2113 struct MHD_DaemonOptionAndValue opt_val; 2114 2115 opt_val.opt = MHD_D_O_NO_ALPN; 2116 opt_val.val.no_alpn = (value); 2117 2118 return opt_val; 2119 } 2120 2121 2122 /** 2123 * Require ACME ALPN challenge support in TLS backend. 2124 * If this option is enabled then TLS backends without ACME ALPN challenge 2125 * support will not be selected automatically. The daemon will fail to start 2126 * if no TLS backend with ACME ALPN is available. 2127 * @param value the value of the parameter * @return structure with the requested setting 2128 */ 2129 static MHD_INLINE struct MHD_DaemonOptionAndValue 2130 MHD_D_OPTION_ACME_ALPN_REQUIRED ( 2131 enum MHD_Bool value 2132 ) 2133 { 2134 struct MHD_DaemonOptionAndValue opt_val; 2135 2136 opt_val.opt = MHD_D_O_ACME_ALPN_REQUIRED; 2137 opt_val.val.acme_alpn_required = (value); 2138 2139 return opt_val; 2140 } 2141 2142 2143 /** 2144 * Provide application name to load dedicated section in TLS backend's configuration file. 2145 * Search for "System-wide configuration of the library" for GnuTLS documentation or 2146 * for "config, OPENSSL LIBRARY CONFIGURATION" for OpenSSL documentation. 2147 * If not specified the default backend configuration is used: 2148 * "@LIBMICROHTTPD" (if available), then "@SYSTEM" (if available) then default priorities, then "NORMAL" for GnuTLS; 2149 * "libmicrohttpd" (if available), then default name ("openssl_conf") for OpenSSL. 2150 * Ignored when MbedTLS is used as daemon's TLS backend. 2151 * @param app_name the name of the application, used as converted to 2152 * uppercase (with '@'-prefixed) for GnuTLS and as converted to 2153 * lowercase for OpenSSL; must not be longer than 127 characters 2154 * @param disable_fallback forbid use fallback/default configuration if specified 2155 * configuration is not found; also forbid ignoring errors in the 2156 * configuration on TLS backends, which may ignoring configuration 2157 * errors 2158 * @return structure with the requested setting 2159 */ 2160 static MHD_INLINE struct MHD_DaemonOptionAndValue 2161 MHD_D_OPTION_TLS_APP_NAME ( 2162 char *app_name, 2163 enum MHD_Bool disable_fallback 2164 ) 2165 { 2166 struct MHD_DaemonOptionAndValue opt_val; 2167 2168 opt_val.opt = MHD_D_O_TLS_APP_NAME; 2169 opt_val.val.tls_app_name.v_app_name = app_name; 2170 opt_val.val.tls_app_name.v_disable_fallback = disable_fallback; 2171 2172 return opt_val; 2173 } 2174 2175 2176 /** 2177 * Set the configuration pathname for OpenSSL configuration file 2178 * Ignored OpenSSL is not used as daemon's TLS backend. 2179 * @param pathname the path and the name of the OpenSSL configuration file, 2180 * if only the name is provided then standard path for 2181 * configuration files is used, 2182 * could be NULL to use default configuration file pathname 2183 * or an empty (zero-size) string to disable file loading 2184 * @param disable_fallback forbid use of fallback/default location and name of 2185 * the OpenSSL configuration file; also forbid initialisation without 2186 * configuration file 2187 * @return structure with the requested setting 2188 */ 2189 static MHD_INLINE struct MHD_DaemonOptionAndValue 2190 MHD_D_OPTION_TLS_OPENSSL_DEF_FILE ( 2191 char *pathname, 2192 enum MHD_Bool disable_fallback 2193 ) 2194 { 2195 struct MHD_DaemonOptionAndValue opt_val; 2196 2197 opt_val.opt = MHD_D_O_TLS_OPENSSL_DEF_FILE; 2198 opt_val.val.tls_openssl_def_file.v_pathname = pathname; 2199 opt_val.val.tls_openssl_def_file.v_disable_fallback = disable_fallback; 2200 2201 return opt_val; 2202 } 2203 2204 2205 /** 2206 * Specify the inactivity timeout for a connection in milliseconds. 2207 * If a connection remains idle (no activity) for this many 2208 * milliseconds, it is closed automatically. 2209 * Use zero for no timeout; this is also the (unsafe!) 2210 * default. 2211 * Values larger than 1209600000 (two weeks) are silently 2212 * clamped to 1209600000. 2213 * Precise closing time is not guaranteed and depends on 2214 * system clock granularity and amount of time spent on 2215 * processing other connections. Typical precision is 2216 * within +/- 30 milliseconds, while the worst case could 2217 * be greater than +/- 1 second. 2218 * Values below 1500 milliseconds are risky as they 2219 * may cause valid connections to be aborted and may 2220 * increase load the server load due to clients' repetitive 2221 * automatic retries. 2222 * @param timeout the timeout in milliseconds, zero for no timeout 2223 * @return structure with the requested setting 2224 */ 2225 static MHD_INLINE struct MHD_DaemonOptionAndValue 2226 MHD_D_OPTION_DEFAULT_TIMEOUT_MILSEC ( 2227 uint_fast32_t timeout 2228 ) 2229 { 2230 struct MHD_DaemonOptionAndValue opt_val; 2231 2232 opt_val.opt = MHD_D_O_DEFAULT_TIMEOUT_MILSEC; 2233 opt_val.val.default_timeout_milsec = timeout; 2234 2235 return opt_val; 2236 } 2237 2238 2239 /** 2240 * Maximum number of (concurrent) network connections served by daemon. 2241 * @note The real maximum number of network connections could be smaller 2242 * than requested due to the system limitations, like FD_SETSIZE when 2243 * polling by select() is used. 2244 * @param glob_limit FIXME 2245 * @return structure with the requested setting 2246 */ 2247 static MHD_INLINE struct MHD_DaemonOptionAndValue 2248 MHD_D_OPTION_GLOBAL_CONNECTION_LIMIT ( 2249 unsigned int glob_limit 2250 ) 2251 { 2252 struct MHD_DaemonOptionAndValue opt_val; 2253 2254 opt_val.opt = MHD_D_O_GLOBAL_CONNECTION_LIMIT; 2255 opt_val.val.global_connection_limit = glob_limit; 2256 2257 return opt_val; 2258 } 2259 2260 2261 /** 2262 * Limit on the number of (concurrent) network connections made to the server from the same IP address. 2263 * Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. 2264 * @param limit FIXME 2265 * @return structure with the requested setting 2266 */ 2267 static MHD_INLINE struct MHD_DaemonOptionAndValue 2268 MHD_D_OPTION_PER_IP_LIMIT ( 2269 unsigned int limit 2270 ) 2271 { 2272 struct MHD_DaemonOptionAndValue opt_val; 2273 2274 opt_val.opt = MHD_D_O_PER_IP_LIMIT; 2275 opt_val.val.per_ip_limit = limit; 2276 2277 return opt_val; 2278 } 2279 2280 2281 /** 2282 * Set a policy callback that accepts/rejects connections based on the client's IP address. The callbeck function will be called before servicing any new incoming connection. 2283 * @param apc the accept policy callback 2284 * @param apc_cls the closure for the callback 2285 * @return structure with the requested setting 2286 */ 2287 static MHD_INLINE struct MHD_DaemonOptionAndValue 2288 MHD_D_OPTION_ACCEPT_POLICY ( 2289 MHD_AcceptPolicyCallback apc, 2290 void *apc_cls 2291 ) 2292 { 2293 struct MHD_DaemonOptionAndValue opt_val; 2294 2295 opt_val.opt = MHD_D_O_ACCEPT_POLICY; 2296 opt_val.val.accept_policy.v_apc = apc; 2297 opt_val.val.accept_policy.v_apc_cls = apc_cls; 2298 2299 return opt_val; 2300 } 2301 2302 2303 /** 2304 * Set mode of connection memory buffer zeroing 2305 * @param buff_zeroing buffer zeroing mode 2306 * @return structure with the requested setting 2307 */ 2308 static MHD_INLINE struct MHD_DaemonOptionAndValue 2309 MHD_D_OPTION_CONN_BUFF_ZEROING ( 2310 enum MHD_ConnBufferZeroingMode buff_zeroing 2311 ) 2312 { 2313 struct MHD_DaemonOptionAndValue opt_val; 2314 2315 opt_val.opt = MHD_D_O_CONN_BUFF_ZEROING; 2316 opt_val.val.conn_buff_zeroing = buff_zeroing; 2317 2318 return opt_val; 2319 } 2320 2321 2322 /** 2323 * Set how strictly MHD will enforce the HTTP protocol. 2324 * @param sl the level of strictness 2325 * @param how the way how to use the requested level 2326 * @return structure with the requested setting 2327 */ 2328 static MHD_INLINE struct MHD_DaemonOptionAndValue 2329 MHD_D_OPTION_PROTOCOL_STRICT_LEVEL ( 2330 enum MHD_ProtocolStrictLevel sl, 2331 enum MHD_UseStictLevel how 2332 ) 2333 { 2334 struct MHD_DaemonOptionAndValue opt_val; 2335 2336 opt_val.opt = MHD_D_O_PROTOCOL_STRICT_LEVEL; 2337 opt_val.val.protocol_strict_level.v_sl = sl; 2338 opt_val.val.protocol_strict_level.v_how = how; 2339 2340 return opt_val; 2341 } 2342 2343 2344 /** 2345 * Set a callback to be called first for every request when the request line is received (before any parsing of the header). 2346 * This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place. 2347 * Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs. 2348 * @param cb the early URI callback 2349 * @param cls the closure for the callback 2350 * @return structure with the requested setting 2351 */ 2352 static MHD_INLINE struct MHD_DaemonOptionAndValue 2353 MHD_D_OPTION_EARLY_URI_LOGGER ( 2354 MHD_EarlyUriLogCallback cb, 2355 void *cls 2356 ) 2357 { 2358 struct MHD_DaemonOptionAndValue opt_val; 2359 2360 opt_val.opt = MHD_D_O_EARLY_URI_LOGGER; 2361 opt_val.val.early_uri_logger.v_cb = cb; 2362 opt_val.val.early_uri_logger.v_cls = cls; 2363 2364 return opt_val; 2365 } 2366 2367 2368 /** 2369 * Disable converting plus ('+') character to space in GET parameters (URI part after '?'). 2370 * Plus conversion is not required by HTTP RFCs, however it required by HTML specifications, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded for details. 2371 * By default plus is converted to space in the query part of URI. 2372 * @param value the value of the parameter * @return structure with the requested setting 2373 */ 2374 static MHD_INLINE struct MHD_DaemonOptionAndValue 2375 MHD_D_OPTION_DISABLE_URI_QUERY_PLUS_AS_SPACE ( 2376 enum MHD_Bool value 2377 ) 2378 { 2379 struct MHD_DaemonOptionAndValue opt_val; 2380 2381 opt_val.opt = MHD_D_O_DISABLE_URI_QUERY_PLUS_AS_SPACE; 2382 opt_val.val.disable_uri_query_plus_as_space = (value); 2383 2384 return opt_val; 2385 } 2386 2387 2388 /** 2389 * Suppresse use of 'Date:' header. 2390 * According to RFC should be suppressed only if the system has no RTC. 2391 * The 'Date:' is not suppressed (the header is enabled) by default. 2392 * @param value the value of the parameter * @return structure with the requested setting 2393 */ 2394 static MHD_INLINE struct MHD_DaemonOptionAndValue 2395 MHD_D_OPTION_SUPPRESS_DATE_HEADER ( 2396 enum MHD_Bool value 2397 ) 2398 { 2399 struct MHD_DaemonOptionAndValue opt_val; 2400 2401 opt_val.opt = MHD_D_O_SUPPRESS_DATE_HEADER; 2402 opt_val.val.suppress_date_header = (value); 2403 2404 return opt_val; 2405 } 2406 2407 2408 /** 2409 * Use SHOUTcast for responses. 2410 * This will cause *all* responses to begin with the SHOUTcast 'ICY' line instead of 'HTTP'. 2411 * @param value the value of the parameter * @return structure with the requested setting 2412 */ 2413 static MHD_INLINE struct MHD_DaemonOptionAndValue 2414 MHD_D_OPTION_ENABLE_SHOUTCAST ( 2415 enum MHD_Bool value 2416 ) 2417 { 2418 struct MHD_DaemonOptionAndValue opt_val; 2419 2420 opt_val.opt = MHD_D_O_ENABLE_SHOUTCAST; 2421 opt_val.val.enable_shoutcast = (value); 2422 2423 return opt_val; 2424 } 2425 2426 2427 /** 2428 * Maximum memory size per connection. 2429 * Default is 32kb. 2430 * Values above 128kb are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems. 2431 * The size should be large enough to fit all request headers (together with internal parsing information). 2432 * @param value the value of the parameter * @return structure with the requested setting 2433 */ 2434 static MHD_INLINE struct MHD_DaemonOptionAndValue 2435 MHD_D_OPTION_CONN_MEMORY_LIMIT ( 2436 size_t value 2437 ) 2438 { 2439 struct MHD_DaemonOptionAndValue opt_val; 2440 2441 opt_val.opt = MHD_D_O_CONN_MEMORY_LIMIT; 2442 opt_val.val.conn_memory_limit = (value); 2443 2444 return opt_val; 2445 } 2446 2447 2448 /** 2449 * The size of the shared memory pool for accamulated upload processing. 2450 * The same large pool is shared for all connections server by MHD and used when application requests avoiding of incremental upload processing to accamulate complete content upload before giving it to the application. 2451 * Default is 8Mb. 2452 * Can be set to zero to disable share pool. 2453 * @param value the value of the parameter * @return structure with the requested setting 2454 */ 2455 static MHD_INLINE struct MHD_DaemonOptionAndValue 2456 MHD_D_OPTION_LARGE_POOL_SIZE ( 2457 size_t value 2458 ) 2459 { 2460 struct MHD_DaemonOptionAndValue opt_val; 2461 2462 opt_val.opt = MHD_D_O_LARGE_POOL_SIZE; 2463 opt_val.val.large_pool_size = (value); 2464 2465 return opt_val; 2466 } 2467 2468 2469 /** 2470 * Desired size of the stack for the threads started by MHD. 2471 * Use 0 for system default, which is also MHD default. 2472 * Works only with #MHD_D_OPTION_WM_WORKER_THREADS() or #MHD_D_OPTION_WM_THREAD_PER_CONNECTION(). 2473 * @param value the value of the parameter * @return structure with the requested setting 2474 */ 2475 static MHD_INLINE struct MHD_DaemonOptionAndValue 2476 MHD_D_OPTION_STACK_SIZE ( 2477 size_t value 2478 ) 2479 { 2480 struct MHD_DaemonOptionAndValue opt_val; 2481 2482 opt_val.opt = MHD_D_O_STACK_SIZE; 2483 opt_val.val.stack_size = (value); 2484 2485 return opt_val; 2486 } 2487 2488 2489 /** 2490 * The the maximum FD value. 2491 * The limit is applied to all sockets used by MHD. 2492 * If listen socket FD is equal or higher that specified value, the daemon fail to start. 2493 * If new connection FD is equal or higher that specified value, the connection is rejected. 2494 * Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case. 2495 * Silently ignored on W32 (WinSock sockets). 2496 * @param max_fd FIXME 2497 * @return structure with the requested setting 2498 */ 2499 static MHD_INLINE struct MHD_DaemonOptionAndValue 2500 MHD_D_OPTION_FD_NUMBER_LIMIT ( 2501 MHD_Socket max_fd 2502 ) 2503 { 2504 struct MHD_DaemonOptionAndValue opt_val; 2505 2506 opt_val.opt = MHD_D_O_FD_NUMBER_LIMIT; 2507 opt_val.val.fd_number_limit = max_fd; 2508 2509 return opt_val; 2510 } 2511 2512 2513 /** 2514 * Enable `turbo`. 2515 * Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations. 2516 * Most effects only happen with internal threads with epoll. 2517 * The 'turbo' mode is not enabled (mode is disabled) by default. 2518 * @param value the value of the parameter * @return structure with the requested setting 2519 */ 2520 static MHD_INLINE struct MHD_DaemonOptionAndValue 2521 MHD_D_OPTION_TURBO ( 2522 enum MHD_Bool value 2523 ) 2524 { 2525 struct MHD_DaemonOptionAndValue opt_val; 2526 2527 opt_val.opt = MHD_D_O_TURBO; 2528 opt_val.val.turbo = (value); 2529 2530 return opt_val; 2531 } 2532 2533 2534 /** 2535 * Disable some internal thread safety. 2536 * Indicates that MHD daemon will be used by application in single-threaded mode only. When this flag is set then application must call any MHD function only within a single thread. 2537 * This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment. 2538 * Not compatible with any internal threads modes. 2539 * If MHD is compiled with custom configuration for embedded projects without threads support, this option is mandatory. 2540 * Thread safety is not disabled (safety is enabled) by default. 2541 * @param value the value of the parameter * @return structure with the requested setting 2542 */ 2543 static MHD_INLINE struct MHD_DaemonOptionAndValue 2544 MHD_D_OPTION_DISABLE_THREAD_SAFETY ( 2545 enum MHD_Bool value 2546 ) 2547 { 2548 struct MHD_DaemonOptionAndValue opt_val; 2549 2550 opt_val.opt = MHD_D_O_DISABLE_THREAD_SAFETY; 2551 opt_val.val.disable_thread_safety = (value); 2552 2553 return opt_val; 2554 } 2555 2556 2557 /** 2558 * You need to set this option if you want to disable use of HTTP Upgrade. 2559 * Upgrade may require usage of additional internal resources, which we can avoid providing if they will not be used. 2560 * You should only use this option if you do not use upgrade functionality and need a generally minor boost in performance and resources saving. 2561 * The upgrade is not disallowed (upgrade is allowed) by default. 2562 * @param value the value of the parameter * @return structure with the requested setting 2563 */ 2564 static MHD_INLINE struct MHD_DaemonOptionAndValue 2565 MHD_D_OPTION_DISALLOW_UPGRADE ( 2566 enum MHD_Bool value 2567 ) 2568 { 2569 struct MHD_DaemonOptionAndValue opt_val; 2570 2571 opt_val.opt = MHD_D_O_DISALLOW_UPGRADE; 2572 opt_val.val.disallow_upgrade = (value); 2573 2574 return opt_val; 2575 } 2576 2577 2578 /** 2579 * Disable #MHD_action_suspend() functionality. 2580 * 2581 You should only use this function if you do not use suspend functionality and need a generally minor boost in performance. 2582 * The suspend is not disallowed (suspend is allowed) by default. 2583 * @param value the value of the parameter * @return structure with the requested setting 2584 */ 2585 static MHD_INLINE struct MHD_DaemonOptionAndValue 2586 MHD_D_OPTION_DISALLOW_SUSPEND_RESUME ( 2587 enum MHD_Bool value 2588 ) 2589 { 2590 struct MHD_DaemonOptionAndValue opt_val; 2591 2592 opt_val.opt = MHD_D_O_DISALLOW_SUSPEND_RESUME; 2593 opt_val.val.disallow_suspend_resume = (value); 2594 2595 return opt_val; 2596 } 2597 2598 2599 /** 2600 * Disable cookies parsing. 2601 * 2602 Disable automatic cookies processing if cookies are not used. 2603 * Cookies are automatically parsed by default. 2604 * @param value the value of the parameter * @return structure with the requested setting 2605 */ 2606 static MHD_INLINE struct MHD_DaemonOptionAndValue 2607 MHD_D_OPTION_DISABLE_COOKIES ( 2608 enum MHD_Bool value 2609 ) 2610 { 2611 struct MHD_DaemonOptionAndValue opt_val; 2612 2613 opt_val.opt = MHD_D_O_DISABLE_COOKIES; 2614 opt_val.val.disable_cookies = (value); 2615 2616 return opt_val; 2617 } 2618 2619 2620 /** 2621 * Set a callback to be called for pre-start finalisation. 2622 * 2623 The specified callback will be called one time, after network initialisation, TLS pre-initialisation, but before the start of the internal threads (if allowed) 2624 * @param cb the pre-start callback 2625 * @param cb_cls the closure for the callback 2626 * @return structure with the requested setting 2627 */ 2628 static MHD_INLINE struct MHD_DaemonOptionAndValue 2629 MHD_D_OPTION_DAEMON_READY_CALLBACK ( 2630 MHD_DaemonReadyCallback cb, 2631 void *cb_cls 2632 ) 2633 { 2634 struct MHD_DaemonOptionAndValue opt_val; 2635 2636 opt_val.opt = MHD_D_O_DAEMON_READY_CALLBACK; 2637 opt_val.val.daemon_ready_callback.v_cb = cb; 2638 opt_val.val.daemon_ready_callback.v_cb_cls = cb_cls; 2639 2640 return opt_val; 2641 } 2642 2643 2644 /** 2645 * Set a function that should be called whenever a connection is started or closed. 2646 * @param ncc the callback for notifications 2647 * @param cls the closure for the callback 2648 * @return structure with the requested setting 2649 */ 2650 static MHD_INLINE struct MHD_DaemonOptionAndValue 2651 MHD_D_OPTION_NOTIFY_CONNECTION ( 2652 MHD_NotifyConnectionCallback ncc, 2653 void *cls 2654 ) 2655 { 2656 struct MHD_DaemonOptionAndValue opt_val; 2657 2658 opt_val.opt = MHD_D_O_NOTIFY_CONNECTION; 2659 opt_val.val.notify_connection.v_ncc = ncc; 2660 opt_val.val.notify_connection.v_cls = cls; 2661 2662 return opt_val; 2663 } 2664 2665 2666 /** 2667 * Register a function that should be called whenever a stream is started or closed. 2668 * For HTTP/1.1 this callback is called one time for every connection. 2669 * @param nsc the callback for notifications 2670 * @param cls the closure for the callback 2671 * @return structure with the requested setting 2672 */ 2673 static MHD_INLINE struct MHD_DaemonOptionAndValue 2674 MHD_D_OPTION_NOTIFY_STREAM ( 2675 MHD_NotifyStreamCallback nsc, 2676 void *cls 2677 ) 2678 { 2679 struct MHD_DaemonOptionAndValue opt_val; 2680 2681 opt_val.opt = MHD_D_O_NOTIFY_STREAM; 2682 opt_val.val.notify_stream.v_nsc = nsc; 2683 opt_val.val.notify_stream.v_cls = cls; 2684 2685 return opt_val; 2686 } 2687 2688 2689 /** 2690 * Set strong random data to be used by MHD. 2691 * Currently the data is only needed for Digest Auth module. 2692 * Daemon support for Digest Auth is enabled automatically if this option is used. 2693 * The recommended size is between 8 and 32 bytes. Security can be lower for sizes less or equal four. 2694 * Sizes larger then 32 (or, probably, larger than 16 - debatable) will not increase the security. 2695 * @param buf_size the size of the buffer 2696 * @param buf the buffer with strong random data, the content will be copied by MHD 2697 * @return structure with the requested setting 2698 */ 2699 static MHD_INLINE struct MHD_DaemonOptionAndValue 2700 MHD_D_OPTION_RANDOM_ENTROPY ( 2701 size_t buf_size, 2702 /* const */ void *buf 2703 ) 2704 { 2705 struct MHD_DaemonOptionAndValue opt_val; 2706 2707 opt_val.opt = MHD_D_O_RANDOM_ENTROPY; 2708 opt_val.val.random_entropy.v_buf_size = buf_size; 2709 opt_val.val.random_entropy.v_buf = buf; 2710 2711 return opt_val; 2712 } 2713 2714 2715 /** 2716 * Specify the size of the internal hash map array that tracks generated digest nonces usage. 2717 * When the size of the map is too small then need to handle concurrent DAuth requests, a lot of stale nonce results will be produced. 2718 * By default the size is 1000 entries. 2719 * @param size the size of the map array 2720 * @return structure with the requested setting 2721 */ 2722 static MHD_INLINE struct MHD_DaemonOptionAndValue 2723 MHD_D_OPTION_AUTH_DIGEST_MAP_SIZE ( 2724 size_t size 2725 ) 2726 { 2727 struct MHD_DaemonOptionAndValue opt_val; 2728 2729 opt_val.opt = MHD_D_O_AUTH_DIGEST_MAP_SIZE; 2730 opt_val.val.auth_digest_map_size = size; 2731 2732 return opt_val; 2733 } 2734 2735 2736 /** 2737 * Nonce validity time (in seconds) used for Digest Auth. 2738 * If followed by zero value the value is silently ignored. 2739 * @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest() 2740 * @param timeout FIXME 2741 * @return structure with the requested setting 2742 */ 2743 static MHD_INLINE struct MHD_DaemonOptionAndValue 2744 MHD_D_OPTION_AUTH_DIGEST_NONCE_TIMEOUT ( 2745 unsigned int timeout 2746 ) 2747 { 2748 struct MHD_DaemonOptionAndValue opt_val; 2749 2750 opt_val.opt = MHD_D_O_AUTH_DIGEST_NONCE_TIMEOUT; 2751 opt_val.val.auth_digest_nonce_timeout = timeout; 2752 2753 return opt_val; 2754 } 2755 2756 2757 /** 2758 * Default maximum nc (nonce count) value used for Digest Auth. 2759 * If followed by zero value the value is silently ignored. 2760 * @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest() 2761 * @param max_nc FIXME 2762 * @return structure with the requested setting 2763 */ 2764 static MHD_INLINE struct MHD_DaemonOptionAndValue 2765 MHD_D_OPTION_AUTH_DIGEST_DEF_MAX_NC ( 2766 uint_fast32_t max_nc 2767 ) 2768 { 2769 struct MHD_DaemonOptionAndValue opt_val; 2770 2771 opt_val.opt = MHD_D_O_AUTH_DIGEST_DEF_MAX_NC; 2772 opt_val.val.auth_digest_def_max_nc = max_nc; 2773 2774 return opt_val; 2775 } 2776 2777 2778 /** 2779 * Terminate the list of the options 2780 * @return the terminating object of struct MHD_DaemonOptionAndValue 2781 */ 2782 static MHD_INLINE struct MHD_DaemonOptionAndValue 2783 MHD_D_OPTION_TERMINATE (void) 2784 { 2785 struct MHD_DaemonOptionAndValue opt_val; 2786 2787 opt_val.opt = MHD_D_O_END; 2788 2789 return opt_val; 2790 } 2791 2792 2793 MHD_RESTORE_WARN_UNUSED_FUNC_ 2794 #endif /* !MHD_USE_COMPOUND_LITERALS || !MHD_USE_DESIG_NEST_INIT */