view.c revision 9c3531d72aeaad6c5f01efe6a1c82023e1379e4d
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/* $Id: view.c,v 1.71 2000/06/22 21:54:56 tale Exp $ */
#include <config.h>
#include <dns/keytable.h>
#include <dns/rdataset.h>
#include <dns/resolver.h>
{
/*
* Create a view.
*/
return (ISC_R_NOMEMORY);
goto cleanup_view;
}
if (result != ISC_R_SUCCESS) {
"isc_mutex_init() failed: %s",
goto cleanup_name;
}
if (result != ISC_R_SUCCESS) {
"isc_rwlock_init() failed: %s",
goto cleanup_mutex;
}
if (result != ISC_R_SUCCESS) {
"dns_zt_create() failed: %s",
goto cleanup_rwlock;
}
if (result != ISC_R_SUCCESS) {
"dns_keytable_create() failed: %s",
goto cleanup_zt;
}
if (result != ISC_R_SUCCESS) {
"dns_keytable_create() failed: %s",
goto cleanup_secroots;
}
if (result != ISC_R_SUCCESS)
goto cleanup_trustedkeys;
/*
* Initialize configuration data with default values.
*/
if (result != ISC_R_SUCCESS)
goto cleanup_dynkeys;
return (ISC_R_SUCCESS);
return (result);
}
static inline void
}
static isc_boolean_t
/*
* Caller must be holding the view lock.
*/
return (ISC_TRUE);
return (ISC_FALSE);
}
void
source->references++;
}
void
view->references--;
if (view->references == 0) {
if (!RESSHUTDOWN(view))
if (!ADBSHUTDOWN(view))
if (!REQSHUTDOWN(view))
}
if (done)
}
void
}
void
if (done)
}
static void
if (done)
}
static void
if (done)
}
static void
if (done)
}
unsigned int options,
{
/*
* Create a resolver and address database for the view.
*/
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS) {
return (result);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
&view->requestmgr);
if (result != ISC_R_SUCCESS) {
return (result);
}
return (ISC_R_SUCCESS);
}
void
/*
* Set the view's cache.
*/
}
}
void
/*
* Set the view's hints database.
*/
}
void
/*
* Set the view's static TSIG keyring.
*/
}
void
}
/*
* Add zone 'zone' to 'view'.
*/
return (result);
}
void
/*
* Freeze view.
*/
}
}
if (result == DNS_R_PARTIALMATCH) {
}
return (result);
}
{
/*
* Find an rdataset whose owner name is 'name', and whose type is
* 'type'.
*/
/*
* Initialize.
*/
/*
* Find a database to answer the query.
*/
else if (result != ISC_R_SUCCESS)
goto cleanup;
else
goto cleanup;
/*
* Now look for an answer in the database.
*/
if (result == DNS_R_DELEGATION ||
result == ISC_R_NOTFOUND) {
if (sigrdataset != NULL &&
if (!is_cache) {
/*
* Either the answer is in the cache, or we
* don't know it.
*/
dns_db_detach(&db);
goto db_find;
}
} else {
/*
* We don't have the data in the cache. If we've got
* glue from the zone, use it.
*/
if (dns_rdataset_isassociated(&zrdataset)) {
if (sigrdataset != NULL &&
result = DNS_R_GLUE;
goto cleanup;
}
}
/*
* We don't know the answer.
*/
} else if (result == DNS_R_GLUE) {
/*
* We found an answer, but the cache may be better.
* Remember what we've got and go look in the cache.
*/
if (sigrdataset != NULL &&
}
dns_db_detach(&db);
goto db_find;
}
/*
* Otherwise, the glue is the best answer.
*/
}
if (sigrdataset != NULL &&
/*
* We just used a hint. Let the resolver know it
* should consider priming.
*/
result = DNS_R_HINT;
} else if (result == DNS_R_NXDOMAIN ||
result == DNS_R_NXRRSET)
}
/*
* We don't care about any DNSSEC proof data in these cases.
*/
if (sigrdataset != NULL &&
}
if (dns_rdataset_isassociated(&zrdataset)) {
}
dns_db_detach(&db);
return (result);
}
{
if (result == DNS_R_NXDOMAIN) {
/*
* The rdataset and sigrdataset of the relevant NXT record
* may be returned, but the caller cannot use them because
* foundname is not returned by this simplified API. We
* disassociate them here to prevent any misuse by the caller.
*/
if (sigrdataset != NULL &&
} else if (result != ISC_R_SUCCESS &&
result != DNS_R_GLUE &&
result != DNS_R_HINT &&
result != DNS_R_NCACHENXDOMAIN &&
result != DNS_R_NCACHENXRRSET &&
result != DNS_R_NXRRSET &&
result != ISC_R_NOTFOUND) {
if (sigrdataset != NULL &&
}
return (result);
}
{
/*
* Find the best known zonecut containing 'name'.
*/
/*
* Initialize.
*/
/*
* Find the right database.
*/
if (result == ISC_R_NOTFOUND) {
/*
* We're not directly authoritative for this query name, nor
* is it a subdomain of any zone for which we're
* authoritative.
*/
/*
* We have a cache; try it.
*/
} else {
/*
* Maybe we have hints...
*/
goto finish;
}
} else if (result != ISC_R_SUCCESS) {
/*
* Something is broken.
*/
goto cleanup;
}
/*
* Look for the zonecut.
*/
if (!is_cache) {
if (result == DNS_R_DELEGATION)
else if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* We found an answer, but the cache may be better.
*/
NULL);
if (result != ISC_R_SUCCESS)
goto cleanup;
if (sigrdataset != NULL &&
}
dns_db_detach(&db);
goto db_find;
}
} else {
if (result == ISC_R_SUCCESS) {
/*
* We found a zonecut in the cache, but our
* zone delegation is better.
*/
}
} else if (result == ISC_R_NOTFOUND) {
/*
* We didn't find anything in the cache, but we
* have a zone delegation, so use it.
*/
} else {
/*
* Maybe we have hints...
*/
}
} else {
/*
* Something bad happened.
*/
goto cleanup;
}
}
if (use_zone) {
if (dns_rdataset_isassociated(rdataset)) {
if (sigrdataset != NULL &&
}
if (result != ISC_R_SUCCESS)
goto cleanup;
if (sigrdataset != NULL &&
/*
* We've found nothing so far, but we have hints.
*/
if (result != ISC_R_SUCCESS) {
/*
* We can't even find the hints for the root
* nameservers!
*/
}
}
if (dns_rdataset_isassociated(&zrdataset)) {
}
dns_db_detach(&db);
return (result);
}
{
break;
}
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
}
view->dynamickeys);
}