Pārlūkot izejas kodu

Sorted Daemon Option values, added missing values

Evgeny Grin (Karlson2k) 1 gadu atpakaļ
vecāks
revīzija
a4300eeb74
5 mainītis faili ar 317 papildinājumiem un 176 dzēšanām
  1. 1 0
      .gitattributes
  2. 221 158
      scripts/d_options.rec
  3. 1 1
      scripts/d_options.sh
  4. 5 0
      src/include/mhd_future.h
  5. 89 17
      src/include/microhttpd2.h

+ 1 - 0
.gitattributes

@@ -6,3 +6,4 @@ makefile.am	eol=lf
 *.key	eol=lf
 *.crt	eol=lf
 *.pem	eol=lf
+*.rec	eol=lf

+ 221 - 158
scripts/d_options.rec

@@ -15,106 +15,37 @@
 %type: Name,Type,Argument1,Member1,Argument2,Member2,Argument3,Member3 line
 %unique: Type Value Argument1 Description1 Member1 Argument2 Description2 Member2 Argument3 Description3 Member3
 
-Name: SUPPRESS_DATE_HEADER
-Value: 41
-Type: enum MHD_Bool
-Comment: Suppresses use of "Date:" header.
-+ According to RFC should be used only if the system has no RTC.
-+ The "Date:" is not suppressed (the header is enabled) by default.
+# MHD behaviour
 
-Name: TURBO
-Value: 42
-Type: enum MHD_Bool
-Comment: Enable `turbo`.  
-+ Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
-+ Most effects only happen with internal threads with epoll.
-+ The 'turbo' mode is not enabled (mode is disabled) by default.
+Name: work_mode
+Value: 40
+Comment: Set MHD threading and polling mode
+Argument1: struct MHD_WorkModeWithParam wmp
 
-Name: DISABLE_THREAD_SAFETY
-Value: 43
-Type: enum MHD_Bool
-Comment: Disable some internal thread safety.
-+ 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.
-+ This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment.
-+ Not compatible with any internal threads modes.
-+ Thread safety is not disabled (safety is enabled) by default.
+Name: poll_syscall
+Value: 41
+Comment: Select a sockets watch system call used for internal polling.
+Argument1: enum MHD_SockPollSyscall els
 
-Name: DISALLOW_UPGRADE
-Value: 44
-Type: enum MHD_Bool
-Comment: You need to set this option if you want to disable use of HTTP "Upgrade".
-+ "Upgrade" may require usage of additional internal resources, which we can avoid providing if they will not be used.
-+ You should only use this option if you do not use "Upgrade" functionality and need a generally minor boost in performance and resources saving.
-+ The "Upgrade" is not disallowed ("upgrade" is allowed) by default.
+# Listen socket
 
-Name: DISALLOW_SUSPEND_RESUME
-Value: 45
-Type: enum MHD_Bool
-Comment: Disable #MHD_action_suspend() functionality.
+Name: bind_port
+Value: 80
+Type: struct MHD_DaemonOptionValueBind
+Comment: Bind to the given TCP port and address family.
 +
-+ You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
-+ The suspend is not disallowed (suspend is allowed) by default.
-
-Name: ENABLE_SHOUTCAST
-Value: 46
-Type: enum MHD_Bool
-Comment: Use SHOUTcast.  This will cause *all* responses to begin with the SHOUTcast "ICY" line instead of "HTTP".
-
-Name: DISABLE_URI_QUERY_PLUS_AS_SPACE
-Value: 47
-Type: enum MHD_Bool
-Comment: Disable converting plus ('+') character to space in GET parameters (URI part after '?').
-+ 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.
-+ By default plus is converted to space in the query part of URI.
-
-Name: listen addr reuse
-Value: 48
-Comment: Select mode of reusing address:port listen address.
 + Ineffective in conjunction with #MHD_daemon_listen_socket().
