|
|
c5d972 |
commit 62a321b12d0e397af88fa422db65079332f971dc
|
|
|
c5d972 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
c5d972 |
Date: Fri Jun 24 18:16:41 2022 +0200
|
|
|
c5d972 |
|
|
|
c5d972 |
support: Change non-address output format of support_format_dns_packet
|
|
|
c5d972 |
|
|
|
c5d972 |
It makes sense to include the owner name (LHS) and record type in the
|
|
|
c5d972 |
output, so that they can be checked for correctness.
|
|
|
c5d972 |
|
|
|
c5d972 |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/support/support_format_dns_packet.c b/support/support_format_dns_packet.c
|
|
|
c5d972 |
index 1170eafb0f008fee..ef862bc4c8d14af0 100644
|
|
|
c5d972 |
--- a/support/support_format_dns_packet.c
|
|
|
c5d972 |
+++ b/support/support_format_dns_packet.c
|
|
|
c5d972 |
@@ -101,6 +101,17 @@ extract_name (struct in_buffer full, struct in_buffer *in, struct dname *value)
|
|
|
c5d972 |
return true;
|
|
|
c5d972 |
}
|
|
|
c5d972 |
|
|
|
c5d972 |
+static void
|
|
|
c5d972 |
+extract_name_data (struct in_buffer full, struct in_buffer *rdata,
|
|
|
c5d972 |
+ const struct dname *owner, const char *typename, FILE *out)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ struct dname name;
|
|
|
c5d972 |
+ if (extract_name (full, rdata, &name))
|
|
|
c5d972 |
+ fprintf (out, "data: %s %s %s\n", owner->name, typename, name.name);
|
|
|
c5d972 |
+ else
|
|
|
c5d972 |
+ fprintf (out, "error: malformed CNAME/PTR record\n");
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
char *
|
|
|
c5d972 |
support_format_dns_packet (const unsigned char *buffer, size_t length)
|
|
|
c5d972 |
{
|
|
|
c5d972 |
@@ -206,14 +217,11 @@ support_format_dns_packet (const unsigned char *buffer, size_t length)
|
|
|
c5d972 |
}
|
|
|
c5d972 |
break;
|
|
|
c5d972 |
case T_CNAME:
|
|
|
c5d972 |
+ extract_name_data (full, &rdata, &rname, "CNAME", mem.out);
|
|
|
c5d972 |
+ break;
|
|
|
c5d972 |
case T_PTR:
|
|
|
c5d972 |
- {
|
|
|
c5d972 |
- struct dname name;
|
|
|
c5d972 |
- if (extract_name (full, &rdata, &name))
|
|
|
c5d972 |
- fprintf (mem.out, "name: %s\n", name.name);
|
|
|
c5d972 |
- else
|
|
|
c5d972 |
- fprintf (mem.out, "error: malformed CNAME/PTR record\n");
|
|
|
c5d972 |
- }
|
|
|
c5d972 |
+ extract_name_data (full, &rdata, &rname, "PTR", mem.out);
|
|
|
c5d972 |
+ break;
|
|
|
c5d972 |
}
|
|
|
c5d972 |
}
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/support/tst-support_format_dns_packet.c b/support/tst-support_format_dns_packet.c
|
|
|
c5d972 |
index b1135eebc6c02d55..35f475fe86177772 100644
|
|
|
c5d972 |
--- a/support/tst-support_format_dns_packet.c
|
|
|
c5d972 |
+++ b/support/tst-support_format_dns_packet.c
|
|
|
c5d972 |
@@ -85,8 +85,8 @@ test_multiple_cnames (void)
|
|
|
c5d972 |
"\xc0\x00\x02\x01";
|
|
|
c5d972 |
check_packet (packet, sizeof (packet) - 1, __func__,
|
|
|
c5d972 |
"name: www.example\n"
|
|
|
c5d972 |
- "name: www1.example\n"
|
|
|
c5d972 |
- "name: www2.example\n"
|
|
|
c5d972 |
+ "data: www.example CNAME www1.example\n"
|
|
|
c5d972 |
+ "data: www1.example CNAME www2.example\n"
|
|
|
c5d972 |
"address: 192.0.2.1\n");
|
|
|
c5d972 |
}
|
|
|
c5d972 |
|