request.c revision 94baac869a70b529a24ff23d8dc899faa5d4fdc4
7d98a1783f222964bcde7d56dab77b822706204dBob Halley * Copyright (C) 2000, 2001 Internet Software Consortium.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * Permission to use, copy, modify, and distribute this software for any
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * purpose with or without fee is hereby granted, provided that the above
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * copyright notice and this permission notice appear in all copies.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley/* $Id: request.c,v 1.54 2001/01/27 02:28:32 bwelling Exp $ */
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#define VALID_REQUEST(request) ((request) != NULL && \
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halleytypedef ISC_LIST(dns_request_t) dns_requestlist_t;
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley /* locked */
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley unsigned int hash;
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence unsigned int hash;
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson#define DNS_REQUEST_F_TIMEDOUT 0x0008 /* cancelled due to a timeout */
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson#define DNS_REQUEST_F_TCP 0x0010 /* This request used TCP */
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson (((r)->flags & DNS_REQUEST_F_CANCELED) != 0)
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson (((r)->flags & DNS_REQUEST_F_CONNECTING) != 0)
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson (((r)->flags & DNS_REQUEST_F_SENDING) != 0)
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void mgr_destroy(dns_requestmgr_t *requestmgr);
44fee668021c7ceef4ee1c848031d883a508b359James Bristerstatic void mgr_shutdown(dns_requestmgr_t *requestmgr);
44fee668021c7ceef4ee1c848031d883a508b359James Bristerstatic unsigned int mgr_gethash(dns_requestmgr_t *requestmgr);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void send_shutdown_events(dns_requestmgr_t *requestmgr);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic isc_result_t req_render(dns_message_t *message, isc_buffer_t **buffer,
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void req_senddone(isc_task_t *task, isc_event_t *event);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void req_response(isc_task_t *task, isc_event_t *event);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void req_timeout(isc_task_t *task, isc_event_t *event);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void req_connected(isc_task_t *task, isc_event_t *event);
44fee668021c7ceef4ee1c848031d883a508b359James Bristerstatic void req_sendevent(dns_request_t *request, isc_result_t result);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafssonstatic void req_cancel(dns_request_t *request);
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafssonstatic void req_destroy(dns_request_t *request);
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafssonstatic void req_log(int level, const char *fmt, ...);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson req_log(ISC_LOG_DEBUG(3), "dns_requestmgr_create");
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson REQUIRE(requestmgrp != NULL && *requestmgrp == NULL);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson socket = dns_dispatch_getsocket(dispatchv4);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson REQUIRE(isc_socket_gettype(socket) == isc_sockettype_udp);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson socket = dns_dispatch_getsocket(dispatchv6);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson REQUIRE(isc_socket_gettype(socket) == isc_sockettype_udp);
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson requestmgr = isc_mem_get(mctx, sizeof(*requestmgr));
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson isc_mem_put(mctx, requestmgr, sizeof(*requestmgr));
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley for (i = 0; i < DNS_REQUEST_NLOCKS; i++) {
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson while (--i >= 0)
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley isc_mem_put(mctx, requestmgr, sizeof(*requestmgr));
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;
return (result);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_boolean_t
int match;
match > 0)
if (drop) {
return (drop);
static isc_result_t
unsigned int attrs;
return (result);
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);
isc_region_t r;
return (DNS_R_BLACKHOLED);
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
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);
return (DNS_R_BLACKHOLED);
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (setkey)
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);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (tcp)
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_SUCCESS);
unsigned int options)
request);
return (result);
return (result);
isc_region_t r;
goto done;
r.length);
goto done;
done: