[svn] commit: r4073 - /branches/trac458/src/bin/auth/query.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Dec 29 09:09:18 UTC 2010
Author: vorner
Date: Wed Dec 29 09:09:18 2010
New Revision: 4073
Log:
MX processing implementatiton
Modified:
branches/trac458/src/bin/auth/query.cc
Modified: branches/trac458/src/bin/auth/query.cc
==============================================================================
--- branches/trac458/src/bin/auth/query.cc (original)
+++ branches/trac458/src/bin/auth/query.cc Wed Dec 29 09:09:18 2010
@@ -12,8 +12,12 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <vector>
+#include <boost/foreach.hpp>
+
#include <dns/message.h>
#include <dns/rcode.h>
+#include <dns/rdataclass.h>
#include <datasrc/memory_datasrc.h>
@@ -21,6 +25,7 @@
using namespace isc::dns;
using namespace isc::datasrc;
+using namespace std;
namespace isc {
namespace auth {
@@ -53,6 +58,45 @@
response_.setRcode(Rcode::NOERROR());
response_.addRRset(Message::SECTION_ANSWER,
boost::const_pointer_cast<RRset>(db_result.rrset));
+ // Some additional processing
+ if (qtype_ == RRType::MX()) {
+ // We look up these RR types
+ vector<RRType> interesting_types;
+ interesting_types.push_back(RRType::A());
+ interesting_types.push_back(RRType::AAAA());
+ // Go trough all the RRs in the RRset
+ for (RdataIteratorPtr i(
+ db_result.rrset->getRdataIterator()); !i->isLast();
+ i->next())
+ {
+ // Who does it talk about?
+ Name name(
+ dynamic_cast<const isc::dns::rdata::generic::MX &>(
+ i->getCurrent()).getMXName());
+ // Look up both addresses
+ BOOST_FOREACH(const RRType& type, interesting_types) {
+ // Recursively call query
+ Message response(Message::RENDER);
+ Query sub(memory_datasrc_, name, type, response);
+ sub.process();
+ // And run trough all the answers and look if some
+ // of them match
+ for (SectionIterator<RRsetPtr> ai(
+ response.beginSection(
+ Message::SECTION_ANSWER)); ai !=
+ response.endSection(Message::SECTION_ANSWER);
+ ++ ai)
+ {
+ if ((*ai)->getType() == type &&
+ (*ai)->getName() == name)
+ {
+ response_.addRRset(
+ Message::SECTION_ADDITIONAL, *ai);
+ }
+ }
+ }
+ }
+ }
// TODO : fill in authority and addtional sections.
break;
case Zone::DELEGATION:
More information about the bind10-changes
mailing list