GNU libmicrohttpd
0.9.29
|
internal shared structures More...
#include "platform.h"
#include "microhttpd.h"
#include "mhd_options.h"
#include "mhd_threads.h"
#include "mhd_locks.h"
#include "mhd_sockets.h"
#include "mhd_itc_types.h"
Go to the source code of this file.
Data Structures | |
struct | MHD_NonceNc |
struct | MHD_HTTP_Header |
struct | MHD_Response |
struct | MHD_Connection |
struct | UpgradeEpollHandle |
struct | MHD_UpgradeResponseHandle |
struct | MHD_Daemon |
Macros | |
#define | MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); BUILTIN_NOT_REACHED; } while (0) |
#define | MHD_fd_close_chk_(fd) |
#define | EXTRA_CHECKS MHD_NO |
#define | MHD_MAX(a, b) (((a)<(b)) ? (b) : (a)) |
#define | MHD_MIN(a, b) (((a)<(b)) ? (a) : (b)) |
#define | MHD_BUF_INC_SIZE 1024 |
#define | BUILTIN_NOT_REACHED |
#define | MAX_NONCE_LENGTH 129 |
#define | DEBUG_STATES MHD_NO |
#define | RESERVE_EBUF_SIZE 8 |
#define | EXTRA_CHECK(a) |
#define | DLL_insert(head, tail, element) |
#define | DLL_remove(head, tail, element) |
#define | XDLL_insert(head, tail, element) |
#define | XDLL_remove(head, tail, element) |
#define | EDLL_insert(head, tail, element) |
#define | EDLL_remove(head, tail, element) |
Typedefs | |
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 *write_to, 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 int(* | MHD_ArgumentIterator_) (struct MHD_Connection *connection, const char *key, const char *value, enum MHD_ValueKind kind) |
Functions | |
void | MHD_unescape_plus (char *arg) |
int | MHD_parse_arguments_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers) |
void | MHD_cleanup_upgraded_connection_ (struct MHD_Connection *connection) |
Variables | |
MHD_PanicCallback | mhd_panic |
void * | mhd_panic_cls |
internal shared structures
Definition in file internal.h.
#define BUILTIN_NOT_REACHED |
Definition at line 113 of file internal.h.
#define DEBUG_STATES MHD_NO |
Should all state transitions be printed to stderr?
Definition at line 518 of file internal.h.
#define DLL_insert | ( | head, | |
tail, | |||
element | |||
) |
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 1548 of file internal.h.
Referenced by cleanup_connection(), close_connection(), internal_add_connection(), MHD_response_execute_upgrade_(), MHD_suspend_connection(), and resume_suspended_connections().
#define DLL_remove | ( | head, | |
tail, | |||
element | |||
) |
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 1569 of file internal.h.
Referenced by cleanup_connection(), close_connection(), internal_add_connection(), MHD_cleanup_connections(), MHD_cleanup_upgraded_connection_(), MHD_suspend_connection(), and resume_suspended_connections().
#define EDLL_insert | ( | head, | |
tail, | |||
element | |||
) |
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 1637 of file internal.h.
Referenced by internal_add_connection(), MHD_connection_handle_idle(), MHD_poll(), and resume_suspended_connections().
#define EDLL_remove | ( | head, | |
tail, | |||
element | |||
) |
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 1656 of file internal.h.
Referenced by MHD_cleanup_connections(), MHD_poll(), and MHD_suspend_connection().
#define EXTRA_CHECK | ( | a | ) |
Definition at line 1536 of file internal.h.
Referenced by build_header_response(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_connection_handle_write(), MHD_connection_update_event_loop_info(), MHD_response_execute_upgrade_(), parse_connection_headers(), process_broken_line(), transmit_error_response(), and try_ready_chunked_body().
#define EXTRA_CHECKS MHD_NO |
Should we perform additional sanity checks at runtime (on our internal invariants)? This may lead to aborts, but can be useful for debugging.
Definition at line 81 of file internal.h.
#define MAX_NONCE_LENGTH 129 |
Maximum length of a nonce in digest authentication. 32(MD5 Hex) + 8(Timestamp Hex) + 1(NULL); hence 41 should suffice, but Opera (already) takes more (see Mantis #1633), so we've increased the value to support something longer...
Definition at line 191 of file internal.h.
Referenced by check_nonce_nc(), and MHD_digest_auth_check().
#define MHD_BUF_INC_SIZE 1024 |
Minimum 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).
Definition at line 94 of file internal.h.
Referenced by MHD_start_daemon_va(), and try_grow_read_buffer().
#define MHD_fd_close_chk_ | ( | fd | ) |
Close FD and abort execution if error is detected.
fd | the FD to close |
Definition at line 72 of file internal.h.
Referenced by MHD_stop_daemon().
#define MHD_MAX | ( | a, | |
b | |||
) | (((a)<(b)) ? (b) : (a)) |
Definition at line 83 of file internal.h.
#define MHD_MIN | ( | a, | |
b | |||
) | (((a)<(b)) ? (a) : (b)) |
Definition at line 84 of file internal.h.
Referenced by try_ready_chunked_body(), and try_ready_normal_body().
#define MHD_PANIC | ( | msg | ) | do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); BUILTIN_NOT_REACHED; } while (0) |
Trigger 'panic' action based on fatal errors.
msg | error message (const char *) |
Definition at line 59 of file internal.h.
Referenced by close_all_connections(), internal_add_connection(), MHD_cleanup_connections(), MHD_cleanup_upgraded_connection_(), MHD_connection_handle_write(), MHD_init(), MHD_ip_limit_del(), MHD_poll(), MHD_quiesce_daemon(), MHD_response_execute_upgrade_(), MHD_resume_connection(), MHD_start_daemon_va(), MHD_stop_daemon(), MHD_suspend_connection(), and resume_suspended_connections().
#define RESERVE_EBUF_SIZE 8 |
Buffer we use for upgrade response handling in the unlikely case where the memory pool was so small it had no buffer capacity left. Note that we don't expect to ever use this buffer, so it's mostly wasted memory (except that it allows us to handle a tricky error condition nicely). So no need to make this one big. Applications that want to perform well should just pick an adequate size for the memory pools.
Definition at line 937 of file internal.h.
Referenced by MHD_response_execute_upgrade_().
#define XDLL_insert | ( | head, | |
tail, | |||
element | |||
) |
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 1593 of file internal.h.
Referenced by internal_add_connection(), MHD_set_connection_option(), resume_suspended_connections(), and update_last_activity().
#define XDLL_remove | ( | head, | |
tail, | |||
element | |||
) |
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 1614 of file internal.h.
Referenced by cleanup_connection(), close_connection(), internal_add_connection(), MHD_set_connection_option(), MHD_suspend_connection(), and update_last_activity().
typedef void*(* LogCallback) (void *cls, const char *uri, struct MHD_Connection *con) |
Signature of function called to log URI accesses.
cls | closure |
uri | uri being accessed |
con | connection handle |
Definition at line 1073 of file internal.h.
typedef int(* MHD_ArgumentIterator_) (struct MHD_Connection *connection, const char *key, const char *value, enum MHD_ValueKind kind) |
Callback invoked when iterating over key / value argument pairs during parsing.
connection | context of the iteration |
key | 0-terminated key string, never NULL |
value | 0-terminated value string, may be NULL |
kind | origin of the key-value pair |
Definition at line 1690 of file internal.h.
typedef ssize_t(* ReceiveCallback) (struct MHD_Connection *conn, void *write_to, size_t max_bytes) |
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 537 of file internal.h.
typedef ssize_t(* TransmitCallback) (struct MHD_Connection *conn, const void *write_to, 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 551 of file internal.h.
typedef size_t(* UnescapeCallback) (void *cls, struct MHD_Connection *conn, char *uri) |
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 1087 of file internal.h.
enum MHD_CONNECTION_STATE |
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 377 of file internal.h.
What is this connection waiting for?
Definition at line 161 of file internal.h.
enum MHD_EpollState |
State of the socket with respect to epoll (bitmask).
Definition at line 120 of file internal.h.
void MHD_cleanup_upgraded_connection_ | ( | struct MHD_Connection * | connection | ) |
Finally cleanup upgrade-related resources. It should be called when TLS buffers have been drained and application signaled MHD by MHD_UPGRADE_ACTION_CLOSE.
connection | handle to the upgraded connection to clean |
Definition at line 920 of file daemon.c.
References _, MHD_UpgradeResponseHandle::connection, MHD_Connection::daemon, DLL_remove, MHD_cleanup_upgraded_connection_(), MHD_connection_close_(), MHD_EPOLL_STATE_READ_READY, MHD_EPOLL_STATE_WRITE_READY, MHD_INVALID_SOCKET, MHD_PANIC, MHD_recv_, MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_resume_connection(), MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_EINTR_, MHD_send_, MHD_socket_close_chk_, MHD_socket_get_error_, MHD_USE_EPOLL, MHD_USE_THREAD_PER_CONNECTION, MHD_USE_TLS, MHD_YES, NULL, MHD_Daemon::options, MHD_Connection::socket_fd, MHD_Connection::urh, and MHD_UpgradeResponseHandle::was_closed.
Referenced by MHD_cleanup_upgraded_connection_(), and MHD_upgrade_action().
int MHD_parse_arguments_ | ( | struct MHD_Connection * | connection, |
enum MHD_ValueKind | kind, | ||
char * | args, | ||
MHD_ArgumentIterator_ | cb, | ||
unsigned int * | num_headers | ||
) |
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 | |
[out] | num_headers | set to the number of headers found |
Definition at line 186 of file internal.c.
References MHD_Connection::daemon, MHD_NO, MHD_unescape_plus(), MHD_YES, NULL, MHD_Daemon::unescape_callback, and MHD_Daemon::unescape_callback_cls.
Referenced by check_argument_match(), and parse_initial_message_line().
void MHD_unescape_plus | ( | char * | arg | ) |
Convert all occurrences of '+' to ' '.
arg | string that is modified (in place), must be 0-terminated |
Definition at line 119 of file internal.c.
References NULL.
Referenced by MHD_parse_arguments_(), and post_process_urlencoded().
MHD_PanicCallback mhd_panic |
Handler for fatal errors.
Definition at line 119 of file daemon.c.
Referenced by build_header_response(), MHD_create_post_processor(), MHD_init(), MHD_set_panic_func(), post_process_multipart(), post_process_urlencoded(), and process_request_body().
void* mhd_panic_cls |
Closure argument for "mhd_panic".
Closure argument for mhd_panic.
Definition at line 124 of file daemon.c.
Referenced by build_header_response(), MHD_create_post_processor(), MHD_init(), MHD_set_panic_func(), post_process_multipart(), post_process_urlencoded(), and process_request_body().