|
@@ -13,14 +13,19 @@
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
#include <datasrc/memory/zone_data_loader.h>
|
|
#include <datasrc/memory/zone_data_loader.h>
|
|
|
|
+#include <datasrc/memory/zone_data_updater.h>
|
|
#include <datasrc/memory/logger.h>
|
|
#include <datasrc/memory/logger.h>
|
|
#include <datasrc/memory/segment_object_holder.h>
|
|
#include <datasrc/memory/segment_object_holder.h>
|
|
|
|
|
|
#include <dns/rdataclass.h>
|
|
#include <dns/rdataclass.h>
|
|
|
|
+#include <dns/rrset.h>
|
|
#include <dns/masterload.h>
|
|
#include <dns/masterload.h>
|
|
|
|
|
|
#include <boost/foreach.hpp>
|
|
#include <boost/foreach.hpp>
|
|
#include <boost/bind.hpp>
|
|
#include <boost/bind.hpp>
|
|
|
|
+#include <boost/noncopyable.hpp>
|
|
|
|
+
|
|
|
|
+#include <map>
|
|
|
|
|
|
using namespace isc::dns;
|
|
using namespace isc::dns;
|
|
using namespace isc::dns::rdata;
|
|
using namespace isc::dns::rdata;
|
|
@@ -31,6 +36,50 @@ namespace memory {
|
|
|
|
|
|
using detail::SegmentObjectHolder;
|
|
using detail::SegmentObjectHolder;
|
|
|
|
|
|
|
|
+// A helper internal class for \c loadZoneData(). make it non-copyable
|
|
|
|
+// to avoid accidental copy.
|
|
|
|
+//
|
|
|
|
+// The current internal implementation expects that both a normal
|
|
|
|
+// (non RRSIG) RRset and (when signed) its RRSIG are added at once.
|
|
|
|
+// Also in the current implementation, the input sequence of RRsets
|
|
|
|
+// are grouped with their owner name (so once a new owner name is encountered,
|
|
|
|
+// no subsequent RRset has the previous owner name), but the ordering
|
|
|
|
+// in the same group is not fixed. So we hold all RRsets of the same
|
|
|
|
+// owner name in node_rrsets_ and node_rrsigsets_, and add the matching
|
|
|
|
+// pairs of RRsets to the zone when we see a new owner name.
|
|
|
|
+//
|
|
|
|
+// The caller is responsible for adding the RRsets of the last group
|
|
|
|
+// in the input sequence by explicitly calling flushNodeRRsets() at the
|
|
|
|
+// end. It's cleaner and more robust if we let the destructor of this class
|
|
|
|
+// do it, but since we cannot guarantee the adding operation is exception free,
|
|
|
|
+// we don't choose that option to maintain the common expectation for
|
|
|
|
+// destructors.
|
|
|
|
+class ZoneDataLoader : boost::noncopyable {
|
|
|
|
+public:
|
|
|
|
+ ZoneDataLoader(util::MemorySegment& mem_sgmt,
|
|
|
|
+ const isc::dns::RRClass rrclass,
|
|
|
|
+ const isc::dns::Name& zone_name, ZoneData& zone_data) :
|
|
|
|
+ updater_(mem_sgmt, rrclass, zone_name, zone_data)
|
|
|
|
+ {}
|
|
|
|
+
|
|
|
|
+ void addFromLoad(const isc::dns::ConstRRsetPtr& rrset);
|
|
|
|
+ void flushNodeRRsets();
|
|
|
|
+
|
|
|
|
+private:
|
|
|
|
+ typedef std::map<isc::dns::RRType, isc::dns::ConstRRsetPtr> NodeRRsets;
|
|
|
|
+ typedef NodeRRsets::value_type NodeRRsetsVal;
|
|
|
|
+
|
|
|
|
+ // A helper to identify the covered type of an RRSIG.
|
|
|
|
+ static isc::dns::RRType getCoveredType
|
|
|
|
+ (const isc::dns::ConstRRsetPtr& sig_rrset);
|
|
|
|
+ const isc::dns::Name& getCurrentName() const;
|
|
|
|
+
|
|
|
|
+private:
|
|
|
|
+ NodeRRsets node_rrsets_;
|
|
|
|
+ NodeRRsets node_rrsigsets_;
|
|
|
|
+ ZoneDataUpdater updater_;
|
|
|
|
+};
|
|
|
|
+
|
|
void
|
|
void
|
|
ZoneDataLoader::addFromLoad(const ConstRRsetPtr& rrset) {
|
|
ZoneDataLoader::addFromLoad(const ConstRRsetPtr& rrset) {
|
|
// If we see a new name, flush the temporary holders, adding the
|
|
// If we see a new name, flush the temporary holders, adding the
|