diff options
Diffstat (limited to 'src/lib/daemon_options.c')
-rw-r--r-- | src/lib/daemon_options.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/lib/daemon_options.c b/src/lib/daemon_options.c index 3adee960..db0be522 100644 --- a/src/lib/daemon_options.c +++ b/src/lib/daemon_options.c | |||
@@ -23,6 +23,7 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "internal.h" | 25 | #include "internal.h" |
26 | #include <dlfcn.h> | ||
26 | 27 | ||
27 | 28 | ||
28 | /** | 29 | /** |
@@ -150,7 +151,7 @@ MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, | |||
150 | unsigned int queue_length) | 151 | unsigned int queue_length) |
151 | { | 152 | { |
152 | daemon->fast_open_method = fom; | 153 | daemon->fast_open_method = fom; |
153 | daemon->fast_open_queue_length = queue_length; | 154 | daemon->fo_queue_length = queue_length; |
154 | switch (fom) | 155 | switch (fom) |
155 | { | 156 | { |
156 | case MHD_FOM_DISABLE: | 157 | case MHD_FOM_DISABLE: |
@@ -204,7 +205,6 @@ MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, | |||
204 | const struct sockaddr *sa, | 205 | const struct sockaddr *sa, |
205 | size_t sa_len) | 206 | size_t sa_len) |
206 | { | 207 | { |
207 | daemon->sa_given = true; | ||
208 | memcpy (&daemon->listen_sa, | 208 | memcpy (&daemon->listen_sa, |
209 | sa, | 209 | sa, |
210 | sa_len); | 210 | sa_len); |
@@ -338,37 +338,37 @@ MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, | |||
338 | const char *ciphers) | 338 | const char *ciphers) |
339 | { | 339 | { |
340 | #ifndef HTTPS_SUPPORT | 340 | #ifndef HTTPS_SUPPORT |
341 | return MHD_TLS_DISABLED; | 341 | return MHD_SC_TLS_DISABLED; |
342 | #else | 342 | #else |
343 | char filename[1024]; | 343 | char filename[1024]; |
344 | int res; | 344 | int res; |
345 | MHD_TLS_PluginInit init; | 345 | MHD_TLS_PluginInit init; |
346 | 346 | ||
347 | /* todo: .dll on W32? */ | 347 | /* todo: .dll on W32? */ |
348 | res = MHD_snprintf (filename, | 348 | res = MHD_snprintf_ (filename, |
349 | sizeof (filename), | 349 | sizeof (filename), |
350 | "%s/libmicrohttpd_tls_%s.so", | 350 | "%s/libmicrohttpd_tls_%s.so", |
351 | MHD_PLUGIN_INSTALL_PREFIX, | 351 | MHD_PLUGIN_INSTALL_PREFIX, |
352 | tls_backend); | 352 | tls_backend); |
353 | if (0 >= res) | 353 | if (0 >= res) |
354 | return MHD_BACKEND_UNSUPPORTED; /* string too long? */ | 354 | return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* string too long? */ |
355 | if (NULL == | 355 | if (NULL == |
356 | (daemon->tls_backend_lib = dlopen (filename, | 356 | (daemon->tls_backend_lib = dlopen (filename, |
357 | RTLD_NOW | RTLD_LOCAL))) | 357 | RTLD_NOW | RTLD_LOCAL))) |
358 | return MHD_BACKEND_UNSUPPORTED; /* plugin not found */ | 358 | return MHD_SC_BACKEND_UNSUPPORTED; /* plugin not found */ |
359 | if (NULL == (init = dlsym (daemon->tls_backend_lib, | 359 | if (NULL == (init = dlsym (daemon->tls_backend_lib, |
360 | "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR))) | 360 | "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR))) |
361 | 361 | ||
362 | { | 362 | { |
363 | dlclose (daemon->tls_backend_lib); | 363 | dlclose (daemon->tls_backend_lib); |
364 | daemon->tls_backend_lib = NULL; | 364 | daemon->tls_backend_lib = NULL; |
365 | return MHD_BACKEND_UNSUPPORTED; /* possibly wrong version installed */ | 365 | return MHD_SC_BACKEND_UNSUPPORTED; /* possibly wrong version installed */ |
366 | } | 366 | } |
367 | if (NULL == (daemon->tls_backend = init (ciphers))) | 367 | if (NULL == (daemon->tls_api = init (ciphers))) |
368 | { | 368 | { |
369 | dlclose (daemon->tls_backend_lib); | 369 | dlclose (daemon->tls_backend_lib); |
370 | daemon->tls_backend_lib = NULL; | 370 | daemon->tls_backend_lib = NULL; |
371 | return MHD_CIPHERS_INVALID; /* possibly wrong version installed */ | 371 | return MHD_SC_CIPHERS_INVALID; /* possibly wrong version installed */ |
372 | } | 372 | } |
373 | return MHD_SC_OK; | 373 | return MHD_SC_OK; |
374 | #endif | 374 | #endif |
@@ -396,8 +396,8 @@ MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, | |||
396 | { | 396 | { |
397 | struct MHD_TLS_Plugin *plugin; | 397 | struct MHD_TLS_Plugin *plugin; |
398 | 398 | ||
399 | if (NULL == (plugin = daemon->tls_backend)) | 399 | if (NULL == (plugin = daemon->tls_api)) |
400 | return MHD_TLS_BACKEND_UNINITIALIZED; | 400 | return MHD_SC_TLS_BACKEND_UNINITIALIZED; |
401 | return plugin->init_kcp (plugin->cls, | 401 | return plugin->init_kcp (plugin->cls, |
402 | mem_key, | 402 | mem_key, |
403 | mem_cert, | 403 | mem_cert, |
@@ -420,8 +420,8 @@ MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, | |||
420 | { | 420 | { |
421 | struct MHD_TLS_Plugin *plugin; | 421 | struct MHD_TLS_Plugin *plugin; |
422 | 422 | ||
423 | if (NULL == (plugin = daemon->tls_backend)) | 423 | if (NULL == (plugin = daemon->tls_api)) |
424 | return MHD_TLS_BACKEND_UNINITIALIZED; | 424 | return MHD_SC_TLS_BACKEND_UNINITIALIZED; |
425 | return plugin->init_dhparams (plugin->cls, | 425 | return plugin->init_dhparams (plugin->cls, |
426 | dh); | 426 | dh); |
427 | } | 427 | } |
@@ -442,8 +442,8 @@ MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, | |||
442 | { | 442 | { |
443 | struct MHD_TLS_Plugin *plugin; | 443 | struct MHD_TLS_Plugin *plugin; |
444 | 444 | ||
445 | if (NULL == (plugin = daemon->tls_backend)) | 445 | if (NULL == (plugin = daemon->tls_api)) |
446 | return MHD_TLS_BACKEND_UNINITIALIZED; | 446 | return MHD_SC_TLS_BACKEND_UNINITIALIZED; |
447 | return plugin->init_mem_trust (plugin->cls, | 447 | return plugin->init_mem_trust (plugin->cls, |
448 | mem_trust); | 448 | mem_trust); |
449 | } | 449 | } |
@@ -462,9 +462,9 @@ MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, | |||
462 | { | 462 | { |
463 | struct MHD_TLS_Plugin *plugin; | 463 | struct MHD_TLS_Plugin *plugin; |
464 | 464 | ||
465 | if (NULL == (plugin = daemon->tls_backend)) | 465 | if (NULL == (plugin = daemon->tls_api)) |
466 | return MHD_TLS_BACKEND_UNINITIALIZED; | 466 | return MHD_SC_TLS_BACKEND_UNINITIALIZED; |
467 | return MHD_TLS_BACKEND_OPERATION_UNSUPPORTED; | 467 | return MHD_SC_TLS_BACKEND_OPERATION_UNSUPPORTED; |
468 | } | 468 | } |
469 | 469 | ||
470 | 470 | ||
@@ -483,16 +483,17 @@ MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, | |||
483 | * | 483 | * |
484 | * @param daemon daemon to configure callback for | 484 | * @param daemon daemon to configure callback for |
485 | * @param cb must be of type `gnutls_certificate_retrieve_function2 *`. | 485 | * @param cb must be of type `gnutls_certificate_retrieve_function2 *`. |
486 | * @return #MHD_SC_OK on success | ||
486 | */ | 487 | */ |
487 | void | 488 | enum MHD_StatusCode |
488 | MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, | 489 | MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, |
489 | void *cb) | 490 | void *cb) |
490 | { | 491 | { |
491 | struct MHD_TLS_Plugin *plugin; | 492 | struct MHD_TLS_Plugin *plugin; |
492 | 493 | ||
493 | if (NULL == (plugin = daemon->tls_backend)) | 494 | if (NULL == (plugin = daemon->tls_api)) |
494 | return MHD_TLS_BACKEND_UNINITIALIZED; | 495 | return MHD_SC_TLS_BACKEND_UNINITIALIZED; |
495 | return MHD_TLS_BACKEND_OPERATION_UNSUPPORTED; | 496 | return MHD_SC_TLS_BACKEND_OPERATION_UNSUPPORTED; |
496 | } | 497 | } |
497 | 498 | ||
498 | 499 | ||
@@ -544,8 +545,8 @@ MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, | |||
544 | MHD_EarlyUriLogCallback cb, | 545 | MHD_EarlyUriLogCallback cb, |
545 | void *cb_cls) | 546 | void *cb_cls) |
546 | { | 547 | { |
547 | daemon->early_uri_logger_cb = cb; | 548 | daemon->early_uri_logger = cb; |
548 | daemon->early_uri_logger_cb_cls = cb_cls; | 549 | daemon->early_uri_logger_cls = cb_cls; |
549 | } | 550 | } |
550 | 551 | ||
551 | 552 | ||
@@ -710,7 +711,7 @@ MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, | |||
710 | MHD_DLOG (daemon, | 711 | MHD_DLOG (daemon, |
711 | _("Specified value for NC_SIZE too large\n")); | 712 | _("Specified value for NC_SIZE too large\n")); |
712 | #endif | 713 | #endif |
713 | return MHD_DIGEST_AUTH_NC_LENGTH_TOO_BIG; | 714 | return MHD_SC_DIGEST_AUTH_NC_LENGTH_TOO_BIG; |
714 | } | 715 | } |
715 | if (0 < nc_length) | 716 | if (0 < nc_length) |
716 | { | 717 | { |
@@ -725,13 +726,13 @@ MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, | |||
725 | _("Failed to allocate memory for nonce-nc map: %s\n"), | 726 | _("Failed to allocate memory for nonce-nc map: %s\n"), |
726 | MHD_strerror_ (errno)); | 727 | MHD_strerror_ (errno)); |
727 | #endif | 728 | #endif |
728 | return MHD_DIGEST_AUTH_NC_ALLOCATION_FAILURE; | 729 | return MHD_SC_DIGEST_AUTH_NC_ALLOCATION_FAILURE; |
729 | } | 730 | } |
730 | } | 731 | } |
731 | daemon->digest_nc_length = nc_length; | 732 | daemon->digest_nc_length = nc_length; |
732 | return MHD_SC_OK; | 733 | return MHD_SC_OK; |
733 | #else | 734 | #else |
734 | return MHD_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD; | 735 | return MHD_SC_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD; |
735 | #endif | 736 | #endif |
736 | } | 737 | } |
737 | 738 | ||