Commit 955a5de8 authored by Michal Vaner's avatar Michal Vaner
Browse files

Implement adding SOA

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac455@4042 e5f2f494-b856-4b98-b285-d166d9295462
parent a733d4c3
......@@ -25,6 +25,24 @@ using namespace isc::datasrc;
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 {
bool keep_doing = true;
......@@ -60,11 +78,11 @@ Query::process() const {
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:
......
......@@ -14,6 +14,8 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <exceptions/exceptions.h>
namespace isc {
namespace dns {
class Message;
......@@ -23,6 +25,7 @@ class RRType;
namespace datasrc {
class MemoryDataSrc;
class Zone;
}
namespace auth {
......@@ -104,11 +107,24 @@ public:
/// 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;
};
}
......
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