mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 18:19:42 +00:00
libdns refactoring: get rid of multiple versions of dns_zone_setfile, dns_zone_notifyreceive, dns_zone_dumptostream, dns_zone_getserial
This commit is contained in:
parent
42ee8c853a
commit
7dbc6768d6
@ -691,7 +691,8 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
||||
CHECK(dns_name_fromtext(origin, &buffer, dns_rootname, 0, NULL));
|
||||
CHECK(dns_zone_setorigin(zone, origin));
|
||||
CHECK(dns_zone_setdbtype(zone, 1, (const char * const *) dbtype));
|
||||
CHECK(dns_zone_setfile2(zone, filename, fileformat));
|
||||
CHECK(dns_zone_setfile(zone, filename, fileformat,
|
||||
&dns_master_style_default));
|
||||
if (journal != NULL)
|
||||
CHECK(dns_zone_setjournal(zone, journal));
|
||||
|
||||
@ -764,8 +765,8 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
|
||||
}
|
||||
}
|
||||
|
||||
result = dns_zone_dumptostream3(zone, output, fileformat, style,
|
||||
rawversion);
|
||||
result = dns_zone_dumptostream(zone, output, fileformat, style,
|
||||
rawversion);
|
||||
if (output != stdout)
|
||||
(void)isc_stdio_close(output);
|
||||
|
||||
|
@ -6145,7 +6145,8 @@ add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx) {
|
||||
defaultview ? "managed-keys" : view->name,
|
||||
defaultview ? "bind" : "mkeys",
|
||||
filename, sizeof(filename)));
|
||||
CHECK(dns_zone_setfile(zone, filename));
|
||||
CHECK(dns_zone_setfile(zone, filename, dns_masterformat_text,
|
||||
&dns_master_style_default));
|
||||
|
||||
dns_zone_setview(zone, view);
|
||||
dns_zone_settype(zone, dns_zone_key);
|
||||
@ -13936,10 +13937,18 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex,
|
||||
}
|
||||
|
||||
/* Serial number */
|
||||
serial = dns_zone_getserial(mayberaw);
|
||||
result = dns_zone_getserial(mayberaw, &serial);
|
||||
/* XXXWPK TODO this is to mirror old behavior with dns_zone_getserial */
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
serial = 0;
|
||||
}
|
||||
snprintf(serbuf, sizeof(serbuf), "%u", serial);
|
||||
if (hasraw) {
|
||||
signed_serial = dns_zone_getserial(zone);
|
||||
result = dns_zone_getserial(zone, &signed_serial);
|
||||
/* XXXWPK TODO ut supra */
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
serial = 0;
|
||||
}
|
||||
snprintf(sserbuf, sizeof(sserbuf), "%u", signed_serial);
|
||||
}
|
||||
|
||||
|
@ -1494,7 +1494,7 @@ zone_xmlrender(dns_zone_t *zone, void *arg) {
|
||||
TRY0(xmlTextWriterEndElement(writer)); /* type */
|
||||
|
||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "serial"));
|
||||
if (dns_zone_getserial2(zone, &serial) == ISC_R_SUCCESS)
|
||||
if (dns_zone_getserial(zone, &serial) == ISC_R_SUCCESS)
|
||||
TRY0(xmlTextWriterWriteFormatString(writer, "%u", serial));
|
||||
else
|
||||
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "-"));
|
||||
@ -2271,7 +2271,7 @@ zone_jsonrender(dns_zone_t *zone, void *arg) {
|
||||
dns_rdataclass_format(rdclass, classbuf, sizeof(classbuf));
|
||||
class_only = classbuf;
|
||||
|
||||
if (dns_zone_getserial2(zone, &serial) != ISC_R_SUCCESS)
|
||||
if (dns_zone_getserial(zone, &serial) != ISC_R_SUCCESS)
|
||||
zoneobj = addzone(zone_name_only, class_only,
|
||||
user_zonetype(zone), 0, ISC_FALSE);
|
||||
else
|
||||
|
@ -1049,21 +1049,21 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
||||
size_t signedlen = strlen(filename) + sizeof(SIGNED);
|
||||
char *signedname;
|
||||
|
||||
RETERR(dns_zone_setfile3(raw, filename,
|
||||
masterformat, masterstyle));
|
||||
RETERR(dns_zone_setfile(raw, filename,
|
||||
masterformat, masterstyle));
|
||||
signedname = isc_mem_get(mctx, signedlen);
|
||||
if (signedname == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
(void)snprintf(signedname, signedlen, "%s" SIGNED, filename);
|
||||
result = dns_zone_setfile3(zone, signedname,
|
||||
dns_masterformat_raw, NULL);
|
||||
result = dns_zone_setfile(zone, signedname,
|
||||
dns_masterformat_raw, NULL);
|
||||
isc_mem_put(mctx, signedname, signedlen);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
} else
|
||||
RETERR(dns_zone_setfile3(zone, filename,
|
||||
masterformat, masterstyle));
|
||||
RETERR(dns_zone_setfile(zone, filename,
|
||||
masterformat, masterstyle));
|
||||
|
||||
obj = NULL;
|
||||
result = cfg_map_get(zoptions, "journal", &obj);
|
||||
|
@ -107,7 +107,8 @@ setup(const char *zonename, const char *filename, const char *classname) {
|
||||
result = dns_zone_setdbtype(zone, 1, &rbt);
|
||||
ERRRET(result, "dns_zone_setdatabase");
|
||||
|
||||
result = dns_zone_setfile(zone, filename);
|
||||
result = dns_zone_setfile(zone, filename, dns_masterformat_text,
|
||||
&dns_master_style_default);
|
||||
ERRRET(result, "dns_zone_setfile");
|
||||
|
||||
region.base = classname;
|
||||
@ -190,7 +191,9 @@ query(void) {
|
||||
if (s != NULL)
|
||||
*s = '\0';
|
||||
if (strcmp(buf, "dump") == 0) {
|
||||
dns_zone_dumptostream(zone, stdout);
|
||||
dns_zone_dumptostream(zone, stdout,
|
||||
dns_masterformat_text,
|
||||
&dns_master_style_default, 0);
|
||||
continue;
|
||||
}
|
||||
if (strlen(buf) == 0U)
|
||||
|
@ -154,7 +154,7 @@ load_zone(dns_zone_t *zone) {
|
||||
goto cleanup;
|
||||
zone_dynamic = (result == DNS_R_DYNAMIC);
|
||||
|
||||
CHECK(dns_zone_getserial2(zone, &serial));
|
||||
CHECK(dns_zone_getserial(zone, &serial));
|
||||
dns_zone_log(zone, ISC_LOG_INFO, "loaded serial %u", serial);
|
||||
|
||||
if (zone_dynamic)
|
||||
|
@ -178,15 +178,10 @@ dns_zone_getclass(dns_zone_t *zone);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp);
|
||||
|
||||
isc_uint32_t
|
||||
dns_zone_getserial(dns_zone_t *zone);
|
||||
dns_zone_getserial(dns_zone_t *zone, isc_uint32_t *serialp);
|
||||
/*%<
|
||||
* Returns the current serial number of the zone. On success, the SOA
|
||||
* serial of the zone will be copied into '*serialp'.
|
||||
* dns_zone_getserial() cannot catch failure cases and is deprecated by
|
||||
* dns_zone_getserial2().
|
||||
*
|
||||
* Requires:
|
||||
*\li 'zone' to be a valid zone.
|
||||
@ -272,14 +267,8 @@ dns_zone_getorigin(dns_zone_t *zone);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_zone_setfile(dns_zone_t *zone, const char *file);
|
||||
|
||||
isc_result_t
|
||||
dns_zone_setfile2(dns_zone_t *zone, const char *file,
|
||||
dns_masterformat_t format);
|
||||
isc_result_t
|
||||
dns_zone_setfile3(dns_zone_t *zone, const char *file,
|
||||
dns_masterformat_t format, const dns_master_style_t *style);
|
||||
dns_zone_setfile(dns_zone_t *zone, const char *file,
|
||||
dns_masterformat_t format, const dns_master_style_t *style);
|
||||
/*%<
|
||||
* Sets the name of the master file in the format of 'format' from which
|
||||
* the zone loads its database to 'file'.
|
||||
@ -289,15 +278,6 @@ dns_zone_setfile3(dns_zone_t *zone, const char *file,
|
||||
* For zones with persistent databases, the file name
|
||||
* setting is ignored.
|
||||
*
|
||||
* dns_zone_setfile() is a backward-compatible form of
|
||||
* dns_zone_setfile2(), which always specifies the
|
||||
* dns_masterformat_text (RFC1035) format.
|
||||
*
|
||||
* dns_zone_setfile2() is a backward-compatible form of
|
||||
* dns_zone_setfile3(), which also specifies the style
|
||||
* that should be used if a zone using the 'text'
|
||||
* masterformat is ever dumped.
|
||||
*
|
||||
* Require:
|
||||
*\li 'zone' to be a valid zone.
|
||||
*
|
||||
@ -602,15 +582,9 @@ dns_zone_dump(dns_zone_t *zone);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_zone_dumptostream(dns_zone_t *zone, FILE *fd);
|
||||
|
||||
isc_result_t
|
||||
dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
const dns_master_style_t *style);
|
||||
isc_result_t
|
||||
dns_zone_dumptostream3(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
const dns_master_style_t *style,
|
||||
const isc_uint32_t rawversion);
|
||||
dns_zone_dumptostream(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
const dns_master_style_t *style,
|
||||
const isc_uint32_t rawversion);
|
||||
/*%<
|
||||
* Write the zone to stream 'fd' in the specified 'format'.
|
||||
* If the 'format' is dns_masterformat_text (RFC1035), 'style' also
|
||||
@ -632,17 +606,6 @@ dns_zone_dumptostream3(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
*\li 'fd' to be a stream open for writing.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);
|
||||
/*%<
|
||||
* The same as dns_zone_dumptostream, but dumps the zone with
|
||||
* different dump settings (dns_master_style_full).
|
||||
*
|
||||
* Require:
|
||||
*\li 'zone' to be a valid zone.
|
||||
*\li 'fd' to be a stream open for writing.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_zone_maintenance(dns_zone_t *zone);
|
||||
/*%<
|
||||
@ -1266,10 +1229,7 @@ dns_zone_getjournalsize(dns_zone_t *zone);
|
||||
|
||||
isc_result_t
|
||||
dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
|
||||
dns_message_t *msg);
|
||||
isc_result_t
|
||||
dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from,
|
||||
isc_sockaddr_t *to, dns_message_t *msg);
|
||||
isc_sockaddr_t *to, dns_message_t *msg);
|
||||
/*%<
|
||||
* Tell the zone that it has received a NOTIFY message from another
|
||||
* server. This may cause some zone maintenance activity to occur.
|
||||
|
@ -168,7 +168,8 @@ ATF_TC_BODY(asyncload_zone, tc) {
|
||||
|
||||
ATF_CHECK(!dns__zone_loadpending(zone));
|
||||
ATF_CHECK(!done);
|
||||
dns_zone_setfile(zone, "testdata/zt/zone1.db");
|
||||
dns_zone_setfile(zone, "testdata/zt/zone1.db", dns_masterformat_text,
|
||||
&dns_master_style_default);
|
||||
|
||||
args.arg1 = zone;
|
||||
args.arg2 = &done;
|
||||
@ -216,17 +217,20 @@ ATF_TC_BODY(asyncload_zt, tc) {
|
||||
|
||||
result = dns_test_makezone("foo", &zone1, NULL, ISC_TRUE);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
dns_zone_setfile(zone1, "testdata/zt/zone1.db");
|
||||
dns_zone_setfile(zone1, "testdata/zt/zone1.db",
|
||||
dns_masterformat_text, &dns_master_style_default);
|
||||
view = dns_zone_getview(zone1);
|
||||
|
||||
result = dns_test_makezone("bar", &zone2, view, ISC_TRUE);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
dns_zone_setfile(zone2, "testdata/zt/zone1.db");
|
||||
dns_zone_setfile(zone2, "testdata/zt/zone1.db",
|
||||
dns_masterformat_text, &dns_master_style_default);
|
||||
|
||||
/* This one will fail to load */
|
||||
result = dns_test_makezone("fake", &zone3, view, ISC_TRUE);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
dns_zone_setfile(zone3, "testdata/zt/nonexistent.db");
|
||||
dns_zone_setfile(zone3, "testdata/zt/nonexistent.db",
|
||||
dns_masterformat_text, &dns_master_style_default);
|
||||
|
||||
zt = view->zonetable;
|
||||
ATF_REQUIRE(zt != NULL);
|
||||
|
@ -1132,14 +1132,11 @@ dns_zone_dialup
|
||||
dns_zone_dlzpostload
|
||||
dns_zone_dump
|
||||
dns_zone_dumptostream
|
||||
dns_zone_dumptostream2
|
||||
dns_zone_dumptostream3
|
||||
dns_zone_expire
|
||||
dns_zone_first
|
||||
dns_zone_flush
|
||||
dns_zone_forcereload
|
||||
dns_zone_forwardupdate
|
||||
dns_zone_fulldumptostream
|
||||
dns_zone_get_parentcatz
|
||||
dns_zone_get_rpz_num
|
||||
dns_zone_getadded
|
||||
@ -1191,7 +1188,6 @@ dns_zone_getrequestexpire
|
||||
dns_zone_getrequestixfr
|
||||
dns_zone_getrequeststats
|
||||
dns_zone_getserial
|
||||
dns_zone_getserial2
|
||||
dns_zone_getserialupdatemethod
|
||||
dns_zone_getsignatures
|
||||
dns_zone_getsigresigninginterval
|
||||
@ -1228,7 +1224,6 @@ dns_zone_nameonly
|
||||
dns_zone_next
|
||||
dns_zone_notify
|
||||
dns_zone_notifyreceive
|
||||
dns_zone_notifyreceive2
|
||||
dns_zone_nscheck
|
||||
dns_zone_refresh
|
||||
dns_zone_rekey
|
||||
@ -1254,8 +1249,6 @@ dns_zone_setdb
|
||||
dns_zone_setdbtype
|
||||
dns_zone_setdialup
|
||||
dns_zone_setfile
|
||||
dns_zone_setfile2
|
||||
dns_zone_setfile3
|
||||
dns_zone_setflag
|
||||
dns_zone_setforwardacl
|
||||
dns_zone_setidlein
|
||||
|
@ -1337,7 +1337,7 @@ dns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp) {
|
||||
dns_zone_getserial(dns_zone_t *zone, isc_uint32_t *serialp) {
|
||||
isc_result_t result;
|
||||
unsigned int soacount;
|
||||
|
||||
@ -1360,18 +1360,6 @@ dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
dns_zone_getserial(dns_zone_t *zone) {
|
||||
isc_result_t result;
|
||||
isc_uint32_t serial;
|
||||
|
||||
result = dns_zone_getserial2(zone, &serial);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
serial = 0; /* XXX: not really correct, but no other choice */
|
||||
|
||||
return (serial);
|
||||
}
|
||||
|
||||
/*
|
||||
* Single shot.
|
||||
*/
|
||||
@ -1619,23 +1607,9 @@ dns_zone_setstring(dns_zone_t *zone, char **field, const char *value) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_setfile(dns_zone_t *zone, const char *file) {
|
||||
return (dns_zone_setfile3(zone, file, dns_masterformat_text,
|
||||
&dns_master_style_default));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_setfile2(dns_zone_t *zone, const char *file,
|
||||
dns_masterformat_t format)
|
||||
{
|
||||
return (dns_zone_setfile3(zone, file, format,
|
||||
&dns_master_style_default));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_setfile3(dns_zone_t *zone, const char *file,
|
||||
dns_masterformat_t format,
|
||||
const dns_master_style_t *style)
|
||||
dns_zone_setfile(dns_zone_t *zone, const char *file,
|
||||
dns_masterformat_t format,
|
||||
const dns_master_style_t *style)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
@ -10526,31 +10500,13 @@ dumptostream(dns_zone_t *zone, FILE *fd, const dns_master_style_t *style,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_dumptostream3(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
const dns_master_style_t *style,
|
||||
const isc_uint32_t rawversion)
|
||||
dns_zone_dumptostream(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
const dns_master_style_t *style,
|
||||
const isc_uint32_t rawversion)
|
||||
{
|
||||
return (dumptostream(zone, fd, style, format, rawversion));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format,
|
||||
const dns_master_style_t *style) {
|
||||
return (dumptostream(zone, fd, style, format, DNS_RAWFORMAT_VERSION));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_dumptostream(dns_zone_t *zone, FILE *fd) {
|
||||
return (dumptostream(zone, fd, &dns_master_style_default,
|
||||
dns_masterformat_text, 0));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd) {
|
||||
return (dumptostream(zone, fd, &dns_master_style_full,
|
||||
dns_masterformat_text, 0));
|
||||
}
|
||||
|
||||
void
|
||||
dns_zone_unload(dns_zone_t *zone) {
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
@ -13141,14 +13097,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
|
||||
|
||||
isc_result_t
|
||||
dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
|
||||
dns_message_t *msg)
|
||||
{
|
||||
return (dns_zone_notifyreceive2(zone, from, NULL, msg));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from,
|
||||
isc_sockaddr_t *to, dns_message_t *msg)
|
||||
isc_sockaddr_t *to, dns_message_t *msg)
|
||||
{
|
||||
unsigned int i;
|
||||
dns_rdata_soa_t soa;
|
||||
@ -13193,7 +13142,7 @@ dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from,
|
||||
LOCK_ZONE(zone);
|
||||
INSIST(zone != zone->raw);
|
||||
if (inline_secure(zone)) {
|
||||
result = dns_zone_notifyreceive2(zone->raw, from, to, msg);
|
||||
result = dns_zone_notifyreceive(zone->raw, from, to, msg);
|
||||
UNLOCK_ZONE(zone);
|
||||
return (result);
|
||||
}
|
||||
|
@ -148,8 +148,8 @@ ns_notify_start(ns_client_t *client) {
|
||||
notify_log(client, ISC_LOG_INFO,
|
||||
"received notify for zone '%s'%s",
|
||||
namebuf, tsigbuf);
|
||||
result = dns_zone_notifyreceive2(zone, from, to,
|
||||
request);
|
||||
result = dns_zone_notifyreceive(zone, from, to,
|
||||
request);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,8 @@ ns_test_serve_zone(const char *zonename, const char *filename,
|
||||
/*
|
||||
* Set path to the master file for the zone and then load it.
|
||||
*/
|
||||
dns_zone_setfile(served_zone, filename);
|
||||
dns_zone_setfile(served_zone, filename, dns_masterformat_text,
|
||||
&dns_master_style_default);
|
||||
result = dns_zone_load(served_zone);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto release_zone;
|
||||
|
Loading…
x
Reference in New Issue
Block a user