GNU libmicrohttpd  0.9.5
internal.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  (C) 2007, 2008, 2009, 2010 Daniel Pittman and Christian Grothoff
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
27 #ifndef INTERNAL_H
28 #define INTERNAL_H
29 
30 #include "platform.h"
31 #include "microhttpd.h"
32 #if HTTPS_SUPPORT
33 #include <gnutls/gnutls.h>
34 #endif
35 
40 #define EXTRA_CHECKS MHD_NO
41 
42 #define MHD_MAX(a,b) ((a)<(b)) ? (b) : (a)
43 #define MHD_MIN(a,b) ((a)<(b)) ? (a) : (b)
44 
50 #define MHD_BUF_INC_SIZE 2048
51 
56 
60 extern void *mhd_panic_cls;
61 
67  {
72 
77 
82  };
83 
84 
88 struct MHD_Pollfd
89 {
93  int fd;
94 
99 };
100 
101 
108 #define MAX_NONCE_LENGTH 129
109 
110 
115 struct MHD_NonceNc
116 {
117 
122  unsigned int nc;
123 
128 
129 };
130 
131 #if HAVE_MESSAGES
132 
136 void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...);
137 
138 #endif
139 
150 size_t MHD_http_unescape (void *cls,
151  struct MHD_Connection *connection,
152  char *val);
153 
158 {
163 
168  char *header;
169 
173  char *value;
174 
180 
181 };
182 
187 {
188 
195 
200  char *data;
201 
206  void *crc_cls;
207 
213 
219 
224  pthread_mutex_t mutex;
225 
229  uint64_t total_size;
230 
235  uint64_t data_start;
236 
240  off_t fd_off;
241 
245  size_t data_size;
246 
251 
256  unsigned int reference_count;
257 
261  int fd;
262 
263 };
264 
280 {
286 
291 
296 
301 
306 
311 
316 
321 
327 
333 
339 
344 
349 
355 
360 
365 
370 
375 
380 
386 
387  /*
388  * SSL/TLS connection states
389  */
390 
397 
398 };
399 
403 #define DEBUG_STATES MHD_NO
404 
405 #if HAVE_MESSAGES
406 #if DEBUG_STATES
407 const char *
408 MHD_state_to_string (enum MHD_CONNECTION_STATE state);
409 #endif
410 #endif
411 
420 typedef ssize_t (*ReceiveCallback) (struct MHD_Connection * conn,
421  void *write_to, size_t max_bytes);
422 
423 
432 typedef ssize_t (*TransmitCallback) (struct MHD_Connection * conn,
433  const void *write_to, size_t max_bytes);
434 
435 
440 {
441 
446 
451 
456 
461 
472  struct MemoryPool *pool;
473 
481 
486  char *method;
487 
492  char *url;
493 
498  char *version;
499 
506  char *read_buffer;
507 
513 
519  char *last;
520 
527  char *colon;
528 
533  struct sockaddr *addr;
534 
539  pthread_t pid;
540 
548 
554 
559 
564 
570 
576 
583 
589 
593  socklen_t addr_len;
594 
600 
607 
614 
623 
628 
633  unsigned int responseCode;
634 
643 
648 
657 
664  unsigned int current_chunk_size;
665 
670  unsigned int current_chunk_offset;
671 
675  int (*read_handler) (struct MHD_Connection * connection);
676 
680  int (*write_handler) (struct MHD_Connection * connection);
681 
685  int (*idle_handler) (struct MHD_Connection * connection);
686 
691 
696 
697 #if HTTPS_SUPPORT
698 
701  gnutls_session_t tls_session;
702 
706  int protocol;
707 
711  int cipher;
712 
713 #endif
714 };
715 
723 typedef void * (*LogCallback)(void * cls, const char * uri);
724 
734 typedef size_t (*UnescapeCallback)(void *cls,
735  struct MHD_Connection *conn,
736  char *uri);
737 
742 {
743 
748 
753 
758 
765 
769  void *apc_cls;
770 
776 
781 
790 
795 
800 
805 
806 #if HAVE_MESSAGES
807 
811  void (*custom_error_log) (void *cls, const char *fmt, va_list va);
812 
816  void *custom_error_log_cls;
817 #endif
818 
823 
828 
833 
837  size_t pool_size;
838 
843 
847  unsigned int worker_pool_size;
848 
852  pthread_t pid;
853 
857  pthread_mutex_t per_ip_connection_mutex;
858 
863 
867  int shutdown;
868 
872  unsigned int max_connections;
873 
878  unsigned int connection_timeout;
879 
885 
890 
894  uint16_t port;
895 
896 #if HTTPS_SUPPORT
897 
900  gnutls_priority_t priority_cache;
901 
906  gnutls_credentials_type_t cred_type;
907 
911  gnutls_certificate_credentials_t x509_cred;
912 
916  gnutls_dh_params_t dh_params;
917 
921  const char *https_mem_key;
922 
926  const char *https_mem_cert;
927 
931  const char *https_mem_trust;
932 
933 #endif
934 
935 #ifdef DAUTH_SUPPORT
936 
940  const char *digest_auth_random;
941 
945  struct MHD_NonceNc *nnc;
946 
950  pthread_mutex_t nnc_lock;
951 
955  unsigned int digest_auth_rand_size;
956 
960  unsigned int nonce_nc_size;
961 
962 #endif
963 
964 };
965 
966 
967 #if EXTRA_CHECKS
968 #define EXTRA_CHECK(a) if (!(a)) abort();
969 #else
970 #define EXTRA_CHECK(a)
971 #endif
972 
973 
974 
975 #endif