Parse DNSSEC AD and CD bits

Parse authentic data (AD) and checking disabled (CD) bits according to
RFC 2535. Leaves the Z field as-is, in case users are already handling
this elsewhere and depend on the value being the integer for all 3 bits.

https://www.rfc-editor.org/rfc/rfc2535#section-6.1

Fixes #2672
This commit is contained in:
Michael R. Torres 2023-01-23 02:17:59 +00:00 committed by Michael
parent c29b98b224
commit fe8390c646
28 changed files with 305 additions and 285 deletions

View file

@ -1791,6 +1791,8 @@ DNS_MsgInfo::DNS_MsgInfo(DNS_RawMsgHdr* hdr, int arg_is_query)
RD = (flags & 0x0100) != 0;
RA = (flags & 0x0080) != 0;
Z = (flags & 0x0070) >> 4;
AD = (flags & 0x0020) >> 5;
CD = (flags & 0x0010) >> 4;
rcode = (flags & 0x000f);
qdcount = ntohs(hdr->qdcount);
@ -1823,10 +1825,12 @@ RecordValPtr DNS_MsgInfo::BuildHdrVal()
r->Assign(6, static_cast<bool>(RD));
r->Assign(7, static_cast<bool>(RA));
r->Assign(8, Z);
r->Assign(9, qdcount);
r->Assign(10, ancount);
r->Assign(11, nscount);
r->Assign(12, arcount);
r->Assign(9, static_cast<bool>(AD));
r->Assign(10, static_cast<bool>(CD));
r->Assign(11, qdcount);
r->Assign(12, ancount);
r->Assign(13, nscount);
r->Assign(14, arcount);
return r;
}