query.c revision cde2f4dabe028abc1f090c2faaa8f029d32243dc
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 1999-2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
15a44745412679c30a6d022733925af70a38b715David Lawrence * copyright notice and this permission notice appear in all copies.
1840745dd553b2ff5b114a03cde40a2a404aa559Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1840745dd553b2ff5b114a03cde40a2a404aa559Michael Graff * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1840745dd553b2ff5b114a03cde40a2a404aa559Michael Graff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
e13d04fda918c0c14c2247475bb99e0760d9a6a4Evan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
a4520e13fbf5218b78db2934e76ea1d869bbcdfdBob Halley * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
53a4e18582ae0c50f3742d2f6b684231a50be038Curtis Blackburn * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
53a4e18582ae0c50f3742d2f6b684231a50be038Curtis Blackburn * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
af9f195c9e128fc9cc5912498b8f7f26f07887c3Evan Hunt * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
bcf966e6146943ebcac1603a52468f5292612b18Evan Hunt/* $Id: query.c,v 1.212 2001/11/16 23:58:39 gson Exp $ */
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews#define PARTIALANSWER(c) (((c)->query.attributes & \
08a768e82ad64ede97f640c88e02984b59122753Michael Graff#define USECACHE(c) (((c)->query.attributes & \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define RECURSIONOK(c) (((c)->query.attributes & \
878d3073b13833ee1a50dfeabf8e400b6fdfc754Brian Wellington#define RECURSING(c) (((c)->query.attributes & \
08a768e82ad64ede97f640c88e02984b59122753Michael Graff#define CACHEGLUEOK(c) (((c)->query.attributes & \
dbb012765c735ee0d82dedb116cdc7cf18957814Evan Hunt#define WANTRECURSION(c) (((c)->query.attributes & \
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews#define WANTDNSSEC(c) (((c)->query.attributes & \
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrews#define NOAUTHORITY(c) (((c)->query.attributes & \
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉#define NOADDITIONAL(c) (((c)->query.attributes & \
850d70818503ca1b0f98c9c70b16b51e789fd705Andreas Gustafsson#define CTRACE(m) ((void)m)
dd16d9d9e77c2d906ee5ffa3dd9f71cacfbcb081Brian Wellington#define QTRACE(m) ((void)m)
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉static unsigned char ip6int_ndata[] = "\003ip6\003int";
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉static unsigned char ip6int_offsets[] = { 0, 4, 8 };
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
56b40c0185bcbd4a04422acc1211b5e2d2ba8a3eBob Halleyquery_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
01b8865b1462ba219c90cf6c00f1bf0fdf780d9bBrian Wellington dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset);
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halleystatic inline void
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halleyquery_adda6rrset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset,
fd35453765c6494d077edca44f4d998af5fd4cfaDavid Lawrencequery_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype);
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrencesynth_fwd_respond(ns_client_t *client, dns_adbfind_t *find);
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrewssynth_fwd_finddone(isc_task_t *task, isc_event_t *ev);
a00f9e2f50675bd43cc6a9fe2669709162a2ccb4Evan Huntsynth_finish(ns_client_t *client, isc_result_t result);
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Huntsynth_rev_byaddrdone_arpa(isc_task_t *task, isc_event_t *event);
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Huntsynth_rev_byaddrdone_int(isc_task_t *task, isc_event_t *event);
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉synth_rev_respond(ns_client_t *client, dns_byaddrevent_t *bevent);
f4cbe536b11da614fe05aeaeff41e324854cda7bMark Andrews * Increment query statistics counters.
f4cbe536b11da614fe05aeaeff41e324854cda7bMark Andrewsstatic inline void
c05abe6ef4f5e1ffb4bdd7608ff60efd6aa76f27Brian Wellingtoninc_stats(ns_client_t *client, dns_statscounter_t counter) {
5af195d1dbe4c266a47264111a9293069041209dMark Andrews isc_uint64_t *zonestats = dns_zone_getstatscounters(zone);
cd5724d610cb2b17f38fcca51d51138f1e64b4c5Bob Halley if (client->message->rcode == dns_rcode_noerror) {
922e6a3c2ac4ef900dd9dc99f0cc137f18372583Andreas Gustafsson if (ISC_LIST_EMPTY(client->message->sections[DNS_SECTION_ANSWER])) {
4ab6d6464f5490a30acf1e292c7f3f26dc99d6dbMark Andrews } else if (client->message->rcode == dns_rcode_nxdomain) {
8a5809527e6c85e39699901712a455d5480907c1Evan Hunt /* We end up here in case of YXDOMAIN, and maybe others */
c3b9fad5e3be639c9b36ff0ac921c30133da395cMar Andrewsquery_error(ns_client_t *client, isc_result_t result) {
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);
return (result);
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) {
if (log) {
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
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;
if (fetch_cancelled)
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)
if (is_zone) {
goto cleanup;
goto cleanup;
goto cleanup;
is_zone &&
goto cleanup;
switch (result) {
case ISC_R_SUCCESS:
case DNS_R_GLUE:
case DNS_R_ZONECUT:
case ISC_R_NOTFOUND:
goto cleanup;
goto cleanup;
case DNS_R_DELEGATION:
if (is_zone) {
goto db_find;
&sigrdataset);
goto cleanup;
case DNS_R_NXRRSET:
goto cleanup;
goto cleanup;
case DNS_R_NXDOMAIN:
goto cleanup;
goto cleanup;
case DNS_R_NCACHENXDOMAIN:
case DNS_R_NCACHENXRRSET:
goto cleanup;
case DNS_R_CNAME:
goto cleanup;
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 (is_zone) {
goto restart;
switch (qtype) {
case dns_rdatatype_any:
case dns_rdatatype_ixfr:
case dns_rdatatype_axfr:
case dns_rdatatype_maila:
case dns_rdatatype_mailb:
case dns_rdatatype_tkey:
isc_buffer_t b;
goto fail;
goto fail;
goto fail;
goto fail;
goto find_again;
goto done;
goto fail;
fail:
done:
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
static isc_result_t
int hexval;
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
return (result);
return (ISC_R_SUCCESS);
goto cleanup;
goto fail;
goto fail;
fail: