]> sourceware.org Git - glibc.git/commitdiff
support: Change non-address output format of support_format_dns_packet
authorFlorian Weimer <fweimer@redhat.com>
Fri, 24 Jun 2022 16:16:41 +0000 (18:16 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 24 Jun 2022 16:18:41 +0000 (18:18 +0200)
It makes sense to include the owner name (LHS) and record type in the
output, so that they can be checked for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
support/support_format_dns_packet.c
support/tst-support_format_dns_packet.c

index e8b3c125e3d25c995123eb7610b1d6ec73dfe27d..14344bc1bf9c6897660581e2f70f85e7cd6a78ac 100644 (file)
@@ -90,6 +90,17 @@ extract_name (struct in_buffer full, struct in_buffer *in, struct dname *value)
   return true;
 }
 
+static void
+extract_name_data (struct in_buffer full, struct in_buffer *rdata,
+                   const struct dname *owner, const char *typename, FILE *out)
+{
+  struct dname name;
+  if (extract_name (full, rdata, &name))
+    fprintf (out, "data: %s %s %s\n", owner->name, typename, name.name);
+  else
+    fprintf (out, "error: malformed CNAME/PTR record\n");
+}
+
 char *
 support_format_dns_packet (const unsigned char *buffer, size_t length)
 {
@@ -195,14 +206,11 @@ support_format_dns_packet (const unsigned char *buffer, size_t length)
           }
           break;
         case T_CNAME:
+          extract_name_data (full, &rdata, &rname, "CNAME", mem.out);
+          break;
         case T_PTR:
-          {
-            struct dname name;
-            if (extract_name (full, &rdata, &name))
-              fprintf (mem.out, "name: %s\n", name.name);
-            else
-              fprintf (mem.out, "error: malformed CNAME/PTR record\n");
-          }
+          extract_name_data (full, &rdata, &rname, "PTR", mem.out);
+          break;
         }
     }
 
index cb7ff53b874641a2731352c839fe4cad003d4c9e..9839aa767e9b57d98877b98947e3b93853984c99 100644 (file)
@@ -85,8 +85,8 @@ test_multiple_cnames (void)
     "\xc0\x00\x02\x01";
   check_packet (packet, sizeof (packet) - 1, __func__,
                 "name: www.example\n"
-                "name: www1.example\n"
-                "name: www2.example\n"
+                "data: www.example CNAME www1.example\n"
+                "data: www1.example CNAME www2.example\n"
                 "address: 192.0.2.1\n");
 }
 
This page took 0.047336 seconds and 5 git commands to generate.