2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

833. [cleanup] Moved dns_soa_*() from <dns/journal.h> to

<dns/soa.h>, and extended them to support
			all the integer-valued fields of the SOA RR.
This commit is contained in:
Andreas Gustafsson 2001-05-21 23:56:34 +00:00
parent ec4df1f908
commit e7a4f58d55
7 changed files with 202 additions and 53 deletions

View File

@ -1,4 +1,8 @@
833. [cleanup] Moved dns_soa_*() from <dns/journal.h> to
<dns/soa.h>, and extended them to support
all the integer-valued fields of the SOA RR.
832. [bug] The default location for named.conf in named-checkconf 832. [bug] The default location for named.conf in named-checkconf
should depend on --sysconfdir like it does in named. should depend on --sysconfdir like it does in named.
[RT #1258] [RT #1258]

View File

@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.124 2001/03/05 22:48:51 bwelling Exp $ # $Id: Makefile.in,v 1.125 2001/05/21 23:56:30 gson Exp $
srcdir = @srcdir@ srcdir = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
@ -94,7 +94,7 @@ OBJS = a6.@O@ acl.@O@ adb.@O@ byaddr.@O@ \
name.@O@ ncache.@O@ nxt.@O@ peer.@O@ \ name.@O@ ncache.@O@ nxt.@O@ peer.@O@ \
rbt.@O@ rbtdb.@O@ rbtdb64.@O@ rdata.@O@ rdatalist.@O@ \ rbt.@O@ rbtdb.@O@ rbtdb64.@O@ rdata.@O@ rdatalist.@O@ \
rdataset.@O@ rdatasetiter.@O@ rdataslab.@O@ request.@O@ \ rdataset.@O@ rdatasetiter.@O@ rdataslab.@O@ request.@O@ \
resolver.@O@ result.@O@ rootns.@O@ sdb.@O@ ssu.@O@ \ resolver.@O@ result.@O@ rootns.@O@ sdb.@O@ soa.@O@ ssu.@O@ \
stats.@O@ tcpmsg.@O@ time.@O@ timer.@O@ tkey.@O@ \ stats.@O@ tcpmsg.@O@ time.@O@ timer.@O@ tkey.@O@ \
tsig.@O@ ttl.@O@ validator.@O@ \ tsig.@O@ ttl.@O@ validator.@O@ \
version.@O@ view.@O@ xfrin.@O@ zone.@O@ zonekey.@O@ zt.@O@ \ version.@O@ view.@O@ xfrin.@O@ zone.@O@ zonekey.@O@ zt.@O@ \
@ -110,7 +110,7 @@ SRCS = a6.c acl.c adb.c byaddr.c \
name.c ncache.c nxt.c peer.c \ name.c ncache.c nxt.c peer.c \
rbt.c rbtdb.c rbtdb64.c rdata.c rdatalist.c \ rbt.c rbtdb.c rbtdb64.c rdata.c rdatalist.c \
rdataset.c rdatasetiter.c rdataslab.c request.c \ rdataset.c rdatasetiter.c rdataslab.c request.c \
resolver.c result.c rootns.c sdb.c ssu.c \ resolver.c result.c rootns.c sdb.c soa.c ssu.c \
stats.c tcpmsg.c time.c timer.c tkey.c \ stats.c tcpmsg.c time.c timer.c tkey.c \
tsig.c ttl.c validator.c \ tsig.c ttl.c validator.c \
version.c view.c xfrin.c zone.c zonekey.c zt.c ${OTHERSRCS} version.c view.c xfrin.c zone.c zonekey.c zt.c ${OTHERSRCS}

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: journal.h,v 1.22 2001/01/09 21:52:53 bwelling Exp $ */ /* $Id: journal.h,v 1.23 2001/05/21 23:56:33 gson Exp $ */
#ifndef DNS_JOURNAL_H #ifndef DNS_JOURNAL_H
#define DNS_JOURNAL_H 1 #define DNS_JOURNAL_H 1
@ -63,35 +63,13 @@ typedef struct dns_journal dns_journal_t;
ISC_LANG_BEGINDECLS ISC_LANG_BEGINDECLS
/**************************************************************************/ /**************************************************************************/
/*
* Misc. utilities
* XXX these belong in a general-purpose DNS library
*/
isc_uint32_t
dns_soa_getserial(dns_rdata_t *rdata);
/*
* Extract the serial number from the rdata of a SOA record.
*
* Requires:
* rdata refers to the rdata of a well-formed SOA record.
*/
void
dns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata);
/*
* Change the serial number of a SOA record by modifying the
* rdata in-place.
*
* Requires:
* rdata refers to the rdata of a well-formed SOA record.
*/
isc_result_t isc_result_t
dns_db_createsoatuple(dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx, dns_db_createsoatuple(dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx,
dns_diffop_t op, dns_difftuple_t **tp); dns_diffop_t op, dns_difftuple_t **tp);
/* /*
* Create a diff tuple for the current database SOA. * Create a diff tuple for the current database SOA.
* XXX this probably belongs somewhere else.
*/ */

