mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 07:40:00 -04:00
Move setresign to rdataset.c and rename it
The setresign method is not diff specific, it only returns the minimum resign time of an rdataset. Move it to rdataset.c to simplify late refactoring.
This commit is contained in:
parent
399f0c191a
commit
6f726ae3db
3 changed files with 53 additions and 36 deletions
|
|
@ -203,41 +203,6 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep) {
|
|||
}
|
||||
}
|
||||
|
||||
static isc_stdtime_t
|
||||
setresign(dns_rdataset_t *modified) {
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_rrsig_t sig;
|
||||
int64_t when;
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_rdataset_first(modified);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
dns_rdataset_current(modified, &rdata);
|
||||
(void)dns_rdata_tostruct(&rdata, &sig, NULL);
|
||||
if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
|
||||
when = 0;
|
||||
} else {
|
||||
when = dns_time64_from32(sig.timeexpire);
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
|
||||
result = dns_rdataset_next(modified);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(modified, &rdata);
|
||||
(void)dns_rdata_tostruct(&rdata, &sig, NULL);
|
||||
if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
|
||||
goto next_rr;
|
||||
}
|
||||
if (when == 0 || dns_time64_from32(sig.timeexpire) < when) {
|
||||
when = dns_time64_from32(sig.timeexpire);
|
||||
}
|
||||
next_rr:
|
||||
dns_rdata_reset(&rdata);
|
||||
result = dns_rdataset_next(modified);
|
||||
}
|
||||
INSIST(result == ISC_R_NOMORE);
|
||||
return (isc_stdtime_t)when;
|
||||
}
|
||||
|
||||
static void
|
||||
getownercase(dns_rdataset_t *rdataset, dns_name_t *name) {
|
||||
|
|
@ -407,7 +372,7 @@ diff_apply(const dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver,
|
|||
op == DNS_DIFFOP_ADDRESIGN))
|
||||
{
|
||||
isc_stdtime_t resign;
|
||||
resign = setresign(&ardataset);
|
||||
resign = dns_rdataset_minresign(&ardataset);
|
||||
dns_db_setsigningtime(db, &ardataset,
|
||||
resign);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -632,6 +632,19 @@ dns_rdataset_getheader(const dns_rdataset_t *rdataset);
|
|||
* \li 'rdataset' is a valid rdataset.
|
||||
*/
|
||||
|
||||
isc_stdtime_t
|
||||
dns_rdataset_minresign(dns_rdataset_t *rdataset);
|
||||
/*%<
|
||||
* Return the minimum resign time from an RRSIG rdataset.
|
||||
*
|
||||
* This function iterates through all RRSIG records in the rdataset
|
||||
* and returns the earliest expiration time, which indicates when
|
||||
* the signatures should be resigned.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'rdataset' is a valid rdataset.
|
||||
*/
|
||||
|
||||
/*%
|
||||
* Returns true if the rdataset is of type 'type', or type RRSIG
|
||||
* and covers 'type'.
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <dns/ncache.h>
|
||||
#include <dns/rdata.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/time.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#define MAX_SHUFFLE 100
|
||||
|
|
@ -597,3 +598,41 @@ dns_rdataset_getheader(const dns_rdataset_t *rdataset) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
isc_stdtime_t
|
||||
dns_rdataset_minresign(dns_rdataset_t *rdataset) {
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_rrsig_t sig;
|
||||
int64_t when;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
||||
|
||||
result = dns_rdataset_first(rdataset);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
(void)dns_rdata_tostruct(&rdata, &sig, NULL);
|
||||
if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
|
||||
when = 0;
|
||||
} else {
|
||||
when = dns_time64_from32(sig.timeexpire);
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
|
||||
result = dns_rdataset_next(rdataset);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
(void)dns_rdata_tostruct(&rdata, &sig, NULL);
|
||||
if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
|
||||
goto next_rr;
|
||||
}
|
||||
if (when == 0 || dns_time64_from32(sig.timeexpire) < when) {
|
||||
when = dns_time64_from32(sig.timeexpire);
|
||||
}
|
||||
next_rr:
|
||||
dns_rdata_reset(&rdata);
|
||||
result = dns_rdataset_next(rdataset);
|
||||
}
|
||||
INSIST(result == ISC_R_NOMORE);
|
||||
return (isc_stdtime_t)when;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue