mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 22:50:29 +00:00
resolved: tests for dns_resource_record_to_wire_format()
Note this function does not produce compressed domain names in the RDATA when serializing the RR.
This commit is contained in:
committed by
Luca Boccassi
parent
f6d2ad95ed
commit
77018b2f47
@@ -2307,6 +2307,43 @@ TEST(dns_resource_record_to_string_svcb) {
|
||||
ASSERT_STREQ(str, "_443._wss.example.com IN SVCB 9 sock.example.com mandatory=\"\\000\\001\\000\\003\" alpn=\"websocket\" no-default-alpn port=443 ipv4hint=114.132.253.58,72.188.199.192 ipv6hint=f234:322e:b825:3835:2fd7:db7b:287e:60bb key99");
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* dns_resource_record_to_wire_format()
|
||||
* ================================================================ */
|
||||
|
||||
TEST(dns_resource_record_to_wire_format) {
|
||||
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
|
||||
int r;
|
||||
|
||||
rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_CNAME, "www.example.com");
|
||||
ASSERT_NOT_NULL(rr);
|
||||
rr->ttl = 3600;
|
||||
rr->cname.name = strdup("example.com");
|
||||
|
||||
ASSERT_OK(dns_resource_record_to_wire_format(rr, true));
|
||||
|
||||
const uint8_t data[] = {
|
||||
/* name */ 0x03, 'w', 'w', 'w',
|
||||
0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
|
||||
0x03, 'c', 'o', 'm',
|
||||
0x00,
|
||||
/* CNAME */ 0x00, 0x05,
|
||||
/* IN */ 0x00, 0x01,
|
||||
/* ttl */ 0x00, 0x00, 0x0e, 0x10,
|
||||
/* rdata */ 0x00, 0x0d,
|
||||
/* name */ 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
|
||||
0x03, 'c', 'o', 'm',
|
||||
0x00
|
||||
};
|
||||
|
||||
ASSERT_EQ(rr->wire_format_size, sizeof(data));
|
||||
ASSERT_EQ(rr->wire_format_rdata_offset, 27u);
|
||||
ASSERT_EQ(rr->wire_format_canonical, true);
|
||||
|
||||
r = memcmp(rr->wire_format, data, sizeof(data));
|
||||
ASSERT_EQ(r, 0);
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* dns_resource_record_clamp_ttl()
|
||||
* ================================================================ */
|
||||
|
||||
Reference in New Issue
Block a user