arg(name).arg(rrclass).arg(reason);
}
+void
+addRR(const isc::dns::Name& name, const isc::dns::RRClass& rrclass,
+ const isc::dns::RRType& type, const isc::dns::RRTTL& ttl,
+ const isc::dns::rdata::RdataPtr& data, ZoneUpdater* updater)
+{
+ // We get description of one RR. The updater takes RRset, so we
+ // wrap it up and push there. It should collate the RRsets of the
+ // same name and type together, since the addRRset should "merge".
+ isc::dns::BasicRRset rrset(name, rrclass, type, ttl);
+ rrset.addRdata(data);
+ updater->addRRset(rrset);
+}
+
}
isc::dns::MasterLoaderCallbacks
rrclass, _1, _2, _3)));
}
-isc::dns::AddRRsetCallback
+isc::dns::AddRRCallback
createMasterLoaderAddCallback(ZoneUpdater& updater) {
- return (boost::bind(&ZoneUpdater::addRRset, &updater,
- // The callback provides a shared pointer, we
- // need the object. This bind unpacks the object.
- boost::bind(&isc::dns::RRsetPtr::operator*, _1)));
+ return (boost::bind(addRR, _1, _2, _3, _4, _5, &updater));
}
}
/// \param updater The zone updater to use.
/// \return The callback to be passed to MasterLoader.
/// \throw std::bad_alloc when allocation fails.
-isc::dns::AddRRsetCallback
+isc::dns::AddRRCallback
createMasterLoaderAddCallback(ZoneUpdater& updater);
}
#include <dns/rrset.h>
#include <dns/rrclass.h>
#include <dns/rrttl.h>
+#include <dns/rdata.h>
#include <exceptions/exceptions.h>
// the correct ones, according to a predefined set in a list.
virtual void addRRset(const isc::dns::AbstractRRset& rrset) {
ASSERT_FALSE(expected_rrsets_.empty());
- // In our tests, pointer equality is enough.
- EXPECT_EQ(expected_rrsets_.front().get(), &rrset);
+
+ EXPECT_EQ(expected_rrsets_.front().get()->toText(), rrset.toText());
// And remove this RRset, as it has been used.
expected_rrsets_.pop_front();
}
isc::dns::RRClass::IN(), &ok_))
{}
// Generate a new RRset, put it to the updater and return it.
- isc::dns::RRsetPtr generateRRset() {
+ void generateRRset(isc::dns::AddRRCallback callback) {
const isc::dns::RRsetPtr
result(new isc::dns::RRset(isc::dns::Name("example.org"),
isc::dns::RRClass::IN(),
isc::dns::RRType::A(),
isc::dns::RRTTL(3600)));
+ const isc::dns::rdata::RdataPtr
+ data(isc::dns::rdata::createRdata(isc::dns::RRType::A(),
+ isc::dns::RRClass::IN(),
+ "192.0.2.1"));
+
+ result->addRdata(data);
updater_.expected_rrsets_.push_back(result);
- return (result);
+
+ callback(result->getName(), result->getClass(), result->getType(),
+ result->getTTL(), data);
}
// An updater to be passed to the context
MockUpdater updater_;
// Try adding some RRsets.
TEST_F(MasterLoaderCallbackTest, addRRset) {
- isc::dns::AddRRsetCallback
+ isc::dns::AddRRCallback
callback(createMasterLoaderAddCallback(updater_));
// Put some of them in.
- EXPECT_NO_THROW(callback(generateRRset()));
- EXPECT_NO_THROW(callback(generateRRset()));
+ EXPECT_NO_THROW(generateRRset(callback));
+ EXPECT_NO_THROW(generateRRset(callback));
// They all get pushed there right away, so there are none in the queue
EXPECT_TRUE(updater_.expected_rrsets_.empty());
}
#include <dns/rrttl.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
-#include <dns/rrset.h>
#include <dns/rdata.h>
using std::string;
const Name& zone_origin,
const RRClass& zone_class,
const MasterLoaderCallbacks& callbacks,
- const AddRRsetCallback& add_callback,
+ const AddRRCallback& add_callback,
MasterLoader::Options options) :
lexer_(),
zone_origin_(zone_origin),
// the Rdata. The errors should have been reported by
// callbacks_ already, so we just need to not report the RR
if (data != rdata::RdataPtr()) {
- // Create the RRset. We don't need the RRSIG, so we are good
- // with the basic one
- const RRsetPtr rrset(new BasicRRset(name, rrclass, rrtype,
- ttl));
- rrset->addRdata(data);
- // OK now, so give the RRset with single RR to the caller
- add_callback_(rrset);
+ add_callback_(name, rrclass, rrtype, ttl, data);
// Good, we loaded another one
++count;
const Name& zone_origin_;
const RRClass zone_class_;
MasterLoaderCallbacks callbacks_;
- AddRRsetCallback add_callback_;
+ AddRRCallback add_callback_;
MasterLoader::Options options_;
- RRsetPtr current_rrset_;
};
MasterLoader::MasterLoader(const char* master_file,
const Name& zone_origin,
const RRClass& zone_class,
const MasterLoaderCallbacks& callbacks,
- const AddRRsetCallback& add_callback,
+ const AddRRCallback& add_callback,
Options options)
{
impl_ = new MasterLoaderImpl(master_file, zone_origin,
const Name& zone_origin,
const RRClass& zone_class,
const MasterLoaderCallbacks& callbacks,
- const AddRRsetCallback& add_callback,
+ const AddRRCallback& add_callback,
Options options = DEFAULT);
~MasterLoader();
namespace isc {
namespace dns {
-
-class AbstractRRset;
-typedef boost::shared_ptr<AbstractRRset> RRsetPtr;
+class Name;
+class RRClass;
+class RRType;
+class RRTTL;
+namespace rdata {
+class Rdata;
+typedef boost::shared_ptr<Rdata> RdataPtr;
+}
/// \brief Type of callback to add a RRset.
///
/// \param RRset The rrset to add. It does not contain the accompanying
/// RRSIG (if the zone is signed), they are reported with separate
/// calls to the callback.
-typedef boost::function<void(const RRsetPtr& rrset)> AddRRsetCallback;
+typedef boost::function<void(const Name& name, const RRClass& rrclass,
+ const RRType& rrtype, const RRTTL& rrttl,
+ const rdata::RdataPtr& rdata)>
+ AddRRCallback;
/// \brief Set of issue callbacks for a loader.
///
}
}
- void addRRset(const RRsetPtr& rrset) {
+ void addRRset(const Name& name, const RRClass& rrclass,
+ const RRType& rrtype, const RRTTL& rrttl,
+ const rdata::RdataPtr& data) {
+ const RRsetPtr rrset(new BasicRRset(name, rrclass, rrtype, rrttl));
+ rrset->addRdata(data);
rrsets_.push_back(rrset);
}
file).c_str(), origin, rrclass,
callbacks_,
boost::bind(&MasterLoaderTest::addRRset,
- this, _1), options));
+ this, _1, _2, _3, _4, _5),
+ options));
}
// Check the next RR in the ones produced by the loader