GNU libmicrohttpd
0.9.5
Main Page
Data Structures
Files
File List
Globals
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
55
extern
MHD_PanicCallback
mhd_panic
;
56
60
extern
void
*
mhd_panic_cls
;
61
66
enum
MHD_PollActions
67
{
71
MHD_POLL_ACTION_NOTHING
= 0,
72
76
MHD_POLL_ACTION_IN
= 1,
77
81
MHD_POLL_ACTION_OUT
= 2
82
};
83
84
88
struct
MHD_Pollfd
89
{
93
int
fd
;
94
98
enum
MHD_PollActions
events
;
99
};
100
101
108
#define MAX_NONCE_LENGTH 129
109
110
115
struct
MHD_NonceNc
116
{
117
122
unsigned
int
nc
;
123
127
char
nonce
[
MAX_NONCE_LENGTH
];
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
157
struct
MHD_HTTP_Header
158
{
162
struct
MHD_HTTP_Header
*
next
;
163
168
char
*
header
;
169
173
char
*
value
;
174
179
enum
MHD_ValueKind
kind
;
180
181
};
182
186
struct
MHD_Response
187
{
188
194
struct
MHD_HTTP_Header
*
first_header
;
195
200
char
*
data
;
201
206
void
*
crc_cls
;
207
212
MHD_ContentReaderCallback
crc
;
213
218
MHD_ContentReaderFreeCallback
crfc
;
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
250
size_t
data_buffer_size
;
251
256
unsigned
int
reference_count
;
257
261
int
fd
;
262
263
};
264
279
enum
MHD_CONNECTION_STATE
280
{
285
MHD_CONNECTION_INIT
= 0,
286
290
MHD_CONNECTION_URL_RECEIVED
=
MHD_CONNECTION_INIT
+ 1,
291
295
MHD_CONNECTION_HEADER_PART_RECEIVED
=
MHD_CONNECTION_URL_RECEIVED
+ 1,
296
300
MHD_CONNECTION_HEADERS_RECEIVED
=
MHD_CONNECTION_HEADER_PART_RECEIVED
+ 1,
301
305
MHD_CONNECTION_HEADERS_PROCESSED
=
MHD_CONNECTION_HEADERS_RECEIVED
+ 1,
306
310
MHD_CONNECTION_CONTINUE_SENDING
=
MHD_CONNECTION_HEADERS_PROCESSED
+ 1,
311
315
MHD_CONNECTION_CONTINUE_SENT
=
MHD_CONNECTION_CONTINUE_SENDING
+ 1,
316
320
MHD_CONNECTION_BODY_RECEIVED
=
MHD_CONNECTION_CONTINUE_SENT
+ 1,
321
326
MHD_CONNECTION_FOOTER_PART_RECEIVED
=
MHD_CONNECTION_BODY_RECEIVED
+ 1,
327
332
MHD_CONNECTION_FOOTERS_RECEIVED
=
MHD_CONNECTION_FOOTER_PART_RECEIVED
+ 1,
333
338
MHD_CONNECTION_HEADERS_SENDING
=
MHD_CONNECTION_FOOTERS_RECEIVED
+ 1,
339
343
MHD_CONNECTION_HEADERS_SENT
=
MHD_CONNECTION_HEADERS_SENDING
+ 1,
344
348
MHD_CONNECTION_NORMAL_BODY_READY
=
MHD_CONNECTION_HEADERS_SENT
+ 1,
349
354
MHD_CONNECTION_NORMAL_BODY_UNREADY
=
MHD_CONNECTION_NORMAL_BODY_READY
+ 1,
355
359
MHD_CONNECTION_CHUNKED_BODY_READY
=
MHD_CONNECTION_NORMAL_BODY_UNREADY
+ 1,
360
364
MHD_CONNECTION_CHUNKED_BODY_UNREADY
=
MHD_CONNECTION_CHUNKED_BODY_READY
+ 1,
365
369
MHD_CONNECTION_BODY_SENT
=
MHD_CONNECTION_CHUNKED_BODY_UNREADY
+ 1,
370
374
MHD_CONNECTION_FOOTERS_SENDING
=
MHD_CONNECTION_BODY_SENT
+ 1,
375
379
MHD_CONNECTION_FOOTERS_SENT
=
MHD_CONNECTION_FOOTERS_SENDING
+ 1,
380
385
MHD_CONNECTION_CLOSED
=
MHD_CONNECTION_FOOTERS_SENT
+ 1,
386
387
/*
388
* SSL/TLS connection states
389
*/
390
396
MHD_TLS_CONNECTION_INIT
=
MHD_CONNECTION_CLOSED
+ 1
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
439
struct
MHD_Connection
440
{
441
445
struct
MHD_Connection
*
next
;
446
450
struct
MHD_Daemon
*
daemon
;
451
455
struct
MHD_HTTP_Header
*
headers_received
;
456
460
struct
MHD_Response
*
response
;
461
472
struct
MemoryPool *
pool
;
473
480
void
*
client_context
;
481
486
char
*
method
;
487
492
char
*
url
;
493
498
char
*
version
;
499
506
char
*
read_buffer
;
507
512
char
*
write_buffer
;
513
519
char
*
last
;
520
527
char
*
colon
;
528
533
struct
sockaddr *
addr
;
534
539
pthread_t
pid
;
540
547
size_t
read_buffer_size
;
548
553
size_t
read_buffer_offset
;
554
558
size_t
write_buffer_size
;
559
563
size_t
write_buffer_send_offset
;
564
569
size_t
write_buffer_append_offset
;
570
575
uint64_t
remaining_upload_size
;
576
582
uint64_t
response_write_position
;
583
588
size_t
continue_message_write_offset
;
589
593
socklen_t
addr_len
;
594
599
time_t
last_activity
;
600
606
int
client_aware
;
607
613
int
socket_fd
;
614
622
int
read_closed
;
623
627
enum
MHD_CONNECTION_STATE
state
;
628
633
unsigned
int
responseCode
;
634
642
int
response_unready
;
643
647
int
have_chunked_response
;
648
656
int
have_chunked_upload
;
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
690
ReceiveCallback
recv_cls
;
691
695
TransmitCallback
send_cls
;
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
741
struct
MHD_Daemon
742
{
743
747
MHD_AccessHandlerCallback
default_handler
;
748
752
void
*
default_handler_cls
;
753
757
struct
MHD_Connection
*
connections
;
758
764
MHD_AcceptPolicyCallback
apc
;
765
769
void
*
apc_cls
;
770
775
MHD_RequestCompletedCallback
notify_completed
;
776
780
void
*
notify_completed_cls
;
781
789
LogCallback
uri_log_callback
;
790
794
void
*
uri_log_callback_cls
;
795
799
UnescapeCallback
unescape_callback
;
800
804
void
*
unescape_callback_cls
;
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
822
struct
MHD_Daemon
*
master
;
823
827
struct
MHD_Daemon
*
worker_pool
;
828
832
void
*
per_ip_connection_count
;
833
837
size_t
pool_size
;
838
842
size_t
thread_stack_size
;
843
847
unsigned
int
worker_pool_size
;
848
852
pthread_t
pid
;
853
857
pthread_mutex_t
per_ip_connection_mutex
;
858
862
int
socket_fd
;
863
867
int
shutdown
;
868
872
unsigned
int
max_connections
;
873
878
unsigned
int
connection_timeout
;
879
884
unsigned
int
per_ip_connection_limit
;
885
889
enum
MHD_OPTION
options
;
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
src
daemon
internal.h
Generated by
1.8.3.1