GNU libmicrohttpd  0.9.29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
internal.h File Reference

internal shared structures More...

#include "platform.h"
#include "microhttpd.h"
#include "platform_interface.h"
Include dependency graph for internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MHD_NonceNc
 
struct  MHD_HTTP_Header
 
struct  MHD_Response
 
struct  MHD_Connection
 
struct  MHD_Daemon
 

Macros

#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 MHD_PANIC(msg)   do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); BUILTIN_NOT_REACHED; } while (0)
 
#define MAX_NONCE_LENGTH   129
 
#define DEBUG_STATES   MHD_NO
 
#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)
 

Enumerations

enum  MHD_EpollState {
  MHD_EPOLL_STATE_UNREADY = 0, MHD_EPOLL_STATE_READ_READY = 1, MHD_EPOLL_STATE_WRITE_READY = 2, MHD_EPOLL_STATE_IN_EREADY_EDLL = 4,
  MHD_EPOLL_STATE_IN_EPOLL_SET = 8, MHD_EPOLL_STATE_SUSPENDED = 16
}
 
enum  MHD_ConnectionEventLoopInfo { MHD_EVENT_LOOP_INFO_READ = 0, MHD_EVENT_LOOP_INFO_WRITE = 1, MHD_EVENT_LOOP_INFO_BLOCK = 2, MHD_EVENT_LOOP_INFO_CLEANUP = 3 }
 
enum  MHD_CONNECTION_STATE {
  MHD_CONNECTION_INIT = 0, MHD_CONNECTION_URL_RECEIVED = MHD_CONNECTION_INIT + 1, MHD_CONNECTION_HEADER_PART_RECEIVED = MHD_CONNECTION_URL_RECEIVED + 1, MHD_CONNECTION_HEADERS_RECEIVED = MHD_CONNECTION_HEADER_PART_RECEIVED + 1,
  MHD_CONNECTION_HEADERS_PROCESSED = MHD_CONNECTION_HEADERS_RECEIVED + 1, MHD_CONNECTION_CONTINUE_SENDING = MHD_CONNECTION_HEADERS_PROCESSED + 1, MHD_CONNECTION_CONTINUE_SENT = MHD_CONNECTION_CONTINUE_SENDING + 1, MHD_CONNECTION_BODY_RECEIVED = MHD_CONNECTION_CONTINUE_SENT + 1,
  MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1, MHD_CONNECTION_FOOTERS_RECEIVED = MHD_CONNECTION_FOOTER_PART_RECEIVED + 1, MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_FOOTERS_RECEIVED + 1, MHD_CONNECTION_HEADERS_SENT = MHD_CONNECTION_HEADERS_SENDING + 1,
  MHD_CONNECTION_NORMAL_BODY_READY = MHD_CONNECTION_HEADERS_SENT + 1, MHD_CONNECTION_NORMAL_BODY_UNREADY = MHD_CONNECTION_NORMAL_BODY_READY + 1, MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_NORMAL_BODY_UNREADY + 1, MHD_CONNECTION_CHUNKED_BODY_UNREADY = MHD_CONNECTION_CHUNKED_BODY_READY + 1,
  MHD_CONNECTION_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1, MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1, MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1,
  MHD_CONNECTION_IN_CLEANUP = MHD_CONNECTION_CLOSED + 1, MHD_TLS_CONNECTION_INIT = MHD_CONNECTION_IN_CLEANUP + 1
}
 

Functions

time_t MHD_monotonic_time (void)
 
void MHD_unescape_plus (char *arg)
 

Variables

MHD_PanicCallback mhd_panic
 
void * mhd_panic_cls
 

Detailed Description

internal shared structures

Author
Daniel Pittman
Christian Grothoff

Definition in file internal.h.

Macro Definition Documentation

#define BUILTIN_NOT_REACHED

Definition at line 82 of file internal.h.

#define DEBUG_STATES   MHD_NO

Should all state transitions be printed to stderr?

Definition at line 472 of file internal.h.

#define DLL_insert (   head,
  tail,
  element 
)
Value:
do { \
EXTRA_CHECK (NULL == (element)->next); \
EXTRA_CHECK (NULL == (element)->prev); \
(element)->next = (head); \
(element)->prev = NULL; \
if ((tail) == NULL) \
(tail) = element; \
else \
(head)->prev = element; \
(head) = (element); } while (0)
#define NULL
Definition: reason_phrase.c:31
#define EXTRA_CHECK(a)
Definition: internal.h:1273

Insert an element at the head of a DLL. Assumes that head, tail and element are structs with prev and next fields.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to insert

Definition at line 1285 of file internal.h.

Referenced by cleanup_connection(), close_connection(), internal_add_connection(), MHD_suspend_connection(), resume_suspended_connections(), SPDYF_session_accept(), SPDYF_session_close(), and SPDYF_stream_new().

