From 2096647926c18c6380fd97813384358ca743320a Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 1 Dec 2015 17:22:59 +0100 Subject: [PATCH] Add URI QType --- docs/markdown/types.md | 4 ++++ pdns/dnsrecords.cc | 7 +++++++ pdns/dnsrecords.hh | 8 ++++++++ pdns/qtype.hh | 2 ++ pdns/test-dnsrecords_cc.cc | 2 ++ 5 files changed, 23 insertions(+) diff --git a/docs/markdown/types.md b/docs/markdown/types.md index 0b98ad633..653b371cd 100644 --- a/docs/markdown/types.md +++ b/docs/markdown/types.md @@ -196,6 +196,10 @@ When a TXT record is longer than 255 characters/bytes (excluding possible enclos quotes), PowerDNS will cut up the content into 255 character/byte chunks for transmission to the client. +## URI +The URI record, specified in [RFC 7553](http://tools.ietf.org/html/rfc7553), is +used to publish mappings from hostnames to URIs. + ## Other types The following, rarely used or obsolete record types, are also supported: diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index cce6ab714..d1c156668 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -480,6 +480,12 @@ boilerplate_conv(TKEY, QType::TKEY, ) TKEYRecordContent::TKEYRecordContent() { d_othersize = 0; } // fix CID#1288932 +boilerplate_conv(URI, QType::URI, + conv.xfr8BitInt(d_priority); + conv.xfr8BitInt(d_weight); + conv.xfrText(d_target, true, false); + ) + static uint16_t makeTag(const std::string& data) { const unsigned char* key=(const unsigned char*)data.c_str(); @@ -601,6 +607,7 @@ void reportOtherTypes() EUI48RecordContent::report(); EUI64RecordContent::report(); MINFORecordContent::report(); + URIRecordContent::report(); } void reportAllTypes() diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index 91df95aab..fc4a6bc00 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -630,6 +630,14 @@ public: private: }; +class URIRecordContent : public DNSRecordContent { + public: + includeboilerplate(URI) + private: + uint8_t d_priority, d_weight; + string d_target; +}; + #define boilerplate(RNAME, RTYPE) \ RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const DNSRecord& dr, PacketReader& pr) \ { \ diff --git a/pdns/qtype.hh b/pdns/qtype.hh index 2228af201..ad121333b 100644 --- a/pdns/qtype.hh +++ b/pdns/qtype.hh @@ -127,6 +127,7 @@ public: MAILB=253, MAILA=254, ANY=255, + URI=256, DLV=32769, ADDR=65400, ALIAS=65401 @@ -216,6 +217,7 @@ private: qtype_insert("MAILB", 253); qtype_insert("MAILA", 254); qtype_insert("ANY", 255); + qtype_insert("URI", 256); qtype_insert("DLV", 32769); qtype_insert("ADDR", 65400); qtype_insert("ALIAS", 65401); diff --git a/pdns/test-dnsrecords_cc.cc b/pdns/test-dnsrecords_cc.cc index 77e17bed6..a5002f8ee 100644 --- a/pdns/test-dnsrecords_cc.cc +++ b/pdns/test-dnsrecords_cc.cc @@ -165,6 +165,8 @@ BOOST_AUTO_TEST_CASE(test_record_types) { (CASE_S(QType::TKEY, "gss-tsig. 12345 12345 3 21 4 dGVzdA== 4 dGVzdA==", "\x08gss-tsig\x00\x00\x00\x30\x39\x00\x00\x30\x39\x00\x03\x00\x15\x00\x04test\x00\x04test", false)) /* (CASE_S(QType::ADDR, "zone format", "line format",false)) */ (CASE_S(QType::DLV, "20642 8 2 04443abe7e94c3985196beae5d548c727b044dda5151e60d7cd76a9fd931d00e", "\x50\xa2\x08\x02\x04\x44\x3a\xbe\x7e\x94\xc3\x98\x51\x96\xbe\xae\x5d\x54\x8c\x72\x7b\x04\x4d\xda\x51\x51\xe6\x0d\x7c\xd7\x6a\x9f\xd9\x31\xd0\x0e",false)) + (CASE_S(QType::URI, "10 1 \"ftp://ftp1.example.com/public\"", "\x0a\x01\x66\x74\x70\x3a\x2f\x2f\x66\x74\x70\x31\x2e\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d\x2f\x70\x75\x62\x6c\x69\x63", false)) + (CASE_S(QType::URI, "10 1 \"ftp://ftp1.example.com/public/with/a/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/long/url\"", "\x0a\x01\x66\x74\x70\x3a\x2f\x2f\x66\x74\x70\x31\x2e\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d\x2f\x70\x75\x62\x6c\x69\x63\x2f\x77\x69\x74\x68\x2f\x61\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x76\x65\x72\x79\x2f\x6c\x6f\x6e\x67\x2f\x75\x72\x6c", false)) (CASE_S((QType::typeenum)65226,"\\# 3 414243","\x41\x42\x43",false)) ; -- 2.40.0