Commit 186817c9 authored by Michael Graff's avatar Michael Graff

make dns_message_findtype() public

parent 49f7148b
......@@ -495,6 +495,23 @@ dns_message_findname(dns_message_t *msg, dns_section_t section,
* type does not.
*/
dns_result_t
dns_message_findtype(dns_name_t *name, dns_rdatatype_t type,
dns_rdatatype_t covers, dns_rdataset_t **rdataset);
/*
* Search the name for the specified type. If it is found, *rdataset is
* filled in with a pointer to that rdataset.
*
* Requires:
* if '**rdataset' is non-NULL, *rdataset needs to be NULL.
*
* 'type' be a valid type, and NOT dns_rdatatype_any.
*
* Returns:
* DNS_R_SUCCESS -- all is well.
* DNS_R_NOTFOUND -- the desired type does not exist.
*/
void
dns_message_movename(dns_message_t *msg, dns_name_t *name,
dns_section_t fromsection,
......
......@@ -682,12 +682,16 @@ findname(dns_name_t **foundname, dns_name_t *target, dns_namelist_t *section)
return (DNS_R_NOTFOUND);
}
static dns_result_t
findtype(dns_rdataset_t **rdataset, dns_name_t *name, dns_rdatatype_t type,
dns_rdatatype_t covers)
dns_result_t
dns_message_findtype(dns_name_t *name, dns_rdatatype_t type,
dns_rdatatype_t covers, dns_rdataset_t **rdataset)
{
dns_rdataset_t *curr;
if (rdataset != NULL) {
REQUIRE(*rdataset == NULL);
}
for (curr = ISC_LIST_TAIL(name->list) ;
curr != NULL ;
curr = ISC_LIST_PREV(curr, link)) {
......@@ -890,7 +894,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx)
/*
* Can't ask the same question twice.
*/
result = findtype(NULL, name, rdtype, 0);
result = dns_message_findtype(name, rdtype, 0, NULL);
if (result == DNS_R_SUCCESS)
return (DNS_R_FORMERR);
......@@ -1091,8 +1095,11 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
if (preserve_order || msg->opcode == dns_opcode_update ||
skip_search)
result = DNS_R_NOTFOUND;
else
result = findtype(&rdataset, name, rdtype, covers);
else {
rdataset = NULL;
result = dns_message_findtype(name, rdtype, covers,
&rdataset);
}
/*
* If we found an rdataset that matches, we need to
......@@ -1602,7 +1609,7 @@ dns_message_findname(dns_message_t *msg, dns_section_t section,
if (type == dns_rdatatype_any)
return (DNS_R_SUCCESS);
result = findtype(rdataset, foundname, type, covers);
result = dns_message_findtype(foundname, type, covers, rdataset);
if (result == DNS_R_NOTFOUND)
return (DNS_R_NXRDATASET);
......
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