dlz.c revision 03e200df5dc283f24a6a349f0b31d3eab26da893
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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.
*/
/*
* Copyright (C) 1999-2001 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: dlz.c,v 1.2 2005/09/05 00:11:01 marka Exp $ */
/*! \file */
/***
*** Imports
***/
#include <config.h>
#include <dns/fixedname.h>
/***
*** Supported DLZ DB Implementations Registry
***/
static isc_rwlock_t dlz_implock;
static void
dlz_initialize(void) {
}
/*%
* Searches the dlz_implementations list for a driver matching name.
*/
static inline dns_dlzimplementation_t *
dlz_impfind(const char *name) {
return (imp);
return (NULL);
}
/***
*** Basic DLZ Methods
***/
{
/*
* Performs checks to make sure data is as we expect it to be.
*/
/* ask driver if the zone is supported */
if (result == ISC_R_NOTIMPLEMENTED)
return (ISC_R_NOTFOUND);
return (result);
}
{
/*
* initialize the dlz_implementations list, this is guaranteed
* to only really happen once.
*/
/*
* Performs checks to make sure data is as we expect it to be.
*/
/* write log message */
/* lock the dlz_implementations list so we can search it. */
/* search for the driver implementation */
"unsupported DLZ database driver '%s'."
" %s not loaded.",
return (ISC_R_NOTFOUND);
}
/* Allocate memory to hold the DLZ database driver */
return (ISC_R_NOMEMORY);
}
/* Make sure memory region is set to all 0's */
/* Create a new database using implementation 'drivername'. */
/* mark the DLZ driver as valid */
if (result == ISC_R_SUCCESS) {
"DLZ driver loaded successfully.");
return (ISC_R_SUCCESS);
} else {
"DLZ driver failed to load.");
}
/* impinfo->methods->create failed. */
return (result);
}
void
/* Write debugging message to log */
"Unloading DLZ driver.");
/*
* Perform checks to make sure data is as we expect it to be.
*/
/* call the drivers destroy method */
/* return memory */
}
}
{
unsigned int namelabels;
unsigned int i;
/*
* Performs checks to make sure data is as we expect it to be.
*/
/* setup a "fixed" dns name */
/* count the number of labels in the name */
/*
* loop through starting with the longest domain name and
* trying shorter names portions of the name until we find a
* match, have an error, or are below the 'minlabels'
* threshold. minlabels is 0, if the standard database didn't
* have a zone name match. Otherwise minlables is the number
* of labels in that name. We need to beat that for a
* "better" match for the DLZ database to be authoritative
* instead of the standard database.
*/
if (i == namelabels) {
if (result != ISC_R_SUCCESS)
return (result);
} else
/* ask SDLZ driver if the zone is supported */
if (result != ISC_R_NOTFOUND)
return (result);
}
return (ISC_R_NOTFOUND);
}
/*%
* Registers a DLZ driver. This basically just adds the dlz
* driver to the list of available drivers in the dlz_implementations list.
*/
{
/* Write debugging message to log */
"Registering DLZ driver '%s'", drivername);
/*
* Performs checks to make sure data is as we expect it to be.
*/
/*
* initialize the dlz_implementations list, this is guaranteed
* to only really happen once.
*/
/* lock the dlz_implementations list so we can modify it. */
/*
* check that another already registered driver isn't using
* the same name
*/
"DLZ Driver '%s' already registered",
return (ISC_R_EXISTS);
}
/*
* Allocate memory for a dlz_implementation object. Error if
* we cannot.
*/
return (ISC_R_NOMEMORY);
}
/* Make sure memory region is set to all 0's */
/* Store the data passed into this method */
/* attach the new dlz_implementation object to a memory context */
/*
* prepare the dlz_implementation object to be put in a list,
* and append it to the list
*/
/* Unlock the dlz_implementations list. */
/* Pass back the dlz_implementation that we created. */
return (ISC_R_SUCCESS);
}
/*%
* Helper function for dns_dlzstrtoargv().
* Pardon the gratuitous recursion.
*/
static isc_result_t
char ***argvp, unsigned int n)
{
/* Discard leading whitespace. */
while (*s == ' ' || *s == '\t')
s++;
if (*s == '\0') {
/* We have reached the end of the string. */
*argcp = n;
return (ISC_R_NOMEMORY);
} else {
char *p = s;
while (*p != ' ' && *p != '\t' && *p != '\0' && *p != '{') {
if (*p == '\n') {
*p = ' ';
goto restart;
}
p++;
}
/* do "grouping", items between { and } are one arg */
if (*p == '{') {
char *t = p;
/*
* shift all characters to left by 1 to get rid of '{'
*/
while (*t != '\0') {
t++;
*(t-1) = *t;
}
while (*p != '\0' && *p != '}') {
p++;
}
/* get rid of '}' character */
if (*p == '}') {
*p = '\0';
p++;
}
/* normal case, no "grouping" */
} else if (*p != '\0')
*p++ = '\0';
if (result != ISC_R_SUCCESS)
return (result);
(*argvp)[n] = s;
}
return (ISC_R_SUCCESS);
}
/*%
* Tokenize the string "s" into whitespace-separated words,
* return the number of words in '*argcp' and an array
* of pointers to the words in '*argvp'. The caller
* must free the array using isc_mem_put(). The string
* is modified in-place.
*/
{
}
/*%
* Unregisters a DLZ driver. This basically just removes the dlz
* driver from the list of available drivers in the dlz_implementations list.
*/
void
/* Write debugging message to log */
"Unregistering DLZ driver.");
/*
* Performs checks to make sure data is as we expect it to be.
*/
/*
* initialize the dlz_implementations list, this is guaranteed
* to only really happen once.
*/
/* lock the dlz_implementations list so we can modify it. */
/* remove the dlz_implementation object from the list */
/*
* return the memory back to the available memory pool and
* remove it from the memory context.
*/
/* Unlock the dlz_implementations list. */
}