-Argument1: enum MHD_DaemonOptionBindType reuse_type
-
-Name: LISTEN_BACKLOG
-Value: 49
-Comment: Use the given backlog for the listen() call.
-+ Works only with // FIXME: reference
-Argument1: unsigned int backlog_size
-
-Name: GLOBAL_CONNECTION_LIMIT
-Value: 50
-Comment: Maximum number of (concurrent) network connections served by daemon
-Argument1: unsigned int glob_limit
-
-Name: PER_IP_LIMIT
-Value: 52
-Comment: Limit on the number of (concurrent) network connections made to the server from the same IP address.
-+ 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.
-Argument1: unsigned int per_ip_limit
-
-Name: DEFAULT_TIMEOUT
-Value: 53
-Comment: After how many seconds of inactivity should a connection automatically be timed out?
-+ Use zero for no timeout, which is also the (unsafe!) default.
-Argument1: unsigned int timeout
-
-Name: logger
-Value: 100
-Type: struct MHD_DaemonOptionValueLogger
-Comment: Set logging method.  Specify NULL to disable logging entirely.  By
-+ default (if this option is not given), MHD writes log messages to stderr.
++ Ineffective in conjunction with #MHD_daemon_bind_sa().
 +
-+ In case of special builds for embedded projects:
-+ Logging will not work if MHD was compiled with "--disable-logging".
-+ (The function will still be exported, but the @a logger will never
-+ be invoked.)
-Argument1: MHD_LoggingCallback cb
-Description1: the logger function to invoke, NULL to disable logging
-Argument2: void *logger_cls
-Description2: the closure for logger @a cb callback
-
++ If neither this option nor the other two mentioned above
++ is specified, MHD will simply not listen on any socket!
+Argument1: enum MHD_AddressFamily af
+Description1: the address family to use
+Argument2: uint_fast16_t port
+Description2: port to use, 0 to let system assign any free port
 
 Name: bind_sa
-Value: 201
+Value: 81
 Type: struct MHD_DaemonOptionValueSA
 Comment: Bind to the given socket address.
 + Ineffective in conjunction with #MHD_daemon_listen_socket().
@@ -123,9 +54,21 @@ Description1: the size of the socket address pointed by @a sa.
 Argument2: const struct sockaddr *sa
 Description2: the address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX)
 
+Name: listen_socket
+Value: 82
+Comment: Accept connections from the given socket.  Socket
++ must be a TCP or UNIX domain (SOCK_STREAM) socket.
+Argument1: MHD_socket listen_fd
+Description1: the listen socket to use, ignored if set to #MHD_INVALID_SOCKET
 
-Name: option_tcp_fastopen
-Value: 200
+Name: listen addr reuse
+Value: 100
+Comment: Select mode of reusing address:port listen address.
++ Ineffective in conjunction with #MHD_daemon_listen_socket().
+Argument1: enum MHD_DaemonOptionBindType reuse_type
+
+Name: tcp_fastopen
+Value: 101
 Type: struct MHD_DaemonOptionValueTFO
 Comment: Configure TCP_FASTOPEN option, including setting a
 + custom @a queue_length.
@@ -136,46 +79,33 @@ Comment: Configure TCP_FASTOPEN option, including setting a
 Argument1: enum MHD_TCPFastOpenType option
 Description1: the type use of of TCP FastOpen
 Argument2: unsigned int queue_length
-Description2: the length of the queue, zero to use system or MHD default
+Description2: the length of the queue, zero to use system or MHD default,
++ silently ignored on platforms without support for custom queue size
 
-Name: bind_port
-Value: 202
-Type: struct MHD_DaemonOptionValueBind
-Comment: Bind to the given TCP port and address family.
-+
-+ Ineffective in conjunction with #MHD_daemon_listen_socket().
-+ Ineffective in conjunction with #MHD_daemon_bind_sa().
-+
-+ If neither this option nor the other two mentioned above
-+ is specified, MHD will simply not listen on any socket!
-Argument1: enum MHD_AddressFamily af
-Description1: the address family to use
-Argument2: uint_fast16_t port
-Description2: port to use, 0 to let system assign any free port
+Name: LISTEN_BACKLOG
+Value: 102
+Comment: Use the given backlog for the listen() call.
++ Works only with // FIXME: reference
+Argument1: unsigned int backlog_size
 
