2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

various style cleanups

This commit is contained in:
Evan Hunt
2020-02-06 10:28:53 -08:00
committed by Matthijs Mekking
parent 58aa084edc
commit 6504e7da95
4 changed files with 100 additions and 61 deletions

View File

@@ -2205,7 +2205,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
for (element = cfg_list_first(kasps); element != NULL; for (element = cfg_list_first(kasps); element != NULL;
element = cfg_list_next(element)) element = cfg_list_next(element))
{ {
const char* kn = cfg_obj_asstring( const char *kn = cfg_obj_asstring(
cfg_tuple_get(cfg_listelt_value(element), cfg_tuple_get(cfg_listelt_value(element),
"name")); "name"));
if (strcmp(kaspname, kn) == 0) { if (strcmp(kaspname, kn) == 0) {

View File

@@ -24,8 +24,7 @@
#include <dns/keyvalues.h> #include <dns/keyvalues.h>
isc_result_t isc_result_t
dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp) dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp) {
{
dns_kasp_t *kasp; dns_kasp_t *kasp;
REQUIRE(name != NULL); REQUIRE(name != NULL);
@@ -60,7 +59,7 @@ dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp)
kasp->parent_propagation_delay = DNS_KASP_PARENT_PROPDELAY; kasp->parent_propagation_delay = DNS_KASP_PARENT_PROPDELAY;
kasp->parent_registration_delay = DNS_KASP_PARENT_REGDELAY; kasp->parent_registration_delay = DNS_KASP_PARENT_REGDELAY;
// TODO: The rest of the KASP configuration /* TODO: The rest of the KASP configuration */
kasp->magic = DNS_KASP_MAGIC; kasp->magic = DNS_KASP_MAGIC;
*kaspp = kasp; *kaspp = kasp;
@@ -82,14 +81,14 @@ destroy(dns_kasp_t *kasp) {
dns_kasp_key_t *key; dns_kasp_key_t *key;
dns_kasp_key_t *key_next; dns_kasp_key_t *key_next;
ISC_INSIST(!ISC_LINK_LINKED(kasp, link)); REQUIRE(!ISC_LINK_LINKED(kasp, link));
for (key = ISC_LIST_HEAD(kasp->keys); key != NULL; key = key_next) { for (key = ISC_LIST_HEAD(kasp->keys); key != NULL; key = key_next) {
key_next = ISC_LIST_NEXT(key, link); key_next = ISC_LIST_NEXT(key, link);
ISC_LIST_UNLINK(kasp->keys, key, link); ISC_LIST_UNLINK(kasp->keys, key, link);
dns_kasp_key_destroy(key); dns_kasp_key_destroy(key);
} }
ISC_INSIST(ISC_LIST_EMPTY(kasp->keys)); INSIST(ISC_LIST_EMPTY(kasp->keys));
isc_mem_free(kasp->mctx, kasp->name); isc_mem_free(kasp->mctx, kasp->name);
isc_mem_putanddetach(&kasp->mctx, kasp, sizeof(*kasp)); isc_mem_putanddetach(&kasp->mctx, kasp, sizeof(*kasp));
@@ -98,6 +97,7 @@ destroy(dns_kasp_t *kasp) {
void void
dns_kasp_detach(dns_kasp_t **kaspp) { dns_kasp_detach(dns_kasp_t **kaspp) {
REQUIRE(kaspp != NULL && DNS_KASP_VALID(*kaspp)); REQUIRE(kaspp != NULL && DNS_KASP_VALID(*kaspp));
dns_kasp_t *kasp = *kaspp; dns_kasp_t *kasp = *kaspp;
*kaspp = NULL; *kaspp = NULL;
@@ -106,9 +106,10 @@ dns_kasp_detach(dns_kasp_t **kaspp) {
} }
} }
const char* const char *
dns_kasp_getname(dns_kasp_t *kasp) { dns_kasp_getname(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
return (kasp->name); return (kasp->name);
} }
@@ -116,6 +117,7 @@ void
dns_kasp_freeze(dns_kasp_t *kasp) { dns_kasp_freeze(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->frozen = true; kasp->frozen = true;
} }
@@ -123,6 +125,7 @@ void
dns_kasp_thaw(dns_kasp_t *kasp) { dns_kasp_thaw(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
kasp->frozen = false; kasp->frozen = false;
} }
@@ -130,6 +133,7 @@ uint32_t
dns_kasp_signdelay(dns_kasp_t *kasp) { dns_kasp_signdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->signatures_validity - kasp->signatures_refresh); return (kasp->signatures_validity - kasp->signatures_refresh);
} }
@@ -137,6 +141,7 @@ uint32_t
dns_kasp_sigrefresh(dns_kasp_t *kasp) { dns_kasp_sigrefresh(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->signatures_refresh); return (kasp->signatures_refresh);
} }
@@ -144,6 +149,7 @@ void
dns_kasp_setsigrefresh(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setsigrefresh(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->signatures_refresh = value; kasp->signatures_refresh = value;
} }
@@ -151,6 +157,7 @@ uint32_t
dns_kasp_sigvalidity(dns_kasp_t *kasp) { dns_kasp_sigvalidity(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->signatures_validity); return (kasp->signatures_validity);
} }
@@ -158,6 +165,7 @@ void
dns_kasp_setsigvalidity(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setsigvalidity(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->signatures_validity = value; kasp->signatures_validity = value;
} }
@@ -165,6 +173,7 @@ uint32_t
dns_kasp_sigvalidity_dnskey(dns_kasp_t *kasp) { dns_kasp_sigvalidity_dnskey(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->signatures_validity_dnskey); return (kasp->signatures_validity_dnskey);
} }
@@ -172,6 +181,7 @@ void
dns_kasp_setsigvalidity_dnskey(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setsigvalidity_dnskey(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->signatures_validity = value; kasp->signatures_validity = value;
} }
@@ -179,6 +189,7 @@ dns_ttl_t
dns_kasp_dnskeyttl(dns_kasp_t *kasp) { dns_kasp_dnskeyttl(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->dnskey_ttl); return (kasp->dnskey_ttl);
} }
@@ -186,6 +197,7 @@ void
dns_kasp_setdnskeyttl(dns_kasp_t *kasp, dns_ttl_t ttl) { dns_kasp_setdnskeyttl(dns_kasp_t *kasp, dns_ttl_t ttl) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->dnskey_ttl = ttl; kasp->dnskey_ttl = ttl;
} }
@@ -193,6 +205,7 @@ uint32_t
dns_kasp_publishsafety(dns_kasp_t *kasp) { dns_kasp_publishsafety(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->publish_safety); return (kasp->publish_safety);
} }
@@ -200,6 +213,7 @@ void
dns_kasp_setpublishsafety(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setpublishsafety(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->publish_safety = value; kasp->publish_safety = value;
} }
@@ -207,6 +221,7 @@ uint32_t
dns_kasp_retiresafety(dns_kasp_t *kasp) { dns_kasp_retiresafety(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->retire_safety); return (kasp->retire_safety);
} }
@@ -214,6 +229,7 @@ void
dns_kasp_setretiresafety(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setretiresafety(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->retire_safety = value; kasp->retire_safety = value;
} }
@@ -221,6 +237,7 @@ dns_ttl_t
dns_kasp_zonemaxttl(dns_kasp_t *kasp) { dns_kasp_zonemaxttl(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->zone_max_ttl); return (kasp->zone_max_ttl);
} }
@@ -228,6 +245,7 @@ void
dns_kasp_setzonemaxttl(dns_kasp_t *kasp, dns_ttl_t ttl) { dns_kasp_setzonemaxttl(dns_kasp_t *kasp, dns_ttl_t ttl) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->zone_max_ttl = ttl; kasp->zone_max_ttl = ttl;
} }
@@ -235,6 +253,7 @@ uint32_t
dns_kasp_zonepropagationdelay(dns_kasp_t *kasp) { dns_kasp_zonepropagationdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->zone_propagation_delay); return (kasp->zone_propagation_delay);
} }
@@ -242,6 +261,7 @@ void
dns_kasp_setzonepropagationdelay(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setzonepropagationdelay(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->zone_propagation_delay = value; kasp->zone_propagation_delay = value;
} }
@@ -249,6 +269,7 @@ dns_ttl_t
dns_kasp_dsttl(dns_kasp_t *kasp) { dns_kasp_dsttl(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->parent_ds_ttl); return (kasp->parent_ds_ttl);
} }
@@ -256,6 +277,7 @@ void
dns_kasp_setdsttl(dns_kasp_t *kasp, dns_ttl_t ttl) { dns_kasp_setdsttl(dns_kasp_t *kasp, dns_ttl_t ttl) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->parent_ds_ttl = ttl; kasp->parent_ds_ttl = ttl;
} }
@@ -263,6 +285,7 @@ uint32_t
dns_kasp_parentpropagationdelay(dns_kasp_t *kasp) { dns_kasp_parentpropagationdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->parent_propagation_delay); return (kasp->parent_propagation_delay);
} }
@@ -270,6 +293,7 @@ void
dns_kasp_setparentpropagationdelay(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setparentpropagationdelay(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->parent_propagation_delay = value; kasp->parent_propagation_delay = value;
} }
@@ -277,6 +301,7 @@ uint32_t
dns_kasp_parentregistrationdelay(dns_kasp_t *kasp) { dns_kasp_parentregistrationdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->parent_registration_delay); return (kasp->parent_registration_delay);
} }
@@ -284,12 +309,12 @@ void
dns_kasp_setparentregistrationdelay(dns_kasp_t *kasp, uint32_t value) { dns_kasp_setparentregistrationdelay(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
kasp->parent_registration_delay = value; kasp->parent_registration_delay = value;
} }
isc_result_t isc_result_t
dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp) dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp) {
{
dns_kasp_t *kasp = NULL; dns_kasp_t *kasp = NULL;
REQUIRE(kaspp != NULL && *kaspp == NULL); REQUIRE(kaspp != NULL && *kaspp == NULL);
@@ -297,7 +322,6 @@ dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp)
if (list == NULL) { if (list == NULL) {
return (ISC_R_NOTFOUND); return (ISC_R_NOTFOUND);
} }
INSIST(list != NULL);
for (kasp = ISC_LIST_HEAD(*list); kasp != NULL; for (kasp = ISC_LIST_HEAD(*list); kasp != NULL;
kasp = ISC_LIST_NEXT(kasp, link)) kasp = ISC_LIST_NEXT(kasp, link))
@@ -306,31 +330,32 @@ dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp)
break; break;
} }
} }
if (kasp == NULL) { if (kasp == NULL) {
return (ISC_R_NOTFOUND); return (ISC_R_NOTFOUND);
} }
dns_kasp_attach(kasp, kaspp); dns_kasp_attach(kasp, kaspp);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
dns_kasp_keylist_t dns_kasp_keylist_t
dns_kasp_keys(dns_kasp_t *kasp) dns_kasp_keys(dns_kasp_t *kasp) {
{
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen); REQUIRE(kasp->frozen);
return (kasp->keys); return (kasp->keys);
} }
bool bool
dns_kasp_keylist_empty(dns_kasp_t *kasp) dns_kasp_keylist_empty(dns_kasp_t *kasp) {
{
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
return (ISC_LIST_EMPTY(kasp->keys)); return (ISC_LIST_EMPTY(kasp->keys));
} }
void void
dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key) dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key) {
{
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen); REQUIRE(!kasp->frozen);
REQUIRE(key != NULL); REQUIRE(key != NULL);
@@ -339,8 +364,7 @@ dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key)
} }
isc_result_t isc_result_t
dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp) dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp) {
{
dns_kasp_key_t *key; dns_kasp_key_t *key;
REQUIRE(DNS_KASP_VALID(kasp)); REQUIRE(DNS_KASP_VALID(kasp));
@@ -361,16 +385,16 @@ dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp)
} }
void void
dns_kasp_key_destroy(dns_kasp_key_t* key) dns_kasp_key_destroy(dns_kasp_key_t *key) {
{
REQUIRE(key != NULL); REQUIRE(key != NULL);
isc_mem_putanddetach(&key->mctx, key, sizeof(*key)); isc_mem_putanddetach(&key->mctx, key, sizeof(*key));
} }
uint32_t uint32_t
dns_kasp_key_algorithm(dns_kasp_key_t *key) { dns_kasp_key_algorithm(dns_kasp_key_t *key) {
REQUIRE(key != NULL); REQUIRE(key != NULL);
return (key->algorithm); return (key->algorithm);
} }
@@ -420,21 +444,21 @@ dns_kasp_key_size(dns_kasp_key_t *key) {
uint32_t uint32_t
dns_kasp_key_lifetime(dns_kasp_key_t *key) { dns_kasp_key_lifetime(dns_kasp_key_t *key) {
REQUIRE(key != NULL); REQUIRE(key != NULL);
return (key->lifetime); return (key->lifetime);
} }
bool bool
dns_kasp_key_ksk(dns_kasp_key_t *key) { dns_kasp_key_ksk(dns_kasp_key_t *key) {
REQUIRE(key != NULL); REQUIRE(key != NULL);
return (key->role & DNS_KASP_KEY_ROLE_KSK); return (key->role & DNS_KASP_KEY_ROLE_KSK);
} }
bool bool
dns_kasp_key_zsk(dns_kasp_key_t *key) { dns_kasp_key_zsk(dns_kasp_key_t *key) {
REQUIRE(key != NULL); REQUIRE(key != NULL);
return (key->role & DNS_KASP_KEY_ROLE_ZSK); return (key->role & DNS_KASP_KEY_ROLE_ZSK);
} }

View File

@@ -216,21 +216,27 @@ cfg_kasp_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx, isc_log_t *logctx,
maps[i] = NULL; maps[i] = NULL;
/* Configuration: Signatures */ /* Configuration: Signatures */
dns_kasp_setsigrefresh(kasp, get_duration(maps, "signatures-refresh", dns_kasp_setsigrefresh(kasp,
DNS_KASP_SIG_REFRESH)); get_duration(maps, "signatures-refresh",
dns_kasp_setsigvalidity(kasp, get_duration(maps, "signatures-validity", DNS_KASP_SIG_REFRESH));
DNS_KASP_SIG_VALIDITY)); dns_kasp_setsigvalidity(kasp,
dns_kasp_setsigvalidity_dnskey(kasp, get_duration(maps, get_duration(maps, "signatures-validity",
"signatures-validity-dnskey", DNS_KASP_SIG_VALIDITY));
DNS_KASP_SIG_VALIDITY_DNSKEY)); dns_kasp_setsigvalidity_dnskey(kasp,
get_duration(maps,
"signatures-validity-dnskey",
DNS_KASP_SIG_VALIDITY_DNSKEY));
/* Configuration: Keys */ /* Configuration: Keys */
dns_kasp_setdnskeyttl(kasp, get_duration(maps, "dnskey-ttl", dns_kasp_setdnskeyttl(kasp,
DNS_KASP_KEY_TTL)); get_duration(maps, "dnskey-ttl",
dns_kasp_setpublishsafety(kasp, get_duration(maps, "publish-safety", DNS_KASP_KEY_TTL));
DNS_KASP_PUBLISH_SAFETY)); dns_kasp_setpublishsafety(kasp,
dns_kasp_setretiresafety(kasp, get_duration(maps, "retire-safety", get_duration(maps, "publish-safety",
DNS_KASP_RETIRE_SAFETY)); DNS_KASP_PUBLISH_SAFETY));
dns_kasp_setretiresafety(kasp,
get_duration(maps, "retire-safety",
DNS_KASP_RETIRE_SAFETY));
(void)confget(maps, "keys", &keys); (void)confget(maps, "keys", &keys);
if (keys == NULL) { if (keys == NULL) {
@@ -249,33 +255,34 @@ cfg_kasp_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx, isc_log_t *logctx,
} }
} }
} }
ISC_INSIST(!(dns_kasp_keylist_empty(kasp))); INSIST(!(dns_kasp_keylist_empty(kasp)));
/* Configuration: Zone settings */ /* Configuration: Zone settings */
dns_kasp_setzonemaxttl(kasp, get_duration(maps, "max-zone-ttl", dns_kasp_setzonemaxttl(kasp, get_duration(maps, "max-zone-ttl",
DNS_KASP_ZONE_MAXTTL)); DNS_KASP_ZONE_MAXTTL));
dns_kasp_setzonepropagationdelay(kasp, get_duration(maps, dns_kasp_setzonepropagationdelay(kasp, get_duration(maps,
"zone-propagation-delay", "zone-propagation-delay",
DNS_KASP_ZONE_PROPDELAY)); DNS_KASP_ZONE_PROPDELAY));
/* Configuration: Parent settings */ /* Configuration: Parent settings */
dns_kasp_setdsttl(kasp, get_duration(maps, "parent-ds-ttl", dns_kasp_setdsttl(kasp, get_duration(maps, "parent-ds-ttl",
DNS_KASP_DS_TTL)); DNS_KASP_DS_TTL));
dns_kasp_setparentpropagationdelay(kasp, get_duration(maps, dns_kasp_setparentpropagationdelay(kasp, get_duration(maps,
"parent-propagation-delay", "parent-propagation-delay",
DNS_KASP_PARENT_PROPDELAY)); DNS_KASP_PARENT_PROPDELAY));
dns_kasp_setparentregistrationdelay(kasp, get_duration(maps, dns_kasp_setparentregistrationdelay(kasp, get_duration(maps,
"parent-registration-delay", "parent-registration-delay",
DNS_KASP_PARENT_REGDELAY)); DNS_KASP_PARENT_REGDELAY));
// TODO: Rest of the configuration /* TODO: Rest of the configuration */
/* Append it to the list for future lookups. */ /* Append it to the list for future lookups. */
ISC_LIST_APPEND(*kasplist, kasp, link); ISC_LIST_APPEND(*kasplist, kasp, link);
ISC_INSIST(!(ISC_LIST_EMPTY(*kasplist))); INSIST(!(ISC_LIST_EMPTY(*kasplist)));
/* Success: Attach the kasp to the pointer and return. */ /* Success: Attach the kasp to the pointer and return. */
dns_kasp_attach(kasp, kaspp); dns_kasp_attach(kasp, kaspp);
/* Don't detach as kasp is on '*kasplist' */ /* Don't detach as kasp is on '*kasplist' */
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);