#define DLL_remove (   head,
  tail,
  element 
)
Value:
do { \
EXTRA_CHECK ( (NULL != (element)->next) || ((element) == (tail))); \
EXTRA_CHECK ( (NULL != (element)->prev) || ((element) == (head))); \
if ((element)->prev == NULL) \
(head) = (element)->next; \
else \
(element)->prev->next = (element)->next; \
if ((element)->next == NULL) \
(tail) = (element)->prev; \
else \
(element)->next->prev = (element)->prev; \
(element)->next = NULL; \
(element)->prev = NULL; } while (0)
#define NULL
Definition: reason_phrase.c:31
#define EXTRA_CHECK(a)
Definition: internal.h:1273

Remove an element from a DLL. Assumes that head, tail and element are structs with prev and next fields.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to remove

Definition at line 1306 of file internal.h.

Referenced by cleanup_connection(), close_connection(), internal_add_connection(), MHD_cleanup_connections(), MHD_suspend_connection(), resume_suspended_connections(), spdyf_cleanup_sessions(), SPDYF_session_close(), SPDYF_session_destroy(), and SPDYF_session_write().

#define EDLL_insert (   head,
  tail,
  element 
)
Value:
do { \
(element)->nextE = (head); \
(element)->prevE = NULL; \
if ((tail) == NULL) \
(tail) = element; \
else \
(head)->prevE = element; \
(head) = (element); } while (0)
#define NULL
Definition: reason_phrase.c:31

Insert an element at the head of a EDLL. Assumes that head, tail and element are structs with prevE and nextE fields.

Parameters
headpointer to the head of the EDLL
tailpointer to the tail of the EDLL
elementelement to insert

Definition at line 1374 of file internal.h.

Referenced by internal_add_connection(), MHD_connection_handle_idle(), and resume_suspended_connections().

#define EDLL_remove (   head,
  tail,
  element 
)
Value:
do { \
if ((element)->prevE == NULL) \
(head) = (element)->nextE; \
else \
(element)->prevE->nextE = (element)->nextE; \
if ((element)->nextE == NULL) \
(tail) = (element)->prevE; \
else \
(element)->nextE->prevE = (element)->prevE; \
(element)->nextE = NULL; \
(element)->prevE = NULL; } while (0)
#define NULL
Definition: reason_phrase.c:31

Remove an element from a EDLL. Assumes that head, tail and element are structs with prevE and nextE fields.

Parameters
headpointer to the head of the EDLL
tailpointer to the tail of the EDLL
elementelement to remove

Definition at line 1393 of file internal.h.

Referenced by MHD_cleanup_connections(), and MHD_suspend_connection().

#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 52 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 177 of file internal.h.

Referenced by 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 65 of file internal.h.

Referenced by MHD_start_daemon_va(), and try_grow_read_buffer().

#define MHD_MAX (   a,
 
)    ((a)<(b)) ? (b) : (a)

Definition at line 54 of file internal.h.

#define MHD_MIN (   a,
 
)    ((a)<(b)) ? (a) : (b)

Definition at line 55 of file internal.h.

Referenced by try_ready_normal_body().

#define XDLL_insert (   head,
  tail,
  element 
)
Value:
do { \
EXTRA_CHECK (NULL == (element)->nextX); \
EXTRA_CHECK (NULL == (element)->prevX); \
(element)->nextX = (head); \
(element)->prevX = NULL; \
if (NULL == (tail)) \
(tail) = element; \
else \
(head)->prevX = element; \
(head) = (element); } while (0)
#define NULL
Definition: reason_phrase.c:31
#define EXTRA_CHECK(a)
Definition: internal.h:1273

Insert an element at the head of a XDLL. Assumes that head, tail and element are structs with prevX and nextX fields.

Parameters
headpointer to the head of the XDLL
tailpointer to the tail of the XDLL
elementelement to insert

Definition at line 1330 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 
)
Value:
do { \
EXTRA_CHECK ( (NULL != (element)->nextX) || ((element) == (tail))); \
EXTRA_CHECK ( (NULL != (element)->prevX) || ((element) == (head))); \
if (NULL == (element)->prevX) \
(head) = (element)->nextX; \
else \
(element)->prevX->nextX = (element)->nextX; \
if (NULL == (element)->nextX) \
(tail) = (element)->prevX; \
else \
(element)->nextX->prevX = (element)->prevX; \
(element)->nextX = NULL; \
(element)->prevX = NULL; } while (0)
#define NULL
Definition: reason_phrase.c:31
#define EXTRA_CHECK(a)
Definition: internal.h:1273

Remove an element from a XDLL. Assumes that head, tail and element are structs with prevX and nextX fields.

Parameters
headpointer to the head of the XDLL
tailpointer to the tail of the XDLL
elementelement to remove

Definition at line 1351 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 Documentation

typedef void*(* LogCallback)(void *cls, const char *uri, struct MHD_Connection *con)

Signature of function called to log URI accesses.

Parameters
clsclosure
uriuri being accessed
conconnection handle
Returns
new closure

Definition at line 867 of file internal.h.

typedef ssize_t(* ReceiveCallback)(struct MHD_Connection *conn, void *write_to, size_t max_bytes)

