Commit f16244fa authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2098] supported getName()

parent 0e19763b
......@@ -89,11 +89,14 @@ TEST_F(TreeNodeRRsetTest, create) {
const TreeNodeRRset rrset1(RRClass::IN(), www_node_, a_rdataset_, true);
EXPECT_EQ(RRClass::IN(), rrset1.getClass());
EXPECT_EQ(RRType::A(), rrset1.getType());
EXPECT_EQ(www_name_, rrset1.getName());
EXPECT_EQ(1, rrset1.getRdataCount());
EXPECT_EQ(1, rrset1.getRRsigDataCount());
const TreeNodeRRset rrset2(RRClass::IN(), www_node_, a_rdataset_, false);
EXPECT_EQ(RRClass::IN(), rrset2.getClass());
EXPECT_EQ(RRType::A(), rrset2.getType());
EXPECT_EQ(www_name_, rrset2.getName());
EXPECT_EQ(1, rrset2.getRdataCount());
EXPECT_EQ(0, rrset2.getRRsigDataCount());
}
......
......@@ -41,7 +41,15 @@ namespace memory {
const Name&
TreeNodeRRset::getName() const {
isc_throw(Unexpected, "unexpected method called on TreeNodeRRset");
if (name_ == NULL) {
uint8_t labels_buf[LabelSequence::MAX_SERIALIZED_LENGTH];
const LabelSequence node_labels = node_->getAbsoluteLabels(labels_buf);
size_t data_len;
const uint8_t* data = node_labels.getData(&data_len);
util::InputBuffer buffer(data, data_len);
name_ = new Name(buffer);
}
return (*name_);
}
const RRTTL&
......
......@@ -61,10 +61,12 @@ public:
const RdataSet* rdataset, bool dnssec_ok) :
node_(node), rdataset_(rdataset),
rrsig_count_(rdataset_->getSigRdataCount()), rrclass_(rrclass),
dnssec_ok_(dnssec_ok)
dnssec_ok_(dnssec_ok), name_(NULL)
{}
virtual ~TreeNodeRRset() {}
virtual ~TreeNodeRRset() {
delete name_;
}
virtual unsigned int getRdataCount() const {
return (rdataset_->getRdataCount());
......@@ -116,6 +118,7 @@ private:
const size_t rrsig_count_;
const dns::RRClass rrclass_;
const bool dnssec_ok_;
mutable dns::Name* name_;
};
} // namespace memory
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment