Commit 53c89208 authored by Brian Wellington's avatar Brian Wellington
Browse files

Added dns_nxt_typepresent()

parent b5fff54f
57. [func] Added dns_nxt_typepresent()
56. [bug] SIG records were not properly returned in cached
negative answers.
......
......@@ -50,6 +50,17 @@ dns_buildnxt(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
* Build a NXT record and add it to a database.
*/
isc_boolean_t
dns_nxt_typepresent(dns_rdata_t *nxt, dns_rdatatype_t type);
/*
* Determine if a type is marked as present in an NXT record.
*
* Requires:
* 'nxt' points to a valid rdataset of type NXT
* 'type' < 128
*
*/
ISC_LANG_ENDDECLS
#endif /* DNS_NXT_H */
......@@ -164,3 +164,28 @@ dns_buildnxt(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
dns_rdataset_disassociate(&rdataset);
return (result);
}
isc_boolean_t
dns_nxt_typepresent(dns_rdata_t *nxt, dns_rdatatype_t type) {
dns_name_t name;
isc_region_t r, r2;
unsigned char *nxt_bits;
int nxt_bits_length, byte;
REQUIRE(nxt != NULL);
REQUIRE(nxt->type == dns_rdatatype_nxt);
REQUIRE(type < 128);
dns_rdata_toregion(nxt, &r);
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &r);
dns_name_toregion(&name, &r2);
nxt_bits = ((unsigned char *)r.base) + r2.length;
nxt_bits_length = r.length - r2.length;
INSIST(nxt_bits_length >= 4);
byte = type >> 3;
if (byte > nxt_bits_length)
return (ISC_FALSE);
else
return (ISC_TF(bit_isset(nxt_bits, type)));
}
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