aboutsummaryrefslogtreecommitdiff
path: root/src/lib/daemon_options.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/daemon_options.c')
-rw-r--r--src/lib/daemon_options.c140
1 files changed, 70 insertions, 70 deletions
diff --git a/src/lib/daemon_options.c b/src/lib/daemon_options.c
index 4d7bbdf1..04c9cb2f 100644
--- a/src/lib/daemon_options.c
+++ b/src/lib/daemon_options.c
@@ -38,8 +38,8 @@
38 */ 38 */
39void 39void
40MHD_daemon_set_logger (struct MHD_Daemon *daemon, 40MHD_daemon_set_logger (struct MHD_Daemon *daemon,
41 MHD_LoggingCallback logger, 41 MHD_LoggingCallback logger,
42 void *logger_cls) 42 void *logger_cls)
43{ 43{
44 daemon->logger = logger; 44 daemon->logger = logger;
45 daemon->logger_cls = logger_cls; 45 daemon->logger_cls = logger_cls;
@@ -148,8 +148,8 @@ MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon)
148 */ 148 */
149enum MHD_Bool 149enum MHD_Bool
150MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, 150MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon,
151 enum MHD_FastOpenMethod fom, 151 enum MHD_FastOpenMethod fom,
152 unsigned int queue_length) 152 unsigned int queue_length)
153{ 153{
154 daemon->fast_open_method = fom; 154 daemon->fast_open_method = fom;
155 daemon->fo_queue_length = queue_length; 155 daemon->fo_queue_length = queue_length;
@@ -185,8 +185,8 @@ MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon,
185 */ 185 */
186void 186void
187MHD_daemon_bind_port (struct MHD_Daemon *daemon, 187MHD_daemon_bind_port (struct MHD_Daemon *daemon,
188 enum MHD_AddressFamily af, 188 enum MHD_AddressFamily af,
189 uint16_t port) 189 uint16_t port)
190{ 190{
191 daemon->listen_af = af; 191 daemon->listen_af = af;
192 daemon->listen_port = port; 192 daemon->listen_port = port;
@@ -204,12 +204,12 @@ MHD_daemon_bind_port (struct MHD_Daemon *daemon,
204 */ 204 */
205void 205void
206MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, 206MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon,
207 const struct sockaddr *sa, 207 const struct sockaddr *sa,
208 size_t sa_len) 208 size_t sa_len)
209{ 209{
210 memcpy (&daemon->listen_sa, 210 memcpy (&daemon->listen_sa,
211 sa, 211 sa,
212 sa_len); 212 sa_len);
213 daemon->listen_sa_len = sa_len; 213 daemon->listen_sa_len = sa_len;
214} 214}
215 215
@@ -223,7 +223,7 @@ MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon,
223 */ 223 */
224void 224void
225MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, 225MHD_daemon_listen_backlog (struct MHD_Daemon *daemon,
226 int listen_backlog) 226 int listen_backlog)
227{ 227{
228 daemon->listen_backlog = listen_backlog; 228 daemon->listen_backlog = listen_backlog;
229} 229}
@@ -275,7 +275,7 @@ MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon)
275 */ 275 */
276void 276void
277MHD_daemon_listen_socket (struct MHD_Daemon *daemon, 277MHD_daemon_listen_socket (struct MHD_Daemon *daemon,
278 MHD_socket listen_socket) 278 MHD_socket listen_socket)
279{ 279{
280 daemon->listen_socket = listen_socket; 280 daemon->listen_socket = listen_socket;
281} 281}
@@ -290,7 +290,7 @@ MHD_daemon_listen_socket (struct MHD_Daemon *daemon,
290 */ 290 */
291enum MHD_Bool 291enum MHD_Bool
292MHD_daemon_event_loop (struct MHD_Daemon *daemon, 292MHD_daemon_event_loop (struct MHD_Daemon *daemon,
293 enum MHD_EventLoopSyscall els) 293 enum MHD_EventLoopSyscall els)
294{ 294{
295 switch (els) 295 switch (els)
296 { 296 {
@@ -326,7 +326,7 @@ MHD_daemon_event_loop (struct MHD_Daemon *daemon,
326 */ 326 */
327void 327void
328MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, 328MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon,
329 enum MHD_ProtocolStrictLevel sl) 329 enum MHD_ProtocolStrictLevel sl)
330{ 330{
331 daemon->protocol_strict_level = sl; 331 daemon->protocol_strict_level = sl;
332} 332}
@@ -349,8 +349,8 @@ MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon,
349 */ 349 */
350enum MHD_StatusCode 350enum MHD_StatusCode
351MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, 351MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon,
352 const char *tls_backend, 352 const char *tls_backend,
353 const char *ciphers) 353 const char *ciphers)
354{ 354{
355#if ! (defined(HTTPS_SUPPORT) && defined (HAVE_DLFCN_H)) 355#if ! (defined(HTTPS_SUPPORT) && defined (HAVE_DLFCN_H))
356 return MHD_SC_TLS_DISABLED; 356 return MHD_SC_TLS_DISABLED;
@@ -361,18 +361,18 @@ MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon,
361 361
362 /* todo: .dll on W32? */ 362 /* todo: .dll on W32? */
363 res = MHD_snprintf_ (filename, 363 res = MHD_snprintf_ (filename,
364 sizeof (filename), 364 sizeof (filename),
365 "%s/libmicrohttpd_tls_%s.so", 365 "%s/libmicrohttpd_tls_%s.so",
366 MHD_PLUGIN_INSTALL_PREFIX, 366 MHD_PLUGIN_INSTALL_PREFIX,
367 tls_backend); 367 tls_backend);
368 if (0 >= res) 368 if (0 >= res)
369 return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* string too long? */ 369 return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* string too long? */
370 if (NULL == 370 if (NULL ==
371 (daemon->tls_backend_lib = dlopen (filename, 371 (daemon->tls_backend_lib = dlopen (filename,
372 RTLD_NOW | RTLD_LOCAL))) 372 RTLD_NOW | RTLD_LOCAL)))
373 return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* plugin not found */ 373 return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* plugin not found */
374 if (NULL == (init = dlsym (daemon->tls_backend_lib, 374 if (NULL == (init = dlsym (daemon->tls_backend_lib,
375 "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR))) 375 "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR)))
376 376
377 { 377 {
378 dlclose (daemon->tls_backend_lib); 378 dlclose (daemon->tls_backend_lib);
@@ -405,9 +405,9 @@ MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon,
405 */ 405 */
406enum MHD_StatusCode 406enum MHD_StatusCode
407MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, 407MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon,
408 const char *mem_key, 408 const char *mem_key,
409 const char *mem_cert, 409 const char *mem_cert,
410 const char *pass) 410 const char *pass)
411{ 411{
412#ifndef HTTPS_SUPPORT 412#ifndef HTTPS_SUPPORT
413 return MHD_SC_TLS_DISABLED; 413 return MHD_SC_TLS_DISABLED;
@@ -417,9 +417,9 @@ MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon,
417 if (NULL == (plugin = daemon->tls_api)) 417 if (NULL == (plugin = daemon->tls_api))
418 return MHD_SC_TLS_BACKEND_UNINITIALIZED; 418 return MHD_SC_TLS_BACKEND_UNINITIALIZED;
419 return plugin->init_kcp (plugin->cls, 419 return plugin->init_kcp (plugin->cls,
420 mem_key, 420 mem_key,
421 mem_cert, 421 mem_cert,
422 pass); 422 pass);
423#endif 423#endif
424} 424}
425 425
@@ -435,7 +435,7 @@ MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon,
435 */ 435 */
436enum MHD_StatusCode 436enum MHD_StatusCode
437MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, 437MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon,
438 const char *dh) 438 const char *dh)
439{ 439{
440#ifndef HTTPS_SUPPORT 440#ifndef HTTPS_SUPPORT
441 return MHD_SC_TLS_DISABLED; 441 return MHD_SC_TLS_DISABLED;
@@ -445,7 +445,7 @@ MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon,
445 if (NULL == (plugin = daemon->tls_api)) 445 if (NULL == (plugin = daemon->tls_api))
446 return MHD_SC_TLS_BACKEND_UNINITIALIZED; 446 return MHD_SC_TLS_BACKEND_UNINITIALIZED;
447 return plugin->init_dhparams (plugin->cls, 447 return plugin->init_dhparams (plugin->cls,
448 dh); 448 dh);
449#endif 449#endif
450} 450}
451 451
@@ -461,7 +461,7 @@ MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon,
461 */ 461 */
462enum MHD_StatusCode 462enum MHD_StatusCode
463MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, 463MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon,
464 const char *mem_trust) 464 const char *mem_trust)
465{ 465{
466#ifndef HTTPS_SUPPORT 466#ifndef HTTPS_SUPPORT
467 return MHD_SC_TLS_DISABLED; 467 return MHD_SC_TLS_DISABLED;
@@ -471,7 +471,7 @@ MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon,
471 if (NULL == (plugin = daemon->tls_api)) 471 if (NULL == (plugin = daemon->tls_api))
472 return MHD_SC_TLS_BACKEND_UNINITIALIZED; 472 return MHD_SC_TLS_BACKEND_UNINITIALIZED;
473 return plugin->init_mem_trust (plugin->cls, 473 return plugin->init_mem_trust (plugin->cls,
474 mem_trust); 474 mem_trust);
475#endif 475#endif
476} 476}
477 477
@@ -485,7 +485,7 @@ MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon,
485 */ 485 */
486enum MHD_StatusCode 486enum MHD_StatusCode
487MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, 487MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon,
488 int gnutls_credentials) 488 int gnutls_credentials)
489{ 489{
490#ifndef HTTPS_SUPPORT 490#ifndef HTTPS_SUPPORT
491 return MHD_SC_TLS_DISABLED; 491 return MHD_SC_TLS_DISABLED;
@@ -518,7 +518,7 @@ MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon,
518 */ 518 */
519enum MHD_StatusCode 519enum MHD_StatusCode
520MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, 520MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon,
521 void *cb) 521 void *cb)
522{ 522{
523#ifndef HTTPS_SUPPORT 523#ifndef HTTPS_SUPPORT
524 return MHD_SC_TLS_DISABLED; 524 return MHD_SC_TLS_DISABLED;
@@ -541,7 +541,7 @@ MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon,
541 */ 541 */
542void 542void
543MHD_daemon_threading_mode (struct MHD_Daemon *daemon, 543MHD_daemon_threading_mode (struct MHD_Daemon *daemon,
544 enum MHD_ThreadingMode tm) 544 enum MHD_ThreadingMode tm)
545{ 545{
546 daemon->threading_mode = tm; 546 daemon->threading_mode = tm;
547} 547}
@@ -558,8 +558,8 @@ MHD_daemon_threading_mode (struct MHD_Daemon *daemon,
558 */ 558 */
559void 559void
560MHD_daemon_accept_policy (struct MHD_Daemon *daemon, 560MHD_daemon_accept_policy (struct MHD_Daemon *daemon,
561 MHD_AcceptPolicyCallback apc, 561 MHD_AcceptPolicyCallback apc,
562 void *apc_cls) 562 void *apc_cls)
563{ 563{
564 daemon->accept_policy_cb = apc; 564 daemon->accept_policy_cb = apc;
565 daemon->accept_policy_cb_cls = apc_cls; 565 daemon->accept_policy_cb_cls = apc_cls;
@@ -577,8 +577,8 @@ MHD_daemon_accept_policy (struct MHD_Daemon *daemon,
577 */ 577 */
578void 578void
579MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, 579MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon,
580 MHD_EarlyUriLogCallback cb, 580 MHD_EarlyUriLogCallback cb,
581 void *cb_cls) 581 void *cb_cls)
582{ 582{
583 daemon->early_uri_logger_cb = cb; 583 daemon->early_uri_logger_cb = cb;
584 daemon->early_uri_logger_cb_cls = cb_cls; 584 daemon->early_uri_logger_cb_cls = cb_cls;
@@ -595,8 +595,8 @@ MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon,
595 */ 595 */
596void 596void
597MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, 597MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon,
598 MHD_NotifyConnectionCallback ncc, 598 MHD_NotifyConnectionCallback ncc,
599 void *ncc_cls) 599 void *ncc_cls)
600{ 600{
601 daemon->notify_connection_cb = ncc; 601 daemon->notify_connection_cb = ncc;
602 daemon->notify_connection_cb_cls = ncc_cls; 602 daemon->notify_connection_cb_cls = ncc_cls;
@@ -616,8 +616,8 @@ MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon,
616 */ 616 */
617void 617void
618MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, 618MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon,
619 size_t memory_limit_b, 619 size_t memory_limit_b,
620 size_t memory_increment_b) 620 size_t memory_increment_b)
621{ 621{
622 if (memory_increment_b >= memory_limit_b) 622 if (memory_increment_b >= memory_limit_b)
623 MHD_PANIC ("sane memory increment must be below memory limit"); 623 MHD_PANIC ("sane memory increment must be below memory limit");
@@ -636,7 +636,7 @@ MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon,
636 */ 636 */
637void 637void
638MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, 638MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon,
639 size_t stack_limit_b) 639 size_t stack_limit_b)
640{ 640{
641 daemon->thread_stack_limit_b = stack_limit_b; 641 daemon->thread_stack_limit_b = stack_limit_b;
642} 642}
@@ -659,8 +659,8 @@ MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon,
659 */ 659 */
660void 660void
661MHD_daemon_connection_limits (struct MHD_Daemon *daemon, 661MHD_daemon_connection_limits (struct MHD_Daemon *daemon,
662 unsigned int global_connection_limit, 662 unsigned int global_connection_limit,
663 unsigned int ip_connection_limit) 663 unsigned int ip_connection_limit)
664{ 664{
665 daemon->global_connection_limit = global_connection_limit; 665 daemon->global_connection_limit = global_connection_limit;
666 daemon->ip_connection_limit = ip_connection_limit; 666 daemon->ip_connection_limit = ip_connection_limit;
@@ -677,7 +677,7 @@ MHD_daemon_connection_limits (struct MHD_Daemon *daemon,
677 */ 677 */
678void 678void
679MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon, 679MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon,
680 unsigned int timeout_s) 680 unsigned int timeout_s)
681{ 681{
682 daemon->connection_default_timeout = (time_t) timeout_s; 682 daemon->connection_default_timeout = (time_t) timeout_s;
683} 683}
@@ -696,8 +696,8 @@ MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon,
696 */ 696 */
697void 697void
698MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, 698MHD_daemon_unescape_cb (struct MHD_Daemon *daemon,
699 MHD_UnescapeCallback unescape_cb, 699 MHD_UnescapeCallback unescape_cb,
700 void *unescape_cb_cls) 700 void *unescape_cb_cls)
701{ 701{
702 daemon->unescape_cb = unescape_cb; 702 daemon->unescape_cb = unescape_cb;
703 daemon->unescape_cb_cls = unescape_cb_cls; 703 daemon->unescape_cb_cls = unescape_cb_cls;
@@ -715,8 +715,8 @@ MHD_daemon_unescape_cb (struct MHD_Daemon *daemon,
715 */ 715 */
716void 716void
717MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, 717MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon,
718 size_t buf_size, 718 size_t buf_size,
719 const void *buf) 719 const void *buf)
720{ 720{
721#if ENABLE_DAUTH 721#if ENABLE_DAUTH
722 daemon->digest_auth_random_buf = buf; 722 daemon->digest_auth_random_buf = buf;
@@ -739,34 +739,34 @@ MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon,
739 */ 739 */
740enum MHD_StatusCode 740enum MHD_StatusCode
741MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, 741MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon,
742 size_t nc_length) 742 size_t nc_length)
743{ 743{
744#if ENABLE_DAUTH 744#if ENABLE_DAUTH
745 if ( ( (size_t) (nc_length * sizeof (struct MHD_NonceNc))) / 745 if ( ( (size_t) (nc_length * sizeof (struct MHD_NonceNc)))
746 sizeof (struct MHD_NonceNc) != nc_length) 746 / sizeof (struct MHD_NonceNc) != nc_length)
747 { 747 {
748#ifdef HAVE_MESSAGES 748#ifdef HAVE_MESSAGES
749 MHD_DLOG (daemon, 749 MHD_DLOG (daemon,
750 _("Specified value for NC_SIZE too large\n")); 750 _ ("Specified value for NC_SIZE too large\n"));
751#endif 751#endif
752 return MHD_SC_DIGEST_AUTH_NC_LENGTH_TOO_BIG; 752 return MHD_SC_DIGEST_AUTH_NC_LENGTH_TOO_BIG;
753 } 753 }
754 if (0 < nc_length) 754 if (0 < nc_length)
755 {
756 if (NULL != daemon->nnc)
757 free (daemon->nnc);
758 daemon->nnc = malloc (daemon->nonce_nc_size
759 * sizeof (struct MHD_NonceNc));
760 if (NULL == daemon->nnc)
755 { 761 {
756 if (NULL != daemon->nnc)
757 free (daemon->nnc);
758 daemon->nnc = malloc (daemon->nonce_nc_size *
759 sizeof (struct MHD_NonceNc));
760 if (NULL == daemon->nnc)
761 {
762#ifdef HAVE_MESSAGES 762#ifdef HAVE_MESSAGES
763 MHD_DLOG (daemon, 763 MHD_DLOG (daemon,
764 _("Failed to allocate memory for nonce-nc map: %s\n"), 764 _ ("Failed to allocate memory for nonce-nc map: %s\n"),
765 MHD_strerror_ (errno)); 765 MHD_strerror_ (errno));
766#endif 766#endif
767 return MHD_SC_DIGEST_AUTH_NC_ALLOCATION_FAILURE; 767 return MHD_SC_DIGEST_AUTH_NC_ALLOCATION_FAILURE;
768 }
769 } 768 }
769 }
770 daemon->digest_nc_length = nc_length; 770 daemon->digest_nc_length = nc_length;
771 return MHD_SC_OK; 771 return MHD_SC_OK;
772#else 772#else