-Name: listen_socket
-Value: 206
-Comment: Accept connections from the given socket.  Socket
-+ must be a TCP or UNIX domain (SOCK_STREAM) socket.
-Argument1: MHD_socket listen_fd
-Description1: the listen socket to use, ignored if set to #MHD_INVALID_SOCKET
+Name: sigpipe suppressed
+Value: 103
+Type: enum MHD_Bool
+Comment: Inform that SIGPIPE is suppressed or handled by application.
++ If suppressed, allows MHD to use network functions that could generate SIGPIPE, like `sendfile()`.
++ Silently ignored when MHD creates internal threads as for them SIGPIPE is suppressed automatically.
 
-Name: event_loop
-Value: 207
-Comment: Select a particular event loop internal system call.
-Argument1: enum MHD_EventLoopSyscal els
+# TLS settings
 
-Name: protocol_strict_level
-Value: 210
-Type: struct MHD_DaemonOptionValueStrctLvl
-Comment: Set how strictly MHD will enforce the HTTP protocol.
-Argument1: enum MHD_ProtocolStrictLevel sl
-Description1: the level of strictness
-Argument2: enum MHD_UseStictLevel how
-Description2: the way how to set the requested level
+Name: TLS
+Value: 120
+Comment: Enable TLS
+Argument1: enum MHD_TlsBackend backend
+Description1: the TLS backend to use,
++ #MHD_TLS_BACKEND_NONE for non-TLS (plain TCP) connections
 
 Name: tls_psk_callback
-Value: 211
+Value: 121
 Type: struct MHD_DaemonOptionValueTlsPskCB
 Comment: Configure PSK to use for the TLS key exchange.
 Argument1: MHD_PskServerCredentialsCallback psk_cb
@@ -183,19 +113,34 @@ Description1: the function to call to obtain pre-shared key
 Argument2: void *psk_cb_cls
 Description2: the closure for @a psk_cb
 
-Name: daemon_ready_callback
-Value: 212
-Type: struct MHD_DaemonOptionValueReadyCB
-Comment: Set a callback to be called for pre-start finalisation.
-+ 
-+ The specified callback will be called one time, after network initialisation, TLS pre-initialisationб but before the start of the internal threads (if allowed)ю
-Argument1: MHD_DaemonReadyCallback cb
-Description1: the pre-start callback
-Argument2: void *cb_cls
-Description2: the closure for the callback
+Name: no alpn
+Value: 122
+Type: enum MHD_Bool
+Comment: Controls ALPN for TLS connection.
++ Silently ignored for non-TLS.
++ By default ALPN is automatically used for TLS connections.
+
+# Connection processing
+
+Name: DEFAULT_TIMEOUT
+Value: 160
+Comment: After how many seconds of inactivity should a connection automatically be timed out?
++ Use zero for no timeout, which is also the (unsafe!) default.
+Argument1: unsigned int timeout
+
+Name: GLOBAL_CONNECTION_LIMIT
+Value: 161
+Comment: Maximum number of (concurrent) network connections served by daemon
+Argument1: unsigned int glob_limit
+
+Name: PER_IP_LIMIT
+Value: 162
+Comment: Limit on the number of (concurrent) network connections made to the server from the same IP address.
++ 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.
+Argument1: unsigned int per_ip_limit
 
 Name: accept_policy
-Value: 213
+Value: 163
 Type: struct MHD_DaemonOptionValueAcceptPol
 Comment: Set a policy callback that accepts/rejects connections based on the client's IP address.  This function will be called before a connection object is created.
 Argument1: MHD_AcceptPolicyCallback apc
@@ -203,8 +148,19 @@ Description1: the accept policy callback
 Argument2: void *apc_cls
 Description2: the closure for the callback
 
+# Requests processing
+
+Name: protocol_strict_level
+Value: 200
+Type: struct MHD_DaemonOptionValueStrctLvl
+Comment: Set how strictly MHD will enforce the HTTP protocol.
+Argument1: enum MHD_ProtocolStrictLevel sl
+Description1: the level of strictness
+Argument2: enum MHD_UseStictLevel how
+Description2: the way how to set the requested level
+
 Name: early_uri_logger