80
lib/dns/include/dns/soa.h Normal file
View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: soa.h,v 1.1 2001/05/21 23:56:34 gson Exp $ */
#ifndef DNS_SOA_H
#define DNS_SOA_H 1
/*****
***** Module Info
*****/
/*
* SOA utilities.
*/
/***
*** Imports
***/
#include <isc/lang.h>
#include <isc/types.h>
#include <dns/types.h>
ISC_LANG_BEGINDECLS
isc_uint32_t
dns_soa_getserial(dns_rdata_t *rdata);
isc_uint32_t
dns_soa_getrefresh(dns_rdata_t *rdata);
isc_uint32_t
dns_soa_getretry(dns_rdata_t *rdata);
isc_uint32_t
dns_soa_getexpire(dns_rdata_t *rdata);
isc_uint32_t
dns_soa_getminimum(dns_rdata_t *rdata);
/*
* Extract an integer field from the rdata of a SOA record.
*
* Requires:
* rdata refers to the rdata of a well-formed SOA record.
*/
void
dns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata);
void
dns_soa_setrefresh(isc_uint32_t val, dns_rdata_t *rdata);
void
dns_soa_setretry(isc_uint32_t val, dns_rdata_t *rdata);
void
dns_soa_setexpire(isc_uint32_t val, dns_rdata_t *rdata);
void
dns_soa_setminimum(isc_uint32_t val, dns_rdata_t *rdata);
/*
* Change an integer field of a SOA record by modifying the
* rdata in-place.
*
* Requires:
* rdata refers to the rdata of a well-formed SOA record.
*/
ISC_LANG_ENDDECLS
#endif /* DNS_SOA_H */

View File

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: journal.c,v 1.74 2001/05/17 18:14:36 gson Exp $ */ /* $Id: journal.c,v 1.75 2001/05/21 23:56:31 gson Exp $ */
#include <config.h> #include <config.h>
@ -37,6 +37,7 @@
#include <dns/rdataset.h> #include <dns/rdataset.h>
#include <dns/rdatasetiter.h> #include <dns/rdatasetiter.h>
#include <dns/result.h> #include <dns/result.h>
#include <dns/soa.h>
/* /*
* When true, accept IXFR difference sequences where the * When true, accept IXFR difference sequences where the
@ -87,31 +88,6 @@ encode_uint32(isc_uint32_t val, unsigned char *p) {
p[3] = (isc_uint8_t)(val >> 0); p[3] = (isc_uint8_t)(val >> 0);
} }
isc_uint32_t
dns_soa_getserial(dns_rdata_t *rdata) {
INSIST(rdata->type == dns_rdatatype_soa);
/*
* Locate the serial number within the SOA RDATA based
* on its position relative to the end of the data.
* (it starts 20 bytes from the end). This is a bit of
* a kludge, but the alternative approach of using
* dns_rdata_tostruct() and dns_rdata_fromstruct()
* would involve a lot of unnecessary work (like
* building domain names and allocating temporary memory)
* when all we really want to do is to change 32 bits of
* fixed-sized data.
*/
INSIST(rdata->length > 20);
return (decode_uint32(rdata->data + rdata->length - 20));
}
void
dns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata) {
INSIST(rdata->type == dns_rdatatype_soa);
INSIST(rdata->length > 20);
encode_uint32(val, rdata->data + rdata->length - 20);
}
isc_result_t isc_result_t
dns_db_createsoatuple(dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx, dns_db_createsoatuple(dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx,
dns_diffop_t op, dns_difftuple_t **tp) dns_diffop_t op, dns_difftuple_t **tp)

109
lib/dns/soa.c Normal file
View File

