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