-Value: 214
+Value: 201
 Type: struct MHD_DaemonOptionValueUriCB
 Comment: Set a callback to be called first for every request (before any parsing of the header).  This callback is the only way to get raw (unmodified) request URI as URI is parsed and modified by MHD in-place.
 + Mandatory URI modification may apply before this call, like binary zero replacement, as required by RFCs.
@@ -213,8 +169,106 @@ Description1: the early URI callback
 Argument2: void *cls
 Description2: the closure for the callback
 
+Name: DISABLE_URI_QUERY_PLUS_AS_SPACE
+Value: 202
+Type: enum MHD_Bool
+Comment: Disable converting plus ('+') character to space in GET parameters (URI part after '?').
++ 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.
++ By default plus is converted to space in the query part of URI.
+
+# Responses processing
+
+Name: SUPPRESS_DATE_HEADER
+Value: 240
+Type: enum MHD_Bool
+Comment: Suppresses use of "Date:" header.
++ According to RFC should be used only if the system has no RTC.
++ The "Date:" is not suppressed (the header is enabled) by default.
+
+Name: ENABLE_SHOUTCAST
+Value: 241
+Type: enum MHD_Bool
+Comment: Use SHOUTcast.  This will cause *all* responses to begin with the SHOUTcast "ICY" line instead of "HTTP".
+
+# MHD limits
+
+Name: conn memory limit
+Value: 280
+Type: size_t
+Comment: Maximum memory size per connection.
++ Default is 32 kb.
++ Values above 128k are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffersare unlikely to support window sizes above 64k on most systems. 
++ The size should be large enough to fit all request headers (together with internal parsing information).
+
+Name: stack size
+Value: 281
+Type: size_t
+Comment: Desired size of the stack for the threads started by MHD.
++ Use 0 for system default, which is also MHD default.
++ Only useful if mode with the internal threads is selected.
+
+Name: fd_number_limit
+Value: 282
+Comment: The the maximum FD value.
++ The limit is applied to all sockets used by MHD. 
++ If listen socket FD is equal or higher that specified value, the daemon fail to start.
++ If new connection FD is equal or higher that specified value, the connection is rejected.
++ Useful if application uses select() for polling the sockets, system FD_SETSIZE is good value for this option in such case.
++ Does not work if MHD uses internal sockets polling. // TODO: set references
++ Does not work on W32 (WinSock sockets).
+Argument1: MHD_Socket max_fd
+
+# MHD optimisations
+
+Name: TURBO
+Value: 320
+Type: enum MHD_Bool
+Comment: Enable `turbo`.  
++ Disables certain calls to `shutdown()`, enables aggressive non-blocking optimistic reads and other potentially unsafe optimisations.
++ Most effects only happen with internal threads with epoll.
++ The 'turbo' mode is not enabled (mode is disabled) by default.
+
+Name: DISABLE_THREAD_SAFETY
+Value: 321
+Type: enum MHD_Bool
+Comment: Disable some internal thread safety.
++ 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.
++ This flag turns off some internal thread-safety and allows MHD making some of the internal optimisations suitable only for single-threaded environment.
++ Not compatible with any internal threads modes.
++ Thread safety is not disabled (safety is enabled) by default.
+
+Name: DISALLOW_UPGRADE
+Value: 322
+Type: enum MHD_Bool
+Comment: You need to set this option if you want to disable use of HTTP "Upgrade".
++ "Upgrade" may require usage of additional internal resources, which we can avoid providing if they will not be used.
++ You should only use this option if you do not use "Upgrade" functionality and need a generally minor boost in performance and resources saving.
++ The "Upgrade" is not disallowed ("upgrade" is allowed) by default.
+
+Name: DISALLOW_SUSPEND_RESUME
+Value: 323
+Type: enum MHD_Bool
+Comment: Disable #MHD_action_suspend() functionality.
++
++ You should only use this function if you do not use suspend functionality and need a generally minor boost in performance.
++ The suspend is not disallowed (suspend is allowed) by default.
+
+# Notification callbacks
+
+Name: daemon_ready_callback
+Value: 360
+Type: struct MHD_DaemonOptionValueReadyCB
+Comment: Set a callback to be called for pre-start finalisation.
++ 
++ The specified callback will be called one time, after network initialisation, TLS pre-initialisationб but before the start of the internal threads (if allowed)ю
+Argument1: MHD_DaemonReadyCallback cb
+Description1: the pre-start callback
+Argument2: void *cb_cls
+Description2: the closure for the callback
+
 Name: notify_connection
