62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Permission to use, copy, modify, and distribute this software for any
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * purpose with or without fee is hereby granted, provided that the
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * above copyright notice and this permission notice appear in all
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * USE OR PERFORMANCE OF THIS SOFTWARE.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * conceived and contributed by Rob Butler.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Permission to use, copy, modify, and distribute this software for any
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * purpose with or without fee is hereby granted, provided that the
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * above copyright notice and this permission notice appear in all
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * USE OR PERFORMANCE OF THIS SOFTWARE.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Permission to use, copy, modify, and/or distribute this software for any
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * purpose with or without fee is hereby granted, provided that the above
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * copyright notice and this permission notice appear in all copies.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * PERFORMANCE OF THIS SOFTWARE.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * This is simply a merge of Andrew Tridgell's dlz_example.c and the
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * This provides the externally loadable bdbhpt DLZ driver, without
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * update support
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt/* should the bdb driver use threads. */
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt/* bdbhpt database names */
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * This structure contains all our DB handles and helper functions we
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * inherit from the dlz_dlopen driver
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* Helper functions from the dlz_dlopen driver */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Huntb9_add_helper(struct bdbhpt_instance *db, const char *helper_name, void *ptr);
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Reverses a string in place.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) {
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Parses the DBT from the Berkeley DB into a parsed_data record
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * The parsed_data record should be allocated before and passed into the
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * bdbhpt_parse_data function. The char (type & data) fields should not
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * be "free"d as that memory is part of the DBT data field. It will be
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * "free"d when the DBT is freed.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Huntbdbhpt_parse_data(log_t *log, char *in, bdbhpt_parsed_data_t *pd) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * String should be formatted as:
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * replication_id
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * remaining data
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * 9191 host 10 A 127.0.0.1
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * server1_212 host 10 A 127.0.0.2
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * {xxxx-xxxx-xxxx-xxxx-xxxx} host 10 MX 20 mail.example.com
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * we don't need the replication id, so don't
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * bother saving a pointer to it.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* find space after replication id */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* verify we found a space */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* make sure it is safe to increment pointer */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* save pointer to host */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* find space after host and change it to a '\0' */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* verify we found a space */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* change the space to a null (string terminator) */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* make sure it is safe to increment pointer */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* save pointer to ttl string */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* find space after ttl and change it to a '\0' */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* verify we found a space */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* change the space to a null (string terminator) */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* make sure it is safe to increment pointer */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* save pointer to dns type */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* find space after type and change it to a '\0' */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* verify we found a space */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* change the space to a null (string terminator) */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* make sure it is safe to increment pointer */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* save pointer to remainder of DNS data */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* convert ttl string to integer */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "ttl must be a positive number");
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* if we get this far everything should have worked. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * See if a zone transfer is allowed
72c86c105a7cf315036d7131a4ef408bc6227639Evan Huntdlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt bdbhpt_instance_t *db = (bdbhpt_instance_t *) dbdata;
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* check to see if we are authoritative for the zone first. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt result = dlz_findzonedb(dbdata, name, NULL, NULL);
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt switch(db->client->get(db->client, NULL, &key, &data, DB_GET_BOTH)) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* free any memory duplicate string in the key field */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* free any memory allocated to the data field. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Perform a zone transfer
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * BDB does not allow a secondary index on a database that allows
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * duplicates. We have a few options:
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * 1) kill speed by having lookup method use a secondary db which
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * is associated to the primary DB with the DNS data. Then have
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * another secondary db for zone transfer which also points to
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * the dns_data primary. NO - The point of this driver is
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * lookup performance.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * 2) Blow up database size by storing DNS data twice. Once for
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * the lookup (dns_data) database, and a second time for the zone
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * transfer (dns_xfr) database. NO - That would probably require
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * a larger cache to provide good performance. Also, that would
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * make the DB larger on disk potentially slowing it as well.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * 3) Loop through the dns_xfr database with a cursor to get
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * all the different hosts in a zone. Then use the zone & host
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * together to lookup the data in the dns_data database. YES -
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * This may slow down zone xfr's a little, but that's ok they
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * don't happen as often and don't need to be as fast. We can
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * also use this table when deleting a zone (The BDB driver
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * is read only - the delete would be used during replication
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * updates by a separate process).
72c86c105a7cf315036d7131a4ef408bc6227639Evan Huntdlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt bdbhpt_instance_t *db = (bdbhpt_instance_t *) dbdata;
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt char *tmp = NULL, *tmp_zone, *tmp_zone_host = NULL;
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* get a cursor to loop through dns_xfr table */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt if (db->xfr->cursor(db->xfr, NULL, &xfr_cursor, 0) != 0) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* get a cursor to loop through dns_data table */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt if (db->data->cursor(db->data, NULL, &dns_cursor, 0) != 0) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* loop through xfr table for specified zone. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt while ((bdbhptres = xfr_cursor->c_get(xfr_cursor, &xfr_key,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* +1 to allow for space between zone and host names */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* +1 to allow for null term at end of string. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt dns_key.data = tmp_zone_host = malloc(dns_key.size + 1);
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * construct search key for dns_data.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * zone_name(a space)host_name
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt strncat(dns_key.data, xfr_data.data, xfr_data.size);
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* +1 to allow for null term at end of string. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* copy data to tmp string, and append null term. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* split string into dns data parts. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt } /* end inner while loop */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* clean up memory */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt } /* end outer while loop */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* free any memory */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* get rid of cursors */
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Performs bdbhpt cleanup.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Used by bdbhpt_create if there is an error starting up.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Used by bdbhpt_destroy when the driver is shutting down.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* close databases */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* close environment */
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * See if we handle a given zone
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt bdbhpt_instance_t *db = (bdbhpt_instance_t *) dbdata;
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * reverse string to take advantage of BDB locality of reference
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * if we need futher lookups because the zone doesn't match the
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * first time.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt switch(db->zone->get(db->zone, NULL, &key, &data, 0)) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* free any memory duplicate string in the key field */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* free any memory allocated to the data field. */
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Hunt * Look up one record in the database.
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Huntisc_result_t dlz_lookup(const char *zone, const char *name,
62d63e5f02a5e7fcda59cf361149e3d7c78477beEvan Huntisc_result_t dlz_lookup(const char *zone, const char *name, void *dbdata,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt bdbhpt_instance_t *db = (bdbhpt_instance_t *) dbdata;
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* allocate mem for key */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt key.data = keyStr = malloc((key.size + 1) * sizeof(char));
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* get a cursor to loop through data */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt if (db->data->cursor(db->data, NULL, &data_cursor, 0) != 0) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt while ((bdbhptres = data_cursor->c_get(data_cursor, &key, &data,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt if (bdbhpt_parse_data(db->log, tmp, &pd) != ISC_R_SUCCESS)
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt result = db->putrr(lookup, pd.type, pd.ttl, pd.data);
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt } /* end while loop */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* get rid of cursor */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Initialises, sets flags and then opens Berkeley databases.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Huntbdbhpt_opendb(log_t *log, DB_ENV *db_env, DBTYPE db_type, DB **db,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* Initialise the database. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: could not initialize %s database. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "BerkeleyDB error: %s",
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* set database flags. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt if ((result = (*db)->set_flags(*db, flags)) != 0) {
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: could not set flags for %s database. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "BerkeleyDB error: %s",
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* open the database. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt if ((result = (*db)->open(*db, NULL, db_file, db_name, db_type,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: could not open %s database in %s. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "BerkeleyDB error: %s",
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Called to initialize the driver
72c86c105a7cf315036d7131a4ef408bc6227639Evan Huntdlz_create(const char *dlzname, unsigned int argc, char *argv[],
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt void **dbdata, ...)
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* Allocate memory for our db structures and helper functions */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* Fill in the helper functions */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt while ((helper_name = va_arg(ap, const char *)) != NULL)
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt b9_add_helper(db, helper_name, va_arg(ap, void*));
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* verify we have 4 arg's passed to the driver */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: please supply 3 command line args. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Transactional mode. Highest safety - lowest speed.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: using transactional mode.");
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Concurrent mode. Lower safety (no rollback) -
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * higher speed.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: using concurrent mode.");
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Private mode. No inter-process communication & no locking.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Lowest saftey - highest speed.
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: using private mode.");
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "operating mode must be set to P or C or T. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * create bdbhpt environment
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Basically bdbhpt allocates and assigns memory to db->dbenv
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: db environment could not be created. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* open bdbhpt environment */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "db environment at '%s' could not be opened. "
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "BerkeleyDB error: %s",
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* open dlz_data database. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt result = bdbhpt_opendb(db->log, db->dbenv, DB_UNKNOWN, &db->data,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* open dlz_xfr database. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt result = bdbhpt_opendb(db->log, db->dbenv, DB_UNKNOWN, &db->xfr,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* open dlz_zone database. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt result = bdbhpt_opendb(db->log, db->dbenv, DB_UNKNOWN, &db->zone,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt /* open dlz_client database. */
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt result = bdbhpt_opendb(db->log, db->dbenv, DB_UNKNOWN, &db->client,
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "bdbhpt_dynamic: version %s, started",
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Shut down the backend
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt struct bdbhpt_instance *db = (struct bdbhpt_instance *)dbdata;
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt "dlz_bdbhpt_dynamic (%s): shutting down",
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Return the version of the API
72c86c105a7cf315036d7131a4ef408bc6227639Evan Hunt * Register a helper function from the bind9 dlz_dlopen driver
72c86c105a7cf315036d7131a4ef408bc6227639Evan Huntb9_add_helper(struct bdbhpt_instance *db, const char *helper_name, void *ptr) {