Function to receive plaintext data.

Parameters
connthe connection struct
write_towhere to write received data
max_bytesmaximum number of bytes to receive
Returns
number of bytes written to write_to

Definition at line 490 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.

Parameters
connthe connection struct
read_fromwhere to read data to transmit
max_bytesmaximum number of bytes to transmit
Returns
number of bytes transmitted

Definition at line 502 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().

Parameters
clsclosure
connconnection handle
uri0-terminated string to unescape (should be updated)
Returns
length of the resulting string

Definition at line 880 of file internal.h.

Enumeration Type Documentation

States in a state machine for a connection.

Transitions are any-state to CLOSED, any state to state+1, FOOTERS_SENT to INIT. CLOSED is the terminal state and 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 CLOSED or INIT requires the write to be complete.

Enumerator
MHD_CONNECTION_INIT 

Connection just started (no headers received). Waiting for the line with the request type, URL and version.

MHD_CONNECTION_URL_RECEIVED 

1: We got the URL (and request type and version). Wait for a header line.

MHD_CONNECTION_HEADER_PART_RECEIVED 

2: We got part of a multi-line request header. Wait for the rest.

MHD_CONNECTION_HEADERS_RECEIVED 

3: We got the request headers. Process them.

MHD_CONNECTION_HEADERS_PROCESSED 

4: We have processed the request headers. Send 100 continue.

MHD_CONNECTION_CONTINUE_SENDING 

5: We have processed the headers and need to send 100 CONTINUE.

MHD_CONNECTION_CONTINUE_SENT 

6: We have sent 100 CONTINUE (or do not need to). Read the message body.

MHD_CONNECTION_BODY_RECEIVED 

7: We got the request body. Wait for a line of the footer.

MHD_CONNECTION_FOOTER_PART_RECEIVED 

8: We got part of a line of the footer. Wait for the rest.

MHD_CONNECTION_FOOTERS_RECEIVED 

9: We received the entire footer. Wait for a response to be queued and prepare the response headers.

MHD_CONNECTION_HEADERS_SENDING 

10: We have prepared the response headers in the writ buffer. Send the response headers.

MHD_CONNECTION_HEADERS_SENT 

11: We have sent the response headers. Get ready to send the body.

MHD_CONNECTION_NORMAL_BODY_READY 

12: We are ready to send a part of a non-chunked body. Send it.

MHD_CONNECTION_NORMAL_BODY_UNREADY 

13: We are waiting for the client to provide more data of a non-chunked body.

MHD_CONNECTION_CHUNKED_BODY_READY 

14: We are ready to send a chunk.

MHD_CONNECTION_CHUNKED_BODY_UNREADY 

15: We are waiting for the client to provide a chunk of the body.

MHD_CONNECTION_BODY_SENT 

16: We have sent the response body. Prepare the footers.

MHD_CONNECTION_FOOTERS_SENDING 

17: We have prepared the response footer. Send it.

MHD_CONNECTION_FOOTERS_SENT 

18: We have sent the response footer. Shutdown or restart.

MHD_CONNECTION_CLOSED 

19: This connection is to be closed.

MHD_CONNECTION_IN_CLEANUP 

20: This connection is finished (only to be freed)

MHD_TLS_CONNECTION_INIT 

The initial connection state for all secure connectoins Handshake messages will be processed in this state & while in the 'MHD_TLS_HELLO_REQUEST' state

Definition at line 344 of file internal.h.

What is this connection waiting for?

Enumerator
MHD_EVENT_LOOP_INFO_READ 

We are waiting to be able to read.

MHD_EVENT_LOOP_INFO_WRITE 

We are waiting to be able to write.

MHD_EVENT_LOOP_INFO_BLOCK 

We are waiting for the application to provide data.

MHD_EVENT_LOOP_INFO_CLEANUP 

We are finished and are awaiting cleanup.

Definition at line 147 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?

Definition at line 106 of file internal.h.

Function Documentation

time_t MHD_monotonic_time ( void  )

Equivalent to time(NULL) but tries to use some sort of monotonic clock that isn't affected by someone setting the system real time clock.

Returns
'current' time

Equivalent to time(NULL) but tries to use some sort of monotonic clock that isn't affected by someone setting the system real time clock.

Returns
'current' time

Definition at line 182 of file internal.c.

References NULL.

Referenced by internal_add_connection(), MHD_connection_handle_idle(), MHD_digest_auth_check(), MHD_get_timeout(), MHD_handle_connection(), MHD_queue_auth_fail_response(), MHD_tls_connection_handle_idle(), run_tls_handshake(), and update_last_activity().

Here is the caller graph for this function:

void MHD_unescape_plus ( char *  arg)

Convert all occurences of '+' to ' '.

Parameters
argstring that is modified (in place), must be 0-terminated

Definition at line 113 of file internal.c.

References NULL.

Referenced by parse_arguments(), and post_process_urlencoded().

Here is the caller graph for this function:

Variable Documentation

void* mhd_panic_cls