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); BUILTIN_NOT_REACHED; } while (0) 65 #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); BUILTIN_NOT_REACHED; } while (0) 78 #define MHD_fd_close_chk_(fd) do { \ 79 if (0 == close ((fd)) && (EBADF == errno)) \ 80 MHD_PANIC(_("Failed to close FD.\n")); \ 87 #define EXTRA_CHECKS MHD_NO 89 #define MHD_MAX(a,b) (((a)<(b)) ? (b) : (a)) 90 #define MHD_MIN(a,b) (((a)<(b)) ? (a) : (b)) 100 #define MHD_BUF_INC_SIZE 1024 114 #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) 115 #define BUILTIN_NOT_REACHED __builtin_unreachable() 116 #elif defined(_MSC_FULL_VER) 117 #define BUILTIN_NOT_REACHED __assume(0) 119 #define BUILTIN_NOT_REACHED 122 #ifndef MHD_STATICSTR_LEN_ 126 #define MHD_STATICSTR_LEN_(macro) (sizeof(macro)/sizeof(char) - 1) 207 #define MHD_TEST_ALLOW_SUSPEND_RESUME 8192 215 #define MAX_NONCE_LENGTH 129 322 #ifdef UPGRADE_SUPPORT 333 void *upgrade_handler_cls;
515 #ifdef UPGRADE_SUPPORT 520 MHD_CONNECTION_UPGRADE
546 #define DEBUG_STATES MHD_NO 580 const void *read_from,
758 MHD_thread_handle_ID_
pid;
809 #if defined(_MHD_HAVE_SENDFILE) 810 enum MHD_resp_sender_
812 MHD_resp_sender_std = 0,
813 MHD_resp_sender_sendfile
945 #ifdef UPGRADE_SUPPORT 952 struct MHD_UpgradeResponseHandle *urh;
960 gnutls_session_t tls_session;
1001 #ifdef UPGRADE_SUPPORT 1011 #define RESERVE_EBUF_SIZE 8 1019 struct UpgradeEpollHandle
1025 struct MHD_UpgradeResponseHandle *urh;
1057 struct MHD_UpgradeResponseHandle
1066 #ifdef HTTPS_SUPPORT 1070 struct MHD_UpgradeResponseHandle *next;
1075 struct MHD_UpgradeResponseHandle *prev;
1077 #ifdef EPOLL_SUPPORT 1081 struct MHD_UpgradeResponseHandle *nextE;
1086 struct MHD_UpgradeResponseHandle *prevE;
1091 bool in_eready_list;
1113 size_t in_buffer_size;
1120 size_t out_buffer_size;
1129 size_t in_buffer_used;
1138 size_t out_buffer_used;
1143 struct UpgradeEpollHandle app;
1149 struct UpgradeEpollHandle mhd;
1155 char e_buf[RESERVE_EBUF_SIZE];
1169 volatile bool was_closed;
1206 (*LogCallback)(
void *cls,
1275 #ifdef EPOLL_SUPPORT 1286 #ifdef UPGRADE_SUPPORT 1290 struct MHD_UpgradeResponseHandle *eready_urh_head;
1295 struct MHD_UpgradeResponseHandle *eready_urh_tail;
1394 #ifdef HAVE_MESSAGES 1399 void (*custom_error_log) (
void *cls,
const char *fmt, va_list va);
1404 void *custom_error_log_cls;
1474 #ifdef EPOLL_SUPPORT 1484 bool listen_socket_in_epoll;
1486 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 1491 int epoll_upgrade_fd;
1497 bool upgrade_fd_in_epoll;
1581 #ifdef HTTPS_SUPPORT 1582 #ifdef UPGRADE_SUPPORT 1588 struct MHD_UpgradeResponseHandle *urh_head;
1595 struct MHD_UpgradeResponseHandle *urh_tail;
1601 gnutls_priority_t priority_cache;
1607 gnutls_credentials_type_t cred_type;
1612 gnutls_certificate_credentials_t x509_cred;
1617 gnutls_dh_params_t dh_params;
1619 #if GNUTLS_VERSION_MAJOR >= 3 1624 gnutls_certificate_retrieve_function2 *cert_callback;
1630 const char *https_mem_key;
1635 const char *https_mem_cert;
1640 const char *https_key_password;
1645 const char *https_mem_trust;
1650 gnutls_dh_params_t https_mem_dhparams;
1659 #ifdef DAUTH_SUPPORT 1664 const char *digest_auth_random;
1674 MHD_mutex_ nnc_lock;
1679 size_t digest_auth_rand_size;
1684 unsigned int nonce_nc_size;
1692 unsigned int fastopen_queue_size;
1710 #define DLL_insert(head,tail,element) do { \ 1711 mhd_assert (NULL == (element)->next); \ 1712 mhd_assert (NULL == (element)->prev); \ 1713 (element)->next = (head); \ 1714 (element)->prev = NULL; \ 1715 if ((tail) == NULL) \ 1718 (head)->prev = element; \ 1719 (head) = (element); } while (0) 1731 #define DLL_remove(head,tail,element) do { \ 1732 mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ 1733 mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ 1734 if ((element)->prev == NULL) \ 1735 (head) = (element)->next; \ 1737 (element)->prev->next = (element)->next; \ 1738 if ((element)->next == NULL) \ 1739 (tail) = (element)->prev; \ 1741 (element)->next->prev = (element)->prev; \ 1742 (element)->next = NULL; \ 1743 (element)->prev = NULL; } while (0) 1755 #define XDLL_insert(head,tail,element) do { \ 1756 mhd_assert (NULL == (element)->nextX); \ 1757 mhd_assert (NULL == (element)->prevX); \ 1758 (element)->nextX = (head); \ 1759 (element)->prevX = NULL; \ 1760 if (NULL == (tail)) \ 1763 (head)->prevX = element; \ 1764 (head) = (element); } while (0) 1776 #define XDLL_remove(head,tail,element) do { \ 1777 mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ 1778 mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ 1779 if (NULL == (element)->prevX) \ 1780 (head) = (element)->nextX; \ 1782 (element)->prevX->nextX = (element)->nextX; \ 1783 if (NULL == (element)->nextX) \ 1784 (tail) = (element)->prevX; \ 1786 (element)->nextX->prevX = (element)->prevX; \ 1787 (element)->nextX = NULL; \ 1788 (element)->prevX = NULL; } while (0) 1799 #define EDLL_insert(head,tail,element) do { \ 1800 (element)->nextE = (head); \ 1801 (element)->prevE = NULL; \ 1802 if ((tail) == NULL) \ 1805 (head)->prevE = element; \ 1806 (head) = (element); } while (0) 1818 #define EDLL_remove(head,tail,element) do { \ 1819 if ((element)->prevE == NULL) \ 1820 (head) = (element)->nextE; \ 1822 (element)->prevE->nextE = (element)->nextE; \ 1823 if ((element)->nextE == NULL) \ 1824 (tail) = (element)->prevE; \ 1826 (element)->nextE->prevE = (element)->prevE; \ 1827 (element)->nextE = NULL; \ 1828 (element)->prevE = NULL; } while (0) 1877 unsigned int *num_headers);
1910 #define MHD_check_response_header_s_token_ci(r,k,tkn) \ 1911 MHD_check_response_header_token_ci((r),(k),(tkn),MHD_STATICSTR_LEN_(tkn))
unsigned int per_ip_connection_limit
void * unescape_callback_cls
additional automatic macros for MHD_config.h
bool MHD_check_response_header_token_ci(const struct MHD_Response *response, const char *key, const char *token, size_t token_len)
uint64_t current_chunk_offset
void internal_suspend_connection_(struct MHD_Connection *connection)
bool data_already_pending
size_t(* UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri)
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
MHD_thread_handle_ID_ pid
time_t connection_timeout
MHD_ContentReaderFreeCallback crfc
void(* MHD_ContentReaderFreeCallback)(void *cls)
struct MHD_Response * response
struct MHD_Connection * normal_timeout_tail
volatile bool was_quiesced
MHD_thread_handle_ID_ pid
struct MHD_HTTP_Header * first_header
MHD_AccessHandlerCallback default_handler
uint64_t remaining_upload_size
unsigned int responseCode
void * uri_log_callback_cls
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
struct MHD_Daemon * daemon
int listening_address_reuse
MHD_mutex_ per_ip_connection_mutex
struct MHD_Connection * manual_timeout_head
MHD_NotifyConnectionCallback notify_connection
struct MHD_Connection * cleanup_head
MHD_PanicCallback mhd_panic
struct MHD_Connection * cleanup_tail
struct MHD_Connection * prev
size_t write_buffer_send_offset
struct MHD_Daemon * worker_pool
struct MHD_Connection * nextX
struct MHD_Connection * manual_timeout_tail
size_t continue_message_write_offset
unsigned int connection_limit
char nonce[MAX_NONCE_LENGTH]
unsigned int worker_pool_size
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
struct MHD_Connection * normal_timeout_head
Header for platform-independent threads abstraction.
UnescapeCallback unescape_callback
ssize_t(* TransmitCallback)(struct MHD_Connection *conn, const void *read_from, size_t max_bytes)
unsigned int listen_backlog_size
unsigned int connection_timeout_dummy
struct MHD_Connection * connections_head
struct MHD_Daemon * master
struct MHD_Connection * next
MHD_AcceptPolicyCallback apc
void *(* LogCallback)(void *cls, const char *uri, struct MHD_Connection *con)
int(* MHD_ArgumentIterator_)(struct MHD_Connection *connection, const char *key, const char *value, enum MHD_ValueKind kind)
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
MHD_RequestCompletedCallback notify_completed
struct MHD_Connection * prevX
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
void * notify_connection_cls
MHD_ContentReaderCallback crc
Types for platform-independent inter-thread communication.
void MHD_unescape_plus(char *arg)
struct MHD_Connection * suspended_connections_tail
int MHD_parse_arguments_(struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
void * per_ip_connection_count
size_t read_buffer_offset
void * default_handler_cls
MHD_ConnectionEventLoopInfo
MHD_mutex_ cleanup_connection_mutex
uint64_t current_chunk_size
Header for platform-independent locks abstraction.
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
struct MHD_Connection * connections_tail
MHD_FLAG
Flags for the struct MHD_Daemon.
struct MHD_HTTP_Header * headers_received_tail
struct MHD_Connection * suspended_connections_head