uint16_t optcode, optlen;
unsigned char *optdata;
unsigned int saveindent = dns_master_indent;
+ unsigned int optindent;
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(target != NULL);
isc_buffer_init(&optbuf, rdata.data, rdata.length);
isc_buffer_add(&optbuf, rdata.length);
+ optindent = dns_master_indent;
while (isc_buffer_remaininglength(&optbuf) != 0) {
+ bool extra_text = false;
+ dns_master_indent = optindent;
INSIST(isc_buffer_remaininglength(&optbuf) >= 4U);
optcode = isc_buffer_getuint16(&optbuf);
optlen = isc_buffer_getuint16(&optbuf);
ADD_STRING(target, "\n");
continue;
}
+ } else if (optcode == DNS_OPT_EDE) {
+ INDENT(style);
+ ADD_STRING(target, "EDE");
+ if (optlen >= 2U) {
+ uint16_t ede;
+ ADD_STRING(target, ":\n");
+ dns_master_indent++;
+ INDENT(style);
+ ADD_STRING(target, "INFO-CODE:");
+ ede = isc_buffer_getuint16(&optbuf);
+ snprintf(buf, sizeof(buf), " %u", ede);
+ ADD_STRING(target, buf);
+ if (ede < ARRAY_SIZE(edetext)) {
+ ADD_STRING(target, " (");
+ ADD_STRING(target,
+ edetext[ede]);
+ ADD_STRING(target, ")");
+ }
+ ADD_STRING(target, "\n");
+ optlen -= 2;
+ if (optlen != 0) {
+ INDENT(style);
+ ADD_STRING(target,
+ "EXTRA-TEXT");
+ extra_text = true;
+ }
+ }
} else if (optcode == DNS_OPT_CLIENT_TAG) {
uint16_t id;
INDENT(style);
if (optlen != 0) {
int i;
+ bool utf8ok = false;
+
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 (extra_text) {
+ utf8ok = isc_utf8_valid(optdata,
+ optlen);
+ }
+ if (!utf8ok) {
+ 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);
* For non-COOKIE options, add a printable
* version
*/
- ADD_STRING(target, "(\"");
+ if (!extra_text) {
+ ADD_STRING(target, "(\"");
+ } else {
+ ADD_STRING(target, "\"");
+ }
if (isc_buffer_availablelength(target) < optlen)
{
result = ISC_R_NOSPACE;
goto cleanup;
}
for (i = 0; i < optlen; i++) {
- if (isprint(optdata[i]))
- isc_buffer_putmem(target,
- &optdata[i],
- 1);
- else
+ if (isprint(optdata[i]) ||
+ (utf8ok && optdata[i] > 127)) {
+ isc_buffer_putmem(
+ target, &optdata[i], 1);
+ } else {
isc_buffer_putstr(target, ".");
+ }
+ }
+ if (!extra_text) {
+ ADD_STRING(target, "\")");
+ } else {
+ ADD_STRING(target, "\"");
}
- ADD_STRING(target, "\")");
}
ADD_STRING(target, "\n");
}
+ dns_master_indent = optindent;
result = ISC_R_SUCCESS;
goto cleanup;
case DNS_PSEUDOSECTION_TSIG:
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,
if (isc_buffer_availablelength(target) < optlen)
return (ISC_R_NOSPACE);
for (i = 0; i < optlen; i++) {
- if (isprint(optdata[i])) {
- isc_buffer_putmem(
- target, &optdata[i], 1);
- } else if (utf8ok && optdata[i] > 127) {
+ if (isprint(optdata[i]) ||
+ (utf8ok && optdata[i] > 127)) {
isc_buffer_putmem(
target, &optdata[i], 1);
} else {