e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews * Copyright (C) 2000-2002, 2004-2016 Internet Systems Consortium, Inc. ("ISC")
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define REQUESTMGR_MAGIC ISC_MAGIC('R', 'q', 'u', 'M')
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define VALID_REQUESTMGR(mgr) ISC_MAGIC_VALID(mgr, REQUESTMGR_MAGIC)
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define REQUEST_MAGIC ISC_MAGIC('R', 'q', 'u', '!')
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define VALID_REQUEST(request) ISC_MAGIC_VALID(request, REQUEST_MAGIC)
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewstypedef ISC_LIST(dns_request_t) dns_requestlist_t;
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews /* locked */
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews isc_boolean_t canceling; /* ctlevent outstanding */
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define DNS_REQUEST_F_CANCELED 0x0004 /*%< ctlevent received, or otherwise
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews synchronously canceled */
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define DNS_REQUEST_F_TIMEDOUT 0x0008 /*%< canceled due to a timeout */
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrews#define DNS_REQUEST_F_TCP 0x0010 /*%< This request used TCP */
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void mgr_destroy(dns_requestmgr_t *requestmgr);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void mgr_shutdown(dns_requestmgr_t *requestmgr);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic unsigned int mgr_gethash(dns_requestmgr_t *requestmgr);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void send_shutdown_events(dns_requestmgr_t *requestmgr);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic isc_result_t req_render(dns_message_t *message, isc_buffer_t **buffer,
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_senddone(isc_task_t *task, isc_event_t *event);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_response(isc_task_t *task, isc_event_t *event);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_timeout(isc_task_t *task, isc_event_t *event);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic isc_socket_t * req_getsocket(dns_request_t *request);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_connected(isc_task_t *task, isc_event_t *event);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_sendevent(dns_request_t *request, isc_result_t result);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_destroy(dns_request_t *request);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void req_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
e4bea1f716ba373cce734278c3067746f6a0fd59Mark Andrewsstatic void do_cancel(isc_task_t *task, isc_event_t *event);
return (ISC_R_NOMEMORY);
return (result);
for (i = 0; i < DNS_REQUEST_NLOCKS; i++) {
return (result);
return (ISC_R_SUCCESS);
if (need_destroy)
if (need_destroy)
for (i = 0; i < DNS_REQUEST_NLOCKS; i++)
static inline isc_result_t
isc_region_t r;
* as we do in resolver.c, but we prefer implementation simplicity
return (ISC_R_NOMEMORY);
sendevent, 0);
return (result);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_boolean_t
match > 0)
if (drop) {
return (drop);
static isc_result_t
return (result);
} else if (!newtcp) {
return (result);
return (result);
#ifndef BROKEN_TCP_BIND_BEFORE_CONNECT
goto cleanup;
attrs = 0;
return (result);
static isc_result_t
case PF_INET:
case PF_INET6:
return (ISC_R_NOTIMPLEMENTED);
return (ISC_R_FAMILYNOSUPPORT);
return (ISC_R_SUCCESS);
attrs = 0;
case PF_INET:
case PF_INET6:
return (ISC_R_NOTIMPLEMENTED);
attrmask = 0;
dispatchp));
static isc_result_t
if (tcp)
return (result);
static isc_result_t
return (result);
if (udptimeout != 0)
requestp));
requestp));
isc_region_t r;
return (DNS_R_BLACKHOLED);
return (result);
if (udptimeout == 0)
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto again;
goto cleanup;
goto cleanup;
if (tcp)
goto cleanup;
if (tcp)
goto cleanup;
goto unlink;
goto unlink;
goto unlink;
request);
return (ISC_R_SUCCESS);
return (result);
if (udptimeout != 0)
requestp));
requestp));
return (ISC_R_FAMILYMISMATCH);
return (DNS_R_BLACKHOLED);
return (result);
if (udptimeout == 0)
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (settsigkey) {
goto cleanup;
goto use_tcp;
goto cleanup;
goto cleanup;
goto cleanup;
goto unlink;
goto unlink;
goto unlink;
request);
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
isc_region_t r;
return (result);
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (tcp)
goto cleanup;
return (ISC_R_SUCCESS);
if (cleanup_cctx)
return (result);
unsigned int options)
request);
return (result);
return (result);
return (result);
return (result);
static isc_socket_t *
return (sock);
isc_region_t r;
goto done;
r.length);
goto done;
done: