mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Report Extended DNS Error codes
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
||||
#include <isc/utf8.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/dnssec.h>
|
||||
@@ -127,6 +128,32 @@ static const char *opcodetext[] = { "QUERY", "IQUERY", "STATUS",
|
||||
"RESERVED12", "RESERVED13", "RESERVED14",
|
||||
"RESERVED15" };
|
||||
|
||||
static const char *edetext[] = { "Other",
|
||||
"Unsupported DNSKEY Algorithm",
|
||||
"Unsupported DS Digest Type",
|
||||
"Stale Answer",
|
||||
"Forged Answer",
|
||||
"DNSSEC Indeterminate",
|
||||
"DNSSEC Bogus",
|
||||
"Signature Expired",
|
||||
"Signature Not Yet Valid",
|
||||
"DNSKEY Missing",
|
||||
"RRSIGs Missing",
|
||||
"No Zone Key Bit Set",
|
||||
"NSEC Missing",
|
||||
"Cached Error",
|
||||
"Not Ready",
|
||||
"Blocked",
|
||||
"Censored",
|
||||
"Filtered",
|
||||
"Prohibited",
|
||||
"Stale NXDOMAIN Answer",
|
||||
"Not Authoritative",
|
||||
"Not Supported",
|
||||
"No Reachable Authority",
|
||||
"Network Error",
|
||||
"Invalid Data" };
|
||||
|
||||
/*%
|
||||
* "helper" type, which consists of a block of some type, and is linkable.
|
||||
* For it to work, sizeof(dns_msgblock_t) must be a multiple of the pointer
|
||||
@@ -3590,7 +3617,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
|
||||
* Print EDNS info, if any.
|
||||
*
|
||||
* WARNING: The option contents may be malformed as
|
||||
* dig +ednsopt=value:<content> does not validity
|
||||
* dig +ednsopt=value:<content> does not perform validity
|
||||
* checking.
|
||||
*/
|
||||
dns_rdata_init(&rdata);
|
||||
@@ -4004,6 +4031,36 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
|
||||
ADD_STRING(target, "\n");
|
||||
continue;
|
||||
}
|
||||
} else if (optcode == DNS_OPT_EDE) {
|
||||
ADD_STRING(target, "; EDE:");
|
||||
if (optlen >= 2U) {
|
||||
uint16_t ede;
|
||||
ede = isc_buffer_getuint16(&optbuf);
|
||||
snprintf(buf, sizeof(buf), " %u", ede);
|
||||
ADD_STRING(target, buf);
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
if (ede < ARRAY_SIZE(edetext)) {
|
||||
ADD_STRING(target, " (");
|
||||
ADD_STRING(target,
|
||||
edetext[ede]);
|
||||
ADD_STRING(target, ")");
|
||||
}
|
||||
optlen -= 2;
|
||||
if (optlen != 0) {
|
||||
ADD_STRING(target, ":");
|
||||
}
|
||||
} else if (optlen == 1U) {
|
||||
/* Malformed */
|
||||
optdata = isc_buffer_current(&optbuf);
|
||||
snprintf(buf, sizeof(buf),
|
||||
" %02x (\"%c\")\n", optdata[0],
|
||||
isprint(optdata[0])
|
||||
? optdata[0]
|
||||
: '.');
|
||||
isc_buffer_forward(&optbuf, optlen);
|
||||
ADD_STRING(target, buf);
|
||||
continue;
|
||||
}
|
||||
} else if (optcode == DNS_OPT_CLIENT_TAG) {
|
||||
uint16_t id;
|
||||
ADD_STRING(target, "; CLIENT-TAG:");
|
||||
@@ -4038,19 +4095,22 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
|
||||
ADD_STRING(target, " ");
|
||||
|
||||
optdata = isc_buffer_current(&optbuf);
|
||||
for (i = 0; i < optlen; i++) {
|
||||
const char *sep;
|
||||
switch (optcode) {
|
||||
case DNS_OPT_COOKIE:
|
||||
sep = "";
|
||||
break;
|
||||
default:
|
||||
sep = " ";
|
||||
break;
|
||||
if (optcode != DNS_OPT_EDE) {
|
||||
for (i = 0; i < optlen; i++) {
|
||||
const char *sep;
|
||||
switch (optcode) {
|
||||
case DNS_OPT_COOKIE:
|
||||
sep = "";
|
||||
break;
|
||||
default:
|
||||
sep = " ";
|
||||
break;
|
||||
}
|
||||
snprintf(buf, sizeof(buf),
|
||||
"%02x%s", optdata[i],
|
||||
sep);
|
||||
ADD_STRING(target, buf);
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%02x%s",
|
||||
optdata[i], sep);
|
||||
ADD_STRING(target, buf);
|
||||
}
|
||||
|
||||
isc_buffer_forward(&optbuf, optlen);
|
||||
@@ -4087,9 +4147,13 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
|
||||
|
||||
/*
|
||||
* For non-COOKIE options, add a printable
|
||||
* version
|
||||
* version.
|
||||
*/
|
||||
ADD_STRING(target, "(\"");
|
||||
if (optcode != DNS_OPT_EDE) {
|
||||
ADD_STRING(target, "(\"");
|
||||
} else {
|
||||
ADD_STRING(target, "(");
|
||||
}
|
||||
if (isc_buffer_availablelength(target) < optlen)
|
||||
{
|
||||
return (ISC_R_NOSPACE);
|
||||
@@ -4102,7 +4166,11 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
|
||||
isc_buffer_putstr(target, ".");
|
||||
}
|
||||
}
|
||||
ADD_STRING(target, "\")");
|
||||
if (optcode != DNS_OPT_EDE) {
|
||||
ADD_STRING(target, "\")");
|
||||
} else {
|
||||
ADD_STRING(target, ")");
|
||||
}
|
||||
}
|
||||
ADD_STRING(target, "\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user