
  $   Sˆl–Ãa¾”ji?u@?pÜŠbÑ¿Þ„Ø¿ÎÁÜ ?÷     S/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#ifndef DNS_RESOLVER_H
#define DNS_RESOLVER_H 1

/*****
***** Module Info
*****/

/*! \file dns/resolver.h
 *
 * \brief
 * This is the BIND 9 resolver, the module responsible for resolving DNS
 * requests by iteratively querying authoritative servers and following
 * referrals.  This is a "full resolver", not to be confused with
 * the stub resolvers most people associate with the word "resolver".
 * The full resolver is part of the caching name server or resolver
 * daemon the stub resolver talks to.
 *
 * MP:
 *\li	The module ensures appropriate synchronization of data structures it
 *	creates and manipulates.
 *
 * Reliability:
 *\li	No anticipated impact.
 *
 * Resources:
 *\li	TBS
 *
 * Security:
 *\li	No anticipated impact.
 *
 * Standards:
 *\li	RFCs:	1034, 1035, 2181, TBS
 *\li	Drafts:	TBS
 */

#include <inttypes.h>
#include <stdbool.h>

#include <isc/lang.h>
#include <isc/socket.h>
#include <isc/stats.h>

#include <dns/fixedname.h>
#include <dns/types.h>

ISC_LANG_BEGINDECLS

/*%
 * A dns_fetchevent_t is sent when a 'fetch' completes.  Any of 'db',
 * 'node', 'rdataset', and 'sigrdataset' may be bound.  It is the
 * receiver's responsibility to detach before freeing the event.
 * \brief
 * 'rdataset', 'sigrdataset', 'client' and 'id' are the values that were
 * supplied when dns_resolver_createfetch() was called.  They are returned
 *  to the caller so that they may be freed.
 */
typedef struct dns_fetchevent {
	ISC_EVENT_COMMON(struct dns_fetchevent);
	dns_fetch_t	    *fetch;
	isc_result_t	      result;
	dns_rdatatype_t	      qtype;
	dns_db_t		 *db;
	dns_dbnode_t	     *node;
	dns_rdataset_t       *rdataset;
	dns_rdataset_t       *sigrdataset;
	dns_fixedname_t	      foundname;
	const isc_sockaddr_t *client;
	dns_messageid_t	      id;
	isc_result_t	      vresult;
} dns_fetchevent_t;

/*%
 * The two quota types (fetches-per-zone and fetches-per-server)
 */
typedef enum { dns_quotatype_zone = 0, dns_quotatype_server } dns_quotatype_t;

/*
 * Options that modify how a 'fetch' is done.
 */
#define DNS_FETCHOPT_TCP	 0x00000001 /*%< Use TCP. */
#define DNS_FETCHOPT_UNSHARED	 0x00000002 /*%< See below. */
#define DNS_FETCHOPT_RECURSIVE	 0x00000004 /*%< Set RD? */
#define DNS_FETCHOPT_NOEDNS0	 0x00000008 /*%< Do not use EDNS. */
#define DNS_FETCHOPT_FORWARDONLY 0x00000010 /*%< Only use forwarders. */
#define DNS_FETCHOPT_NOVALIDATE	 0x00000020 /*%< Disable validation. */
#define DNS_FETCHOPT_EDNS512                                       \
	0x00000040			 /*%< Advertise a 512 byte \
					  *   UDP buffer. */
#define DNS_FETCHOPT_WANTNSID 0x00000080 /*%< Request NSID */
#define DNS_FETCHOPT_PREFETCH 0x00000100 /*%< Do prefetch */
#define DNS_FETCHOPT_NOCDFLAG 0x00000200 /*%< Don't set CD flag. */
#define DNS_FETCHOPT_NONTA    0x00000400 /*%< Ignore NTA table. */
/* RESERVED ECS				0x00000000 */
/* RESERVED ECS				0x00001000 */
/* RESERVED ECS				0x00002000 */
/* RESERVED TCPCLIENT			0x00004000 */
#define DNS_FETCHOPT_NOCACHED 0x00008000 /*%< Force cache update. */
#define DNS_FETCHOPT_QMINIMIZE    \
	0x00010000 /*%< Use qname \
		    *    minimization. */
#define DNS_FETCHOPT_NOFOLLOW        \
	0x00020000 /*%< Don't follow \
		    *   delegations */
#define DNS_FETCHOPT_QMIN_STRICT            \
	0x00040000 /*%< Do not work around  \
		    *   servers that return \
		    *   errors on non-empty \
		    *   terminals. */
#define DNS_FETCHOPT_QMIN_USE_A            \
	0x00080000 /*%< Use A type queries \
		    *   instead of NS when \
		    *   doing minimization */
#define DNS_FETCHOPT_QMIN_SKIP_IP6A      \
	0x00100000 /*%< Skip some labels \
		    *   when doing qname \
		    *   minimizat