1999-01-28 23:53:36 +00:00
|
|
|
/*
|
2011-08-29 23:46:44 +00:00
|
|
|
* Copyright (C) 2004, 2005, 2007-2009, 2011 Internet Systems Consortium, Inc. ("ISC")
|
2001-01-09 22:01:04 +00:00
|
|
|
* Copyright (C) 1999-2001 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2007-06-18 23:47:57 +00:00
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
1999-01-28 23:53:36 +00:00
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2004-03-05 05:14:21 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL ISC 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.
|
1999-01-28 23:53:36 +00:00
|
|
|
*/
|
|
|
|
|
2011-08-29 23:46:44 +00:00
|
|
|
/* $Id: db_test.c,v 1.70 2011/08/29 23:46:44 tbox Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
2008-09-25 04:02:39 +00:00
|
|
|
/*! \file
|
2005-04-27 04:57:32 +00:00
|
|
|
* \author
|
1999-04-01 04:14:25 +00:00
|
|
|
* Principal Author: Bob Halley
|
|
|
|
*/
|
|
|
|
|
1999-01-28 23:53:36 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1999-01-29 07:05:09 +00:00
|
|
|
#include <stdlib.h>
|
1999-01-28 23:53:36 +00:00
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
#include <isc/commandline.h>
|
2000-11-28 03:34:10 +00:00
|
|
|
#include <isc/log.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/mem.h>
|
1999-10-09 02:42:55 +00:00
|
|
|
#include <isc/time.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/string.h>
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-01-28 23:53:36 +00:00
|
|
|
|
|
|
|
#include <dns/db.h>
|
1999-04-17 01:38:04 +00:00
|
|
|
#include <dns/dbiterator.h>
|
1999-04-14 02:37:44 +00:00
|
|
|
#include <dns/dbtable.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/fixedname.h>
|
2000-11-28 03:34:10 +00:00
|
|
|
#include <dns/log.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/rdataset.h>
|
|
|
|
#include <dns/rdatasetiter.h>
|
|
|
|
#include <dns/result.h>
|
1999-01-28 23:53:36 +00:00
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
#define MAXHOLD 100
|
|
|
|
#define MAXVERSIONS 100
|
1999-01-29 07:05:09 +00:00
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
typedef struct dbinfo {
|
|
|
|
dns_db_t * db;
|
|
|
|
dns_dbversion_t * version;
|
|
|
|
dns_dbversion_t * wversion;
|
|
|
|
dns_dbversion_t * rversions[MAXVERSIONS];
|
|
|
|
int rcount;
|
|
|
|
dns_dbnode_t * hold_nodes[MAXHOLD];
|
|
|
|
int hold_count;
|
1999-04-19 22:53:33 +00:00
|
|
|
dns_dbiterator_t * dbiterator;
|
|
|
|
dns_dbversion_t * iversion;
|
|
|
|
int pause_every;
|
1999-09-02 16:43:45 +00:00
|
|
|
isc_boolean_t ascending;
|
1999-04-17 01:38:04 +00:00
|
|
|
ISC_LINK(struct dbinfo) link;
|
|
|
|
} dbinfo;
|
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
static isc_mem_t * mctx = NULL;
|
|
|
|
static char dbtype[128];
|
|
|
|
static dns_dbtable_t * dbtable;
|
1999-04-17 01:38:04 +00:00
|
|
|
static ISC_LIST(dbinfo) dbs;
|
|
|
|
static dbinfo * cache_dbi = NULL;
|
|
|
|
static int pause_every = 0;
|
1999-09-02 16:43:45 +00:00
|
|
|
static isc_boolean_t ascending = ISC_TRUE;
|
1999-01-29 07:05:09 +00:00
|
|
|
|
1999-06-18 22:46:46 +00:00
|
|
|
static void
|
2000-06-01 19:11:07 +00:00
|
|
|
print_result(const char *message, isc_result_t result) {
|
1999-06-18 22:46:46 +00:00
|
|
|
|
2011-08-28 23:53:59 +00:00
|
|
|
if (message == NULL)
|
1999-06-18 22:46:46 +00:00
|
|
|
message = "";
|
2011-08-28 23:53:59 +00:00
|
|
|
printf("%s%sresult %08x: %s\n", message, (*message == '\0') ? "" : " ",
|
2005-03-16 22:22:31 +00:00
|
|
|
result, isc_result_totext(result));
|
1999-06-18 22:46:46 +00:00
|
|
|
}
|
|
|
|
|
1999-03-11 06:02:50 +00:00
|
|
|
static void
|
|
|
|
print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
|
|
|
|
isc_buffer_t text;
|
|
|
|
char t[1000];
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_t result;
|
1999-03-11 06:02:50 +00:00
|
|
|
isc_region_t r;
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&text, t, sizeof(t));
|
1999-04-30 21:15:02 +00:00
|
|
|
result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE,
|
|
|
|
&text);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&text, &r);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
1999-03-11 06:02:50 +00:00
|
|
|
printf("%.*s", (int)r.length, (char *)r.base);
|
|
|
|
else
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-03-11 06:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_rdatasets(dns_name_t *name, dns_rdatasetiter_t *rdsiter) {
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_t result;
|
1999-03-11 06:02:50 +00:00
|
|
|
dns_rdataset_t rdataset;
|
|
|
|
|
|
|
|
dns_rdataset_init(&rdataset);
|
|
|
|
result = dns_rdatasetiter_first(rdsiter);
|
2000-04-06 22:03:35 +00:00
|
|
|
while (result == ISC_R_SUCCESS) {
|
1999-03-11 06:02:50 +00:00
|
|
|
dns_rdatasetiter_current(rdsiter, &rdataset);
|
|
|
|
print_rdataset(name, &rdataset);
|
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
result = dns_rdatasetiter_next(rdsiter);
|
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_NOMORE)
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-03-11 06:02:50 +00:00
|
|
|
}
|
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
static dbinfo *
|
|
|
|
select_db(char *origintext) {
|
|
|
|
dns_fixedname_t forigin;
|
|
|
|
dns_name_t *origin;
|
|
|
|
isc_buffer_t source;
|
|
|
|
size_t len;
|
|
|
|
dbinfo *dbi;
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_t result;
|
1999-04-17 01:38:04 +00:00
|
|
|
|
|
|
|
if (strcasecmp(origintext, "cache") == 0) {
|
|
|
|
if (cache_dbi == NULL)
|
|
|
|
printf("the cache does not exist\n");
|
|
|
|
return (cache_dbi);
|
|
|
|
}
|
|
|
|
len = strlen(origintext);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, origintext, len);
|
1999-04-17 01:38:04 +00:00
|
|
|
isc_buffer_add(&source, len);
|
|
|
|
dns_fixedname_init(&forigin);
|
|
|
|
origin = dns_fixedname_name(&forigin);
|
2009-09-01 00:22:28 +00:00
|
|
|
result = dns_name_fromtext(origin, &source, dns_rootname, 0, NULL);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("bad name", result);
|
1999-04-17 01:38:04 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dbi = ISC_LIST_HEAD(dbs);
|
|
|
|
dbi != NULL;
|
|
|
|
dbi = ISC_LIST_NEXT(dbi, link)) {
|
|
|
|
if (dns_name_compare(dns_db_origin(dbi->db), origin) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (dbi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-09-02 16:43:45 +00:00
|
|
|
list(dbinfo *dbi, char *seektext) {
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_fixedname_t fname;
|
|
|
|
dns_name_t *name;
|
|
|
|
dns_dbnode_t *node;
|
|
|
|
dns_rdatasetiter_t *rdsiter;
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_t result;
|
1999-04-17 01:38:04 +00:00
|
|
|
int i;
|
1999-09-02 16:43:45 +00:00
|
|
|
size_t len;
|
|
|
|
dns_fixedname_t fseekname;
|
|
|
|
dns_name_t *seekname;
|
|
|
|
isc_buffer_t source;
|
1999-04-17 01:38:04 +00:00
|
|
|
|
1999-04-19 22:53:33 +00:00
|
|
|
dns_fixedname_init(&fname);
|
|
|
|
name = dns_fixedname_name(&fname);
|
|
|
|
|
|
|
|
if (dbi->dbiterator == NULL) {
|
|
|
|
INSIST(dbi->iversion == NULL);
|
|
|
|
if (dns_db_iszone(dbi->db)) {
|
|
|
|
if (dbi->version != NULL)
|
|
|
|
dns_db_attachversion(dbi->db, dbi->version,
|
|
|
|
&dbi->iversion);
|
|
|
|
else
|
|
|
|
dns_db_currentversion(dbi->db, &dbi->iversion);
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
result = dns_db_createiterator(dbi->db, 0, &dbi->dbiterator);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
1999-09-02 16:43:45 +00:00
|
|
|
if (seektext != NULL) {
|
|
|
|
len = strlen(seektext);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, seektext, len);
|
1999-09-02 16:43:45 +00:00
|
|
|
isc_buffer_add(&source, len);
|
|
|
|
dns_fixedname_init(&fseekname);
|
|
|
|
seekname = dns_fixedname_name(&fseekname);
|
|
|
|
result = dns_name_fromtext(seekname, &source,
|
1999-09-02 16:52:14 +00:00
|
|
|
dns_db_origin(
|
|
|
|
dbi->db),
|
2009-09-01 00:22:28 +00:00
|
|
|
0, NULL);
|
1999-09-02 16:43:45 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
|
|
|
result = dns_dbiterator_seek(
|
|
|
|
dbi->dbiterator,
|
|
|
|
seekname);
|
|
|
|
} else if (dbi->ascending)
|
|
|
|
result = dns_dbiterator_first(dbi->dbiterator);
|
|
|
|
else
|
|
|
|
result = dns_dbiterator_last(dbi->dbiterator);
|
|
|
|
}
|
1999-04-19 22:53:33 +00:00
|
|
|
} else
|
2000-04-06 22:03:35 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
1999-04-17 01:38:04 +00:00
|
|
|
|
|
|
|
node = NULL;
|
|
|
|
rdsiter = NULL;
|
|
|
|
i = 0;
|
2000-04-06 22:03:35 +00:00
|
|
|
while (result == ISC_R_SUCCESS) {
|
1999-04-19 22:53:33 +00:00
|
|
|
result = dns_dbiterator_current(dbi->dbiterator, &node, name);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN)
|
1999-04-17 01:38:04 +00:00
|
|
|
break;
|
1999-04-19 22:53:33 +00:00
|
|
|
result = dns_db_allrdatasets(dbi->db, node, dbi->iversion, 0,
|
1999-04-17 01:38:04 +00:00
|
|
|
&rdsiter);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_detachnode(dbi->db, &node);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
print_rdatasets(name, rdsiter);
|
|
|
|
dns_rdatasetiter_destroy(&rdsiter);
|
|
|
|
dns_db_detachnode(dbi->db, &node);
|
1999-09-02 16:43:45 +00:00
|
|
|
if (dbi->ascending)
|
|
|
|
result = dns_dbiterator_next(dbi->dbiterator);
|
|
|
|
else
|
|
|
|
result = dns_dbiterator_prev(dbi->dbiterator);
|
1999-04-17 01:38:04 +00:00
|
|
|
i++;
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS && i == dbi->pause_every) {
|
1999-04-19 22:53:33 +00:00
|
|
|
printf("[more...]\n");
|
|
|
|
result = dns_dbiterator_pause(dbi->dbiterator);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS)
|
1999-04-19 22:53:33 +00:00
|
|
|
return;
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_NOMORE)
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-17 01:38:04 +00:00
|
|
|
|
1999-04-19 22:53:33 +00:00
|
|
|
dns_dbiterator_destroy(&dbi->dbiterator);
|
|
|
|
if (dbi->iversion != NULL)
|
|
|
|
dns_db_closeversion(dbi->db, &dbi->iversion, ISC_FALSE);
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
|
|
|
|
1999-06-18 22:46:46 +00:00
|
|
|
static isc_result_t
|
2000-06-01 19:11:07 +00:00
|
|
|
load(const char *filename, const char *origintext, isc_boolean_t cache) {
|
1999-04-14 02:37:44 +00:00
|
|
|
dns_fixedname_t forigin;
|
|
|
|
dns_name_t *origin;
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_t result;
|
1999-04-14 02:37:44 +00:00
|
|
|
isc_buffer_t source;
|
|
|
|
size_t len;
|
1999-04-17 01:38:04 +00:00
|
|
|
dbinfo *dbi;
|
|
|
|
unsigned int i;
|
|
|
|
|
2001-11-27 01:56:32 +00:00
|
|
|
dbi = isc_mem_get(mctx, sizeof(*dbi));
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi == NULL)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_NOMEMORY);
|
1999-04-14 02:37:44 +00:00
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->db = NULL;
|
|
|
|
dbi->version = NULL;
|
|
|
|
dbi->wversion = NULL;
|
|
|
|
for (i = 0; i < MAXVERSIONS; i++)
|
|
|
|
dbi->rversions[i] = NULL;
|
|
|
|
dbi->hold_count = 0;
|
|
|
|
for (i = 0; i < MAXHOLD; i++)
|
|
|
|
dbi->hold_nodes[i] = NULL;
|
1999-04-19 22:53:33 +00:00
|
|
|
dbi->dbiterator = NULL;
|
|
|
|
dbi->iversion = NULL;
|
|
|
|
dbi->pause_every = pause_every;
|
1999-09-02 16:43:45 +00:00
|
|
|
dbi->ascending = ascending;
|
2000-11-28 03:34:10 +00:00
|
|
|
ISC_LINK_INIT(dbi, link);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
len = strlen(origintext);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, origintext, len);
|
1999-04-14 02:37:44 +00:00
|
|
|
isc_buffer_add(&source, len);
|
|
|
|
dns_fixedname_init(&forigin);
|
|
|
|
origin = dns_fixedname_name(&forigin);
|
2009-09-01 00:22:28 +00:00
|
|
|
result = dns_name_fromtext(origin, &source, dns_rootname, 0, NULL);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-04-14 02:37:44 +00:00
|
|
|
return (result);
|
|
|
|
|
2000-06-07 02:38:41 +00:00
|
|
|
result = dns_db_create(mctx, dbtype, origin,
|
2000-06-08 16:58:39 +00:00
|
|
|
cache ? dns_dbtype_cache : dns_dbtype_zone,
|
2000-06-07 02:38:41 +00:00
|
|
|
dns_rdataclass_in,
|
1999-04-17 01:38:04 +00:00
|
|
|
0, NULL, &dbi->db);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2001-11-27 01:56:32 +00:00
|
|
|
isc_mem_put(mctx, dbi, sizeof(*dbi));
|
1999-04-14 02:37:44 +00:00
|
|
|
return (result);
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
1999-04-14 02:37:44 +00:00
|
|
|
|
|
|
|
printf("loading %s (%s)\n", filename, origintext);
|
1999-04-17 01:38:04 +00:00
|
|
|
result = dns_db_load(dbi->db, filename);
|
2000-10-17 07:22:39 +00:00
|
|
|
if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) {
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_detach(&dbi->db);
|
2001-11-27 01:56:32 +00:00
|
|
|
isc_mem_put(mctx, dbi, sizeof(*dbi));
|
1999-04-14 02:37:44 +00:00
|
|
|
return (result);
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
1999-04-14 02:37:44 +00:00
|
|
|
printf("loaded\n");
|
|
|
|
|
|
|
|
if (cache) {
|
1999-04-17 01:38:04 +00:00
|
|
|
INSIST(cache_dbi == NULL);
|
|
|
|
dns_dbtable_adddefault(dbtable, dbi->db);
|
|
|
|
cache_dbi = dbi;
|
1999-04-14 02:37:44 +00:00
|
|
|
} else {
|
2000-04-06 22:03:35 +00:00
|
|
|
if (dns_dbtable_add(dbtable, dbi->db) != ISC_R_SUCCESS) {
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_detach(&dbi->db);
|
2001-11-27 01:56:32 +00:00
|
|
|
isc_mem_put(mctx, dbi, sizeof(*dbi));
|
1999-04-14 02:37:44 +00:00
|
|
|
return (result);
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ISC_LIST_APPEND(dbs, dbi, link);
|
1999-04-14 02:37:44 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-04-14 02:37:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unload_all(void) {
|
1999-04-17 01:38:04 +00:00
|
|
|
dbinfo *dbi, *dbi_next;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
for (dbi = ISC_LIST_HEAD(dbs); dbi != NULL; dbi = dbi_next) {
|
|
|
|
dbi_next = ISC_LIST_NEXT(dbi, link);
|
|
|
|
if (dns_db_iszone(dbi->db))
|
|
|
|
dns_dbtable_remove(dbtable, dbi->db);
|
|
|
|
else {
|
|
|
|
INSIST(dbi == cache_dbi);
|
|
|
|
dns_dbtable_removedefault(dbtable);
|
|
|
|
cache_dbi = NULL;
|
|
|
|
}
|
|
|
|
dns_db_detach(&dbi->db);
|
|
|
|
ISC_LIST_UNLINK(dbs, dbi, link);
|
2001-11-27 01:56:32 +00:00
|
|
|
isc_mem_put(mctx, dbi, sizeof(*dbi));
|
1999-04-14 02:37:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
#define DBI_CHECK(dbi) \
|
|
|
|
if ((dbi) == NULL) { \
|
|
|
|
printf("You must first select a database with !DB\n"); \
|
|
|
|
continue; \
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-01-28 23:53:36 +00:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[]) {
|
|
|
|
dns_db_t *db;
|
|
|
|
dns_dbnode_t *node;
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_t result;
|
1999-04-14 02:37:44 +00:00
|
|
|
dns_name_t name;
|
1999-01-28 23:53:36 +00:00
|
|
|
dns_offsets_t offsets;
|
|
|
|
size_t len;
|
1999-03-11 06:02:50 +00:00
|
|
|
isc_buffer_t source, target;
|
1999-01-28 23:53:36 +00:00
|
|
|
char s[1000];
|
1999-01-29 07:05:09 +00:00
|
|
|
char b[255];
|
1999-08-31 22:14:06 +00:00
|
|
|
dns_rdataset_t rdataset, sigrdataset;
|
1999-01-29 23:36:41 +00:00
|
|
|
int ch;
|
1999-04-01 04:14:25 +00:00
|
|
|
dns_rdatatype_t type = 1;
|
1999-03-05 23:26:47 +00:00
|
|
|
isc_boolean_t printnode = ISC_FALSE;
|
|
|
|
isc_boolean_t addmode = ISC_FALSE;
|
1999-03-06 00:51:12 +00:00
|
|
|
isc_boolean_t delmode = ISC_FALSE;
|
1999-04-09 19:18:52 +00:00
|
|
|
isc_boolean_t holdmode = ISC_FALSE;
|
1999-03-05 23:26:47 +00:00
|
|
|
isc_boolean_t verbose = ISC_FALSE;
|
1999-04-01 04:14:25 +00:00
|
|
|
isc_boolean_t done = ISC_FALSE;
|
1999-04-09 01:15:12 +00:00
|
|
|
isc_boolean_t quiet = ISC_FALSE;
|
|
|
|
isc_boolean_t time_lookups = ISC_FALSE;
|
1999-04-01 04:14:25 +00:00
|
|
|
isc_boolean_t found_as;
|
2000-04-19 18:48:46 +00:00
|
|
|
isc_boolean_t find_zonecut = ISC_FALSE;
|
|
|
|
isc_boolean_t noexact_zonecut = ISC_FALSE;
|
1999-04-17 01:38:04 +00:00
|
|
|
int i, v;
|
1999-03-11 06:02:50 +00:00
|
|
|
dns_rdatasetiter_t *rdsiter;
|
1999-04-01 04:14:25 +00:00
|
|
|
char t1[256];
|
|
|
|
char t2[256];
|
|
|
|
isc_buffer_t tb1, tb2;
|
|
|
|
isc_region_t r1, r2;
|
|
|
|
dns_fixedname_t foundname;
|
|
|
|
dns_name_t *fname;
|
2000-04-19 18:48:46 +00:00
|
|
|
unsigned int options = 0, zcoptions;
|
1999-10-09 02:42:55 +00:00
|
|
|
isc_time_t start, finish;
|
1999-04-14 02:37:44 +00:00
|
|
|
char *origintext;
|
1999-04-17 01:38:04 +00:00
|
|
|
dbinfo *dbi;
|
|
|
|
dns_dbversion_t *version;
|
|
|
|
dns_name_t *origin;
|
1999-04-27 23:20:27 +00:00
|
|
|
size_t memory_quota = 0;
|
1999-06-16 23:47:09 +00:00
|
|
|
dns_trust_t trust = 0;
|
2000-01-25 19:30:51 +00:00
|
|
|
unsigned int addopts;
|
2000-11-28 03:34:10 +00:00
|
|
|
isc_log_t *lctx = NULL;
|
1999-04-14 02:37:44 +00:00
|
|
|
|
1999-06-18 22:46:46 +00:00
|
|
|
dns_result_register();
|
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
1999-04-20 22:27:27 +00:00
|
|
|
RUNTIME_CHECK(dns_dbtable_create(mctx, dns_rdataclass_in, &dbtable) ==
|
2000-04-06 22:03:35 +00:00
|
|
|
ISC_R_SUCCESS);
|
1999-01-29 23:36:41 +00:00
|
|
|
|
2008-09-25 04:02:39 +00:00
|
|
|
|
2000-11-28 03:34:10 +00:00
|
|
|
|
1999-02-11 04:56:56 +00:00
|
|
|
strcpy(dbtype, "rbt");
|
2000-11-28 03:34:10 +00:00
|
|
|
while ((ch = isc_commandline_parse(argc, argv, "c:d:t:z:P:Q:glpqvT"))
|
1999-10-06 20:07:25 +00:00
|
|
|
!= -1) {
|
1999-01-29 23:36:41 +00:00
|
|
|
switch (ch) {
|
1999-04-01 04:14:25 +00:00
|
|
|
case 'c':
|
1999-10-06 20:07:25 +00:00
|
|
|
result = load(isc_commandline_argument, ".", ISC_TRUE);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-06-18 22:46:46 +00:00
|
|
|
printf("cache load(%s) %08x: %s\n",
|
1999-10-06 20:07:25 +00:00
|
|
|
isc_commandline_argument, result,
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_totext(result));
|
1999-01-29 23:36:41 +00:00
|
|
|
break;
|
1999-02-11 04:56:56 +00:00
|
|
|
case 'd':
|
1999-10-06 20:07:25 +00:00
|
|
|
strcpy(dbtype, isc_commandline_argument);
|
1999-02-11 04:56:56 +00:00
|
|
|
break;
|
1999-04-01 04:14:25 +00:00
|
|
|
case 'g':
|
1999-04-09 01:15:12 +00:00
|
|
|
options |= (DNS_DBFIND_GLUEOK|DNS_DBFIND_VALIDATEGLUE);
|
|
|
|
break;
|
2008-09-25 04:02:39 +00:00
|
|
|
case 'l':
|
2000-11-28 03:34:10 +00:00
|
|
|
RUNTIME_CHECK(isc_log_create(mctx, &lctx,
|
|
|
|
NULL) == ISC_R_SUCCESS);
|
|
|
|
isc_log_setcontext(lctx);
|
|
|
|
dns_log_init(lctx);
|
|
|
|
dns_log_setcontext(lctx);
|
|
|
|
break;
|
1999-04-09 01:15:12 +00:00
|
|
|
case 'q':
|
|
|
|
quiet = ISC_TRUE;
|
|
|
|
verbose = ISC_FALSE;
|
1999-01-29 23:36:41 +00:00
|
|
|
break;
|
1999-03-05 23:26:47 +00:00
|
|
|
case 'p':
|
|
|
|
printnode = ISC_TRUE;
|
|
|
|
break;
|
1999-04-17 01:38:04 +00:00
|
|
|
case 'P':
|
1999-10-06 20:07:25 +00:00
|
|
|
pause_every = atoi(isc_commandline_argument);
|
1999-04-17 01:38:04 +00:00
|
|
|
break;
|
1999-04-27 23:20:27 +00:00
|
|
|
case 'Q':
|
1999-10-06 20:07:25 +00:00
|
|
|
memory_quota = atoi(isc_commandline_argument);
|
1999-04-27 23:20:27 +00:00
|
|
|
isc_mem_setquota(mctx, memory_quota);
|
|
|
|
break;
|
1999-04-01 04:14:25 +00:00
|
|
|
case 't':
|
1999-10-06 20:07:25 +00:00
|
|
|
type = atoi(isc_commandline_argument);
|
1999-04-01 04:14:25 +00:00
|
|
|
break;
|
1999-04-09 01:15:12 +00:00
|
|
|
case 'T':
|
|
|
|
time_lookups = ISC_TRUE;
|
|
|
|
break;
|
1999-03-05 23:26:47 +00:00
|
|
|
case 'v':
|
|
|
|
verbose = ISC_TRUE;
|
|
|
|
break;
|
1999-04-01 04:14:25 +00:00
|
|
|
case 'z':
|
1999-10-06 20:07:25 +00:00
|
|
|
origintext = strrchr(isc_commandline_argument, '/');
|
1999-04-14 02:37:44 +00:00
|
|
|
if (origintext == NULL)
|
1999-10-06 20:07:25 +00:00
|
|
|
origintext = isc_commandline_argument;
|
1999-04-14 02:37:44 +00:00
|
|
|
else
|
|
|
|
origintext++; /* Skip '/'. */
|
1999-10-06 20:07:25 +00:00
|
|
|
result = load(isc_commandline_argument, origintext,
|
|
|
|
ISC_FALSE);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-06-18 22:46:46 +00:00
|
|
|
printf("zone load(%s) %08x: %s\n",
|
1999-10-06 20:07:25 +00:00
|
|
|
isc_commandline_argument, result,
|
1999-06-18 22:46:46 +00:00
|
|
|
isc_result_totext(result));
|
1999-04-01 04:14:25 +00:00
|
|
|
break;
|
1999-01-29 23:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-06 20:07:25 +00:00
|
|
|
argc -= isc_commandline_index;
|
|
|
|
argv += isc_commandline_index;
|
2011-08-28 23:53:59 +00:00
|
|
|
POST(argv);
|
1999-01-29 07:05:09 +00:00
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
if (argc != 0)
|
|
|
|
printf("ignoring trailing arguments\n");
|
1999-04-01 04:14:25 +00:00
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
/*
|
|
|
|
* Some final initialization...
|
|
|
|
*/
|
1999-04-01 04:14:25 +00:00
|
|
|
dns_fixedname_init(&foundname);
|
|
|
|
fname = dns_fixedname_name(&foundname);
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi = NULL;
|
|
|
|
origin = dns_rootname;
|
|
|
|
version = NULL;
|
1999-01-29 07:05:09 +00:00
|
|
|
|
1999-04-09 01:15:12 +00:00
|
|
|
if (time_lookups) {
|
2001-11-30 01:59:49 +00:00
|
|
|
TIME_NOW(&start);
|
1999-04-09 01:15:12 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 04:14:25 +00:00
|
|
|
while (!done) {
|
1999-04-09 01:15:12 +00:00
|
|
|
if (!quiet)
|
|
|
|
printf("\n");
|
2001-11-27 01:56:32 +00:00
|
|
|
if (fgets(s, sizeof(s), stdin) == NULL) {
|
1999-04-01 04:14:25 +00:00
|
|
|
done = ISC_TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
len = strlen(s);
|
2005-03-16 22:22:31 +00:00
|
|
|
if (len > 0U && s[len - 1] == '\n') {
|
1999-04-17 01:38:04 +00:00
|
|
|
s[len - 1] = '\0';
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
if (verbose && dbi != NULL) {
|
|
|
|
if (dbi->wversion != NULL)
|
|
|
|
printf("future version (%p)\n", dbi->wversion);
|
|
|
|
for (i = 0; i < dbi->rcount; i++)
|
|
|
|
if (dbi->rversions[i] != NULL)
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("open version %d (%p)\n", i,
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->rversions[i]);
|
1999-03-05 23:26:47 +00:00
|
|
|
}
|
1999-01-29 07:05:09 +00:00
|
|
|
dns_name_init(&name, offsets);
|
1999-03-05 23:26:47 +00:00
|
|
|
if (strcmp(s, "!R") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
|
|
|
if (dbi->rcount == MAXVERSIONS) {
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("too many open versions\n");
|
|
|
|
continue;
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_currentversion(dbi->db,
|
|
|
|
&dbi->rversions[dbi->rcount]);
|
|
|
|
printf("opened version %d\n", dbi->rcount);
|
|
|
|
dbi->version = dbi->rversions[dbi->rcount];
|
|
|
|
version = dbi->version;
|
|
|
|
dbi->rcount++;
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!W") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
|
|
|
if (dbi->wversion != NULL) {
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("using existing future version\n");
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->version = dbi->wversion;
|
|
|
|
version = dbi->version;
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
result = dns_db_newversion(dbi->db, &dbi->wversion);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-03-05 23:26:47 +00:00
|
|
|
else
|
|
|
|
printf("newversion\n");
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->version = dbi->wversion;
|
|
|
|
version = dbi->version;
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!C") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-03-05 23:26:47 +00:00
|
|
|
addmode = ISC_FALSE;
|
1999-03-06 00:51:12 +00:00
|
|
|
delmode = ISC_FALSE;
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi->version == NULL)
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi->version == dbi->wversion) {
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("closing future version\n");
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->wversion = NULL;
|
1999-03-05 23:26:47 +00:00
|
|
|
} else {
|
1999-04-17 01:38:04 +00:00
|
|
|
for (i = 0; i < dbi->rcount; i++) {
|
|
|
|
if (dbi->version ==
|
|
|
|
dbi->rversions[i]) {
|
|
|
|
dbi->rversions[i] = NULL;
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("closing open version %d\n",
|
|
|
|
i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_closeversion(dbi->db, &dbi->version, ISC_TRUE);
|
|
|
|
version = NULL;
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!X") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-03-05 23:26:47 +00:00
|
|
|
addmode = ISC_FALSE;
|
1999-03-06 00:51:12 +00:00
|
|
|
delmode = ISC_FALSE;
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi->version == NULL)
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi->version == dbi->wversion) {
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("aborting future version\n");
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->wversion = NULL;
|
1999-03-05 23:26:47 +00:00
|
|
|
} else {
|
1999-04-17 01:38:04 +00:00
|
|
|
for (i = 0; i < dbi->rcount; i++) {
|
|
|
|
if (dbi->version ==
|
|
|
|
dbi->rversions[i]) {
|
|
|
|
dbi->rversions[i] = NULL;
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("closing open version %d\n",
|
|
|
|
i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_closeversion(dbi->db, &dbi->version, ISC_FALSE);
|
|
|
|
version = NULL;
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!A") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-03-06 00:51:12 +00:00
|
|
|
delmode = ISC_FALSE;
|
1999-03-05 23:26:47 +00:00
|
|
|
if (addmode)
|
|
|
|
addmode = ISC_FALSE;
|
|
|
|
else
|
|
|
|
addmode = ISC_TRUE;
|
|
|
|
printf("addmode = %s\n", addmode ? "TRUE" : "FALSE");
|
|
|
|
continue;
|
1999-03-06 00:51:12 +00:00
|
|
|
} else if (strcmp(s, "!D") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-03-06 00:51:12 +00:00
|
|
|
addmode = ISC_FALSE;
|
|
|
|
if (delmode)
|
|
|
|
delmode = ISC_FALSE;
|
|
|
|
else
|
|
|
|
delmode = ISC_TRUE;
|
|
|
|
printf("delmode = %s\n", delmode ? "TRUE" : "FALSE");
|
|
|
|
continue;
|
1999-04-09 19:18:52 +00:00
|
|
|
} else if (strcmp(s, "!H") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-04-09 19:18:52 +00:00
|
|
|
if (holdmode)
|
|
|
|
holdmode = ISC_FALSE;
|
|
|
|
else
|
|
|
|
holdmode = ISC_TRUE;
|
|
|
|
printf("holdmode = %s\n", holdmode ? "TRUE" : "FALSE");
|
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!HR") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
|
|
|
for (i = 0; i < dbi->hold_count; i++)
|
|
|
|
dns_db_detachnode(dbi->db,
|
|
|
|
&dbi->hold_nodes[i]);
|
|
|
|
dbi->hold_count = 0;
|
1999-04-09 19:18:52 +00:00
|
|
|
holdmode = ISC_FALSE;
|
|
|
|
printf("held nodes have been detached\n");
|
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!VC") == 0) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-04-09 19:18:52 +00:00
|
|
|
printf("switching to current version\n");
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->version = NULL;
|
1999-04-09 19:18:52 +00:00
|
|
|
version = NULL;
|
|
|
|
continue;
|
1999-03-05 23:26:47 +00:00
|
|
|
} else if (strstr(s, "!V") == s) {
|
1999-04-17 01:38:04 +00:00
|
|
|
DBI_CHECK(dbi);
|
1999-03-05 23:26:47 +00:00
|
|
|
v = atoi(&s[2]);
|
1999-04-17 01:38:04 +00:00
|
|
|
if (v >= dbi->rcount) {
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("unknown open version %d\n", v);
|
|
|
|
continue;
|
1999-04-17 01:38:04 +00:00
|
|
|
} else if (dbi->rversions[v] == NULL) {
|
1999-03-05 23:26:47 +00:00
|
|
|
printf("version %d is not open\n", v);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
printf("switching to open version %d\n", v);
|
1999-04-17 01:38:04 +00:00
|
|
|
dbi->version = dbi->rversions[v];
|
|
|
|
version = dbi->version;
|
1999-03-05 23:26:47 +00:00
|
|
|
continue;
|
1999-06-16 23:47:09 +00:00
|
|
|
} else if (strstr(s, "!TR") == s) {
|
|
|
|
trust = (unsigned int)atoi(&s[3]);
|
|
|
|
printf("trust level is now %u\n", (unsigned int)trust);
|
|
|
|
continue;
|
1999-04-01 04:14:25 +00:00
|
|
|
} else if (strstr(s, "!T") == s) {
|
|
|
|
type = (unsigned int)atoi(&s[2]);
|
|
|
|
printf("now searching for type %u\n", type);
|
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!G") == 0) {
|
|
|
|
if ((options & DNS_DBFIND_GLUEOK) != 0)
|
|
|
|
options &= ~DNS_DBFIND_GLUEOK;
|
|
|
|
else
|
|
|
|
options |= DNS_DBFIND_GLUEOK;
|
|
|
|
printf("glue ok = %s\n",
|
|
|
|
((options & DNS_DBFIND_GLUEOK) != 0) ?
|
|
|
|
"TRUE" : "FALSE");
|
|
|
|
continue;
|
1999-04-09 01:15:12 +00:00
|
|
|
} else if (strcmp(s, "!GV") == 0) {
|
|
|
|
if ((options & DNS_DBFIND_VALIDATEGLUE) != 0)
|
|
|
|
options &= ~DNS_DBFIND_VALIDATEGLUE;
|
|
|
|
else
|
|
|
|
options |= DNS_DBFIND_VALIDATEGLUE;
|
|
|
|
printf("validate glue = %s\n",
|
|
|
|
((options & DNS_DBFIND_VALIDATEGLUE) != 0) ?
|
|
|
|
"TRUE" : "FALSE");
|
|
|
|
continue;
|
1999-08-12 07:51:50 +00:00
|
|
|
} else if (strcmp(s, "!WC") == 0) {
|
|
|
|
if ((options & DNS_DBFIND_NOWILD) != 0)
|
|
|
|
options &= ~DNS_DBFIND_NOWILD;
|
|
|
|
else
|
|
|
|
options |= DNS_DBFIND_NOWILD;
|
|
|
|
printf("wildcard matching = %s\n",
|
|
|
|
((options & DNS_DBFIND_NOWILD) == 0) ?
|
|
|
|
"TRUE" : "FALSE");
|
|
|
|
continue;
|
1999-09-02 16:43:45 +00:00
|
|
|
} else if (strstr(s, "!LS ") == s) {
|
|
|
|
DBI_CHECK(dbi);
|
|
|
|
list(dbi, &s[4]);
|
|
|
|
continue;
|
1999-04-17 01:38:04 +00:00
|
|
|
} else if (strcmp(s, "!LS") == 0) {
|
|
|
|
DBI_CHECK(dbi);
|
1999-09-02 16:43:45 +00:00
|
|
|
list(dbi, NULL);
|
1999-06-08 10:35:23 +00:00
|
|
|
continue;
|
|
|
|
} else if (strstr(s, "!DU ") == s) {
|
|
|
|
DBI_CHECK(dbi);
|
|
|
|
result = dns_db_dump(dbi->db, dbi->version, s+4);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-06-18 22:46:46 +00:00
|
|
|
printf("\n");
|
|
|
|
print_result("", result);
|
|
|
|
}
|
1999-06-16 23:47:09 +00:00
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!PN") == 0) {
|
|
|
|
if (printnode)
|
|
|
|
printnode = ISC_FALSE;
|
|
|
|
else
|
|
|
|
printnode = ISC_TRUE;
|
|
|
|
printf("printnode = %s\n",
|
|
|
|
printnode ? "TRUE" : "FALSE");
|
1999-04-17 01:38:04 +00:00
|
|
|
continue;
|
1999-04-19 22:53:33 +00:00
|
|
|
} else if (strstr(s, "!P") == s) {
|
|
|
|
DBI_CHECK(dbi);
|
|
|
|
v = atoi(&s[2]);
|
|
|
|
dbi->pause_every = v;
|
|
|
|
continue;
|
1999-09-02 16:43:45 +00:00
|
|
|
} else if (strcmp(s, "!+") == 0) {
|
|
|
|
DBI_CHECK(dbi);
|
|
|
|
dbi->ascending = ISC_TRUE;
|
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!-") == 0) {
|
|
|
|
DBI_CHECK(dbi);
|
|
|
|
dbi->ascending = ISC_FALSE;
|
|
|
|
continue;
|
1999-04-17 01:38:04 +00:00
|
|
|
} else if (strcmp(s, "!DB") == 0) {
|
|
|
|
dbi = NULL;
|
|
|
|
origin = dns_rootname;
|
|
|
|
version = NULL;
|
|
|
|
printf("now searching all databases\n");
|
|
|
|
continue;
|
|
|
|
} else if (strncmp(s, "!DB ", 4) == 0) {
|
|
|
|
dbi = select_db(s+4);
|
|
|
|
if (dbi != NULL) {
|
|
|
|
db = dbi->db;
|
|
|
|
origin = dns_db_origin(dbi->db);
|
|
|
|
version = dbi->version;
|
|
|
|
addmode = ISC_FALSE;
|
|
|
|
delmode = ISC_FALSE;
|
|
|
|
holdmode = ISC_FALSE;
|
|
|
|
} else {
|
|
|
|
db = NULL;
|
|
|
|
version = NULL;
|
|
|
|
origin = dns_rootname;
|
|
|
|
printf("database not found; "
|
|
|
|
"now searching all databases\n");
|
|
|
|
}
|
|
|
|
continue;
|
2000-04-19 18:48:46 +00:00
|
|
|
} else if (strcmp(s, "!ZC") == 0) {
|
|
|
|
if (find_zonecut)
|
|
|
|
find_zonecut = ISC_FALSE;
|
|
|
|
else
|
|
|
|
find_zonecut = ISC_TRUE;
|
|
|
|
printf("find_zonecut = %s\n",
|
|
|
|
find_zonecut ? "TRUE" : "FALSE");
|
|
|
|
continue;
|
|
|
|
} else if (strcmp(s, "!NZ") == 0) {
|
|
|
|
if (noexact_zonecut)
|
|
|
|
noexact_zonecut = ISC_FALSE;
|
|
|
|
else
|
|
|
|
noexact_zonecut = ISC_TRUE;
|
|
|
|
printf("noexact_zonecut = %s\n",
|
|
|
|
noexact_zonecut ? "TRUE" : "FALSE");
|
|
|
|
continue;
|
1999-03-05 23:26:47 +00:00
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&source, s, len);
|
1999-01-29 07:05:09 +00:00
|
|
|
isc_buffer_add(&source, len);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&target, b, sizeof(b));
|
2009-09-01 00:22:28 +00:00
|
|
|
result = dns_name_fromtext(&name, &source, origin, 0, &target);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("bad name: ", result);
|
1999-01-29 07:05:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
1999-04-01 04:14:25 +00:00
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi == NULL) {
|
2000-04-19 18:48:46 +00:00
|
|
|
zcoptions = 0;
|
|
|
|
if (noexact_zonecut)
|
|
|
|
zcoptions |= DNS_DBTABLEFIND_NOEXACT;
|
1999-04-17 01:38:04 +00:00
|
|
|
db = NULL;
|
2000-04-19 18:48:46 +00:00
|
|
|
result = dns_dbtable_find(dbtable, &name, zcoptions,
|
|
|
|
&db);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS &&
|
1999-04-17 01:38:04 +00:00
|
|
|
result != DNS_R_PARTIALMATCH) {
|
1999-06-18 22:46:46 +00:00
|
|
|
if (!quiet) {
|
|
|
|
printf("\n");
|
|
|
|
print_result("", result);
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
continue;
|
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&tb1, t1, sizeof(t1));
|
1999-04-17 01:38:04 +00:00
|
|
|
result = dns_name_totext(dns_db_origin(db), ISC_FALSE,
|
|
|
|
&tb1);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-06-18 22:46:46 +00:00
|
|
|
printf("\n");
|
|
|
|
print_result("", result);
|
1999-04-17 01:38:04 +00:00
|
|
|
dns_db_detach(&db);
|
|
|
|
continue;
|
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&tb1, &r1);
|
1999-04-17 01:38:04 +00:00
|
|
|
printf("\ndatabase = %.*s (%s)\n",
|
|
|
|
(int)r1.length, r1.base,
|
|
|
|
(dns_db_iszone(db)) ? "zone" : "cache");
|
1999-04-14 02:37:44 +00:00
|
|
|
}
|
1999-04-05 20:56:03 +00:00
|
|
|
node = NULL;
|
1999-04-01 04:14:25 +00:00
|
|
|
dns_rdataset_init(&rdataset);
|
1999-08-31 22:14:06 +00:00
|
|
|
dns_rdataset_init(&sigrdataset);
|
2000-04-19 18:48:46 +00:00
|
|
|
|
|
|
|
if (find_zonecut && dns_db_iscache(db)) {
|
|
|
|
zcoptions = options;
|
|
|
|
if (noexact_zonecut)
|
|
|
|
zcoptions |= DNS_DBFIND_NOEXACT;
|
|
|
|
result = dns_db_findzonecut(db, &name, zcoptions,
|
|
|
|
0, &node, fname,
|
|
|
|
&rdataset, &sigrdataset);
|
|
|
|
} else {
|
|
|
|
result = dns_db_find(db, &name, version, type,
|
|
|
|
options, 0, &node, fname,
|
|
|
|
&rdataset, &sigrdataset);
|
|
|
|
}
|
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
if (!quiet) {
|
|
|
|
if (dbi != NULL)
|
|
|
|
printf("\n");
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-17 01:38:04 +00:00
|
|
|
}
|
1999-04-01 04:14:25 +00:00
|
|
|
|
|
|
|
found_as = ISC_FALSE;
|
|
|
|
switch (result) {
|
2000-04-06 22:03:35 +00:00
|
|
|
case ISC_R_SUCCESS:
|
1999-04-01 04:14:25 +00:00
|
|
|
case DNS_R_GLUE:
|
|
|
|
case DNS_R_CNAME:
|
1999-04-05 20:56:03 +00:00
|
|
|
case DNS_R_ZONECUT:
|
1999-04-01 04:14:25 +00:00
|
|
|
break;
|
|
|
|
case DNS_R_DNAME:
|
|
|
|
case DNS_R_DELEGATION:
|
|
|
|
found_as = ISC_TRUE;
|
|
|
|
break;
|
2000-04-06 22:03:35 +00:00
|
|
|
case DNS_R_NXRRSET:
|
1999-08-19 20:46:59 +00:00
|
|
|
if (dns_rdataset_isassociated(&rdataset))
|
|
|
|
break;
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi != NULL) {
|
|
|
|
if (holdmode) {
|
|
|
|
RUNTIME_CHECK(dbi->hold_count <
|
|
|
|
MAXHOLD);
|
|
|
|
dbi->hold_nodes[dbi->hold_count++] =
|
|
|
|
node;
|
|
|
|
node = NULL;
|
|
|
|
} else
|
|
|
|
dns_db_detachnode(db, &node);
|
1999-04-14 02:37:44 +00:00
|
|
|
} else {
|
1999-04-09 19:18:52 +00:00
|
|
|
dns_db_detachnode(db, &node);
|
1999-04-14 02:37:44 +00:00
|
|
|
dns_db_detach(&db);
|
|
|
|
}
|
1999-04-01 04:14:25 +00:00
|
|
|
continue;
|
1999-08-26 07:00:43 +00:00
|
|
|
case DNS_R_NXDOMAIN:
|
|
|
|
if (dns_rdataset_isassociated(&rdataset))
|
|
|
|
break;
|
|
|
|
/* FALLTHROUGH */
|
1999-04-01 04:14:25 +00:00
|
|
|
default:
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi == NULL)
|
|
|
|
dns_db_detach(&db);
|
1999-04-09 01:15:12 +00:00
|
|
|
if (quiet)
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-01 04:14:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
1999-04-09 01:15:12 +00:00
|
|
|
if (found_as && !quiet) {
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&tb1, t1, sizeof(t1));
|
|
|
|
isc_buffer_init(&tb2, t2, sizeof(t2));
|
1999-04-01 04:14:25 +00:00
|
|
|
result = dns_name_totext(&name, ISC_FALSE, &tb1);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-14 02:37:44 +00:00
|
|
|
dns_db_detachnode(db, &node);
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi == NULL)
|
|
|
|
dns_db_detach(&db);
|
1999-04-01 04:14:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
result = dns_name_totext(fname, ISC_FALSE, &tb2);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-14 02:37:44 +00:00
|
|
|
dns_db_detachnode(db, &node);
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi == NULL)
|
|
|
|
dns_db_detach(&db);
|
1999-04-01 04:14:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_usedregion(&tb1, &r1);
|
|
|
|
isc_buffer_usedregion(&tb2, &r2);
|
1999-04-01 04:14:25 +00:00
|
|
|
printf("found %.*s as %.*s\n",
|
|
|
|
(int)r1.length, r1.base,
|
|
|
|
(int)r2.length, r2.base);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (printnode)
|
|
|
|
dns_db_printnode(db, node, stdout);
|
|
|
|
|
|
|
|
if (!found_as && type == dns_rdatatype_any) {
|
|
|
|
rdsiter = NULL;
|
1999-04-09 01:15:12 +00:00
|
|
|
result = dns_db_allrdatasets(db, node, version, 0,
|
1999-04-01 04:14:25 +00:00
|
|
|
&rdsiter);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
1999-04-09 01:15:12 +00:00
|
|
|
if (!quiet)
|
|
|
|
print_rdatasets(fname, rdsiter);
|
1999-04-01 04:14:25 +00:00
|
|
|
dns_rdatasetiter_destroy(&rdsiter);
|
|
|
|
} else
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-01 04:14:25 +00:00
|
|
|
} else {
|
1999-04-09 01:15:12 +00:00
|
|
|
if (!quiet)
|
|
|
|
print_rdataset(fname, &rdataset);
|
1999-08-31 22:14:06 +00:00
|
|
|
if (dns_rdataset_isassociated(&sigrdataset)) {
|
|
|
|
if (!quiet)
|
|
|
|
print_rdataset(fname, &sigrdataset);
|
|
|
|
dns_rdataset_disassociate(&sigrdataset);
|
|
|
|
}
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi != NULL && addmode && !found_as) {
|
1999-04-01 04:14:25 +00:00
|
|
|
rdataset.ttl++;
|
1999-06-16 23:47:09 +00:00
|
|
|
rdataset.trust = trust;
|
2000-01-25 19:30:51 +00:00
|
|
|
if (dns_db_iszone(db))
|
|
|
|
addopts = DNS_DBADD_MERGE;
|
|
|
|
else
|
|
|
|
addopts = 0;
|
1999-04-01 04:14:25 +00:00
|
|
|
result = dns_db_addrdataset(db, node, version,
|
1999-05-05 22:57:20 +00:00
|
|
|
0, &rdataset,
|
2000-01-25 19:30:51 +00:00
|
|
|
addopts, NULL);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-09 01:15:12 +00:00
|
|
|
if (printnode)
|
|
|
|
dns_db_printnode(db, node, stdout);
|
1999-04-17 01:38:04 +00:00
|
|
|
} else if (dbi != NULL && delmode && !found_as) {
|
1999-04-01 04:14:25 +00:00
|
|
|
result = dns_db_deleterdataset(db, node,
|
2000-02-08 19:27:36 +00:00
|
|
|
version, type,
|
|
|
|
0);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-06-18 22:46:46 +00:00
|
|
|
print_result("", result);
|
1999-04-09 01:15:12 +00:00
|
|
|
if (printnode)
|
|
|
|
dns_db_printnode(db, node, stdout);
|
1999-01-29 22:21:35 +00:00
|
|
|
}
|
1999-04-01 04:14:25 +00:00
|
|
|
dns_rdataset_disassociate(&rdataset);
|
1999-01-29 07:05:09 +00:00
|
|
|
}
|
1999-04-01 04:14:25 +00:00
|
|
|
|
1999-04-17 01:38:04 +00:00
|
|
|
if (dbi != NULL) {
|
|
|
|
if (holdmode) {
|
|
|
|
RUNTIME_CHECK(dbi->hold_count < MAXHOLD);
|
|
|
|
dbi->hold_nodes[dbi->hold_count++] = node;
|
|
|
|
node = NULL;
|
|
|
|
} else
|
|
|
|
dns_db_detachnode(db, &node);
|
1999-04-14 02:37:44 +00:00
|
|
|
} else {
|
1999-04-09 19:18:52 +00:00
|
|
|
dns_db_detachnode(db, &node);
|
1999-04-14 02:37:44 +00:00
|
|
|
dns_db_detach(&db);
|
|
|
|
}
|
1999-01-28 23:53:36 +00:00
|
|
|
}
|
|
|
|
|
1999-04-09 01:15:12 +00:00
|
|
|
if (time_lookups) {
|
1999-10-09 02:42:55 +00:00
|
|
|
isc_uint64_t usec;
|
|
|
|
|
2001-11-30 01:59:49 +00:00
|
|
|
TIME_NOW(&finish);
|
1999-10-09 02:42:55 +00:00
|
|
|
|
|
|
|
usec = isc_time_microdiff(&finish, &start);
|
|
|
|
|
1999-04-09 01:15:12 +00:00
|
|
|
printf("elapsed time: %lu.%06lu seconds\n",
|
1999-10-10 17:13:29 +00:00
|
|
|
(unsigned long)(usec / 1000000),
|
|
|
|
(unsigned long)(usec % 1000000));
|
1999-04-09 01:15:12 +00:00
|
|
|
}
|
|
|
|
|
1999-04-14 02:37:44 +00:00
|
|
|
unload_all();
|
|
|
|
|
1999-05-12 09:47:59 +00:00
|
|
|
dns_dbtable_detach(&dbtable);
|
1999-01-28 23:53:36 +00:00
|
|
|
|
2000-11-28 03:34:10 +00:00
|
|
|
if (lctx != NULL)
|
|
|
|
isc_log_destroy(&lctx);
|
|
|
|
|
1999-04-09 01:15:12 +00:00
|
|
|
if (!quiet)
|
|
|
|
isc_mem_stats(mctx, stdout);
|
1999-01-28 23:53:36 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|