|
@@ -14,6 +14,7 @@
|
|
|
|
|
|
#include <dns/message.h>
|
|
|
#include <dns/rcode.h>
|
|
|
+#include <dns/rdataclass.h>
|
|
|
|
|
|
#include <datasrc/memory_datasrc.h>
|
|
|
|
|
@@ -21,11 +22,45 @@
|
|
|
|
|
|
using namespace isc::dns;
|
|
|
using namespace isc::datasrc;
|
|
|
+using namespace isc::dns::rdata;
|
|
|
|
|
|
namespace isc {
|
|
|
namespace auth {
|
|
|
|
|
|
void
|
|
|
+Query::getAdditional(const isc::datasrc::Zone& zone,
|
|
|
+ const isc::dns::RRset& rrset) const
|
|
|
+{
|
|
|
+ if (rrset.getType() == RRType::NS()) {
|
|
|
+ // Need to perform the search in the "GLUE OK" mode.
|
|
|
+ RdataIteratorPtr rdata_iterator = rrset.getRdataIterator();
|
|
|
+ for (; !rdata_iterator->isLast(); rdata_iterator->next()) {
|
|
|
+ const Rdata& rdata(rdata_iterator->getCurrent());
|
|
|
+ const generic::NS& ns = dynamic_cast<const generic::NS&>(rdata);
|
|
|
+ findAddrs(zone, ns.getNSName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
+Query::findAddrs(const isc::datasrc::Zone& zone,
|
|
|
+ const isc::dns::Name& qname) const
|
|
|
+{
|
|
|
+ // Find A rrset
|
|
|
+ Zone::FindResult a_result = zone.find(qname, RRType::A());
|
|
|
+ if (a_result.code == Zone::SUCCESS) {
|
|
|
+ response_.addRRset(Message::SECTION_ADDITIONAL,
|
|
|
+ boost::const_pointer_cast<RRset>(a_result.rrset));
|
|
|
+ }
|
|
|
+ // Find AAAA rrset
|
|
|
+ Zone::FindResult aaaa_result = zone.find(qname, RRType::AAAA());
|
|
|
+ if (aaaa_result.code == Zone::SUCCESS) {
|
|
|
+ response_.addRRset(Message::SECTION_ADDITIONAL,
|
|
|
+ boost::const_pointer_cast<RRset>(aaaa_result.rrset));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void
|
|
|
Query::process() const {
|
|
|
bool keep_doing = true;
|
|
|
response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
|
|
@@ -56,7 +91,10 @@ Query::process() const {
|
|
|
// TODO : fill in authority and addtional sections.
|
|
|
break;
|
|
|
case Zone::DELEGATION:
|
|
|
- // TODO : add NS to authority section, fill in additional section.
|
|
|
+ response_.setRcode(Rcode::NOERROR());
|
|
|
+ response_.addRRset(Message::SECTION_AUTHORITY,
|
|
|
+ boost::const_pointer_cast<RRset>(db_result.rrset));
|
|
|
+ getAdditional(*result.zone, *db_result.rrset);
|
|
|
break;
|
|
|
case Zone::NXDOMAIN:
|
|
|
response_.setRcode(Rcode::NXDOMAIN());
|