db.c revision 0d990f57aefcb3a2e82a91367fc600ccf69eea63
/*
*
* dns_db_*() calls on database instances backed by this driver use
* struct sampledb_methods to find appropriate function implementation.
*
* This example re-uses RBT DB implementation from original BIND and blindly
* proxies most of dns_db_*() calls to this underlying RBT DB.
* See struct sampledb below.
*
* Copyright (C) 2009-2015 Red Hat ; see COPYRIGHT for license
*/
#include <config.h>
#include <dns/enumclass.h>
#include <dns/rdatalist.h>
#include <dns/rdatastruct.h>
#include "db.h"
#include "instance.h"
#include "syncptr.h"
#include "util.h"
#define VALID_SAMPLEDB(sampledb) \
struct sampledb {
/*
* Internal RBT database implementation provided by BIND.
* Most dns_db_* calls (find(), createiterator(), etc.)
* are blindly forwarded to this RBT DB.
*/
};
typedef struct sampledb sampledb_t;
/*
* Get full DNS name from the node.
*
* @warning
* The code silently expects that "node" came from RBTDB and thus
* assumption dns_dbnode_t (from RBTDB) == dns_rbtnode_t is correct.
*
* This should work as long as we use only RBTDB and nothing else.
*/
static isc_result_t
}
static void
}
static void
}
static void
unsigned int refs;
if (refs == 0)
}
/*
* This method should never be called, because DB is "persistent".
* See ispersistent() function. It means that database do not need to be
* loaded in the usual sense.
*/
static isc_result_t
fatal_error("current implementation should never call beginload()");
/* Not reached */
return (ISC_R_SUCCESS);
}
/*
* This method should never be called, because DB is "persistent".
* See ispersistent() function. It means that database do not need to be
* loaded in the usual sense.
*/
static isc_result_t
fatal_error("current implementation should never call endload()");
/* Not reached */
return (ISC_R_SUCCESS);
}
static isc_result_t
}
static isc_result_t
{
fatal_error("current implementation should never call dump()");
/* Not reached */
return (ISC_R_SUCCESS);
}
static void
}
static isc_result_t
}
static void
{
}
static void
}
static isc_result_t
{
}
static isc_result_t
{
rdataset, sigrdataset));
}
static isc_result_t
{
sigrdataset));
}
static void
}
static void
}
static isc_result_t
}
static void
}
static isc_result_t
{
}
static isc_result_t
{
}
static isc_result_t
{
}
static isc_result_t
{
}
return (result);
}
static isc_result_t
{
goto cleanup;
}
return (result);
}
/*
* deleterdataset() function is not used during DNS update processing so syncptr
* implementation is left as an exercise to the reader.
*/
static isc_result_t
{
}
static isc_boolean_t
}
static unsigned int
}
/*
* The database does not need to be loaded from disk or written to disk.
* Always return ISC_TRUE.
*/
static isc_boolean_t
return (ISC_TRUE);
}
static void
}
static void
}
static isc_result_t
}
static void
}
static isc_result_t
{
salt, salt_length));
}
static isc_result_t
{
}
static isc_result_t
{
}
static isc_result_t
{
}
static void
}
static isc_boolean_t
}
static dns_stats_t *
}
static void
}
static isc_result_t
}
static isc_result_t
{
}
static isc_result_t
{
}
static isc_result_t
}
static unsigned int
}
/*
* DB interface definition. Database driver uses this structure to
* determine which implementation of dns_db_*() function to call.
*/
static dns_dbmethods_t sampledb_methods = {
dump,
find,
};
/* Auxiliary driver functions. */
/*
* Auxiliary functions add_*() create minimal database which can be loaded.
* This is necessary because this driver create empty 'fake' zone which
* is not loaded from disk so there is no way for user to supply SOA, NS and A
* records.
*
* credit goes to ISC.
*/
static isc_result_t
{
unsigned char buf[DNS_SOA_BUFFERSIZE];
return (result);
}
static isc_result_t
{
isc_buffer_t b;
unsigned char buf[DNS_NAME_MAXWIRE];
&ns, &b));
return (result);
}
static isc_result_t
{
isc_buffer_t b;
unsigned char buf[DNS_NAME_MAXWIRE];
&a, &b));
return (result);
}
/*
* Driver-specific implementation of dns_db_create().
*
* @param[in] argv Database-specific parameters from dns_db_create().
* @param[in] driverarg Driver-specific parameter from dns_db_register().
*/
{
/* Translate instance name to instance pointer. */
/* Create internal instance of RBT DB implementation from BIND. */
/* Create fake SOA, NS, and A records to make database loadable. */
return (ISC_R_SUCCESS);
sizeof(*sampledb));
}
return (result);
}