Commit 66dfced5 authored by Bob Halley's avatar Bob Halley
Browse files

keep track of now and the chain expiration time

parent b8029095
......@@ -54,7 +54,12 @@ foreach(dns_a6context_t *a6ctx, dns_rdataset_t *parent, unsigned int depth,
isc_result_t result;
isc_uint8_t prefixlen, octets;
isc_bitstring_t bitstring;
isc_stdtime_t expiration;
expiration = a6ctx->now + parent->ttl;
if (expiration < a6ctx->expiration || a6ctx->expiration == 0)
a6ctx->expiration = expiration;
depth++;
result = dns_rdataset_first(parent);
while (result == ISC_R_SUCCESS) {
......@@ -85,6 +90,7 @@ foreach(dns_a6context_t *a6ctx, dns_rdataset_t *parent, unsigned int depth,
dns_rdataset_init(&childsig);
result = (a6ctx->find)(a6ctx->arg, &name,
dns_rdatatype_a6,
a6ctx->now,
&child, &childsig);
if (result == ISC_R_SUCCESS) {
/*
......@@ -140,7 +146,7 @@ foreach(dns_a6context_t *a6ctx, dns_rdataset_t *parent, unsigned int depth,
* We have a complete chain.
*/
if (a6ctx->address != NULL)
(a6ctx->address)(a6ctx->arg, &a6ctx->in6addr);
(a6ctx->address)(a6ctx);
}
next_a6:
result = dns_rdataset_next(parent);
......@@ -170,6 +176,8 @@ dns_a6_init(dns_a6context_t *a6ctx, dns_findfunc_t find, dns_rrsetfunc_t rrset,
a6ctx->arg = arg;
a6ctx->chains = 1;
a6ctx->depth = 0;
a6ctx->now = 0;
a6ctx->expiration = 0;
a6ctx->prefixlen = 128;
isc_bitstring_init(&a6ctx->bitstring,
(unsigned char *)a6ctx->in6addr.s6_addr,
......@@ -182,6 +190,7 @@ dns_a6_reset(dns_a6context_t *a6ctx) {
a6ctx->chains = 1;
a6ctx->depth = 0;
a6ctx->expiration = 0;
a6ctx->prefixlen = 128;
}
......@@ -204,12 +213,21 @@ dns_a6_copy(dns_a6context_t *source, dns_a6context_t *target) {
}
isc_result_t
dns_a6_foreach(dns_a6context_t *a6ctx, dns_rdataset_t *rdataset) {
dns_a6_foreach(dns_a6context_t *a6ctx, dns_rdataset_t *rdataset,
isc_stdtime_t now)
{
isc_result_t result;
REQUIRE(VALID_A6CONTEXT(a6ctx));
REQUIRE(rdataset->type == dns_rdatatype_a6);
if (now == 0) {
result = isc_stdtime_get(&now);
if (result != ISC_R_SUCCESS)
return (result);
}
a6ctx->now = now;
result = foreach(a6ctx, rdataset, a6ctx->depth, a6ctx->prefixlen);
if (result == ISC_R_QUOTA)
result = ISC_R_SUCCESS;
......
......@@ -20,6 +20,7 @@
#include <isc/lang.h>
#include <isc/types.h>
#include <isc/stdtime.h>
#include <isc/bitstring.h>
#include <isc/net.h>
#include <isc/result.h>
......@@ -30,6 +31,7 @@ ISC_LANG_BEGINDECLS
typedef isc_result_t (*dns_findfunc_t)(void *arg, dns_name_t *name,
dns_rdatatype_t type,
isc_stdtime_t now,
dns_rdataset_t *rdataset,
dns_rdataset_t *sigrdataset);
......@@ -37,7 +39,7 @@ typedef void (*dns_rrsetfunc_t)(void *arg, dns_name_t *name,
dns_rdataset_t *rdataset,
dns_rdataset_t *sigrdataset);
typedef void (*dns_in6addrfunc_t)(void *arg, struct in6_addr *address);
typedef void (*dns_in6addrfunc_t)(dns_a6context_t *a6ctx);
typedef void (*dns_a6missingfunc_t)(dns_a6context_t *a6ctx, dns_name_t *name);
......@@ -51,6 +53,8 @@ struct dns_a6context {
void * arg;
unsigned int chains;
unsigned int depth;
isc_stdtime_t now;
isc_stdtime_t expiration;
unsigned int prefixlen;
struct in6_addr in6addr;
isc_bitstring_t bitstring;
......@@ -70,7 +74,8 @@ void
dns_a6_copy(dns_a6context_t *source, dns_a6context_t *target);
isc_result_t
dns_a6_foreach(dns_a6context_t *a6ctx, dns_rdataset_t *rdataset);
dns_a6_foreach(dns_a6context_t *a6ctx, dns_rdataset_t *rdataset,
isc_stdtime_t now);
ISC_LANG_ENDDECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment