libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

microhttpd2_generated_daemon_options.h (93140B)


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