Browse Source

Feed nameservers into a list

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac408@3511 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
8677186ac4

+ 16 - 3
src/lib/nsas/nameserver_address_store.cc

@@ -17,6 +17,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 
 
 #include <config.h>
 #include <config.h>
+#include <dns/rdataclass.h>
 
 
 #include "hash_deleter.h"
 #include "hash_deleter.h"
 #include "nsas_entry_compare.h"
 #include "nsas_entry_compare.h"
@@ -57,8 +58,8 @@ typedef shared_ptr<AddressRequestCallback> CallbackPtr;
 // One function to call new on both ZoneEntry and NameserverEntry
 // One function to call new on both ZoneEntry and NameserverEntry
 template<class T>
 template<class T>
 shared_ptr<T>
 shared_ptr<T>
-newT(const std::string& zone, uint16_t class_code) {
-    return (shared_ptr<T>(new T(zone, class_code)));
+newT(const std::string& name, uint16_t class_code) {
+    return (shared_ptr<T>(new T(name, class_code)));
 }
 }
 
 
 }
 }
@@ -91,6 +92,18 @@ NameserverAddressStore::lookup(const std::string& zone, uint16_t class_code,
             isc_throw(NotNS, "Authority section with non-NS RR type: " <<
             isc_throw(NotNS, "Authority section with non-NS RR type: " <<
                 authority.getType().toText());
                 authority.getType().toText());
         }
         }
+        // Make sure the name servers exist
+        RdataIteratorPtr ns(authority.getRdataIterator());
+        for (ns->first(); !ns->isLast(); ns->next()) {
+            Name nsName(dynamic_cast<const rdata::generic::NS&>(
+                ns->getCurrent()).getNSName());
+            pair<bool, NameserverPtr> ns_lookup(
+                nameserver_hash_.getOrAdd(HashKey(nsName.toText(), class_code),
+                bind(newT<NameserverEntry>, nsName.toText(), class_code)));
+            if (ns_lookup.first) { // Is it a new nameserver?
+                // TODO Fill in the values from additional section
+            }
+        }
     } else { // Was already here
     } else { // Was already here
         zone_lru_.touch(zone_ptr);
         zone_lru_.touch(zone_ptr);
         // TODO Do we update the TTL and nameservers here?
         // TODO Do we update the TTL and nameservers here?
@@ -100,7 +113,7 @@ NameserverAddressStore::lookup(const std::string& zone, uint16_t class_code,
 }
 }
 
 
 void NameserverAddressStore::processZone(ZonePtr) {
 void NameserverAddressStore::processZone(ZonePtr) {
-
+    
 }
 }
 
 
 } // namespace nsas
 } // namespace nsas

+ 1 - 1
src/lib/nsas/tests/nameserver_address_store_unittest.cc

@@ -103,7 +103,7 @@ protected:
         }
         }
 
 
         // A nameserver serving data
         // A nameserver serving data
-        authority_->addRdata(rdata::generic::NS(Name("ns.example.com.")));
+        authority_->addRdata(ConstRdataPtr(new rdata::generic::NS(Name("ns.example.com."))));
 
 
         // This is reused because of convenience, clear it just in case
         // This is reused because of convenience, clear it just in case
         NSASCallback::results.clear();
         NSASCallback::results.clear();