-Value: 215
+Value: 361
 Type: struct MHD_DaemonOptionValueNotifConnCB
 Comment: Set a function that should be called whenever a connection is started or closed.
 Argument1: MHD_NotifyConnectionCallback ncc
@@ -223,7 +277,7 @@ Argument2: void *cls
 Description2: the closure for the callback
 
 Name: notify_stream
-Value: 216
+Value: 362
 Type: struct MHD_DaemonOptionValueNotifStreamCB
 Comment: Register a function that should be called whenever a stream is started or closed.
 + For HTTP/1.1 this callback is called one time for every connection.
@@ -232,23 +286,10 @@ Description1: the callback for notifications
 Argument2: void *cls
 Description2: the closure for the callback
 
-Name: conn memory limit
-Value: 217
-Type: size_t
-Comment: Maximum memory size per connection.
-+ Default is 32 kb.
-+ Values above 128k are unlikely to result in much performance benefit, as half of the memory will be typically used for IO, and TCP buffersare unlikely to support window sizes above 64k on most systems. 
-+ The size should be large enough to fit all request headers (together with internal parsing information).
-
-Name: stack size
-Value: 218
-Type: size_t
-Comment: Desired size of the stack for the threads started by MHD.
-+ Use 0 for system default, which is also MHD default.
-+ Only useful if mode with the internal threads is selected.
+# Digest Auth settings
 
 Name: random entropy
-Value: 219
+Value: 400
 Type: struct MHD_DaemonOptionValueRand
 Comment: Set strong random data to be used by MHD.
 + Currently the data is only needed for Digest Auth module.
@@ -259,10 +300,32 @@ Description1: the size of the buffer
 Argument2: const void *buf
 Description2: the buffer with strong random data, the content will be copied by MHD
 
-Name: digest_auth_map_size
-Value: 220
+Name: dauth_map_size
+Value: 401
 Comment: Specify the size of the internal hash map array that tracks generated digest nonces usage.
 + If the size of the map is too small then a lot of "stale nonce" results will be produced.
 + By default the size is 8 bytes (very small).
 Argument1: size_t size
 Description1: the size of the map array
+
+Name: dauth_nonce_bind_type
+Value: 402
+Type: enum MHD_DaemonOptionValueDAuthBindNonce
+Comment: Control the scope of validity of MHD-generated nonces.
++ This regulates how "nonces" are generated and how "nonces" are checked by #MHD_digest_auth_check() and similar functions.
++ This option allows bitwise OR combination of #MHD_DaemonOptionValueDAuthBindNonce values.
++ When this option is not used then default value is #MHD_DAEMON_OPTION_VALUE_DAUTH_BIND_NONCE_NONE.
+
+Name: dauth_def_nonce_timeout
+Value: 403
+Comment: Default nonce timeout value (in seconds) used for Digest Auth.
++ Silently ignored if followed by zero value.
++ @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
+Argument1: unsigned int timeout
+
+Name: dauth_def_max_nc
+Value: 404
+Comment: Default maximum nc (nonce count) value used for Digest Auth.
++ Silently ignored if followed by zero value.
++ @see #MHD_digest_auth_check(), MHD_digest_auth_check_digest()
+Argument1: uint_fast32_t max_nc

+ 1 - 1
scripts/d_options.sh

@@ -170,7 +170,7 @@ def_name_for_type() {
         'uint_fast32_t') echo -n "uint32_val";;
         'uint_fast16_t') echo -n "uint16_val";;
         'size_t') echo -n "sizet_val";;
-        *) printf '%s' "${1// /_}_val"
+        *) local tp="${1,,}" && printf '%s' "${tp// /_}_val";;
     esac
 }
 

+ 5 - 0
src/include/mhd_future.h

@@ -339,3 +339,8 @@ MHD_request_lookup_value_by_static_header (struct MHD_Request *request,
                                            enum MHD_PredefinedHeader skt,
                                            struct MHD_StringNullable *value)
 MHD_FN_PAR_NONNULL_ (1) MHD_FN_PAR_NONNULL_ (4); // TODO: convert like previous
