From dded35f92d404f1aac48a4f61da2045f7353ffac Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 19 Apr 2000 18:49:11 +0000 Subject: [PATCH] noexact support --- lib/dns/dbtable.c | 12 +++++++++--- lib/dns/include/dns/dbtable.h | 9 ++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/dns/dbtable.c b/lib/dns/dbtable.c index b7cf4040ad..1507bdfb9a 100644 --- a/lib/dns/dbtable.c +++ b/lib/dns/dbtable.c @@ -16,7 +16,7 @@ */ /* - * $Id: dbtable.c,v 1.15 2000/04/19 18:23:30 halley Exp $ + * $Id: dbtable.c,v 1.16 2000/04/19 18:49:10 halley Exp $ */ /* @@ -270,15 +270,21 @@ dns_dbtable_removedefault(dns_dbtable_t *dbtable) { } isc_result_t -dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name, dns_db_t **dbp) { +dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name, + unsigned int options, dns_db_t **dbp) +{ dns_db_t *stored_data = NULL; isc_result_t result; + unsigned int rbtoptions = 0; REQUIRE(dbp != NULL && *dbp == NULL); + if ((options & DNS_DBTABLEFIND_NOEXACT) != 0) + rbtoptions |= DNS_RBTFIND_NOEXACT; + RWLOCK(&dbtable->tree_lock, isc_rwlocktype_read); - result = dns_rbt_findname(dbtable->rbt, name, 0, NULL, + result = dns_rbt_findname(dbtable->rbt, name, rbtoptions, NULL, (void **)&stored_data); if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) diff --git a/lib/dns/include/dns/dbtable.h b/lib/dns/include/dns/dbtable.h index 12b8d2f73e..0cac2693d7 100644 --- a/lib/dns/include/dns/dbtable.h +++ b/lib/dns/include/dns/dbtable.h @@ -46,6 +46,8 @@ #include #include +#define DNS_DBTABLEFIND_NOEXACT 0x01 + isc_result_t dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_dbtable_t **dbtablep); @@ -138,10 +140,15 @@ dns_dbtable_removedefault(dns_dbtable_t *dbtable); */ isc_result_t -dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name, dns_db_t **dbp); +dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name, + unsigned int options, dns_db_t **dbp); /* * Find the deepest match to 'name' in the dbtable, and return it * + * Notes: + * If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial + * match (if any) to 'name' will be returned. + * * Returns: ISC_R_SUCCESS on success * no default and match */