123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
- //
- // Permission to use, copy, modify, and/or distribute this software for any
- // purpose with or without fee is hereby granted, provided that the above
- // copyright notice and this permission notice appear in all copies.
- //
- // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- // $Id$
- #include "data_source_static.h"
- #include <dns/name.h>
- #include <dns/rdata.h>
- #include <dns/rdataclass.h>
- #include <dns/rrclass.h>
- #include <dns/rrset.h>
- #include <dns/rrtype.h>
- #include <dns/rrttl.h>
- #include <iostream>
- using namespace std;
- using namespace isc::dns;
- using namespace isc::dns::rdata;
- namespace isc {
- namespace auth {
- StaticDataSrc::StaticDataSrc() : authors_name("authors.bind"),
- version_name("version.bind")
- {
- setClass(RRClass::CH());
- authors = RRsetPtr(new RRset(authors_name, RRClass::CH(),
- RRType::TXT(), RRTTL(0)));
- authors->addRdata(generic::TXT("Evan Hunt"));
- authors->addRdata(generic::TXT("Han Feng"));
- authors->addRdata(generic::TXT("Jelte Jansen"));
- authors->addRdata(generic::TXT("Jeremy C. Reed"));
- authors->addRdata(generic::TXT("Jin Jian"));
- authors->addRdata(generic::TXT("JINMEI Tatuya"));
- authors->addRdata(generic::TXT("Kazunori Fujiwara"));
- authors->addRdata(generic::TXT("Michael Graff"));
- authors->addRdata(generic::TXT("Naoki Kambe"));
- authors->addRdata(generic::TXT("Shane Kerr"));
- authors->addRdata(generic::TXT("Zhang Likun"));
- authors_ns = RRsetPtr(new RRset(authors_name, RRClass::CH(),
- RRType::NS(), RRTTL(0)));
- authors_ns->addRdata(generic::NS(authors_name));
- version = RRsetPtr(new RRset(version_name, RRClass::CH(),
- RRType::TXT(), RRTTL(0)));
- version->addRdata(generic::TXT("BIND10 0.0.0 (pre-alpha)"));
- version_ns = RRsetPtr(new RRset(version_name, RRClass::CH(),
- RRType::NS(), RRTTL(0)));
- version_ns->addRdata(generic::NS(version_name));
- }
- void
- StaticDataSrc::findClosestEnclosure(NameMatch& match) const {
- const Name& qname = match.qname();
- NameComparisonResult::NameRelation cmp;
- cmp = qname.compare(version_name).getRelation();
- if (cmp == NameComparisonResult::EQUAL ||
- cmp == NameComparisonResult::SUBDOMAIN) {
- match.update(*this, version_name);
- return;
- }
- cmp = qname.compare(authors_name).getRelation();
- if (cmp == NameComparisonResult::EQUAL ||
- cmp == NameComparisonResult::SUBDOMAIN) {
- match.update(*this, authors_name);
- return;
- }
- }
- DataSrc::Result
- StaticDataSrc::findRRset(const Query& q,
- const Name& qname,
- const RRClass& qclass,
- const RRType& qtype,
- RRsetList& target,
- uint32_t& flags,
- Name* zone) const
- {
- flags = 0;
- if (qclass != getClass()) {
- return (ERROR);
- }
- bool any = (qtype == RRType::ANY());
- if (qname == version_name) {
- if (qtype == RRType::TXT() || any) {
- target.addRRset(version);
- } else if (qtype == RRType::NS()) {
- target.addRRset(version_ns);
- } else {
- flags = TYPE_NOT_FOUND;
- }
- } else if (qname == authors_name) {
- if (qtype == RRType::TXT() || any) {
- target.addRRset(authors);
- return (SUCCESS);
- } else if (qtype == RRType::NS()) {
- target.addRRset(authors_ns);
- return (SUCCESS);
- } else {
- flags = TYPE_NOT_FOUND;
- }
- } else {
- flags = NAME_NOT_FOUND;
- }
- return (SUCCESS);
- }
- }
- }
|