+
+
+/* FUTURE:
+   (with eventually option "number of masters")
+   MHD_TM_WORKER_THREADS_WITH_MASTER_LISTENER = 3 */

+ 89 - 17
src/include/microhttpd2.h

@@ -1184,7 +1184,6 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode
   ,
   /**
    * We were asked to return a timeout, but, there is no timeout.
-   * FIXME: explain better? Remove?
    */
   MHD_SC_NO_TIMEOUT = 1
   ,
@@ -1411,7 +1410,6 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode
    */
   MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD = 50010
   ,
-  /// FIXME: Similar to 60xxx???
   /**
    * We failed to open the listen socket. Maybe the build
    * supports IPv6, but your kernel does not?
@@ -1692,7 +1690,6 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode
    */
   MHD_SC_SYSCALL_QUIESCE_REQUIRES_ITC = 60001
   ,
-  // FIXME: similar to 50xxx???
   /**
    * We failed to bind the listen socket.
    */
@@ -3195,7 +3192,7 @@ MHD_FN_PAR_NONNULL_ (1);
 enum MHD_FIXED_ENUM_APP_SET_ MHD_TlsBackend
 {
   /**
-   * TODO add descr
+   * Disable TLS, use plain TCP connections
    */
   MHD_TLS_BACKEND_NONE = 0
   ,
@@ -3212,6 +3209,70 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_TlsBackend
   MHD_TLS_BACKEND_GNUTLS = 2
 };
 
+/**
+ * Values for #MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE.
+ *
+ * These values can limit the scope of validity of MHD-generated nonces.
+ * Values can be combined with bitwise OR.
+ * Any value, except #MHD_DAUTH_BIND_NONCE_NONE, enforce function
+ * #MHD_digest_auth_check() (and similar functions) to check nonce by
+ * re-generating it again with the same parameters, which is CPU-intensive
+ * operation.
+ */
+enum MHD_FIXED_FLAGS_ENUM_APP_SET_ MHD_DaemonOptionValueDAuthBindNonce
+{
+  /**
+   * Generated nonces are valid for any request from any client until expired.
+   * This is default and recommended value.
+   * #MHD_digest_auth_check3() (and similar functions) would check only whether
+   * the nonce value that is used by client has been generated by MHD and not
+   * expired yet.
+   * It is recommended because RFC 7616 allows clients to use the same nonce
+   * for any request in the same "protection space".
+   * When checking client's authorisation requests CPU is loaded less if this
+   * value is used.
+   * This mode gives MHD maximum flexibility for nonces generation and can
+   * prevent possible nonce collisions (and corresponding log warning messages)
+   * when clients' requests are intensive.
+   * This value cannot be biwise-OR combined with other values.
+   */
+  MHD_DAEMON_OPTION_VALUE_DAUTH_BIND_NONCE_NONE = 0,
+
+  /**
+   * Generated nonces are valid only for the same realm.
+   */
+  MHD_DAEMON_OPTION_VALUE_DAUTH_BIND_NONCE_REALM = 1 << 0,
+
+  /**
+   * Generated nonces are valid only for the same URI (excluding parameters
+   * after '?' in URI) and request method (GET, POST etc).
+   * Not recommended unless "protection space" is limited to a single URI as
+   * RFC 7616 allows clients to re-use server-generated nonces for any URI
+   * in the same "protection space" which by default consists of all server
+   * URIs.
+   * Before #MHD_VERSION 0x00097701 this was default (and only supported)
+   * nonce bind type.
+   */
+  MHD_DAEMON_OPTION_VALUE_DAUTH_BIND_NONCE_URI = 1 << 1,
+
+  /**
+   * Generated nonces are valid only for the same URI including URI parameters
+   * and request method (GET, POST etc).
+   * This value implies #MHD_DAUTH_BIND_NONCE_URI.
+   * Not recommended for that same reasons as #MHD_DAUTH_BIND_NONCE_URI.
+   */
+  MHD_DAEMON_OPTION_VALUE_DAUTH_BIND_NONCE_URI_PARAMS = 1 << 2,
+
+  /**
+   * Generated nonces are valid only for the single client's IP.
+   * While it looks like security improvement, in practice the same client may
+   * jump from one IP to another (mobile or Wi-Fi handover, DHCP re-assignment,
+   * Multi-NAT, different proxy chain and other reasons), while IP address
+   * spoofing could be used relatively easily.
+   */
+  MHD_DAEMON_OPTION_VALUE_DAUTH_BIND_NONCE_CLIENT_IP = 1 << 3
+};
+
 /**
  * Enable and configure TLS.
  *
@@ -3853,7 +3914,7 @@ MHD_RESTORE_WARN_VARIADIC_MACROS_
 /**
  * Which threading and polling mode should be used by MHD?
  */
