Commit a727e666 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2108] Implement TreeNodeRRset::getTTL()

This is used in the iterator when separating RRs.
parent f60ea8d9
......@@ -138,11 +138,13 @@ protected:
void
checkBasicFields(const AbstractRRset& actual_rrset, const Name& expected_name,
const RRClass& expected_class, const RRType& expected_type,
const uint32_t expected_ttl,
size_t expected_rdatacount, size_t expected_sigcount)
{
EXPECT_EQ(expected_name, actual_rrset.getName());
EXPECT_EQ(expected_class, actual_rrset.getClass());
EXPECT_EQ(expected_type, actual_rrset.getType());
EXPECT_EQ(RRTTL(expected_ttl), actual_rrset.getTTL());
EXPECT_EQ(expected_rdatacount, actual_rrset.getRdataCount());
EXPECT_EQ(expected_sigcount, actual_rrset.getRRsigDataCount());
}
......@@ -150,31 +152,31 @@ checkBasicFields(const AbstractRRset& actual_rrset, const Name& expected_name,
TEST_F(TreeNodeRRsetTest, create) {
// Constructed with RRSIG, and it should be visible.
checkBasicFields(TreeNodeRRset(rrclass_, www_node_, a_rdataset_, true),
www_name_, rrclass_, RRType::A(), 2, 1);
www_name_, rrclass_, RRType::A(), 3600, 2, 1);
// Constructed with RRSIG, and it should be invisible.
checkBasicFields(TreeNodeRRset(rrclass_, www_node_, a_rdataset_, false),
www_name_, rrclass_, RRType::A(), 2, 0);
www_name_, rrclass_, RRType::A(), 3600, 2, 0);
// Constructed without RRSIG, and it would be visible (but of course won't)
checkBasicFields(TreeNodeRRset(rrclass_, origin_node_, ns_rdataset_, true),
origin_name_, rrclass_, RRType::NS(), 1, 0);
origin_name_, rrclass_, RRType::NS(), 3600, 1, 0);
// Constructed without RRSIG, and it should be visible
checkBasicFields(TreeNodeRRset(rrclass_, origin_node_, ns_rdataset_,
false),
origin_name_, rrclass_, RRType::NS(), 1, 0);
origin_name_, rrclass_, RRType::NS(), 3600, 1, 0);
// RRSIG-only case (note the RRset's type is covered type)
checkBasicFields(TreeNodeRRset(rrclass_, www_node_, rrsig_only_rdataset_,
true),
www_name_, rrclass_, RRType::TXT(), 0, 1);
www_name_, rrclass_, RRType::TXT(), 3600, 0, 1);
// RRSIG-only case (note the RRset's type is covered type), but it's
// invisible
checkBasicFields(TreeNodeRRset(rrclass_, www_node_, rrsig_only_rdataset_,
false),
www_name_, rrclass_, RRType::TXT(), 0, 0);
www_name_, rrclass_, RRType::TXT(), 3600, 0, 0);
// Wildcard substitution
checkBasicFields(TreeNodeRRset(match_name_, rrclass_,
wildcard_node_, wildcard_rdataset_,
true),
match_name_, rrclass_, RRType::A(), 2, 1);
match_name_, rrclass_, RRType::A(), 3600, 2, 1);
}
// Templated if and when we support OutputBuffer version of toWire().
......
......@@ -46,7 +46,7 @@ TreeNodeRRset::TreeNodeRRset(const dns::Name& realname,
bool dnssec_ok) :
node_(node), rdataset_(rdataset),
rrsig_count_(rdataset_->getSigRdataCount()), rrclass_(rrclass),
dnssec_ok_(dnssec_ok), name_(NULL)
dnssec_ok_(dnssec_ok), name_(NULL), ttl_(NULL)
{
const LabelSequence labels(realname);
const size_t labels_storangelen = labels.getSerializedLength();
......@@ -69,7 +69,13 @@ TreeNodeRRset::getName() const {
const RRTTL&
TreeNodeRRset::getTTL() const {
isc_throw(Unexpected, "unexpected method called on TreeNodeRRset");
if (ttl_ == NULL) {
util::InputBuffer ttl_buffer(rdataset_->getTTLData(),
sizeof(uint32_t));
ttl_ = new RRTTL(ttl_buffer);
}
return (*ttl_);
}
void
......
......@@ -105,7 +105,7 @@ public:
const RdataSet* rdataset, bool dnssec_ok) :
node_(node), rdataset_(rdataset),
rrsig_count_(rdataset_->getSigRdataCount()), rrclass_(rrclass),
dnssec_ok_(dnssec_ok), name_(NULL), realname_buf_(NULL)
dnssec_ok_(dnssec_ok), name_(NULL), realname_buf_(NULL), ttl_(NULL)
{}
/// \brief Constructor for wildcard-expanded owner name.
......@@ -126,6 +126,7 @@ public:
virtual ~TreeNodeRRset() {
delete[] realname_buf_;
delete ttl_;
delete name_;
}
......@@ -251,6 +252,7 @@ private:
const bool dnssec_ok_;
mutable dns::Name* name_;
uint8_t* realname_buf_;
mutable dns::RRTTL* ttl_;
};
} // 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