GNU libmicrohttpd 1.0.0
|
MHD internal shared structures. More...
#include "mhd_options.h"
#include "platform.h"
#include "microhttpd.h"
#include "mhd_assert.h"
#include "mhd_panic.h"
#include "mhd_locks.h"
#include "mhd_sockets.h"
#include "mhd_itc_types.h"
#include "mhd_str_types.h"
Go to the source code of this file.
Data Structures | |
struct | MHD_NonceNc |
struct | MHD_HTTP_Res_Header |
struct | MHD_HTTP_Req_Header |
struct | MHD_iovec_track_ |
struct | MHD_Response |
struct | MHD_RequestLineProcessing |
struct | MHD_HeaderProcessing |
union | MHD_HeadersProcessing |
union | MHD_StartOrSize |
struct | MHD_Request |
struct | MHD_Reply_Properties |
struct | MHD_Reply |
struct | MHD_Connection |
struct | MHD_Daemon |
Typedefs | |
typedef struct MHD_IoVec | MHD_iovec_ |
typedef size_t | MHD_iov_size_ |
typedef ssize_t(* | ReceiveCallback) (struct MHD_Connection *conn, void *write_to, size_t max_bytes) |
typedef ssize_t(* | TransmitCallback) (struct MHD_Connection *conn, const void *read_from, size_t max_bytes) |
typedef void *(* | LogCallback) (void *cls, const char *uri, struct MHD_Connection *con) |
typedef size_t(* | UnescapeCallback) (void *cls, struct MHD_Connection *conn, char *uri) |
typedef enum MHD_Result(* | MHD_ArgumentIterator_) (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind) |
Functions | |
void | MHD_unescape_plus (char *arg) |
enum MHD_Result | MHD_parse_arguments_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, void *cls) |
bool | MHD_check_response_header_token_ci (const struct MHD_Response *response, const char *key, size_t key_len, const char *token, size_t token_len) |
void | internal_suspend_connection_ (struct MHD_Connection *connection) |
_MHD_static_inline struct MHD_Daemon * | MHD_get_master (struct MHD_Daemon *const daemon) |
Variables | |
enum MHD_tristate | _MHD_FIXED_ENUM |
enum MHD_EpollState | _MHD_FIXED_FLAGS_ENUM |
MHD internal shared structures.
Definition in file internal.h.
#define _MHD_DEBUG_CLOSE _MHD_MACRO_NO |
Add extra debug messages with reasons for closing connections (non-error reasons).
Definition at line 126 of file internal.h.
#define _MHD_DEBUG_CONNECT _MHD_MACRO_NO |
Print extra messages when establishing connections? (only adds non-error messages).
Definition at line 111 of file internal.h.
#define _MHD_DEBUG_SEND_DATA _MHD_MACRO_NO |
Should all data send be printed to stderr?
Definition at line 118 of file internal.h.
Macro to drop 'const' qualifier from pointer without compiler warning. To be used only to deal with broken external APIs, which require non-const pointer to unmodifiable data. Must not be used to transform pointers for MHD needs.
Definition at line 77 of file internal.h.
Referenced by internal_run_from_select(), MHD_create_response_from_iovec(), MHD_send_hdr_and_body_(), new_connection_prepare_(), and parse_options_va().
#define _MHD_MACRO_NO 0 |
"Negative answer"/"false" for use in macros, meaningful for precompiler
Definition at line 83 of file internal.h.
#define _MHD_MACRO_YES 1 |
"Positive answer"/"true" for use in macros, meaningful for precompiler
Definition at line 89 of file internal.h.
#define DEBUG_STATES _MHD_MACRO_NO |
Should all state transitions be printed to stderr?
Definition at line 775 of file internal.h.
Insert an element at the head of a DLL. Assumes that head, tail and element are structs with prev and next fields.
head | pointer to the head of the DLL |
tail | pointer to the tail of the DLL |
element | element to insert |
Definition at line 2658 of file internal.h.
Remove an element from a DLL. Assumes that head, tail and element are structs with prev and next fields.
head | pointer to the head of the DLL |
tail | pointer to the tail of the DLL |
element | element to remove |
Definition at line 2680 of file internal.h.
Insert an element at the head of a EDLL. Assumes that head, tail and element are structs with prevE and nextE fields.
head | pointer to the head of the EDLL |
tail | pointer to the tail of the EDLL |
element | element to insert |
Definition at line 2752 of file internal.h.
Remove an element from a EDLL. Assumes that head, tail and element are structs with prevE and nextE fields.
head | pointer to the head of the EDLL |
tail | pointer to the tail of the EDLL |
element | element to remove |
Definition at line 2772 of file internal.h.
#define MAX_CLIENT_NONCE_LENGTH 129 |
Maximum length of a nonce in digest authentication. 64(SHA-256 Hex) + 12(Timestamp Hex) + 1(NULL); hence 77 should suffice, but Opera (already) takes more (see Mantis #1633), so we've increased the value to support something longer...
Definition at line 257 of file internal.h.
#define MAX_DIGEST_NONCE_LENGTH ((16 + 6) * 2) |
The maximum size of MHD-generated nonce when printed with hexadecimal chars.
This is equal to "(32 bytes for SHA-256 (or SHA-512/256) nonce plus 6 bytes for timestamp) multiplied by two hex chars per byte". Please keep it in sync with digestauth.c
Definition at line 269 of file internal.h.
Referenced by calculate_add_nonce(), check_nonce_nc(), and is_slot_available().
#define MHD_BUF_INC_SIZE 1500 |
Minimum reasonable size by which MHD tries to increment read/write buffers. We usually begin with half the available pool space for the IO-buffer, but if absolutely needed we additively grow by the number of bytes given here (up to – theoretically – the full pool space).
Currently set to reasonable maximum MSS size.
Definition at line 142 of file internal.h.
Check whether response header contains particular static tkn.
Token could be surrounded by spaces and tabs and delimited by comma. Case-insensitive match used for header names and tokens.
r | the response to query |
k | header name |
tkn | the static string of token to find |
Definition at line 2874 of file internal.h.
#define MHD_D_DOES_SCKT_FIT_FDSET_ | ( | sckt, | |
d ) MHD_SCKT_FD_FITS_FDSET_SETSIZE_(sckt,NULL,MHD_D_GET_FD_SETSIZE_(d)) |
Check whether socket sckt fits fd_sets used by the daemon d
Definition at line 2601 of file internal.h.
Referenced by internal_add_connection(), and MHD_start_daemon_va().
#define MHD_D_GET_FD_SETSIZE_ | ( | d | ) | (FD_SETSIZE) |
Get FD_SETSIZE used by the daemon d
Definition at line 2595 of file internal.h.
Referenced by internal_add_connection(), and MHD_start_daemon_va().
Check whether the d daemon has thread-safety enabled.
Definition at line 2583 of file internal.h.
Referenced by internal_add_connection(), MHD_add_connection(), MHD_get_daemon_info(), and new_connections_list_process_().
Checks whether the d daemon is using epoll
Definition at line 2550 of file internal.h.
Referenced by internal_add_connection(), internal_suspend_connection_(), MHD_cleanup_connections(), MHD_connection_handle_idle(), MHD_get_fdset2(), MHD_get_timeout64(), MHD_quiesce_daemon(), MHD_run_from_select2(), MHD_run_wait(), MHD_start_daemon_va(), MHD_stop_daemon(), new_connection_process_(), and resume_suspended_connections().
Checks whether the d daemon is using poll()
Definition at line 2546 of file internal.h.
Referenced by MHD_get_fdset2(), MHD_run_from_select2(), MHD_run_wait(), and process_interim_params().
Checks whether the d daemon is using select()
Definition at line 2542 of file internal.h.
Referenced by internal_add_connection(), MHD_run_wait(), and MHD_start_daemon_va().
Checks whether the d daemon is using thread-per-connection mode
Definition at line 2578 of file internal.h.
Referenced by call_handlers(), cleanup_connection(), close_all_connections(), close_connection(), internal_run_from_select(), internal_suspend_connection_(), MHD_cleanup_connections(), MHD_get_timeout64(), MHD_select(), MHD_set_connection_option(), MHD_start_daemon_va(), MHD_suspend_connection(), MHD_update_last_activity_(), new_connection_process_(), parse_options_va(), and resume_suspended_connections().
Checks whether the d daemon is using internal polling thread
Definition at line 2574 of file internal.h.
Referenced by check_and_grow_read_buffer_space(), cleanup_connection(), close_all_connections(), close_connection(), handle_recv_no_space(), internal_suspend_connection_(), MHD_accept_connection(), MHD_add_connection(), MHD_cleanup_connections(), MHD_connection_close_(), MHD_connection_handle_idle(), MHD_get_fdset2(), MHD_get_timeout64(), MHD_queue_response(), MHD_quiesce_daemon(), MHD_run(), MHD_run_from_select2(), MHD_run_wait(), MHD_start_daemon_va(), MHD_stop_daemon(), MHD_suspend_connection(), new_connection_process_(), parse_options_va(), process_interim_params(), process_request_body(), and resume_suspended_connections().
Close FD and abort execution if error is detected.
fd | the FD to close |
Definition at line 95 of file internal.h.
Definition at line 441 of file internal.h.
Referenced by MHD_create_response_from_iovec().
Protocol should be used as HTTP/1.1 protocol.
See the last paragraph of https://datatracker.ietf.org/doc/html/rfc7230#section-2.6
Definition at line 890 of file internal.h.
Referenced by keepalive_possible(), MHD_queue_response(), need_100_continue(), parse_connection_headers(), and setup_reply_properties().
Returns boolean 'true' if HTTP version is supported by MHD
Definition at line 881 of file internal.h.
Referenced by keepalive_possible(), and MHD_connection_handle_idle().
#define MHD_TEST_ALLOW_SUSPEND_RESUME 8192 |
Additional test value for enum MHD_FLAG to check only for MHD_ALLOW_SUSPEND_RESUME and NOT for MHD_USE_ITC.
Definition at line 249 of file internal.h.
Referenced by close_all_connections(), MHD_resume_connection(), MHD_run_from_select2(), MHD_select(), and MHD_suspend_connection().
#define PRIu64 "llu" |
Definition at line 53 of file internal.h.
Referenced by connection_check_timedout(), get_req_headers(), MHD_set_connection_option(), and parse_options_va().
Insert an element at the head of a XDLL. Assumes that head, tail and element are structs with prevX and nextX fields.
head | pointer to the head of the XDLL |
tail | pointer to the tail of the XDLL |
element | element to insert |
Definition at line 2705 of file internal.h.
Remove an element from a XDLL. Assumes that head, tail and element are structs with prevX and nextX fields.
head | pointer to the head of the XDLL |
tail | pointer to the tail of the XDLL |
element | element to remove |
Definition at line 2727 of file internal.h.
Signature of function called to log URI accesses.
cls | closure |
uri | uri being accessed |
con | connection handle |
Definition at line 1834 of file internal.h.
typedef enum MHD_Result(* MHD_ArgumentIterator_) (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind) |
Callback invoked when iterating over key / value argument pairs during parsing.
cls | context of the iteration |
key | 0-terminated key string, never NULL |
key_size | number of bytes in key |
value | 0-terminated binary data, may include binary zeros, may be NULL |
value_size | number of bytes in value |
kind | origin of the key-value pair |
Definition at line 2793 of file internal.h.
Definition at line 442 of file internal.h.
Internally used I/O vector type for use when writev or sendmsg is not available.
Definition at line 440 of file internal.h.
Function to receive plaintext data.
conn | the connection struct |
write_to | where to write received data |
max_bytes | maximum number of bytes to receive |
Definition at line 794 of file internal.h.
typedef ssize_t(* TransmitCallback) (struct MHD_Connection *conn, const void *read_from, size_t max_bytes) |
Function to transmit plaintext data.
conn | the connection struct |
read_from | where to read data to transmit |
max_bytes | maximum number of bytes to transmit |
Definition at line 808 of file internal.h.
Signature of function called to unescape URIs. See also MHD_http_unescape().
cls | closure |
conn | connection handle |
uri | 0-terminated string to unescape (should be updated) |
Definition at line 1848 of file internal.h.
States in a state machine for a connection.
The main transitions are any-state to MHD_CONNECTION_CLOSED, any state to state+1, MHD_CONNECTION_FOOTERS_SENT to MHD_CONNECTION_INIT. MHD_CONNECTION_CLOSED is the terminal state and MHD_CONNECTION_INIT the initial state.
Note that transitions for reading happen only after the input has been processed; transitions for writing happen after the respective data has been put into the write buffer (the write does not have to be completed yet). A transition to MHD_CONNECTION_CLOSED or MHD_CONNECTION_INIT requires the write to be complete.
Definition at line 612 of file internal.h.
What is this connection waiting for?
Definition at line 214 of file internal.h.
Ability to use same connection for next request
Definition at line 817 of file internal.h.
State of the socket with respect to epoll (bitmask).
Enumerator | |
---|---|
MHD_EPOLL_STATE_UNREADY | The socket is not involved with a defined state in epoll() right now. |
MHD_EPOLL_STATE_READ_READY | epoll() told us that data was ready for reading, and we did not consume all of it yet. |
MHD_EPOLL_STATE_WRITE_READY | epoll() told us that space was available for writing, and we did not consume all of it yet. |
MHD_EPOLL_STATE_IN_EREADY_EDLL | Is this connection currently in the 'eready' EDLL? |
MHD_EPOLL_STATE_IN_EPOLL_SET | Is this connection currently in the epoll() set? |
MHD_EPOLL_STATE_SUSPENDED | Is this connection currently suspended? |
MHD_EPOLL_STATE_ERROR | Is this connection in some error state? |
Definition at line 168 of file internal.h.
The HTTP method.
Only primary methods (specified in RFC9110) are defined here.
Definition at line 898 of file internal.h.
Definition at line 840 of file internal.h.
Automatically assigned flags
Definition at line 404 of file internal.h.
States of TLS transport layer.
Definition at line 758 of file internal.h.
Tri-state on/off/unknown
Enumerator | |
---|---|
_MHD_UNKNOWN | State is not yet checked nor set |
_MHD_OFF | State is "off" / "disabled" |
_MHD_NO | State is "off" / "disabled" |
_MHD_ON | State is "on" / "enabled" |
_MHD_YES | State is "on" / "enabled" |
Definition at line 155 of file internal.h.
void internal_suspend_connection_ | ( | struct MHD_Connection * | connection | ) |
Internal version of MHD_suspend_connection().
connection | the connection to suspend |
Internal version of MHD_suspend_connection().
connection | the connection to suspend |
Definition at line 3224 of file daemon.c.
References _, MHD_Daemon::cleanup_connection_mutex, MHD_Connection::connection_timeout_ms, MHD_Daemon::connection_timeout_ms, MHD_Daemon::connections_head, MHD_Daemon::connections_tail, MHD_Connection::daemon, DLL_insert, DLL_remove, EDLL_remove, MHD_Daemon::manual_timeout_head, MHD_Daemon::manual_timeout_tail, mhd_assert, MHD_D_IS_USING_EPOLL_, MHD_D_IS_USING_THREAD_PER_CONN_, MHD_D_IS_USING_THREADS_, MHD_EPOLL_STATE_IN_EPOLL_SET, MHD_EPOLL_STATE_IN_EREADY_EDLL, MHD_EPOLL_STATE_SUSPENDED, MHD_HTTP_OK, MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_PANIC, MHD_thread_handle_ID_is_current_thread_, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, NULL, MHD_Connection::resuming, MHD_Connection::socket_fd, MHD_Connection::suspended, MHD_Daemon::suspended_connections_head, MHD_Daemon::suspended_connections_tail, MHD_Daemon::worker_pool, and XDLL_remove.
Referenced by MHD_suspend_connection().
bool MHD_check_response_header_token_ci | ( | const struct MHD_Response * | response, |
const char * | key, | ||
size_t | key_len, | ||
const char * | token, | ||
size_t | token_len ) |
Check whether response header contains particular token.
Token could be surrounded by spaces and tabs and delimited by comma. Case-insensitive match used for header names and tokens.
response | the response to query |
key | header name |
key_len | the length of key, not including optional terminating null-character. |
token | the token to find |
token_len | the length of token, not including optional terminating null-character. |
Definition at line 930 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Res_Header::header, MHD_HTTP_Res_Header::header_size, MHD_HTTP_Res_Header::kind, mhd_assert, MHD_HEADER_KIND, MHD_HTTP_OK, MHD_str_equal_caseless_bin_n_(), MHD_str_has_token_caseless_(), MHD_HTTP_Res_Header::next, NULL, and MHD_HTTP_Res_Header::value.
_MHD_static_inline struct MHD_Daemon * MHD_get_master | ( | struct MHD_Daemon *const | daemon | ) |
Trace up to and return master daemon. If the supplied daemon is a master, then return the daemon itself.
daemon | handle to a daemon |
Definition at line 2900 of file internal.h.
References MHD_Daemon::master, mhd_assert, MHD_HTTP_OK, and NULL.
Referenced by calculate_add_nonce(), calculate_add_nonce_with_retry(), check_nonce_nc(), digest_auth_check_all_inner(), MHD_get_connection_info(), MHD_ip_limit_add(), MHD_ip_limit_del(), and queue_auth_required_response3_inner().
enum MHD_Result MHD_parse_arguments_ | ( | struct MHD_Connection * | connection, |
enum MHD_ValueKind | kind, | ||
char * | args, | ||
MHD_ArgumentIterator_ | cb, | ||
void * | cls ) |
Parse and unescape the arguments given by the client as part of the HTTP request URI.
kind | header kind to pass to cb | |
connection | connection to add headers to | |
[in,out] | args | argument URI string (after "?" in URI), clobbered in the process! |
cb | function to call on each key-value pair found | |
cls | the iterator context |
Definition at line 169 of file internal.c.
References MHD_Connection::daemon, MHD_HTTP_OK, MHD_NO, MHD_unescape_plus(), MHD_YES, NULL, MHD_Daemon::unescape_callback, and MHD_Daemon::unescape_callback_cls.
Convert all occurrences of '+' to ' '.
arg | string that is modified (in place), must be 0-terminated |
Definition at line 123 of file internal.c.
References MHD_HTTP_OK, and NULL.
Referenced by MHD_parse_arguments_(), MHD_parse_arguments_(), post_process_urlencoded(), and process_value().
enum MHD_HTTP_Method _MHD_FIXED_ENUM |
enum MHD_ResponseAutoFlags _MHD_FIXED_FLAGS_ENUM |