-enum MHD_FIXED_ENUM_APP_SET_ MHD_ThreadingPollingMode
+enum MHD_FIXED_ENUM_APP_SET_ MHD_WorkMode
 {
   /**
    * The daemon has no internal threads.
@@ -3861,33 +3922,33 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_ThreadingPollingMode
    * MHD internally checks all sockets automatically.
    * This is the default.
    */
-  MHD_TM_EXTERNAL_PERIODIC = 0
+  MHD_WM_EXTERNAL_PERIODIC = 0
   ,
   /**
    * Use an external event loop with level triggers.
    * Application uses #MHD_SocketRegistrationUpdateCallback, level triggered
    * sockets polling (like select() or poll()) and #MHD_daemon_event_update().
    */
-  MHD_TM_EXTERNAL_EVENT_LOOP_CB_LEVEL = 8
+  MHD_WM_EXTERNAL_EVENT_LOOP_CB_LEVEL = 8
   ,
   /**
    * Use an external event loop with edge triggers.
    * Application uses #MHD_SocketRegistrationUpdateCallback, edge triggered
-   * sockets polling (like select() or poll()) and #MHD_daemon_event_update().
+   * sockets polling (like epoll with EPOLLET) and #MHD_daemon_event_update().
    */
-  MHD_TM_EXTERNAL_EVENT_LOOP_CB_EDGE = 9
+  MHD_WM_EXTERNAL_EVENT_LOOP_CB_EDGE = 9
   ,
   /**
    * The daemon has no internal threads.
    * Application uses #MHD_DAEMON_INFO_FIXED_AGGREAGATE_FD to get single FD
    * that triggered when any MHD event happens.
-   * This FD can be watched as aggregate indicator for all MHD events.
+   * This FD can be watched as an aggregate indicator for all MHD events.
    * This mode is available only on selected platforms (currently
    * GNU/Linux only), see #MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD.
    * When the FD is triggered, #MHD_daemon_process_nonblocking() should
    * be called.
    */
-  MHD_TM_EXTERNAL_SINGLE_FD_WATCH = 12
+  MHD_WM_EXTERNAL_SINGLE_FD_WATCH = 16
   ,
   /**
    * Run with one or more worker threads.
@@ -3898,7 +3959,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_ThreadingPollingMode
    * than one, then that number of worker threads and distributed
    * processing of requests among the workers.
    */
-  MHD_TM_WORKER_THREADS = 16
+  MHD_WM_WORKER_THREADS = 24
   ,
 
   /**
@@ -3907,14 +3968,25 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_ThreadingPollingMode
    * is CPU-intensive or blocking, your application is thread-safe and you
    * have plenty of memory (per connection).
    */
-  MHD_TM_THREAD_PER_CONNECTION = 17
-
+  MHD_WM_THREAD_PER_CONNECTION = 32
 };
 
-/* FUTURE:
-   (with eventually option "number of masters")
-   MHD_TM_WORKER_THREADS_WITH_MASTER_LISTENER = 3 */
+union MHD_WorkModeParam
+{
+
+};
 
+struct MHD_WorkModeWithParam
+{
+  /**
+   * The work mode for MHD
+   */
+  enum MHD_WorkMode mode;
+  /**
+   * The parameters used for specified work mode
+   */
+  union MHD_WorkModeParam val;
+};
 
 /**
  * Specify threading mode to use.