REQUIRE(VALID_FWDTABLE(fwdtable));
dns_qpmulti_query(fwdtable->table, &qpr);
- result = dns_qp_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
- NULL);
+ result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
dns_forwarders_t *fwdrs = pval;
*forwardersp = fwdrs;
/*%
* A QP chain holds references to each populated node between the root and
- * a given leaf. It is used internally by `dns_qp_findname_ancestor()` to
- * return a partial match if the specific name requested is not found;
- * optionally it can be passed back to the caller so that individual nodes
- * can be accessed.
+ * a given leaf. It is used internally by `dns_qp_lookup()` to return a
+ * partial match if the specific name requested is not found; optionally it
+ * can be passed back to the caller so that individual nodes can be
+ * accessed.
*/
typedef struct dns_qpchain {
unsigned int magic;
*/
isc_result_t
-dns_qp_findname_ancestor(dns_qpreadable_t qpr, const dns_name_t *name,
- dns_name_t *foundname, dns_name_t *predecessor,
- dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r);
+dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name,
+ dns_name_t *foundname, dns_name_t *predecessor,
+ dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r);
/*%<
- * Find a leaf in a qp-trie that is an ancestor domain of, or equal to, the
- * given DNS name.
+ * Look up a leaf in a qp-trie that is equal to, or an ancestor domain of,
+ * 'name'.
*
- * If 'foundname' is not NULL, it is updated to contain the name found.
- *
- * If 'predecessor' is not NULL, it is updated to contain the DNSSEC
- * predecessor of the searched-for name.
+ * If 'foundname' is not NULL, it will be updated to contain the name
+ * that was found (if any). The return code, ISC_R_SUCCESS or
+ * DNS_R_PARTIALMATCH, indicates whether the name found is name that
+ * was requested, or an ancestor. If the result is ISC_R_NOTFOUND,
+ * 'foundname' will not be updated.
*
* If 'chain' is not NULL, it is updated to contain a QP chain with
* references to the populated nodes in the tree between the root and
- * the name found.
- *
- * The leaf values are assigned to whichever of `*pval_r` and `*ival_r`
- * are not null, unless the return value is ISC_R_NOTFOUND.
+ * the name that was found. If the return code is DNS_R_PARTIALMATCH
+ * then the chain terminates at the closest ancestor found; if it is
+ * ISC_R_SUCCESS then it terminates at the name that was requested.
+ * If the result is ISC_R_NOTFOUND, 'chain' will not be updated.
+ *
+ * If 'predecessor' is not NULL, it will be updated to contain the
+ * closest predecessor of the searched-for name that exists in the
+ * trie.
+ *
+ * The leaf data for the node that was found will be assigned to
+ * whichever of `*pval_r` and `*ival_r` are not NULL, unless the
+ * return value is ISC_R_NOTFOUND.
*
* Requires:
* \li `qpr` is a pointer to a readable qp-trie
REQUIRE(foundname != NULL);
dns_qpmulti_query(keytable->table, &qpr);
- result = dns_qp_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
- NULL);
+ result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
keynode = pval;
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
REQUIRE(wantdnssecp != NULL);
dns_qpmulti_query(keytable->table, &qpr);
- result = dns_qp_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
- NULL);
+ result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
keynode = pval;
if (foundname != NULL) {
REQUIRE(VALID_NAMETREE(nametree));
dns_qpmulti_query(nametree->table, &qpr);
- result = dns_qp_findname_ancestor(&qpr, name, found, NULL, NULL,
- (void **)&node, NULL);
+ result = dns_qp_lookup(&qpr, name, found, NULL, NULL, (void **)&node,
+ NULL);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
switch (nametree->type) {
case DNS_NAMETREE_BOOL:
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
dns_qpmulti_query(ntatable->table, &qpr);
- result = dns_qp_findname_ancestor(&qpr, name, NULL, NULL, NULL, &pval,
- NULL);
+ result = dns_qp_lookup(&qpr, name, NULL, NULL, NULL, &pval, NULL);
nta = pval;
switch (result) {
}
isc_result_t
-dns_qp_findname_ancestor(dns_qpreadable_t qpr, const dns_name_t *name,
- dns_name_t *foundname, dns_name_t *predecessor,
- dns_qpchain_t *chain, void **pval_r,
- uint32_t *ival_r) {
+dns_qp_lookup(dns_qpreadable_t qpr, const dns_name_t *name,
+ dns_name_t *foundname, dns_name_t *predecessor,
+ dns_qpchain_t *chain, void **pval_r, uint32_t *ival_r) {
dns_qpreader_t *qp = dns_qpreader(qpr);
dns_qpkey_t search, found;
size_t searchlen, foundlen;
dns_qpmulti_query(zt->multi, &qpr);
- result = dns_qp_findname_ancestor(&qpr, name, NULL, NULL, &chain, &pval,
- NULL);
+ result = dns_qp_lookup(&qpr, name, NULL, NULL, &chain, &pval, NULL);
if (exactopts == DNS_ZTFIND_EXACT && result == DNS_R_PARTIALMATCH) {
result = ISC_R_NOTFOUND;
} else if (exactopts == DNS_ZTFIND_NOEXACT && result == ISC_R_SUCCESS) {
start = isc_time_monotonic();
for (i = 0; i < n; i++) {
name = dns_fixedname_name(&items[i]);
- dns_qp_findname_ancestor(qp, name, 0, NULL, NULL, NULL, NULL);
+ dns_qp_lookup(qp, name, 0, NULL, NULL, NULL, NULL);
}
stop = isc_time_monotonic();
- snprintf(buf, sizeof(buf),
- "look up %zd names (dns_qp_findname_ancestor):", n);
+ snprintf(buf, sizeof(buf), "look up %zd names (dns_qp_lookup):", n);
printf("%-57s%7.3fsec\n", buf, (stop - start) / (double)NS_PER_SEC);
start = isc_time_monotonic();
++search->ndata[1];
}
- dns_qp_findname_ancestor(qp, search, 0, NULL, NULL, NULL, NULL);
+ dns_qp_lookup(qp, search, 0, NULL, NULL, NULL, NULL);
}
stop = isc_time_monotonic();
snprintf(buf, sizeof(buf),
- "look up %zd wrong names (dns_qp_findname_ancestor):", n);
+ "look up %zd wrong names (dns_qp_lookup):", n);
printf("%-57s%7.3fsec\n", buf, (stop - start) / (double)NS_PER_SEC);
isc_mem_cput(mctx, items, n, sizeof(dns_fixedname_t));
void *pval = NULL;
dns_test_namefromstring(check[i].query, &fn1);
- result = dns_qp_findname_ancestor(qp, name, foundname, NULL,
- NULL, &pval, NULL);
+ result = dns_qp_lookup(qp, name, foundname, NULL, NULL, &pval,
+ NULL);
#if 0
fprintf(stderr, "%s %s (expected %s) "
dns_qpchain_init(qp, &chain);
dns_test_namefromstring(check[i].query, &fn1);
- result = dns_qp_findname_ancestor(qp, name, NULL, NULL, &chain,
- NULL, NULL);
+ result = dns_qp_lookup(qp, name, NULL, NULL, &chain, NULL,
+ NULL);
#if 0
fprintf(stderr, "%s %s (expected %s), "
char *predname = NULL;
dns_test_namefromstring(check[i].query, &fn1);
- result = dns_qp_findname_ancestor(qp, name, NULL, pred, NULL,
- NULL, NULL);
+ result = dns_qp_lookup(qp, name, NULL, pred, NULL, NULL, NULL);
#if 0
fprintf(stderr, "%s: expected %s got %s\n", check[i].query,
isc_result_totext(check[i].result),