@ -0,0 +1,109 @@
/*
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: soa.c,v 1.1 2001/05/21 23:56:32 gson Exp $ */
#include <config.h>
#include <isc/util.h>
#include <dns/rdata.h>
#include <dns/soa.h>
static inline isc_uint32_t
decode_uint32(unsigned char *p) {
return ((p[0] << 24) +
(p[1] << 16) +
(p[2] << 8) +
(p[3] << 0));
}
static inline void
encode_uint32(isc_uint32_t val, unsigned char *p) {
p[0] = (isc_uint8_t)(val >> 24);
p[1] = (isc_uint8_t)(val >> 16);
p[2] = (isc_uint8_t)(val >> 8);
p[3] = (isc_uint8_t)(val >> 0);
}
static isc_uint32_t
soa_get(dns_rdata_t *rdata, int offset) {
INSIST(rdata->type == dns_rdatatype_soa);
/*
* Locate the field within the SOA RDATA based
* on its position relative to the end of the data.
*
* This is a bit of a kludge, but the alternative approach of
* using dns_rdata_tostruct() and dns_rdata_fromstruct() would
* involve a lot of unnecessary work (like building domain
* names and allocating temporary memory) when all we really
* want to do is to get 32 bits of fixed-sized data.
*/
INSIST(rdata->length >= 20);
INSIST(offset >= 0 && offset <= 16);
return (decode_uint32(rdata->data + rdata->length - 20 + offset));
}
isc_uint32_t
dns_soa_getserial(dns_rdata_t *rdata) {
return soa_get(rdata, 0);
}
isc_uint32_t
dns_soa_getrefresh(dns_rdata_t *rdata) {
return soa_get(rdata, 4);
}
isc_uint32_t
dns_soa_getretry(dns_rdata_t *rdata) {
return soa_get(rdata, 8);
}
isc_uint32_t
dns_soa_getexpire(dns_rdata_t *rdata) {
return soa_get(rdata, 12);
}
isc_uint32_t
dns_soa_getminimum(dns_rdata_t *rdata) {
return soa_get(rdata, 16);
}
static void
soa_set(dns_rdata_t *rdata, isc_uint32_t val, int offset) {
INSIST(rdata->type == dns_rdatatype_soa);
INSIST(rdata->length >= 20);
INSIST(offset >= 0 && offset <= 16);
encode_uint32(val, rdata->data + rdata->length - 20 + offset);
}
void
dns_soa_setserial(isc_uint32_t val, dns_rdata_t *rdata) {
return soa_set(rdata, val, 0);
}
void
dns_soa_setrefresh(isc_uint32_t val, dns_rdata_t *rdata) {
return soa_set(rdata, val, 4);
}
void
dns_soa_setretry(isc_uint32_t val, dns_rdata_t *rdata) {
return soa_set(rdata, val, 8);
}
void
dns_soa_setexpire(isc_uint32_t val, dns_rdata_t *rdata) {
return soa_set(rdata, val, 12);
}
void
dns_soa_setminimum(isc_uint32_t val, dns_rdata_t *rdata) {
return soa_set(rdata, val, 16);
}

View File

@ -1019,6 +1019,7 @@
./lib/dns/include/dns/resolver.h C 1999,2000,2001 ./lib/dns/include/dns/resolver.h C 1999,2000,2001
./lib/dns/include/dns/result.h C 1998,1999,2000,2001 ./lib/dns/include/dns/result.h C 1998,1999,2000,2001
./lib/dns/include/dns/rootns.h C 1999,2000,2001 ./lib/dns/include/dns/rootns.h C 1999,2000,2001
./lib/dns/include/dns/soa.h C 2000,2001
./lib/dns/include/dns/sdb.h C 2000,2001 ./lib/dns/include/dns/sdb.h C 2000,2001
./lib/dns/include/dns/secalg.h C 1999,2000,2001 ./lib/dns/include/dns/secalg.h C 1999,2000,2001
./lib/dns/include/dns/secproto.h C 1999,2000,2001 ./lib/dns/include/dns/secproto.h C 1999,2000,2001
@ -1152,6 +1153,7 @@
./lib/dns/result.c C 1998,1999,2000,2001 ./lib/dns/result.c C 1998,1999,2000,2001
./lib/dns/rootns.c C 1999,2000,2001 ./lib/dns/rootns.c C 1999,2000,2001
./lib/dns/sdb.c C 2000,2001 ./lib/dns/sdb.c C 2000,2001
./lib/dns/soa.c C 2000,2001
./lib/dns/sec/.cvsignore X 1999,2000,2001 ./lib/dns/sec/.cvsignore X 1999,2000,2001
./lib/dns/sec/Makefile.in MAKE 1998,1999,2000,2001 ./lib/dns/sec/Makefile.in MAKE 1998,1999,2000,2001
./lib/dns/sec/dst/.cvsignore X 1999,2000,2001 ./lib/dns/sec/dst/.cvsignore X 1999,2000,2001