Commit Diff
Diff:
701145635a171d9360f586686177b5ddf643210c
a0f09d4bd5a244990bae67904455a99c14c02210
Commit:
a0f09d4bd5a244990bae67904455a99c14c02210
Tree:
5ce6c575c44dc4758e2a7e542f4ddbcd0f0b94fc
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Mon Nov 11 05:22:50 2019 UTC
Message:
convert the boolean node dnssec to flags which is uint32_t and make the DNSSEC check a bitmask check for RBT_DNSSEC. This gives us room to have other bitmask booleans such as RBT_APEX and RBT_GLUE.
blob - 492532feacd44cc35103e66ca8f5ea1c46f20e9b
blob + 3c6c6d7883ed1fa85938031dfbe99ce79d80413f
--- db.c
+++ db.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: db.c,v 1.14 2019/11/02 17:24:27 pjp Exp $
+ * $Id: db.c,v 1.15 2019/11/11 05:22:50 pjp Exp $
*/
#include <sys/types.h>
@@ -199,7 +199,7 @@ create_rr(ddDB *db, char *name, int len, int type, voi
rbt->zonelen = len;
humanname = convert_name(name, len);
strlcpy(rbt->humanname, humanname, sizeof(rbt->humanname));
- rbt->dnssec = 0; /* by default not dnssec'ed */
+ rbt->flags &= ~RBT_DNSSEC; /* by default not dnssec'ed */
TAILQ_INIT(&rbt->rrset_head);
}
@@ -346,7 +346,7 @@ find_rr(struct rbtree *rbt, u_int16_t rrtype)
void
flag_rr(struct rbtree *rbt)
{
- rbt->dnssec = 1;
+ rbt->flags |= RBT_DNSSEC;
}
int
blob - 98f53563a9ffdce96ad2e85dbbd83adb2b819008
blob + 06f5410682d4ce1f7e425ceacb62750f1b91433b
--- ddd-db.h
+++ ddd-db.h
@@ -27,7 +27,7 @@
*/
/*
- * $Id: ddd-db.h,v 1.27 2019/11/04 12:10:49 pjp Exp $
+ * $Id: ddd-db.h,v 1.28 2019/11/11 05:22:50 pjp Exp $
*/
#ifndef _DB_H
@@ -332,7 +332,12 @@ struct rbtree {
char zone[DNS_MAXNAME];
int zonelen;
char humanname[DNS_MAXNAME + 1];
- int dnssec;
+ uint32_t flags; /* 32 bit flags */
+
+#define RBT_DNSSEC 0x1 /* this rbtree entry is of type DNSSEC */
+#define RBT_APEX 0x2 /* this rbtree entry is the apex of zone */
+#define RBT_GLUE 0x4 /* this rbtree entry is GLUE data */
+
TAILQ_HEAD(, rrset) rrset_head;
};
blob - 8c61c164e160e803b9f52b7097d959fa43766e57
blob + bc94d5f124a021a5093f2ef182cb12c45d1f373b
--- reply.c
+++ reply.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: reply.c,v 1.87 2019/11/09 07:53:45 pjp Exp $
+ * $Id: reply.c,v 1.88 2019/11/11 05:22:50 pjp Exp $
*/
#include <sys/types.h>
@@ -269,7 +269,7 @@ reply_a(struct sreply *sreply, ddDB *db)
odh->answer = htons(a_count);
/* Add RRSIG reply_a */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -480,7 +480,7 @@ reply_nsec3param(struct sreply *sreply, ddDB *db)
/* Add RRSIG reply_nsec3 */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -705,7 +705,7 @@ reply_nsec3(struct sreply *sreply, ddDB *db)
/* Add RRSIG reply_nsec3 */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -899,7 +899,7 @@ reply_nsec(struct sreply *sreply, ddDB *db)
/* Add RRSIG reply_nsec */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -1093,7 +1093,7 @@ reply_ds(struct sreply *sreply, ddDB *db)
odh->answer = htons(a_count);
/* Add RRSIG reply_ds */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -1290,7 +1290,7 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
odh->answer = htons(dnskey_count);
/* Add RRSIG reply_dnskey */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -1627,7 +1627,7 @@ reply_aaaa(struct sreply *sreply, ddDB *db)
odh->answer = htons(aaaa_count);
/* RRSIG reply_aaaa */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -1821,7 +1821,7 @@ reply_mx(struct sreply *sreply, ddDB *db)
/* RRSIG reply_mx*/
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int origlen = outlen;
tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_MX, rbt, reply, replysize, outlen, 0);
@@ -2038,7 +2038,7 @@ reply_ns(struct sreply *sreply, ddDB *db)
}
/* add RRSIG reply_ns */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int origlen = outlen;
tmplen = additional_rrsig(rbt1->zone, rbt1->zonelen, DNS_TYPE_NS, rbt1, reply, replysize, outlen, 0);
@@ -2154,7 +2154,7 @@ reply_ns(struct sreply *sreply, ddDB *db)
HTONS(odh->additional);
/* additional RRSIG for the additional AAAA */
- if (dnssec && q->dnssecok && rbt0->dnssec) {
+ if (dnssec && q->dnssecok && (rbt0->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(ad0->name, ad0->namelen, DNS_TYPE_AAAA, rbt0, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2203,7 +2203,7 @@ reply_ns(struct sreply *sreply, ddDB *db)
HTONS(odh->additional);
/* additional RRSIG for the additional A RR */
- if (dnssec && q->dnssecok && rbt0->dnssec) {
+ if (dnssec && q->dnssecok && (rbt0->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(ad0->name, ad0->namelen, DNS_TYPE_A, rbt0, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2412,7 +2412,7 @@ reply_cname(struct sreply *sreply, ddDB *db)
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_CNAME, rbt, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2443,7 +2443,7 @@ reply_cname(struct sreply *sreply, ddDB *db)
odh->answer += addcount;
HTONS(odh->answer);
- if (dnssec && q->dnssecok && rbt1->dnssec) {
+ if (dnssec && q->dnssecok && (rbt1->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(((struct cname *)rrp->rdata)->cname, ((struct cname *)rrp->rdata)->cnamelen, DNS_TYPE_A, rbt1, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2473,7 +2473,7 @@ reply_cname(struct sreply *sreply, ddDB *db)
odh->answer += addcount;
HTONS(odh->answer);
- if (dnssec && q->dnssecok && rbt1->dnssec) {
+ if (dnssec && q->dnssecok && (rbt1->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(((struct cname *)rrp->rdata)->cname, ((struct cname *)rrp->rdata)->cnamelen, DNS_TYPE_AAAA, rbt1, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2503,7 +2503,7 @@ reply_cname(struct sreply *sreply, ddDB *db)
odh->answer += addcount;
HTONS(odh->answer);
- if (dnssec && q->dnssecok && rbt1->dnssec) {
+ if (dnssec && q->dnssecok && (rbt1->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(((struct cname *)rrp->rdata)->cname, ((struct cname *)rrp->rdata)->cnamelen, DNS_TYPE_MX, rbt1, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2533,7 +2533,7 @@ reply_cname(struct sreply *sreply, ddDB *db)
odh->answer += addcount;
HTONS(odh->answer);
- if (dnssec && q->dnssecok && rbt1->dnssec) {
+ if (dnssec && q->dnssecok && (rbt1->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(((struct cname *)rrp->rdata)->cname, ((struct cname *)rrp->rdata)->cnamelen, DNS_TYPE_PTR, rbt1, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2723,7 +2723,7 @@ reply_ptr(struct sreply *sreply, ddDB *db)
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_PTR, rbt, reply, replysize, outlen, 0);
if (tmplen == 0) {
@@ -2976,7 +2976,7 @@ reply_soa(struct sreply *sreply, ddDB *db)
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
/* RRSIG reply_soa */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -3162,7 +3162,7 @@ reply_txt(struct sreply *sreply, ddDB *db)
}
/* Add RRSIG reply_txt */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -3483,7 +3483,7 @@ reply_tlsa(struct sreply *sreply, ddDB *db)
odh->answer = htons(tlsa_count);
/* RRSIG reply_tlsa */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -3671,7 +3671,7 @@ reply_sshfp(struct sreply *sreply, ddDB *db)
odh->answer = htons(sshfp_count);
/* RRSIG reply_sshfp */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -3895,7 +3895,7 @@ reply_naptr(struct sreply *sreply, ddDB *db)
/* RRSIG reply_naptr*/
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int origlen = outlen;
tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_NAPTR, rbt, reply, replysize, outlen, 0);
@@ -4089,7 +4089,7 @@ reply_srv(struct sreply *sreply, ddDB *db)
odh->answer = htons(srv_count);
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int origlen = outlen;
tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_SRV, rbt, reply, replysize, outlen, 0);
@@ -4464,7 +4464,7 @@ reply_nxdomain(struct sreply *sreply, ddDB *db)
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
/* RRSIG reply_nxdomain */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
@@ -5177,7 +5177,7 @@ reply_noerror(struct sreply *sreply, ddDB *db)
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
/* RRSIG reply_nxdomain */
- if (dnssec && q->dnssecok && rbt->dnssec) {
+ if (dnssec && q->dnssecok && (rbt->flags & RBT_DNSSEC)) {
int tmplen = 0;
int origlen = outlen;
blob - 492534130a18afef791374f41394a09b32663dcf
blob + 42245af7bcc5a97adfd8704b4cc4e6cd3fd80de5
--- util.c
+++ util.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: util.c,v 1.49 2019/11/11 05:04:21 pjp Exp $
+ * $Id: util.c,v 1.50 2019/11/11 05:22:50 pjp Exp $
*/
#include <sys/types.h>
@@ -350,7 +350,7 @@ lookup_zone(ddDB *db, struct question *question, int *
*returnval = 0;
/* if the find_rrset fails, the find_rr will not get questioned */
if ((rbt = find_rrset(db, p, plen)) == NULL ||
- (rbt->dnssec && (rrset = find_rr(rbt, DNS_TYPE_NSEC3)) != NULL)) {
+ ((rbt->flags & RBT_DNSSEC) && (rrset = find_rr(rbt, DNS_TYPE_NSEC3)) != NULL)) {
if (check_ent(p, plen) == 1) {
*lzerrno = ERR_NODATA;
*returnval = -1;
repomaster@centroid.eu