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 337 #ifdef UPGRADE_SUPPORT 348 void *upgrade_handler_cls;
351 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 527 #ifdef UPGRADE_SUPPORT 532 MHD_CONNECTION_UPGRADE
558 #define DEBUG_STATES MHD_NO 592 const void *read_from,
688 struct MemoryPool *
pool;
767 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 772 MHD_thread_handle_ID_
pid;
824 #if defined(_MHD_HAVE_SENDFILE) 825 enum MHD_resp_sender_
827 MHD_resp_sender_std = 0,
828 MHD_resp_sender_sendfile
893 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 968 #ifdef UPGRADE_SUPPORT 975 struct MHD_UpgradeResponseHandle *urh;
983 gnutls_session_t tls_session;
1024 #ifdef UPGRADE_SUPPORT 1034 #define RESERVE_EBUF_SIZE 8 1042 struct UpgradeEpollHandle
1048 struct MHD_UpgradeResponseHandle *urh;
1080 struct MHD_UpgradeResponseHandle
1089 #ifdef HTTPS_SUPPORT 1093 struct MHD_UpgradeResponseHandle *next;
1098 struct MHD_UpgradeResponseHandle *prev;
1100 #ifdef EPOLL_SUPPORT 1104 struct MHD_UpgradeResponseHandle *nextE;
1109 struct MHD_UpgradeResponseHandle *prevE;
1114 bool in_eready_list;
1136 size_t in_buffer_size;
1143 size_t out_buffer_size;
1152 size_t in_buffer_used;
1161 size_t out_buffer_used;
1166 struct UpgradeEpollHandle app;
1172 struct UpgradeEpollHandle mhd;
1178 char e_buf[RESERVE_EBUF_SIZE];
1192 volatile bool was_closed;
1229 (*LogCallback)(
void *cls,
1298 #ifdef EPOLL_SUPPORT 1309 #ifdef UPGRADE_SUPPORT 1313 struct MHD_UpgradeResponseHandle *eready_urh_head;
1318 struct MHD_UpgradeResponseHandle *eready_urh_tail;
1417 #ifdef HAVE_MESSAGES 1427 void *custom_error_log_cls;
1435 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 1457 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 1461 size_t thread_stack_size;
1477 MHD_thread_handle_ID_
pid;
1507 #ifdef EPOLL_SUPPORT 1517 bool listen_socket_in_epoll;
1519 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 1524 int epoll_upgrade_fd;
1530 bool upgrade_fd_in_epoll;
1539 struct MHD_itc_
itc;
1615 #ifdef HTTPS_SUPPORT 1616 #ifdef UPGRADE_SUPPORT 1622 struct MHD_UpgradeResponseHandle *urh_head;
1629 struct MHD_UpgradeResponseHandle *urh_tail;
1635 gnutls_priority_t priority_cache;
1641 gnutls_credentials_type_t cred_type;
1646 gnutls_certificate_credentials_t x509_cred;
1651 gnutls_dh_params_t dh_params;
1656 gnutls_psk_server_credentials_t psk_cred;
1658 #if GNUTLS_VERSION_MAJOR >= 3 1663 gnutls_certificate_retrieve_function2 *cert_callback;
1673 void *cred_callback_cls;
1676 #if GNUTLS_VERSION_NUMBER >= 0x030603 1681 gnutls_certificate_retrieve_function3 *cert_callback2;
1687 const char *https_mem_key;
1692 const char *https_mem_cert;
1697 const char *https_key_password;
1702 const char *https_mem_trust;
1707 gnutls_dh_params_t https_mem_dhparams;
1716 #ifdef DAUTH_SUPPORT 1721 const char *digest_auth_random;
1728 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 1732 MHD_mutex_ nnc_lock;
1738 size_t digest_auth_rand_size;
1743 unsigned int nonce_nc_size;
1751 unsigned int fastopen_queue_size;
1769 #define DLL_insert(head,tail,element) do { \ 1770 mhd_assert (NULL == (element)->next); \ 1771 mhd_assert (NULL == (element)->prev); \ 1772 (element)->next = (head); \ 1773 (element)->prev = NULL; \ 1774 if ((tail) == NULL) \ 1777 (head)->prev = element; \ 1778 (head) = (element); } while (0) 1790 #define DLL_remove(head,tail,element) do { \ 1791 mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ 1792 mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ 1793 if ((element)->prev == NULL) \ 1794 (head) = (element)->next; \ 1796 (element)->prev->next = (element)->next; \ 1797 if ((element)->next == NULL) \ 1798 (tail) = (element)->prev; \ 1800 (element)->next->prev = (element)->prev; \ 1801 (element)->next = NULL; \ 1802 (element)->prev = NULL; } while (0) 1814 #define XDLL_insert(head,tail,element) do { \ 1815 mhd_assert (NULL == (element)->nextX); \ 1816 mhd_assert (NULL == (element)->prevX); \ 1817 (element)->nextX = (head); \ 1818 (element)->prevX = NULL; \ 1819 if (NULL == (tail)) \ 1822 (head)->prevX = element; \ 1823 (head) = (element); } while (0) 1835 #define XDLL_remove(head,tail,element) do { \ 1836 mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ 1837 mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ 1838 if (NULL == (element)->prevX) \ 1839 (head) = (element)->nextX; \ 1841 (element)->prevX->nextX = (element)->nextX; \ 1842 if (NULL == (element)->nextX) \ 1843 (tail) = (element)->prevX; \ 1845 (element)->nextX->prevX = (element)->prevX; \ 1846 (element)->nextX = NULL; \ 1847 (element)->prevX = NULL; } while (0) 1858 #define EDLL_insert(head,tail,element) do { \ 1859 (element)->nextE = (head); \ 1860 (element)->prevE = NULL; \ 1861 if ((tail) == NULL) \ 1864 (head)->prevE = element; \ 1865 (head) = (element); } while (0) 1877 #define EDLL_remove(head,tail,element) do { \ 1878 if ((element)->prevE == NULL) \ 1879 (head) = (element)->nextE; \ 1881 (element)->prevE->nextE = (element)->nextE; \ 1882 if ((element)->nextE == NULL) \ 1883 (tail) = (element)->prevE; \ 1885 (element)->nextE->prevE = (element)->prevE; \ 1886 (element)->nextE = NULL; \ 1887 (element)->prevE = NULL; } while (0) 1940 unsigned int *num_headers);
1977 #define MHD_check_response_header_s_token_ci(r,k,tkn) \ 1978 MHD_check_response_header_token_ci ((r),(k),MHD_STATICSTR_LEN_ (k), \ 1979 (tkn),MHD_STATICSTR_LEN_ (tkn))
unsigned int per_ip_connection_limit
void * unescape_callback_cls
additional automatic macros for MHD_config.h
uint64_t current_chunk_offset
bool data_already_pending
int(* MHD_PskServerCredentialsCallback)(void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size)
struct MHD_Connection * cleanup_head
enum MHD_CONNECTION_STATE state
uint64_t response_write_position
public interface to libmicrohttpd
enum MHD_ConnKeepAlive keepalive
ssize_t(* ReceiveCallback)(struct MHD_Connection *conn, void *write_to, size_t max_bytes)
enum MHD_ConnectionEventLoopInfo event_loop_info
struct MHD_Connection * prevX
MHD_thread_handle_ID_ pid
time_t connection_timeout
MHD_ContentReaderFreeCallback crfc
MHD_PanicCallback mhd_panic
void(* MHD_ContentReaderFreeCallback)(void *cls)
struct MHD_Response * response
volatile bool was_quiesced
struct MHD_Connection * manual_timeout_head
void *(* LogCallback)(void *cls, const char *uri, struct MHD_Connection *con)
MHD_thread_handle_ID_ pid
MHD_AccessHandlerCallback default_handler
uint64_t remaining_upload_size
unsigned int responseCode
void * uri_log_callback_cls
struct MHD_Daemon * daemon
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
Types for platform-independent inter-thread communication.
void(* MHD_LogCallback)(void *cls, const char *fm, va_list ap)
int listening_address_reuse
MHD_mutex_ per_ip_connection_mutex
MHD_NotifyConnectionCallback notify_connection
struct MHD_Connection * next
struct MHD_HTTP_Header * first_header
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)
size_t write_buffer_send_offset
struct MHD_Connection * connections_tail
struct MHD_Daemon * worker_pool
size_t continue_message_write_offset
bool MHD_parse_arguments_(struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
unsigned int connection_limit
char nonce[MAX_NONCE_LENGTH]
unsigned int worker_pool_size
struct MHD_Connection * connections_head
void internal_suspend_connection_(struct MHD_Connection *connection)
LogCallback uri_log_callback
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
unsigned int reference_count
time_t connection_timeout
ssize_t(* TransmitCallback)(struct MHD_Connection *conn, const void *read_from, size_t max_bytes)
struct MHD_Daemon * master
struct MHD_Connection * manual_timeout_tail
struct MHD_Connection * prev
struct MHD_Connection * normal_timeout_head
struct MHD_Connection * nextX
UnescapeCallback unescape_callback
unsigned int listen_backlog_size
unsigned int connection_timeout_dummy
struct MHD_Connection * suspended_connections_tail
MHD_AcceptPolicyCallback apc
struct MHD_Connection * cleanup_tail
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)
enum MHD_ResponseFlags flags
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
size_t write_buffer_append_offset
struct MHD_Connection * normal_timeout_tail
MHD_RequestCompletedCallback notify_completed
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)
void * notify_completed_cls
TransmitCallback send_cls
bool(* MHD_ArgumentIterator_)(struct MHD_Request *request, const char *key, const char *value, enum MHD_ValueKind kind)
size_t(* UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri)
void * notify_connection_cls
MHD_ContentReaderCallback crc
MHD_ConnectionEventLoopInfo
struct MHD_Connection * suspended_connections_head
void * per_ip_connection_count
size_t read_buffer_offset
void * default_handler_cls
MHD_mutex_ cleanup_connection_mutex
uint64_t current_chunk_size
int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
void(* MHD_NotifyConnectionCallback)(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
struct MHD_HTTP_Header * headers_received
MHD_FLAG
Flags for the struct MHD_Daemon.
struct MHD_HTTP_Header * headers_received_tail
void MHD_unescape_plus(char *arg)