view.c revision fd15c8e32ed0c1cfd3ed737858a81966e7fbaeac
/*
* Copyright (C) 1999 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.
*/
#include <config.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/fixedname.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) {
"dns_zt_create() failed: %s",
goto cleanup_mutex;
}
if (result != ISC_R_SUCCESS) {
"dns_rbt_create() failed: %s",
goto cleanup_zt;
}
return (ISC_R_SUCCESS);
return (result);
}
void
/*
* Attach '*targetp' to 'source'.
*/
source->references++;
}
static inline void
}
static isc_boolean_t
/*
* Caller must be holding the view lock.
*/
return (ISC_TRUE);
return (ISC_FALSE);
}
void
/*
* Detach '*viewp' from its view.
*/
view->references--;
if (view->references == 0) {
if (!RESSHUTDOWN(view))
if (!ADBSHUTDOWN(view))
}
if (done)
}
static void
if (done)
}
static void
if (done)
}
{
/*
* 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);
}
return (ISC_R_SUCCESS);
}
void
/*
* Set the view's cache.
*/
}
}
void
/*
* Set the view's hints database.
*/
}
/*
* 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 != DNS_R_SUCCESS)
goto cleanup;
else
goto cleanup;
/*
* Now look for an answer in the database.
*/
if (result == DNS_R_DELEGATION ||
result == DNS_R_NOTFOUND) {
if (is_zone) {
/*
* 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 (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.
*/
}
result = DNS_R_HINT;
}
if (result != ISC_R_SUCCESS &&
result != DNS_R_GLUE &&
result != DNS_R_HINT &&
result != DNS_R_NCACHENXDOMAIN &&
}
dns_db_detach(&db);
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_zone) {
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 (sigrdataset != NULL &&
}
if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* 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!
*/
}
}
}
dns_db_detach(&db);
return (result);
}
{
break;
}
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
void
}