Also adjust tests.
RRType::CNAME(), this->rrttl_));
this->rrset_->addRdata(rdata::createRdata(this->rrset_->getType(),
this->rrset_->getClass(),
- "www.example.org"));
+ "www.example.org."));
this->updater_->deleteRRset(*this->rrset_);
// The this->updater_ finder should immediately see the deleted results.
RRType::CNAME(), this->rrttl_));
this->rrset_->addRdata(rdata::createRdata(this->rrset_->getType(),
this->rrset_->getClass(),
- "www.example.org"));
+ "www.example.org."));
this->updater_ = this->client_->getUpdater(this->zname_, false);
this->updater_->deleteRRset(*this->rrset_);
// This one will place rr_ns_a_ at a zone cut, making it a glue:
{"ns.example.org. 300 IN NS 192.0.2.2.", &rr_ns_ns_},
{"ns.example.org. 300 IN AAAA 2001:db8::2", &rr_ns_aaaa_},
- {"cname.example.org. 300 IN CNAME canonical.example.org",
+ {"cname.example.org. 300 IN CNAME canonical.example.org.",
&rr_cname_},
{"cname.example.org. 300 IN A 192.0.2.3", &rr_cname_a_},
{"dname.example.org. 300 IN DNAME target.example.org.",
{"example.org. 300 IN A 192.0.2.1", &rr_a_},
{"ns.example.org. 300 IN A 192.0.2.2", &rr_ns_a_},
{"ns.example.org. 300 IN AAAA 2001:db8::2", &rr_ns_aaaa_},
- {"cname.example.org. 300 IN CNAME canonical.example.org",
+ {"cname.example.org. 300 IN CNAME canonical.example.org.",
&rr_cname_},
{"cname.example.org. 300 IN A 192.0.2.3", &rr_cname_a_},
{"dname.example.org. 300 IN DNAME target.example.org.",
// BEGIN_RDATA_NAMESPACE
CNAME::CNAME(const std::string& namestr) :
- cname_(namestr)
-{}
+ // Fill in dummy name and replace it soon below.
+ cname_(Name::ROOT_NAME())
+{
+ try {
+ std::istringstream ss(namestr);
+ MasterLexer lexer;
+ lexer.pushSource(ss);
+
+ cname_ = createNameFromLexer(lexer, NULL);
+
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText, "extra input text for CNAME: "
+ << namestr);
+ }
+ } catch (const MasterLexer::LexerError& ex) {
+ isc_throw(InvalidRdataText, "Failed to construct CNAME from '" <<
+ namestr << "': " << ex.what());
+ }
+}
CNAME::CNAME(InputBuffer& buffer, size_t) :
Rdata(), cname_(buffer)
// there's nothing to specialize
};
-const generic::CNAME rdata_cname("cn.example.com");
-const generic::CNAME rdata_cname2("cn2.example.com");
+const generic::CNAME rdata_cname("cn.example.com.");
+const generic::CNAME rdata_cname2("cn2.example.com.");
const uint8_t wiredata_cname[] = {
0x02, 0x63, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
0x63, 0x6f, 0x6d, 0x00 };
0x03, 0x63, 0x6e, 0x32, 0xc0, 0x03 };
TEST_F(Rdata_CNAME_Test, createFromText) {
- EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com")));
+ EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com.")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com.")));
// should be case sensitive.
- EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("CN.EXAMPLE.COM")));
+ EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("CN.EXAMPLE.COM.")));
// RDATA of a class-independent type should be recognized for any
// "unknown" class.
EXPECT_EQ(0, rdata_cname.compare(*createRdata(RRType("CNAME"),
RRClass(65000),
- "cn.example.com")));
+ "cn.example.com.")));
}
TEST_F(Rdata_CNAME_Test, createFromWire) {
"rdata_cname_fromWire", 71),
DNSMessageFORMERR);
- EXPECT_EQ(0, generic::CNAME("cn2.example.com").compare(
+ EXPECT_EQ(0, generic::CNAME("cn2.example.com.").compare(
*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"rdata_cname_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
// If there's a CNAME at the name instead, it's an error.
rrsets_->removeRRset(Name("*.example.com"), zclass_, RRType::A());
RRsetPtr cname(new RRset(ns_name, zclass_, RRType::CNAME(), RRTTL(60)));
- cname->addRdata(generic::CNAME("cname.example.com"));
+ cname->addRdata(generic::CNAME("cname.example.com."));
rrsets_->addRRset(cname);
EXPECT_FALSE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
expected_errors_.push_back("zone example.com/IN: NS 'ns.example.com' is "
rrset.add_rdata(Rdata(RRType.NS(), RRClass.IN(), nsname))
return rrset
-def create_cname(target='target.example.com', name=Name('example.com'),
+def create_cname(target='target.example.com.', name=Name('example.com'),
ttl=3600):
rrset = RRset(name, RRClass.IN(), RRType.CNAME(), RRTTL(ttl))
rrset.add_rdata(Rdata(RRType.CNAME(), RRClass.IN(), target))
// ... the CNAME records
rrs_in_cname_www1->addRdata(ConstRdataPtr(
- new CNAME("www.example.com")));
+ new CNAME("www.example.com.")));
rrs_in_cname_www2->addRdata(ConstRdataPtr(
- new CNAME("www1.example.com")));
+ new CNAME("www1.example.com.")));
}
Message msg_a; // Pointer to message in RENDER state