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