Commit 0cb5cf23 authored by Michal Vaner's avatar Michal Vaner
Browse files

MX processing implementatiton

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac458@4073 e5f2f494-b856-4b98-b285-d166d9295462
parent cabe7cdd
......@@ -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 @@ Query::process() const {
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:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment