[svn] commit: r4042 - in /branches/trac455/src/bin/auth: query.cc query.h

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Dec 28 13:15:36 UTC 2010


Author: vorner
Date: Tue Dec 28 13:15:33 2010
New Revision: 4042

Log:
Implement adding SOA

Modified:
    branches/trac455/src/bin/auth/query.cc
    branches/trac455/src/bin/auth/query.h

Modified: branches/trac455/src/bin/auth/query.cc
==============================================================================
--- branches/trac455/src/bin/auth/query.cc (original)
+++ branches/trac455/src/bin/auth/query.cc Tue Dec 28 13:15:33 2010
@@ -24,6 +24,24 @@
 
 namespace isc {
 namespace auth {
+
+void
+Query::putSOA(const Zone& zone) const {
+    Zone::FindResult soa_result(zone.find(zone.getOrigin(),
+        RRType::SOA()));
+    if (soa_result.code != Zone::SUCCESS) {
+        isc_throw(NoSOA, "There's no SOA record in zone " <<
+            zone.getOrigin().toText());
+    } else {
+        /*
+         * FIXME:
+         * The const-cast is wrong, but the Message interface seems
+         * to insist.
+         */
+        response_.addRRset(Message::SECTION_AUTHORITY,
+            boost::const_pointer_cast<RRset>(soa_result.rrset));
+    }
+}
 
 void
 Query::process() const {
@@ -60,11 +78,11 @@
                 break;
             case Zone::NXDOMAIN:
                 response_.setRcode(Rcode::NXDOMAIN());
-                // TODO : add SOA to authority section
+                putSOA(*result.zone);
                 break;
             case Zone::NXRRSET:
                 response_.setRcode(Rcode::NOERROR());
-                // TODO : add SOA to authority section
+                putSOA(*result.zone);
                 break;
             case Zone::CNAME:
             case Zone::DNAME:

Modified: branches/trac455/src/bin/auth/query.h
==============================================================================
--- branches/trac455/src/bin/auth/query.h (original)
+++ branches/trac455/src/bin/auth/query.h Tue Dec 28 13:15:33 2010
@@ -14,6 +14,8 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <exceptions/exceptions.h>
+
 namespace isc {
 namespace dns {
 class Message;
@@ -23,6 +25,7 @@
 
 namespace datasrc {
 class MemoryDataSrc;
+class Zone;
 }
 
 namespace auth {
@@ -104,11 +107,24 @@
     /// future version.
     void process() const;
 
+    struct BadZone : public isc::Exception {
+        BadZone(const char* file, size_t line, const char* what) :
+            Exception(file, line, what)
+        { }
+    };
+
+    struct NoSOA : public BadZone {
+        NoSOA(const char* file, size_t line, const char* what) :
+            BadZone(file, line, what)
+        { }
+    };
+
 private:
     const isc::datasrc::MemoryDataSrc& memory_datasrc_;
     const isc::dns::Name& qname_;
     const isc::dns::RRType& qtype_;
     isc::dns::Message& response_;
+    void putSOA(const isc::datasrc::Zone& zone) const;
 };
 
 }




More information about the bind10-changes mailing list