Go to the documentation of this file.
36 #include <gnutls/gnutls.h>
37 #if GNUTLS_VERSION_MAJOR >= 3
38 #include <gnutls/abstract.h>
58 #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); \
59 BUILTIN_NOT_REACHED; } while (0)
66 #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); \
67 BUILTIN_NOT_REACHED; } while (0)
70 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
71 #include "mhd_threads.h"
72 #include "mhd_locks.h"
82 #define MHD_fd_close_chk_(fd) do { \
83 if ( (0 != close ((fd)) && (EBADF == errno)) ) \
84 MHD_PANIC (_ ("Failed to close FD.\n")); \
91 #define EXTRA_CHECKS MHD_NO
93 #define MHD_MAX(a,b) (((a)<(b)) ? (b) : (a))
94 #define MHD_MIN(a,b) (((a)<(b)) ? (a) : (b))
104 #define MHD_BUF_INC_SIZE 1024
118 #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= \
120 #define BUILTIN_NOT_REACHED __builtin_unreachable ()
121 #elif defined(_MSC_FULL_VER)
122 #define BUILTIN_NOT_REACHED __assume (0)
124 #define BUILTIN_NOT_REACHED
127 #ifndef MHD_STATICSTR_LEN_
131 #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1)
212 #define MHD_TEST_ALLOW_SUSPEND_RESUME 8192
220 #define MAX_NONCE_LENGTH 129
338 #ifdef UPGRADE_SUPPORT
349 void *upgrade_handler_cls;
352 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
528 #ifdef UPGRADE_SUPPORT
533 MHD_CONNECTION_UPGRADE
559 #define DEBUG_STATES MHD_NO
594 const void *read_from,
690 struct MemoryPool *
pool;
769 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
774 MHD_thread_handle_ID_
pid;
826 #if defined(_MHD_HAVE_SENDFILE)
827 enum MHD_resp_sender_
829 MHD_resp_sender_std = 0,
830 MHD_resp_sender_sendfile
895 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
970 #ifdef UPGRADE_SUPPORT
977 struct MHD_UpgradeResponseHandle *urh;
985 gnutls_session_t tls_session;
1026 #ifdef UPGRADE_SUPPORT
1036 #define RESERVE_EBUF_SIZE 8
1044 struct UpgradeEpollHandle
1050 struct MHD_UpgradeResponseHandle *urh;
1082 struct MHD_UpgradeResponseHandle
1091 #ifdef HTTPS_SUPPORT
1095 struct MHD_UpgradeResponseHandle *next;
1100 struct MHD_UpgradeResponseHandle *prev;
1102 #ifdef EPOLL_SUPPORT
1106 struct MHD_UpgradeResponseHandle *nextE;
1111 struct MHD_UpgradeResponseHandle *prevE;
1116 bool in_eready_list;
1138 size_t in_buffer_size;
1145 size_t out_buffer_size;
1154 size_t in_buffer_used;
1163 size_t out_buffer_used;
1168 struct UpgradeEpollHandle app;
1174 struct UpgradeEpollHandle mhd;
1180 char e_buf[RESERVE_EBUF_SIZE];
1194 volatile bool was_closed;
1231 (*LogCallback)(
void *cls,
1300 #ifdef EPOLL_SUPPORT
1311 #ifdef UPGRADE_SUPPORT
1315 struct MHD_UpgradeResponseHandle *eready_urh_head;
1320 struct MHD_UpgradeResponseHandle *eready_urh_tail;
1419 #ifdef HAVE_MESSAGES
1429 void *custom_error_log_cls;
1437 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1459 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1463 size_t thread_stack_size;
1479 MHD_thread_handle_ID_
pid;
1509 #ifdef EPOLL_SUPPORT
1519 bool listen_socket_in_epoll;
1521 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
1526 int epoll_upgrade_fd;
1532 bool upgrade_fd_in_epoll;
1541 struct MHD_itc_
itc;
1617 #ifdef HTTPS_SUPPORT
1618 #ifdef UPGRADE_SUPPORT
1624 struct MHD_UpgradeResponseHandle *urh_head;
1631 struct MHD_UpgradeResponseHandle *urh_tail;
1637 gnutls_priority_t priority_cache;
1643 gnutls_credentials_type_t cred_type;
1648 gnutls_certificate_credentials_t x509_cred;
1653 gnutls_dh_params_t dh_params;
1658 gnutls_psk_server_credentials_t psk_cred;
1660 #if GNUTLS_VERSION_MAJOR >= 3
1665 gnutls_certificate_retrieve_function2 *cert_callback;
1675 void *cred_callback_cls;
1678 #if GNUTLS_VERSION_NUMBER >= 0x030603
1683 gnutls_certificate_retrieve_function3 *cert_callback2;
1689 const char *https_mem_key;
1694 const char *https_mem_cert;
1699 const char *https_key_password;
1704 const char *https_mem_trust;
1709 gnutls_dh_params_t https_mem_dhparams;
1718 #ifdef DAUTH_SUPPORT
1723 const char *digest_auth_random;
1730 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1734 MHD_mutex_ nnc_lock;
1740 size_t digest_auth_rand_size;
1745 unsigned int nonce_nc_size;
1753 unsigned int fastopen_queue_size;
1771 #define DLL_insert(head,tail,element) do { \
1772 mhd_assert (NULL == (element)->next); \
1773 mhd_assert (NULL == (element)->prev); \
1774 (element)->next = (head); \
1775 (element)->prev = NULL; \
1776 if ((tail) == NULL) \
1779 (head)->prev = element; \
1780 (head) = (element); } while (0)
1792 #define DLL_remove(head,tail,element) do { \
1793 mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \
1794 mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \
1795 if ((element)->prev == NULL) \
1796 (head) = (element)->next; \
1798 (element)->prev->next = (element)->next; \
1799 if ((element)->next == NULL) \
1800 (tail) = (element)->prev; \
1802 (element)->next->prev = (element)->prev; \
1803 (element)->next = NULL; \
1804 (element)->prev = NULL; } while (0)
1815 #define XDLL_insert(head,tail,element) do { \
1816 mhd_assert (NULL == (element)->nextX); \
1817 mhd_assert (NULL == (element)->prevX); \
1818 (element)->nextX = (head); \
1819 (element)->prevX = NULL; \
1820 if (NULL == (tail)) \
1823 (head)->prevX = element; \
1824 (head) = (element); } while (0)
1836 #define XDLL_remove(head,tail,element) do { \
1837 mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \
1838 mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \
1839 if (NULL == (element)->prevX) \
1840 (head) = (element)->nextX; \
1842 (element)->prevX->nextX = (element)->nextX; \
1843 if (NULL == (element)->nextX) \
1844 (tail) = (element)->prevX; \
1846 (element)->nextX->prevX = (element)->prevX; \
1847 (element)->nextX = NULL; \
1848 (element)->prevX = NULL; } while (0)
1859 #define EDLL_insert(head,tail,element) do { \
1860 (element)->nextE = (head); \
1861 (element)->prevE = NULL; \
1862 if ((tail) == NULL) \
1865 (head)->prevE = element; \
1866 (head) = (element); } while (0)
1878 #define EDLL_remove(head,tail,element) do { \
1879 if ((element)->prevE == NULL) \
1880 (head) = (element)->nextE; \
1882 (element)->prevE->nextE = (element)->nextE; \
1883 if ((element)->nextE == NULL) \
1884 (tail) = (element)->prevE; \
1886 (element)->nextE->prevE = (element)->prevE; \
1887 (element)->nextE = NULL; \
1888 (element)->prevE = NULL; } while (0)
1941 unsigned int *num_headers);
1978 #define MHD_check_response_header_s_token_ci(r,k,tkn) \
1979 MHD_check_response_header_token_ci ((r),(k),MHD_STATICSTR_LEN_ (k), \
1980 (tkn),MHD_STATICSTR_LEN_ (tkn))
struct MHD_HTTP_Header * first_header
struct MHD_Daemon * worker_pool
unsigned int worker_pool_size
LogCallback uri_log_callback
UnescapeCallback unescape_callback
size_t(* UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri)
struct MHD_Connection * nextX
unsigned int listen_backlog_size
unsigned int connection_limit
void *(* LogCallback)(void *cls, const char *uri, struct MHD_Connection *con)
struct MHD_Connection * prev
void(* MHD_ContentReaderFreeCallback)(void *cls)
MHD_AcceptPolicyCallback apc
struct MHD_Connection * cleanup_tail
MHD_ContentReaderFreeCallback crfc
struct MHD_Connection * manual_timeout_tail
void MHD_unescape_plus(char *arg)
unsigned int connection_timeout_dummy
struct MHD_Connection * normal_timeout_tail
additional automatic macros for MHD_config.h
ssize_t(* ReceiveCallback)(struct MHD_Connection *conn, void *write_to, size_t max_bytes)
size_t write_buffer_append_offset
struct MHD_Connection * normal_timeout_head
void * notify_completed_cls
MHD_FLAG
Flags for the struct MHD_Daemon.
MHD_ContentReaderCallback crc
struct MHD_Connection * suspended_connections_tail
unsigned int reference_count
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
struct MHD_Connection * suspended_connections_head
void * per_ip_connection_count
void internal_suspend_connection_(struct MHD_Connection *connection)
TransmitCallback send_cls
MHD_RequestCompletedCallback notify_completed
bool MHD_parse_arguments_(struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
uint64_t current_chunk_size
void * notify_connection_cls
unsigned int per_ip_connection_limit
struct MHD_HTTP_Header * headers_received_tail
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
size_t read_buffer_offset
void(* MHD_NotifyConnectionCallback)(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
void * default_handler_cls
struct MHD_HTTP_Header * headers_received
uint64_t current_chunk_offset
MHD_thread_handle_ID_ pid
time_t connection_timeout
enum MHD_CONNECTION_STATE state
MHD_mutex_ cleanup_connection_mutex
enum MHD_ConnKeepAlive keepalive
int(* MHD_AccessHandlerCallback)(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls)
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
struct MHD_Connection * prevX
ssize_t(* TransmitCallback)(struct MHD_Connection *conn, const void *read_from, size_t max_bytes)
char nonce[MAX_NONCE_LENGTH]
struct MHD_Connection * manual_timeout_head
MHD_ConnectionEventLoopInfo
void * unescape_callback_cls
uint64_t response_write_position
struct MHD_Connection * cleanup_head
void(* MHD_UpgradeHandler)(void *cls, struct MHD_Connection *connection, void *con_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh)
enum MHD_ConnectionEventLoopInfo event_loop_info
bool data_already_pending
MHD_AccessHandlerCallback default_handler
MHD_mutex_ per_ip_connection_mutex
uint64_t remaining_upload_size
MHD_NotifyConnectionCallback notify_connection
struct MHD_Response * response
public interface to libmicrohttpd
Types for platform-independent inter-thread communication.
struct MHD_Daemon * daemon
volatile bool was_quiesced
MHD_thread_handle_ID_ pid
void(* MHD_LogCallback)(void *cls, const char *fm, va_list ap)
struct MHD_Connection * connections_tail
int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
unsigned int responseCode
size_t write_buffer_send_offset
struct MHD_Connection * connections_head
void * uri_log_callback_cls
bool(* MHD_ArgumentIterator_)(struct MHD_Request *request, const char *key, const char *value, enum MHD_ValueKind kind)
struct MHD_Connection * next
int(* MHD_PskServerCredentialsCallback)(void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size)
enum MHD_ResponseFlags flags
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)
int listening_address_reuse
time_t connection_timeout
struct MHD_Daemon * master
MHD_PanicCallback mhd_panic
size_t continue_message_write_offset