query.c revision af5dc286ff4b750deec50d1c006aae5fc38019c0
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright (C) 1999, 2000 Internet Software Consortium.
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * Permission to use, copy, modify, and distribute this software for any
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * purpose with or without fee is hereby granted, provided that the above
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * copyright notice and this permission notice appear in all copies.
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff/* $Id: query.c,v 1.163 2000/12/27 23:01:25 marka Exp $ */
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews#endif /* DNS_OPT_NEWCODES */
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews#define PARTIALANSWER(c) (((c)->query.attributes & \
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff#define USECACHE(c) (((c)->query.attributes & \
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson#define RECURSIONOK(c) (((c)->query.attributes & \
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews#define RECURSING(c) (((c)->query.attributes & \
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington#define CACHEGLUEOK(c) (((c)->query.attributes & \
d0fe07af9cd5278b86bfba65c9a8391e007cd8c9Brian Wellington#define WANTRECURSION(c) (((c)->query.attributes & \
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews#define WANTDNSSEC(c) (((c)->query.attributes & \
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellington#define CTRACE(m) ((void)m)
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews#define QTRACE(m) ((void)m)
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrewsquery_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellingtonstatic inline void
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrewsquery_adda6rrset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset,
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrewsquery_find(ns_client_t *client, dns_fetchevent_t *event);
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * Increment query statistics counters.
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrewscount_query(dns_zone_t *zone, isc_boolean_t is_zone, dns_statscounter_t counter)
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews isc_uint64_t *zonestats = dns_zone_getstatscounters(zone);
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrewsstatic inline void
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews * client->query.qname was dynamically allocated.
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellingtonstatic inline void
c363150ad598e7a8ce03efe2776b8e6950f0de7bBrian Wellingtonquery_reset(ns_client_t *client, isc_boolean_t everything) {
1c3191528684f3dd93ebb122298c2f8ebfc6d397Mark Andrews unsigned int i;
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews * Reset the query state of a client to its default state.
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews * Cancel the fetch if it's running.
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff dns_resolver_cancelfetch(client->query.fetch);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * Cleanup any active versions.
d981ca645597116d227a48bf37cc5edc061c854dBob Halley for (dbversion = ISC_LIST_HEAD(client->query.activeversions);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff dns_db_closeversion(dbversion->db, &dbversion->version,
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley ISC_LIST_INITANDAPPEND(client->query.freeversions,
link);
sizeof *dbversion);
static inline isc_result_t
return (result);
return (ISC_R_SUCCESS);
static inline isc_buffer_t *
isc_region_t r;
return (NULL);
return (NULL);
return (dbuf);
isc_region_t r;
static inline dns_name_t *
isc_region_t r;
return (NULL);
return (name);
static inline dns_rdataset_t *
return (NULL);
return (rdataset);
static inline isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
static inline ns_dbversion_t *
return (NULL);
return (dbversion);
return (result);
static inline ns_dbversion_t *
return (NULL);
return (dbversion);
static inline isc_result_t
unsigned int ztoptions;
DNS_ZTFIND_NOEXACT : 0;
&zone);
goto fail;
goto refuse;
goto fail;
if (new_zone) {
goto refuse;
NS_QUERYATTR_QUERYOKVALID) != 0) {
NS_QUERYATTR_QUERYOK) == 0)
goto refuse;
if (check_acl) {
goto refuse;
return (ISC_R_SUCCESS);
fail:
return (result);
static inline isc_result_t
return (DNS_R_REFUSED);
NS_QUERYATTR_QUERYOKVALID) != 0) {
NS_QUERYATTR_QUERYOK) == 0)
goto refuse;
if (check_acl) {
goto refuse;
return (ISC_R_SUCCESS);
return (result);
static inline isc_result_t
#ifdef DNS_OPT_NEWCODES_LIVE
versionp);
return (result);
static isc_result_t
unsigned int dboptions;
goto cleanup;
if (is_zone) {
goto db_find;
goto cleanup;
goto db_find;
return (result);
static inline isc_boolean_t
section++) {
return (ISC_TRUE);
return (ISC_FALSE);
static isc_result_t
isc_buffer_t b;
return (ISC_R_SUCCESS);
goto cleanup;
goto cleanup;
goto cleanup;
goto try_cache;
goto found;
goto try_glue;
goto found;
goto cleanup;
goto cleanup;
goto addname;
goto addname;
dns_rdatatype_a, 0,
goto addname;
goto addname;
goto addname;
dns_rdatatype_a6, 0,
goto addname;
goto addname;
goto addname;
goto addname;
if (!added_something)
goto cleanup;
if (need_addname)
client);
return (eresult);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
static inline isc_result_t
return (result);
goto cleanup;
goto cleanup;
if (zero_ttl) {
return (eresult);
static inline isc_result_t
return (result);
goto cleanup;
goto cleanup;
return (eresult);
static inline isc_result_t
isc_region_t r;
return (result);
return (result);
return (result);
return (ISC_R_SUCCESS);
isc_buffer_t b;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (is_zone) {
goto cleanup;
goto db_find;
goto cleanup;
if (use_zone) {
goto cleanup;
static inline isc_result_t
* Should get help with this from rdata.c
switch (type) {
case dns_rdatatype_tkey:
return (DNS_R_NOTIMP);
case dns_rdatatype_tsig:
return (DNS_R_FORMERR);
case dns_rdatatype_ixfr:
case dns_rdatatype_axfr:
case dns_rdatatype_mailb:
case dns_rdatatype_maila:
return (DNS_R_REFUSED);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
return (result);
static inline isc_result_t
goto cleanup;
if (!is_zone) {
goto cleanup;
return (result);
#define QUERY_ERROR(r) \
eresult = r; \
static isc_result_t
case dns_rdatatype_a:
return (ISC_R_SUCCESS);
case dns_rdatatype_aaaa:
return (ISC_R_SUCCESS);
return (ISC_R_NOTIMPLEMENTED);
return (INT_MAX);
return (INT_MAX);
case NS_SORTLISTTYPE_1ELEMENT:
case NS_SORTLISTTYPE_2ELEMENT:
case NS_SORTLISTTYPE_NONE:
INSIST(0);
int order;
isc_buffer_t b;
goto cleanup;
goto cleanup;
goto cleanup;
goto resume;
goto cleanup;
if (is_zone)
qtype = 0;
qcount = 0;
qcount++;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
is_zone &&
goto cleanup;
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_GLUE:
#ifdef DNS_OPT_NEWCODES_LIVE
case DNS_R_ZONECUT:
case ISC_R_NOTFOUND:
#ifdef DNS_OPT_NEWCODES_LIVE
goto cleanup;
case DNS_R_DELEGATION:
#ifdef DNS_OPT_NEWCODES_LIVE
if (is_zone) {
goto db_find;
&sigrdataset);
goto cleanup;
case DNS_R_NXRRSET:
goto cleanup;
&tname);
goto cleanup;
case DNS_R_NXDOMAIN:
goto cleanup;
goto cleanup;
&tname);
goto cleanup;
case DNS_R_NCACHENXDOMAIN:
goto ncachenxrrset;
case DNS_R_NCACHENXRRSET:
goto cleanup;
case DNS_R_CNAME:
goto cleanup;
goto cleanup;
goto cleanup;
goto addauth;
case DNS_R_DNAME:
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto addauth;
goto cleanup;
goto cleanup;
goto cleanup;
if (!want_restart) {
if (is_zone) {
goto restart;
case dns_rdatatype_any:
case dns_rdatatype_ixfr:
case dns_rdatatype_axfr:
case dns_rdatatype_maila:
case dns_rdatatype_mailb:
case dns_rdatatype_tkey: