resolver.c revision 9c418665dd0aa21c0f32421a53e42d79d4803be3
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * Copyright (C) 1999, 2000 Internet Software Consortium.
21f1794606dce19928cf455029e173321f166380Mark Andrews * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
21f1794606dce19928cf455029e173321f166380Mark Andrews * copyright notice and this permission notice appear in all copies.
21f1794606dce19928cf455029e173321f166380Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein "res %p: %s", (r), (m))
21f1794606dce19928cf455029e173321f166380Mark Andrews "fetch %p (fctx %p): %s", \
21f1794606dce19928cf455029e173321f166380Mark Andrews "resquery %p (fctx %p): %s", \
21f1794606dce19928cf455029e173321f166380Mark Andrews * Maximum EDNS0 input packet size.
21f1794606dce19928cf455029e173321f166380Mark Andrews#define SEND_BUFFER_SIZE 2048 /* XXXRTH Constant. */
21f1794606dce19928cf455029e173321f166380Mark Andrewstypedef struct query {
21f1794606dce19928cf455029e173321f166380Mark Andrews /* Locked by task event serialization. */
21f1794606dce19928cf455029e173321f166380Mark Andrews unsigned int magic;
21f1794606dce19928cf455029e173321f166380Mark Andrews unsigned int options;
21f1794606dce19928cf455029e173321f166380Mark Andrews#define VALID_QUERY(query) ((query) != NULL && \
21f1794606dce19928cf455029e173321f166380Mark Andrews#define RESQUERY_CONNECTING(q) (((q)->attributes & \
4691e18ca0c900a432bd1e1b6f65f97ee1f3ebcfMark Andrews#define RESQUERY_CANCELED(q) (((q)->attributes & \
} fetchstate;
struct fetchctx {
unsigned int magic;
unsigned int options;
unsigned int bucketnum;
unsigned int references;
unsigned int attributes;
unsigned int pending;
unsigned int validating;
unsigned int restarts;
struct dns_fetch {
unsigned int magic;
void * private;
typedef struct fctxbucket {
} fctxbucket_t;
struct dns_resolver {
unsigned int magic;
unsigned int options;
unsigned int nbuckets;
unsigned int references;
unsigned int activebuckets;
FCTX_ADDRINFO_FORWARDER) != 0)
static inline isc_result_t
ISC_FALSE));
static inline isc_result_t
ISC_FALSE));
unsigned int rtt;
unsigned int factor;
factor);
deventp);
static inline isc_result_t
return (result);
return (result);
return (result);
unsigned int seconds;
static isc_result_t
unsigned int options)
return (result);
goto stop_idle_timer;
goto cleanup_query;
&socket);
goto cleanup_query;
goto cleanup_dispatch;
case PF_INET:
case PF_INET6:
goto cleanup_dispatch;
goto cleanup_dispatch;
goto cleanup_dispatch;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
isc_region_t r;
goto cleanup_temps;
goto cleanup_temps;
task,
goto cleanup_temps;
goto cleanup_message;
DNS_SECTION_QUESTION, 0);
goto cleanup_message;
goto cleanup_message;
goto cleanup_message;
goto cleanup_message;
goto cleanup_message;
goto cleanup_message;
return (ISC_R_SUCCESS);
NULL);
return (result);
unsigned int bucketnum;
if (want_try)
else if (want_done)
else if (bucket_empty)
static inline isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
static inline isc_boolean_t
return (all_bad);
static isc_result_t
isc_region_t r;
return (DNS_R_SERVFAIL);
goto out;
&find);
return (result);
out:
if (all_bad) {
} else if (pruned) {
goto restart;
return (result);
static inline dns_adbaddrinfo_t *
return (addrinfo);
return (addrinfo);
static isc_boolean_t
unsigned int bucketnum;
return (ISC_TRUE);
return (ISC_FALSE);
&cevent);
unsigned int bucketnum;
if (bucket_empty)
unsigned int bucketnum;
if (!done) {
} else if (bucket_empty)
static inline isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_NOMEMORY);
goto cleanup_fetch;
0, ISC_TRUE,
NULL);
goto cleanup_name;
goto cleanup_name;
goto cleanup_name;
goto cleanup_name;
goto cleanup_domain;
goto cleanup_qmessage;
goto cleanup_rmessage;
goto cleanup_rmessage;
return (ISC_R_SUCCESS);
return (result);
static inline isc_result_t
return (DNS_R_FORMERR);
return (result);
return (DNS_R_FORMERR);
return (ISC_R_SUCCESS);
static inline isc_result_t
unsigned int options;
return (result);
if (need_validation) {
!need_validation) {
return (result);
return (result);
* Cache this rdataset/sigrdataset pair as
#ifdef notyet
name,
task,
fctx,
&validator);
#ifdef notyet
options = 0;
eresult =
eresult =
return (result);
static inline isc_result_t
section++) {
&name);
return (result);
static inline isc_result_t
return (result);
if (need_validation) {
return (ISC_R_NOTIMPLEMENTED);
goto unlock;
&node);
goto unlock;
goto unlock;
return (result);
if (gluing)
if (external)
static isc_result_t
NULL);
gluing);
&rdataset);
gluing);
* See query.c.
return (ISC_R_SUCCESS);
static inline isc_result_t
isc_region_t r;
return (result);
return (ISC_R_SUCCESS);
static inline isc_result_t
isc_region_t r;
int order;
return (result);
&nbits);
return (DNS_R_FORMERR);
return (result);
static isc_result_t
return (ISC_R_SUCCESS);
return (DNS_R_FORMERR);
return (DNS_R_FORMERR);
if (aa)
return (result);
return (ISC_R_SUCCESS);
return (DNS_R_FORMERR);
return (DNS_R_FORMERR);
return (DNS_R_FORMERR);
fctx);
return (result);
return (DNS_R_DELEGATION);
if (negative_response)
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int aflag;
aflag = 0;
return (DNS_R_FORMERR);
&tname);
return (result);
if (found) {
if (!chaining) {
if (aflag ==
if (aa)
} else if (external) {
(void)dns_rdataset_additionaldata(
fctx);
if (want_chaining) {
aflag = 0;
return (DNS_R_FORMERR);
&dname);
return (result);
if (found) {
if (!chaining) {
if (aa)
} else if (external) {
if (want_chaining) {
&dname);
return (result);
if (!have_answer)
return (DNS_R_FORMERR);
if (want_chaining) {
return (DNS_R_FORMERR);
if (!external) {
(void)dns_rdataset_additionaldata(
fctx);
return (result);
return (ISC_R_SUCCESS);
unsigned int options;
covers = 0;
goto done;
goto done;
switch (result) {
case ISC_R_UNEXPECTEDEND:
goto done;
case DNS_R_FORMERR:
goto done;
case DNS_R_MOREDATA:
goto done;
goto done;
goto done;
goto done;
if (truncated) {
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
if (keep_trying) {
if (broken_server) {
if (get_nameservers) {
NULL);
} else if (resend) {
unsigned int options,
unsigned int i, buckets_created = 0;
return (ISC_R_NOMEMORY);
goto cleanup_res;
for (i = 0; i < ntasks; i++) {
goto cleanup_buckets;
goto cleanup_buckets;
goto cleanup_buckets;
goto cleanup_udpsocketv4;
goto cleanup_dispatchv4;
goto cleanup_udpsocketv6;
goto cleanup_dispatchv6;
return (ISC_R_SUCCESS);
for (i = 0; i < buckets_created; i++) {
return (result);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
if (want_priming) {
if (need_destroy)
static inline isc_boolean_t
unsigned int options)
return (ISC_FALSE);
isc_buffer_t b;
isc_region_t r;
isc_buffer_available(&b, &r);
isc_buffer_used(&b, &r);
unsigned int bucketnum;
return (ISC_R_NOMEMORY);
goto unlock;
goto unlock;
if (new_fctx) {
return (result);
link);
unsigned int bucketnum;
if (bucket_empty)