const knot_rrset_t *rr = knot_pkt_rr(an, i);
/* Skip the RR if its owner+type doesn't interest us. */
- const bool type_OK = rr->type == query->stype
- || rr->type == KNOT_RRTYPE_CNAME
- || rr->type == KNOT_RRTYPE_DNAME /* TODO: actually handle it */
- || (rr->type == KNOT_RRTYPE_RRSIG
- && knot_rrsig_type_covered(&rr->rrs, 0))
- ;
+ const uint16_t type = kr_rrset_type_maysig(rr);
+ const bool type_OK = rr->type == query->stype || type == query->stype
+ || type == KNOT_RRTYPE_CNAME || type == KNOT_RRTYPE_DNAME;
+ /* TODO: actually handle DNAMEs */
if (!type_OK || !knot_dname_is_equal(rr->owner, cname)) {
continue;
}
/* Skip NSEC3 RRs and their signatures. We don't use them this way.
* They would be stored under the hashed name, etc. */
- if (rr->type == KNOT_RRTYPE_NSEC3
- || (rr->type == KNOT_RRTYPE_RRSIG
- && knot_rrsig_type_covered(&rr->rrs, 0) == KNOT_RRTYPE_NSEC3)) {
+ if (kr_rrset_type_maysig(rr) == KNOT_RRTYPE_NSEC3) {
continue;
}
/* Stash key = {[1] flags, [1-255] owner, [5] type, [1] \x00 } */
char key[KR_RRKEY_LEN];
uint8_t extra_flags = 0;
- uint16_t rrtype = rr->type;
+ uint16_t rrtype = kr_rrset_type_maysig(rr);
/* Stash RRSIGs in a special cache, flag them and set type to its covering RR.
* This way it the stash won't merge RRSIGs together. */
if (rr->type == KNOT_RRTYPE_RRSIG) {
- rrtype = knot_rrsig_type_covered(&rr->rrs, 0);
extra_flags |= KEY_FLAG_RRSIG;
}
int ret = kr_rrkey(key, rr->owner, rrtype, rank);
#include <stdbool.h>
#include <sys/time.h>
#include <netinet/in.h>
+#include <libknot/libknot.h>
#include <libknot/packet/pkt.h>
+#include <libknot/rrset.h>
+#include <libknot/rrtype/rrsig.h>
#include "lib/generic/map.h"
#include "lib/generic/array.h"
#include "lib/defines.h"
memcpy(&x, swap_temp, sizeof(x)); \
} while(0)
+/** Return the (covered) type of an nonempty RRset. */
+static inline uint16_t kr_rrset_type_maysig(const knot_rrset_t *rr)
+{
+ assert(rr && rr->rrs.rr_count && rr->rrs.data);
+ uint16_t type = rr->type;
+ if (type == KNOT_RRTYPE_RRSIG)
+ type = knot_rrsig_type_covered(&rr->rrs, 0);
+ return type;
+}