View File

@@ -989,7 +989,7 @@ numlen(uint32_t num) {
size_t count = 0; size_t count = 0;
if (period == 0) { if (period == 0) {
return 1; return (1);
} }
while (period > 0) { while (period > 0) {
count++; count++;
@@ -1181,8 +1181,8 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
/* Every duration starts with 'P' */ /* Every duration starts with 'P' */
P = strchr(str, 'P'); P = strchr(str, 'P');
if (!P) { if (P == NULL) {
return (ISC_R_BADNUMBER); return (ISC_R_BADNUMBER);
} }
/* Record the time indicator. */ /* Record the time indicator. */
@@ -1190,57 +1190,63 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
/* Record years. */ /* Record years. */
X = strchr(str, 'Y'); X = strchr(str, 'Y');
if (X) { if (X != NULL) {
duration->parts[0] = atoi(str+1); duration->parts[0] = atoi(str+1);
str = X; str = X;
not_weeks = true; not_weeks = true;
} }
/* Record months. */ /* Record months. */
X = strchr(str, 'M'); X = strchr(str, 'M');
/* /*
* M could be months or minutes. This is months if there is no time * M could be months or minutes. This is months if there is no time
* part, or this M indicator is before the time indicator. * part, or this M indicator is before the time indicator.
*/ */
if (X && (!T || (size_t) (X-P) < (size_t) (T-P))) { if (X != NULL && (T == NULL || (size_t) (X-P) < (size_t) (T-P))) {
duration->parts[1] = atoi(str+1); duration->parts[1] = atoi(str+1);
str = X; str = X;
not_weeks = true; not_weeks = true;
} }
/* Record days. */ /* Record days. */
X = strchr(str, 'D'); X = strchr(str, 'D');
if (X) { if (X != NULL) {
duration->parts[3] = atoi(str+1); duration->parts[3] = atoi(str+1);
str = X; str = X;
not_weeks = true; not_weeks = true;
} }
/* Time part? */ /* Time part? */
if (T) { if (T != NULL) {
str = T; str = T;
not_weeks = true; not_weeks = true;
} }
/* Record hours. */ /* Record hours. */
X = strchr(str, 'H'); X = strchr(str, 'H');
if (X && T) { if (X != NULL && T != NULL) {
duration->parts[4] = atoi(str+1); duration->parts[4] = atoi(str+1);
str = X; str = X;
not_weeks = true; not_weeks = true;
} }
/* Record minutes. */ /* Record minutes. */
X = strrchr(str, 'M'); X = strrchr(str, 'M');
/* /*
* M could be months or minutes. This is minutes if there is a time * M could be months or minutes. This is minutes if there is a time
* part and the M indicator is behind the time indicator. * part and the M indicator is behind the time indicator.
*/ */
if (X && T && (size_t) (X-P) > (size_t) (T-P)) { if (X != NULL && T != NULL && (size_t) (X-P) > (size_t) (T-P)) {
duration->parts[5] = atoi(str+1); duration->parts[5] = atoi(str+1);
str = X; str = X;
not_weeks = true; not_weeks = true;
} }
/* Record seconds. */ /* Record seconds. */
X = strchr(str, 'S'); X = strchr(str, 'S');
if (X && T) { if (X != NULL && T != NULL) {
duration->parts[6] = atoi(str+1); duration->parts[6] = atoi(str+1);
str = X; str = X;
not_weeks = true; not_weeks = true;
@@ -1248,7 +1254,7 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
/* Or is the duration configured in weeks? */ /* Or is the duration configured in weeks? */
W = strchr(buf, 'W'); W = strchr(buf, 'W');
if (W) { if (W != NULL) {
if (not_weeks) { if (not_weeks) {
/* Mix of weeks and other indicators is not allowed */ /* Mix of weeks and other indicators is not allowed */
return (ISC_R_BADNUMBER); return (ISC_R_BADNUMBER);
@@ -1267,8 +1273,7 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
} }
static isc_result_t static isc_result_t
cfg__parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret) parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret) {
{
isc_result_t result; isc_result_t result;
cfg_obj_t *obj = NULL; cfg_obj_t *obj = NULL;
cfg_duration_t duration; cfg_duration_t duration;
@@ -1293,6 +1298,7 @@ cfg__parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret)
duration.parts[6] = ttl; duration.parts[6] = ttl;
duration.iso8601 = false; duration.iso8601 = false;
} }
if (result == ISC_R_RANGE) { if (result == ISC_R_RANGE) {
cfg_parser_error(pctx, CFG_LOG_NEAR, cfg_parser_error(pctx, CFG_LOG_NEAR,
"duration or TTL out of range"); "duration or TTL out of range");
@@ -1300,9 +1306,11 @@ cfg__parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret)
} else if (result != ISC_R_SUCCESS) { } else if (result != ISC_R_SUCCESS) {
goto cleanup; goto cleanup;
} }
CHECK(cfg_create_obj(pctx, &cfg_type_duration, &obj)); CHECK(cfg_create_obj(pctx, &cfg_type_duration, &obj));
obj->value.duration = duration; obj->value.duration = duration;
*ret = obj; *ret = obj;
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
cleanup: cleanup:
@@ -1325,7 +1333,7 @@ cfg_parse_duration(cfg_parser_t *pctx, const cfg_type_t *type,
goto cleanup; goto cleanup;
} }
return cfg__parse_duration(pctx, ret); return (parse_duration(pctx, ret));
cleanup: cleanup:
cfg_parser_error(pctx, CFG_LOG_NEAR, cfg_parser_error(pctx, CFG_LOG_NEAR,
@@ -1362,7 +1370,7 @@ cfg_parse_duration_or_unlimited(cfg_parser_t *pctx, const cfg_type_t *type,
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
return cfg__parse_duration(pctx, ret); return (parse_duration(pctx, ret));
cleanup: cleanup:
cfg_parser_error(pctx, CFG_LOG_NEAR, cfg_parser_error(pctx, CFG_LOG_NEAR,