]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
always print a colon after EDNS option names in text output
authorEvan Hunt <each@isc.org>
Sat, 14 Sep 2019 17:23:24 +0000 (10:23 -0700)
committerEvan Hunt <each@isc.org>
Fri, 4 Oct 2019 05:52:16 +0000 (22:52 -0700)
make the same change as in the previous commit to non-YAML text output,
for better readability and consistency between formats.

lib/dns/message.c

index cb5469693b1c3a24b6047454f95a34858a8ed2d9..0377450d02a0e7022156bab205979d46be1b9195 100644 (file)
@@ -3838,8 +3838,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                        INDENT(style);
 
                        if (optcode == DNS_OPT_LLQ) {
+                               ADD_STRING(target, "; LLQ:");
                                if (optlen == 18U) {
-                                       ADD_STRING(target, "; LLQ:");
                                        result = render_llq(&optbuf, target);
                                        if (result != ISC_R_SUCCESS) {
                                                return (result);
@@ -3847,59 +3847,55 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                        ADD_STRING(target, "\n");
                                        continue;
                                }
-                               ADD_STRING(target, "; LLQ");
                        } else if (optcode == DNS_OPT_NSID) {
-                               ADD_STRING(target, "; NSID");
+                               ADD_STRING(target, "; NSID:");
                        } else if (optcode == DNS_OPT_COOKIE) {
-                               ADD_STRING(target, "; COOKIE");
+                               ADD_STRING(target, "; COOKIE:");
                        } else if (optcode == DNS_OPT_CLIENT_SUBNET) {
                                isc_buffer_t ecsbuf;
 
-                               ADD_STRING(target, "; CLIENT-SUBNET");
+                               ADD_STRING(target, "; CLIENT-SUBNET:");
                                isc_buffer_init(&ecsbuf,
                                                isc_buffer_current(&optbuf),
                                                optlen);
                                isc_buffer_add(&ecsbuf, optlen);
                                result = render_ecs(&ecsbuf, target);
-                               if (result == ISC_R_NOSPACE)
+                               if (result == ISC_R_NOSPACE) {
                                        return (result);
+                               }
                                if (result == ISC_R_SUCCESS) {
                                        isc_buffer_forward(&optbuf, optlen);
                                        ADD_STRING(target, "\n");
                                        continue;
                                }
                        } else if (optcode == DNS_OPT_EXPIRE) {
+                               ADD_STRING(target, "; EXPIRE:");
                                if (optlen == 4) {
                                        uint32_t secs;
                                        secs = isc_buffer_getuint32(&optbuf);
-                                       ADD_STRING(target, "; EXPIRE: ");
-                                       snprintf(buf, sizeof(buf), "%u", secs);
+                                       snprintf(buf, sizeof(buf), " %u", secs);
                                        ADD_STRING(target, buf);
                                        ADD_STRING(target, " (");
-                                       result = dns_ttl_totext(secs,
-                                                               true,
-                                                               true,
-                                                               target);
+                                       result = dns_ttl_totext(secs, true,
+                                                               true, target);
                                        if (result != ISC_R_SUCCESS)
                                                return (result);
                                        ADD_STRING(target, ")\n");
                                        continue;
                                }
-                               ADD_STRING(target, "; EXPIRE");
                        } else if (optcode == DNS_OPT_TCP_KEEPALIVE) {
+                               ADD_STRING(target, "; TCP KEEPALIVE:");
                                if (optlen == 2) {
                                        unsigned int dsecs;
                                        dsecs = isc_buffer_getuint16(&optbuf);
-                                       ADD_STRING(target, "; TCP KEEPALIVE:");
                                        snprintf(buf, sizeof(buf), " %u.%u",
                                                 dsecs / 10U, dsecs % 10U);
                                        ADD_STRING(target, buf);
                                        ADD_STRING(target, " secs\n");
                                        continue;
                                }
-                               ADD_STRING(target, "; TCP KEEPALIVE");
                        } else if (optcode == DNS_OPT_PAD) {
-                               ADD_STRING(target, "; PAD");
+                               ADD_STRING(target, "; PAD:");
                                if (optlen > 0U) {
                                        snprintf(buf, sizeof(buf),
                                                 " (%u bytes)", optlen);
@@ -3909,16 +3905,16 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                ADD_STRING(target, "\n");
                                continue;
                        } else if (optcode == DNS_OPT_KEY_TAG) {
-                               ADD_STRING(target, "; KEY-TAG");
+                               ADD_STRING(target, "; KEY-TAG:");
                                if (optlen > 0U && (optlen % 2U) == 0U) {
-                                       const char *sep = "";
+                                       const char *sep = "";
                                        uint16_t id;
                                        while (optlen > 0U) {
                                            id = isc_buffer_getuint16(&optbuf);
-                                           snprintf(buf, sizeof(buf), "%s%u",
+                                           snprintf(buf, sizeof(buf), "%s %u",
                                                     sep, id);
                                            ADD_STRING(target, buf);
-                                           sep = ", ";
+                                           sep = ",";
                                            optlen -= 2;
                                        }
                                        ADD_STRING(target, "\n");
@@ -3926,11 +3922,10 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                }
                        } else if (optcode == DNS_OPT_CLIENT_TAG) {
                                uint16_t id;
-                               ADD_STRING(target, "; CLIENT-TAG");
+                               ADD_STRING(target, "; CLIENT-TAG:");
                                if (optlen == 2U) {
                                        id = isc_buffer_getuint16(&optbuf);
-                                       snprintf(buf, sizeof(buf), ": %u\n",
-                                                id);
+                                       snprintf(buf, sizeof(buf), " %u\n", id);
                                        ADD_STRING(target, buf);
                                        optlen -= 2;
                                        POST(optlen);
@@ -3938,11 +3933,10 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                }
                        } else if (optcode == DNS_OPT_SERVER_TAG) {
                                uint16_t id;
-                               ADD_STRING(target, "; SERVER-TAG");
+                               ADD_STRING(target, "; SERVER-TAG:");
                                if (optlen == 2U) {
                                        id = isc_buffer_getuint16(&optbuf);
-                                       snprintf(buf, sizeof(buf), ": %u\n",
-                                                id);
+                                       snprintf(buf, sizeof(buf), " %u\n", id);
                                        ADD_STRING(target, buf);
                                        optlen -= 2;
                                        POST(optlen);
@@ -3950,13 +3944,14 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                }
                        } else {
                                ADD_STRING(target, "; OPT=");
-                               snprintf(buf, sizeof(buf), "%u", optcode);
+                               snprintf(buf, sizeof(buf), "%u:", optcode);
                                ADD_STRING(target, buf);
                        }
 
                        if (optlen != 0) {
                                int i;
-                               ADD_STRING(target, ": ");
+
+                               ADD_STRING(target, " ");
 
                                optdata = isc_buffer_current(&optbuf);
                                for (i = 0; i < optlen; i++) {