diff --git a/lib/dns/include/dns/keytable.h b/lib/dns/include/dns/keytable.h index 49c35dcb31..d3f14ea246 100644 --- a/lib/dns/include/dns/keytable.h +++ b/lib/dns/include/dns/keytable.h @@ -156,6 +156,28 @@ dns_keytable_findkeynode(dns_keytable_t *keytable, dns_name_t *name, * Any other result indicates an error. */ +isc_result_t +dns_keytable_finddeepestmatch(dns_keytable_t *keytable, dns_name_t *name, + dns_name_t *foundname); +/* + * Search for the deepest match of 'name' in 'keytable'. + * + * Requires: + * + * 'keytable' is a valid keytable. + * + * 'name' is a valid absolute name. + * + * 'foundname' is a name with a dedicated buffer. + * + * Returns: + * + * ISC_R_SUCCESS + * ISC_R_NOTFOUND + * + * Any other result indicates an error. + */ + void dns_keytable_detachkeynode(dns_keytable_t *keytable, dns_keynode_t **keynodep); diff --git a/lib/dns/keytable.c b/lib/dns/keytable.c index dd5866c423..fafbec1ad4 100644 --- a/lib/dns/keytable.c +++ b/lib/dns/keytable.c @@ -285,6 +285,36 @@ dns_keytable_findkeynode(dns_keytable_t *keytable, dns_name_t *name, return (result); } +isc_result_t +dns_keytable_finddeepestmatch(dns_keytable_t *keytable, dns_name_t *name, + dns_name_t *foundname) +{ + isc_result_t result; + dns_keynode_t *knode; + void *data; + + /* + * Search for the deepest match in 'keytable'. + */ + + REQUIRE(VALID_KEYTABLE(keytable)); + REQUIRE(dns_name_isabsolute(name)); + REQUIRE(foundname != NULL); + + RWLOCK(&keytable->rwlock, isc_rwlocktype_read); + + knode = NULL; + data = NULL; + result = dns_rbt_findname(keytable->table, name, foundname, &data); + + if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) + result = ISC_R_SUCCESS; + + RWUNLOCK(&keytable->rwlock, isc_rwlocktype_read); + + return (result); +} + void dns_keytable_detachkeynode(dns_keytable_t *keytable, dns_keynode_t **keynodep)