Browse Source

Remove parkinglot from trunk. It is still in branches/parkinglot if needed.

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@784 e5f2f494-b856-4b98-b285-d166d9295462
Jeremy C. Reed 15 years ago
parent
commit
fadf58e7ee

+ 0 - 2
configure.ac

@@ -148,7 +148,6 @@ AC_CONFIG_FILES([Makefile
                  src/bin/host/Makefile
                  src/bin/msgq/Makefile
                  src/bin/auth/Makefile
-                 src/bin/parkinglot/Makefile
                  src/lib/Makefile
                  src/lib/cc/Makefile
                  src/lib/cc/cpp/Makefile
@@ -181,7 +180,6 @@ AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
            src/bin/msgq/msgq_test
            src/bin/msgq/run_msgq.sh
            src/bin/auth/config.h
-           src/bin/parkinglot/config.h
            src/lib/config/cpp/data_def_unittests_config.h
            src/lib/config/python/isc/config/config_test
            src/lib/dns/cpp/gen-rdatacode.py

+ 1 - 1
src/bin/Makefile.am

@@ -1 +1 @@
-SUBDIRS = bind10 bindctl cfgmgr msgq host cmdctl auth parkinglot
+SUBDIRS = bind10 bindctl cfgmgr msgq host cmdctl auth

+ 0 - 24
src/bin/parkinglot/Makefile.am

@@ -1,24 +0,0 @@
-AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/src/lib -I$(top_builddir)/src/lib/dns/cpp -I$(top_builddir)/include/dns/cpp -I$(top_builddir)/include -I$(top_srcdir)/ext
-
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-
-pkglibexec_PROGRAMS = b10-parkinglot
-
-b10_parkinglot_SOURCES = b10-parkinglot.cc b10-parkinglot.h
-b10_parkinglot_SOURCES += common.cc common.h zoneset.h zoneset.cc main.cc
-b10_parkinglot_SOURCES += data_source_plot.h data_source_plot.cc
-b10_parkinglot_SOURCES += data_source.h data_source.cc
-b10_parkinglot_SOURCES += builtin.h builtin.cc
-b10_parkinglot_LDADD =  $(top_builddir)/src/lib/dns/cpp/.libs/libdns.a
-b10_parkinglot_LDADD += $(top_builddir)/src/lib/config/cpp/libcfgclient.a
-b10_parkinglot_LDADD += $(top_builddir)/src/lib/cc/cpp/libcc.a
-b10_parkinglot_LDADD += $(top_builddir)/src/lib/exceptions/cpp/.libs/libexceptions.a
-
-b10_parkinglotdir = $(DESTDIR)$(pkgdatadir)
-b10_parkinglot_DATA = parkinglot.spec
-
-# TODO: don't install this here
-bin_PROGRAMS = builtin_bench
-builtin_bench_SOURCES = builtin_bench.cc builtin.h builtin.cc
-builtin_bench_LDADD = $(top_builddir)/src/lib/dns/cpp/.libs/libdns.a
-builtin_bench_LDADD += $(top_builddir)/src/lib/exceptions/cpp/.libs/libexceptions.a

+ 0 - 241
src/bin/parkinglot/b10-parkinglot.cc

@@ -1,241 +0,0 @@
-// Copyright (C) 2009  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 <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-
-#include <algorithm>
-#include <set>
-#include <iostream>
-
-#include <dns/buffer.h>
-#include <dns/messagerenderer.h>
-#include <dns/name.h>
-#include <dns/question.h>
-#include <dns/rdataclass.h>
-#include <dns/rrset.h>
-#include <dns/rrttl.h>
-#include <dns/message.h>
-
-#include <cc/data.h>
-
-#include "common.h"
-#include "builtin.h"
-#include "b10-parkinglot.h"
-
-#include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
-
-using namespace std;
-
-using namespace isc::dns;
-using namespace isc::dns::rdata;
-using namespace isc::data;
-
-ParkingLot::ParkingLot(int port) {
-    /*ns1 = Rdata::RdataPtr(new NS("ns1.parking.example"));
-    ns2 = Rdata::RdataPtr(new NS("ns2.parking.example"));
-    ns3 = Rdata::RdataPtr(new NS("ns3.parking.example"));
-    a = Rdata::RdataPtr(new A("127.0.0.1"));
-    aaaa = Rdata::RdataPtr(new AAAA("::1"));
-    */
-
-    int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-    if (s < 0)
-        throw FatalError("failed to open socket");
-
-    struct sockaddr_in sin;
-    sin.sin_family = AF_INET;
-    sin.sin_addr.s_addr = INADDR_ANY;
-    sin.sin_port = htons(port);
-
-    socklen_t sa_len = sizeof(sin);
-#ifdef HAVE_SIN_LEN
-    sin.sin_len = sa_len;
-#endif
-
-    if (bind(s, (struct sockaddr *)&sin, sa_len) < 0)
-        throw FatalError("could not bind socket");
-
-    sock = s;
-}
-
-namespace {
-struct GlueInserter {
-    GlueInserter(const DataSourceParkingLot& data_source,
-                 const Name& zname, const RRClass& qclass,
-                 Message& msg) :
-        data_source_(&data_source), zname_(&zname), qclass_(&qclass),
-        msg_(&msg)
-    {}
-    void operator()(const RRsetPtr rrset)
-    {
-        if (rrset->getType() == RRType::NS()) {
-            RdataIteratorPtr it = rrset->getRdataIterator();
-            for (it->first(); !it->isLast(); it->next()) {
-                const generic::NS& nsrdata =
-                    dynamic_cast<const generic::NS&>(it->getCurrent());
-                data_source_->addToMessage(*msg_, Section::ADDITIONAL(),
-                                           *zname_, nsrdata.getNSName(),
-                                           *qclass_, RRType::A());
-                data_source_->addToMessage(*msg_, Section::ADDITIONAL(),
-                                           *zname_, nsrdata.getNSName(),
-                                           *qclass_, RRType::AAAA());
-            }
-        }
-    }
-    const DataSourceParkingLot* data_source_;
-    const Name* zname_;
-    const RRClass* qclass_;
-    Message* msg_;
-};
-}
-
-namespace {
-const Name authors_name("authors.bind");
-const Name version_name("version.bind");
-}
-
-void
-ParkingLot::processMessage() {
-    struct sockaddr_storage ss;
-    socklen_t sa_len = sizeof(ss);
-    struct sockaddr* sa = static_cast<struct sockaddr*>((void*)&ss);
-    int s = sock;
-    char recvbuf[4096];
-    int cc;
-
-    if ((cc = recvfrom(s, recvbuf, sizeof(recvbuf), 0, sa, &sa_len)) > 0) {
-        Message msg;
-        InputBuffer buffer(recvbuf, cc);
-
-        try {
-            msg.fromWire(buffer);
-        } catch (...) {
-            cerr << "parse failed" << endl;
-            return;
-        }
-
-        cout << "received a message:\n" << msg.toText() << endl;
-
-        if (msg.getRRCount(Section::QUESTION()) != 1) {
-            return;
-        }
-
-        QuestionPtr query = *msg.beginQuestion();
-
-        msg.makeResponse();
-        msg.setHeaderFlag(MessageFlag::AA());
-        Name zname(".");        // ugly, but should work for now
-        msg.setRcode(Rcode::NOERROR());
-        if (query->getType() == RRType::TXT() &&
-            query->getClass() == RRClass::CH() &&
-            query->getName() == authors_name) {
-            msg.addRRset(Section::ANSWER(), getBuiltinAuthors().getAnswer());
-            msg.addRRset(Section::AUTHORITY(),
-                         getBuiltinAuthors().getAuthority());
-        } else if (query->getType() == RRType::TXT() &&
-                   query->getClass() == RRClass::CH() &&
-            query->getName() == version_name) {
-            msg.addRRset(Section::ANSWER(), getBuiltinVersion().getAnswer());
-            msg.addRRset(Section::AUTHORITY(),
-                         getBuiltinVersion().getAuthority());
-        } else if (data_source.hasZoneFor(query->getName(), zname)) {
-            SearchResult::status_type status =
-                data_source.addToMessage(msg, Section::ANSWER(), zname,
-                                         query->getName(), query->getClass(),
-                                         query->getType());
-            bool included_ns = false;
-
-            // rcode is based on this result?
-            if (status == SearchResult::name_not_found) {
-                msg.setRcode(Rcode::NXDOMAIN());
-                if (query->getType() != RRType::NS()) {
-                    status = data_source.addToMessage(msg, Section::AUTHORITY(),
-                                                      zname, zname,
-                                                      query->getClass(),
-                                                      RRType::SOA());
-                }
-            } else {
-                if (query->getType() != RRType::NS()) {
-                    status = data_source.addToMessage(msg, Section::AUTHORITY(),
-                                                      zname, zname,
-                                                      query->getClass(),
-                                                      RRType::NS());
-                }
-                included_ns = true;
-            }
-            // If we included NS records, and their target falls below the zone, add glue
-            if (included_ns) {
-                for_each(msg.beginSection(Section::ANSWER()),
-                         msg.endSection(Section::ANSWER()),
-                         GlueInserter(data_source, zname, query->getClass(),
-                                      msg));
-                for_each(msg.beginSection(Section::AUTHORITY()),
-                         msg.endSection(Section::AUTHORITY()),
-                         GlueInserter(data_source, zname, query->getClass(),
-                                      msg));
-            }
-        } else {
-            msg.setRcode(Rcode::SERVFAIL());
-        }
-
-        OutputBuffer obuffer(4096);
-        MessageRenderer renderer(obuffer);
-        msg.toWire(renderer);
-        cout << "sending a response (" <<
-            boost::lexical_cast<string>(obuffer.getLength())
-                  << " bytes):\n" << msg.toText() << endl;
-        sendto(s, obuffer.getData(), obuffer.getLength(), 0, sa, sa_len);
-    }
-}
-
-ElementPtr
-ParkingLot::updateConfig(isc::data::ElementPtr config) {
-    if (config->contains("zones")) {
-        data_source.clear_zones();
-        BOOST_FOREACH(isc::data::ElementPtr zone_el, config->get("zones")->listValue()) {
-            data_source.serve(zone_el->stringValue());
-        }
-    }
-    if (config->contains("port")) {
-        // todo: what to do with port change. restart automatically?
-        // ignore atm
-    }
-    if (config->contains("a_records")) {
-        data_source.clearARecords();
-        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("a_records")->listValue()) {
-            data_source.addARecord(rel->stringValue());
-        }
-    }
-    if (config->contains("aaaa_records")) {
-        data_source.clearAAAARecords();
-        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("aaaa_records")->listValue()) {
-            data_source.addAAAARecord(rel->stringValue());
-        }
-    }
-    if (config->contains("ns_records")) {
-        data_source.clearNSRecords();
-        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("ns_records")->listValue()) {
-            data_source.addNSRecord(rel->stringValue());
-        }
-    }
-    return isc::data::Element::createFromString("{ \"result\": [0] }");
-}

+ 0 - 44
src/bin/parkinglot/b10-parkinglot.h

@@ -1,44 +0,0 @@
-// Copyright (C) 2009  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$
-
-#ifndef __PARKINGLOT_H
-#define __PARKINGLOT_H 1
-
-#include "zoneset.h"
-#include <cc/data.h>
-#include "data_source_plot.h"
-
-class ParkingLot {
-public:
-    explicit ParkingLot(int port);
-    virtual ~ParkingLot() {}
-    int getSocket() { return (sock); }
-    void processMessage();
-    void command(std::pair<std::string,isc::data::ElementPtr>);
-    void serve(std::string zone_name);
-
-    isc::data::ElementPtr updateConfig(isc::data::ElementPtr config);
-private:
-
-    isc::dns::DataSourceParkingLot data_source;
-    int sock;
-};
-
-#endif // __PARKINGLOT_H
-
-// Local Variables:
-// mode: c++
-// End:

+ 0 - 217
src/bin/parkinglot/builtin.cc

@@ -1,217 +0,0 @@
-// 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 <string>
-#include <vector>
-
-#include <dns/buffer.h>
-#include <dns/messagerenderer.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rrclass.h>
-#include <dns/rrtype.h>
-#include <dns/rrttl.h>
-#include <dns/rrset.h>
-
-#include "builtin.h"
-
-using namespace std;
-using namespace isc::dns;
-using namespace isc::dns::rdata;
-
-namespace {
-const Name authors_name("authors.bind");
-const Name version_name("version.bind");
-
-const char* authors[] = {
-    "Han Feng",
-    "Kazunori Fujiwara",
-    "Michael Graff",
-    "Evan Hunt",
-    "Jelte Jansen",
-    "Jin Jian",
-    "JINMEI Tatuya",
-    "Naoki Kambe",
-    "Shane Kerr",
-    "Zhang Likun",
-    "Jeremy C. Reed",
-    NULL
-};
-
-const char* version[] = {
-    "BIND10 0.0.1",
-    NULL
-};
-
-const char* author_authorities[] = {
-    "authors.bind",
-    NULL
-};
-
-const char* version_authorities[] = {
-    "version.bind",
-    NULL
-};
-
-class BuiltinRRset : public AbstractRRset {
-private:
-    BuiltinRRset(const BuiltinRRset& source);
-    void operator=(const BuiltinRRset& source);
-public:
-    BuiltinRRset(const Name& name, const RRType& rrtype,
-                 const char** rdata_string_list);
-    virtual void addRdata(const rdata::RdataPtr rdata)
-    {
-        // ignore it (or we might throw an exception)
-    }
-    virtual unsigned int getRdataCount() const { return (num_rdata_); }
-    virtual const Name& getName() const { return (name_); }
-    virtual const RRClass& getClass() const { return (rrclass_); }
-    virtual const RRType& getType() const { return (rrtype_); }
-    virtual const RRTTL& getTTL() const { return (rrttl_); }
-    virtual void setTTL(const RRTTL& ttl)
-    {
-        // ignore it (or we might throw an exception)
-    }
-    virtual unsigned int toWire(MessageRenderer& renderer) const;
-    virtual RdataIteratorPtr getRdataIterator() const;
-
-    const Name name_;
-    const RRType rrtype_;
-    const RRClass rrclass_;
-    const RRTTL rrttl_;
-    vector<RdataPtr> rdatavector_;
-    unsigned int num_rdata_;
-    OutputBuffer wire_data_;    // pre-rendered RRset
-    size_t data_offset_;        // offset to the RRset data
-
-    static const size_t DATA_OFFSET = 12; // length of DNS header
-};
-
-class BuiltinRdataIterator : public RdataIterator {
-private:
-    BuiltinRdataIterator() {}
-public:
-    BuiltinRdataIterator(const vector<RdataPtr>& datavector) :
-        datavector_(&datavector) {}
-    ~BuiltinRdataIterator() {}
-    virtual void first() { it_ = datavector_->begin(); }
-    virtual void next() { ++it_; }
-    virtual const rdata::Rdata& getCurrent() const { return (**it_); }
-    virtual bool isLast() const { return (it_ == datavector_->end()); }
-private:
-    const vector<RdataPtr>* datavector_;
-    vector<RdataPtr>::const_iterator it_;
-};
-}
-
-BuiltinRRset::BuiltinRRset(const Name& name, const RRType& rrtype,
-                           const char** rdata_string_list) :
-    name_(name), rrtype_(rrtype), rrclass_(RRClass::CH()), rrttl_(RRTTL(0)),
-    num_rdata_(0), wire_data_(512)
-{
-    MessageRenderer renderer(wire_data_);
-    renderer.skip(DATA_OFFSET); // leave the space for the DNS header
-    renderer.writeName(name);
-    data_offset_ = renderer.getLength(); // remember the start position
-
-    RRset tmprrset(name, rrclass_, rrtype_, rrttl_);
-
-    for (int i = 0; rdata_string_list[i] != NULL; ++i) {
-        RdataPtr rdata = createRdata(rrtype_, rrclass_,
-                                     string(rdata_string_list[i]));
-        rdatavector_.push_back(rdata);
-        tmprrset.addRdata(rdata);
-    }
-
-    // pre-render the RRset
-    tmprrset.toWire(renderer);
-    num_rdata_ = rdatavector_.size();
-}
-
-unsigned int
-BuiltinRRset::toWire(MessageRenderer& renderer) const
-{
-    // XXX: we should confirm the query name matches the pre-rendered data
-    // and it's stored in the Question section.  This proof-of-concept
-    // implementation omits the check for brevity.
-    renderer.writeData(static_cast<const uint8_t*>(wire_data_.getData())
-                       + data_offset_, wire_data_.getLength() - data_offset_);
-    return (num_rdata_);
-}
-
-RdataIteratorPtr
-BuiltinRRset::getRdataIterator() const
-{
-    return (RdataIteratorPtr(new BuiltinRdataIterator(rdatavector_)));
-}
-
-struct BuiltinRRsetsImpl {
-    BuiltinRRsetsImpl(const Name& answer_name, const char** answers,
-                      const char** authorities);
-    RRsetPtr rrset_answer;
-    RRsetPtr rrset_authority;
-};
-
-BuiltinRRsetsImpl::BuiltinRRsetsImpl(const Name& answer_name,
-                                     const char** answers,
-                                     const char** authorities)
-{
-    rrset_answer = RRsetPtr(new BuiltinRRset(answer_name, RRType::TXT(),
-                                             answers));
-    rrset_authority = RRsetPtr(new BuiltinRRset(answer_name, RRType::NS(),
-                                                authorities));
-}
-
-BuiltinRRsets::BuiltinRRsets(const Name& name,
-                             const char** answers,
-                             const char** authorities)
-{
-    impl_ = new BuiltinRRsetsImpl(name, answers, authorities);
-}
-
-BuiltinRRsets::~BuiltinRRsets()
-{
-    delete impl_;
-}
-
-RRsetPtr
-BuiltinRRsets::getAnswer() const
-{
-    return (impl_->rrset_answer);
-}
-
-RRsetPtr
-BuiltinRRsets::getAuthority() const
-{
-    return (impl_->rrset_authority);
-}
-
-const BuiltinRRsets&
-getBuiltinAuthors()
-{
-    static BuiltinRRsets builtin_authors(authors_name, authors,
-                                         author_authorities);
-    return (builtin_authors);
-}
-
-const BuiltinRRsets&
-getBuiltinVersion()
-{
-    static BuiltinRRsets builtin_version(version_name, version,
-                                         version_authorities);
-    return (builtin_version);
-}

+ 0 - 49
src/bin/parkinglot/builtin.h

@@ -1,49 +0,0 @@
-// 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$
-
-#ifndef __BUILTIN_H
-#define __BUILTIN_H 1
-
-#include <boost/shared_ptr.hpp>
-
-#include <dns/name.h>
-#include <dns/rrset.h>
-
-struct BuiltinRRsetsImpl;
-
-class isc::dns::Name;
-
-class BuiltinRRsets {
-public:
-    BuiltinRRsets(const isc::dns::Name& name, const char** answers,
-                  const char** authorities);
-    ~BuiltinRRsets();
-    isc::dns::RRsetPtr getAnswer() const;
-    isc::dns::RRsetPtr getAuthority() const;
-private:
-    BuiltinRRsets(const BuiltinRRsets& source);
-    void operator=(const BuiltinRRsets& source);
-    BuiltinRRsetsImpl* impl_;
-};
-
-const BuiltinRRsets& getBuiltinAuthors();
-const BuiltinRRsets& getBuiltinVersion();
-
-#endif // __BUILTIN_H
-
-// Local Variables:
-// mode: c++
-// End:

+ 0 - 241
src/bin/parkinglot/builtin_bench.cc

@@ -1,241 +0,0 @@
-// 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 <sys/time.h>
-
-#include <algorithm>
-#include <iostream>
-#include <sstream>
-#include <vector>
-
-#include <dns/buffer.h>
-#include <dns/messagerenderer.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rdataclass.h>
-#include <dns/rrclass.h>
-#include <dns/rrtype.h>
-#include <dns/rrttl.h>
-#include <dns/rrset.h>
-
-#include "builtin.h"
-
-using namespace std;
-using namespace isc::dns;
-using namespace isc::dns::rdata;
-
-static const int ITERATION = 100000;
-
-namespace {
-Name authors_name("authors.bind");
-
-inline double
-tv_sub(const struct timeval& t1, const struct timeval& t2)
-{
-    struct timeval result;
-
-    result.tv_sec = t1.tv_sec - t2.tv_sec;
-    result.tv_usec = t1.tv_usec - t2.tv_usec;
-    if (result.tv_usec < 0) {
-        result.tv_usec += 1000000;
-        result.tv_sec--;
-    }
-
-    return (result.tv_sec + result.tv_usec / 1000000.0);
-}
-
-void
-buildAuthors(vector<string>& authors)
-{
-    authors.push_back("Han Feng");
-    authors.push_back("Kazunori Fujiwara");
-    authors.push_back("Michael Graff");
-    authors.push_back("Evan Hunt");
-    authors.push_back("Jelte Jansen");
-    authors.push_back("Jin Jian");
-    authors.push_back("JINMEI Tatuya");
-    authors.push_back("Naoki Kambe");
-    authors.push_back("Shane Kerr"); 
-    authors.push_back("Zhang Likun");
-    authors.push_back("Jeremy C. Reed");
-}
-
-struct RdataInserterFromText
-{
-    RdataInserterFromText(RRsetPtr rrset) : rrset_(rrset) {}
-    void operator()(const string& author)
-    {
-        rrset_->addRdata(generic::TXT(author));
-    }
-    RRsetPtr rrset_;
-};
-
-inline RRsetPtr
-getNormalRRset(const vector<string>& authors)
-{
-    RRsetPtr rrset = RRsetPtr(new RRset(authors_name,  RRClass::CH(),
-                                        RRType::TXT(), RRTTL(0)));
-    for_each(authors.begin(), authors.end(), RdataInserterFromText(rrset));
-
-    return (rrset);
-}
-
-struct RdataInserterFromWire
-{
-    RdataInserterFromWire(RRsetPtr rrset) : rrset_(rrset) {}
-    void operator()(const OutputBuffer& buffer)
-    {
-        InputBuffer b(buffer.getData(), buffer.getLength());
-        rrset_->addRdata(RdataPtr(new generic::TXT(b, buffer.getLength())));
-    }
-    RRsetPtr rrset_;
-};
-
-inline RRsetPtr
-getNormalRRset(const vector<OutputBuffer>& buffers)
-{
-    RRsetPtr rrset = RRsetPtr(new RRset(authors_name,  RRClass::CH(),
-                                        RRType::TXT(), RRTTL(0)));
-    for_each(buffers.begin(), buffers.end(), RdataInserterFromWire(rrset));
-
-    return (rrset);
-}
-
-struct WireDataInserter
-{
-    WireDataInserter(vector<OutputBuffer>& buffers) : buffers_(buffers)
-    {}
-    void operator()(const string& author)
-    {
-        OutputBuffer buffer(0);
-        generic::TXT(author).toWire(buffer);
-        buffers_.push_back(buffer);
-    }
-    vector<OutputBuffer>& buffers_;
-};
-
-void
-showResult(const struct timeval& tv_begin, const struct timeval& tv_end,
-           int iteration, const char* description)
-{
-    double diff = tv_sub(tv_end, tv_begin);
-    cout << description << " " << iteration << " times in "
-         << fixed << diff << "sec ("
-         << static_cast<int>(iteration / diff) << "qps)" << endl;
-}
-}
-
-int
-main(int argc, char* argv[])
-{
-    int iteration = ITERATION;
-    if (argc > 1) {
-        istringstream(argv[1]) >> dec >> iteration;
-    }
-
-    vector<string> authors;
-    buildAuthors(authors);
-
-    struct timeval tv_begin, tv_end;
-    OutputBuffer buffer(512);
-    MessageRenderer renderer(buffer);
-
-    //
-    // Benchmark for rendering an optimized pre-format RRset
-    //
-    gettimeofday(&tv_begin, NULL);
-    for (int i = 0; i < iteration; ++i) {
-        renderer.clear();
-        renderer.skip(12);
-        renderer.writeName(authors_name);
-        RRsetPtr rrset_optimized = getBuiltinAuthors().getAnswer();
-        rrset_optimized->toWire(renderer);
-    }
-    gettimeofday(&tv_end, NULL);
-    showResult(tv_begin, tv_end, iteration, "Rendered optimized RRset");
-
-    vector<unsigned char> data(buffer.getLength());
-    memcpy(&data[0], buffer.getData(), buffer.getLength());
-
-    //
-    // Benchmark for rendering a general purpose RRset of the same content
-    //
-    RRsetPtr rrset_normal = getNormalRRset(authors);
-    gettimeofday(&tv_begin, NULL);
-    for (int i = 0; i < iteration; ++i) {
-        renderer.clear();
-        renderer.skip(12);
-        renderer.writeName(authors_name);
-        rrset_normal->toWire(renderer);
-    }
-    gettimeofday(&tv_end, NULL);
-    showResult(tv_begin, tv_end, iteration, "Rendered normal RRset");
-
-    // Confirm the two sets of output are identical.
-    if (data.size() != buffer.getLength() ||
-        memcmp(&data[0], buffer.getData(), buffer.getLength())) {
-        cerr << "Rendered data mismatch" << endl;
-        return (1);
-    }
-
-    //
-    // Benchmark for rendering a general purpose RRset of the same content,
-    // create RRset from text every time
-    //
-    gettimeofday(&tv_begin, NULL);
-    for (int i = 0; i < iteration; ++i) {
-        renderer.clear();
-        renderer.skip(12);
-        renderer.writeName(authors_name);
-        getNormalRRset(authors)->toWire(renderer);
-    }
-    gettimeofday(&tv_end, NULL);
-    showResult(tv_begin, tv_end, iteration,
-               "Rendered normal RRset with fromText");
-
-    // Confirm the two sets of output are identical.
-    if (data.size() != buffer.getLength() ||
-        memcmp(&data[0], buffer.getData(), buffer.getLength())) {
-        cerr << "Rendered data mismatch" << endl;
-        return (1);
-    }
-
-    //
-    // Benchmark for rendering a general purpose RRset of the same content,
-    // create RRset from wire data every time
-    //
-    vector<OutputBuffer> buffers;
-    for_each(authors.begin(), authors.end(), WireDataInserter(buffers));
-    gettimeofday(&tv_begin, NULL);
-    for (int i = 0; i < iteration; ++i) {
-        renderer.clear();
-        renderer.skip(12);
-        renderer.writeName(authors_name);
-        getNormalRRset(buffers)->toWire(renderer);
-    }
-    gettimeofday(&tv_end, NULL);
-    showResult(tv_begin, tv_end, iteration,
-               "Rendered normal RRset with fromWire");
-
-    // Confirm the two sets of output are identical.
-    if (data.size() != buffer.getLength() ||
-        memcmp(&data[0], buffer.getData(), buffer.getLength())) {
-        cerr << "Rendered data mismatch" << endl;
-        return (1);
-    }
-
-    return (0);
-}

+ 0 - 23
src/bin/parkinglot/common.cc

@@ -1,23 +0,0 @@
-// Copyright (C) 2009  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 "common.h"
-#include <iostream>
-
-FatalError::FatalError(std::string m) {
-    msg = m;
-    std::cerr << msg << std::endl;
-    exit(1);
-}

+ 0 - 36
src/bin/parkinglot/common.h

@@ -1,36 +0,0 @@
-// Copyright (C) 2009  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$
-
-#ifndef __COMMON_H
-#define __COMMON_H 1
-
-#include <stdlib.h>
-#include <string>
-
-class FatalError : public std::exception {
-public:
-    FatalError(std::string m = "fatal error");
-    ~FatalError() throw() {}
-    const char* what() const throw() { return msg.c_str(); }
-private:
-    std::string msg;
-};
-
-#endif // __COMMON_H
-
-// Local Variables:
-// mode: c++
-// End:

+ 0 - 1
src/bin/parkinglot/config.h.in

@@ -1 +0,0 @@
-#define PARKINGLOT_SPECFILE_LOCATION "@prefix@/share/bind/parkinglot.spec"

+ 0 - 20
src/bin/parkinglot/data_source.cc

@@ -1,20 +0,0 @@
-#include <dns/buffer.h>
-#include <dns/name.h>
-#include <dns/rrset.h>
-#include <dns/message.h>
-
-#include <cc/data.h>
-
-#include "data_source.h"
-
-namespace isc {
-namespace dns {
-
-void
-DataSource::getData(isc::dns::RRsetPtr query, isc::dns::Message& answer)
-{
-    return;
-}
-
-}
-}

+ 0 - 123
src/bin/parkinglot/data_source.h

@@ -1,123 +0,0 @@
-// Copyright (C) 2009  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$
-
-#ifndef __DATA_SOURCE_H
-#define __DATA_SOURCE_H
-
-#include <dns/name.h>
-#include <dns/rrset.h>
-
-namespace isc {
-namespace dns {
-
-// do we need to make a template for this?
-// i.e. do we want this to be able to hold more types than RRset?
-class SearchResult {
-public:
-    SearchResult() : status(success) {};
-    enum status_type { success, error, not_implemented,
-                       zone_not_found, name_not_found };
-
-    void addRRset(RRsetPtr rrset) { rrsets.push_back(rrset); }
-
-    status_type getStatus() { return status; }
-    void setStatus(status_type s) { status = s; }
-    
-    /* forward iterator interface */
-    typedef std::vector<RRsetPtr>::iterator iterator;
-    typedef std::vector<RRsetPtr>::const_iterator const_iterator;
-    std::vector<RRsetPtr>::iterator begin() { return rrsets.begin(); }
-    std::vector<RRsetPtr>::iterator end() { return rrsets.end(); }
-    std::vector<RRsetPtr>::const_iterator begin() const { return rrsets.begin(); }
-    std::vector<RRsetPtr>::const_iterator end() const { return rrsets.end(); }
-    
-private:
-    status_type status;
-    std::vector<RRsetPtr> rrsets;
-};
-
-// Base class for a DNS Data Source
-class DataSource {
-public:
-    //enum result { success, not_implemented, error, zone_not_found,
-    //              name_not_found };
-
-    DataSource() {};
-    virtual ~DataSource() {};
-
-    //
-    // 'high-level' methods, these may or may not be overwritten;
-    // depending on the data source the default implementation
-    // may not be most efficient, but should at least provide
-    // the needed functionality
-    //
-
-    // fill in separate lists or simple fill in an answer Message object?
-    void getData(const RRsetPtr query, Message& answer);
-
-    // how to provide highlevel update data?
-    //result handleUpdate()
-    
-
-    //
-    // mandatory 'low-level' methods, an implementation must overwrite these
-    //
-    //
-    // for a 'catch-all' datasource, we need to be able to find
-    // out if it has a zone for a given name
-    //
-    // perhaps this should not set a zone Name, but rather a specific
-    // ZoneRef option (which could be datasource-specific, as it will
-    // only be used to pass along to other calls)
-    // Or even more abstract;
-    // SomeHandler initFind(name, whatever else);
-    virtual bool hasZoneFor(const Name& name, Name& zone_name) = 0;
-
-    // for the zone_name, see getZoneFor, perhaps this needs to be a more
-    // general handle
-    // And perhaps we need a function that does not have that argument too
-    virtual SearchResult findRRsets(const Name& zone_name,
-                                    const Name& name,
-                                    const RRClass& clas,
-                                    const RRType& type) const = 0;
-
-    //
-    // optional 'low-level' methods, an implementation may overwrite these,
-    // by default they return not_implemented
-    //
-    virtual void init() {};
-    virtual void close() {};
-    //virtual result addRR(Name name, int clas, int type,
-    //                     int ttl, Rdata::RdataPtr data)
-    //                    { return not_implemented; };
-    //virtual result delRR(isc::dns::Name name, int clas, int type) = 0;
-    // on name/class/type again? or use an already constructed object?
-    //virtual result getRRSigs(RRsetPtr target, const RRsetPtr rrset)
-    //                        { return not_implemented; };
-    //virtual result getNSECs(RRsetPtr target, const RRsetPtr rrset)
-    //                        { return not_implemented; };
-
-    // check if the zone exists, and if so, return something that could
-    // be used as a pointer for the rest of these functions?
-    // do we need this? do we want this?
-    //virtual int getZone(void* zone, isc::dns::Name name);
-    
-};
-
-}
-}
-
-#endif

+ 0 - 188
src/bin/parkinglot/data_source_plot.cc

@@ -1,188 +0,0 @@
-
-#include <boost/foreach.hpp>
-
-#include <dns/rdataclass.h>
-#include <dns/rrttl.h>
-
-#include "data_source_plot.h"
-
-namespace isc {
-namespace dns {
-
-// this implementation returns fixed records,
-// and does not allow update statements
-
-using namespace isc::dns;
-using namespace isc::dns::rdata;
-using namespace isc::data;
-
-namespace {
-const Name authors_name("authors.bind");
-const Name version_name("version.bind");
-}
-
-void
-DataSourceParkingLot::serve(std::string zone_name) {
-    zones.serve(zone_name);
-}
-
-void
-DataSourceParkingLot::addARecord(std::string data) {
-    a_records.push_back(RdataPtr(new in::A(data)));
-}
-
-void
-DataSourceParkingLot::addAAAARecord(std::string data) {
-    aaaa_records.push_back(RdataPtr(new in::AAAA(data)));
-}
-
-void
-DataSourceParkingLot::addNSRecord(std::string data) {
-    ns_records.push_back(RdataPtr(new generic::NS(data)));
-}
-
-void
-DataSourceParkingLot::setSOARecord(RdataPtr soa_record) {
-}
-
-void
-DataSourceParkingLot::setDefaultZoneData() {
-    clearARecords();
-    clearAAAARecords();
-    clearNSRecords();
-
-    addARecord("127.0.0.1");
-    addAAAARecord("::1");
-    addNSRecord("ns1.parking.example");
-    addNSRecord("ns2.parking.example");
-    addNSRecord("ns3.parking.example");
-}
-
-DataSourceParkingLot::DataSourceParkingLot() {
-    setDefaultZoneData();
-    soa = RdataPtr(new generic::SOA(Name("parking.example"),
-                                    Name("noc.parking.example"),
-                                    1, 1800, 900, 604800, 86400));
-}
-
-bool
-DataSourceParkingLot::hasZoneFor(const Name& name, Name &zone_name)
-{
-    if (name == authors_name) {
-        zone_name = authors_name;
-        return (true);
-    } else if (name == version_name) {
-        zone_name = version_name;
-        return (true);
-    }
-    return zones.findClosest(name, zone_name);
-}
-
-SearchResult
-DataSourceParkingLot::findRRsets(const isc::dns::Name& zone_name,
-                                 const isc::dns::Name& name,
-                                 const isc::dns::RRClass& clas,
-                                 const isc::dns::RRType& type) const
-{
-    SearchResult result;
-    
-    if (clas == RRClass::CH()) {
-        if (type == RRType::TXT()) {
-            if (name == authors_name) {
-                RRsetPtr rrset = RRsetPtr(new RRset(authors_name, RRClass::CH(),
-                                                    RRType::TXT(), RRTTL(0)));
-                rrset->addRdata(generic::TXT("Han Feng"));
-                rrset->addRdata(generic::TXT("Kazunori Fujiwara"));
-                rrset->addRdata(generic::TXT("Michael Graff"));
-                rrset->addRdata(generic::TXT("Evan Hunt"));
-                rrset->addRdata(generic::TXT("Jelte Jansen"));
-                rrset->addRdata(generic::TXT("Jin Jian"));
-                rrset->addRdata(generic::TXT("JINMEI Tatuya"));
-                rrset->addRdata(generic::TXT("Naoki Kambe"));
-                rrset->addRdata(generic::TXT("Shane Kerr")); 
-                rrset->addRdata(generic::TXT("Zhang Likun"));
-                rrset->addRdata(generic::TXT("Jeremy C. Reed")); 
-
-                result.addRRset(rrset);
-                result.setStatus(SearchResult::success);
-            } else if (name == version_name) {
-                RRsetPtr rrset = RRsetPtr(new RRset(version_name, RRClass::CH(),
-                                                    RRType::TXT(), RRTTL(0)));
-                rrset->addRdata(generic::TXT("BIND10 0.0.1"));
-                result.addRRset(rrset);
-                result.setStatus(SearchResult::success);
-            } else {
-                result.setStatus(SearchResult::name_not_found);
-            }
-        } else if (type == RRType::NS()) {
-            if (name == authors_name || name == version_name) {
-                RRsetPtr rrset = RRsetPtr(new RRset(name, RRClass::CH(),
-                                                    RRType::NS(),
-                                                    RRTTL(0)));
-                rrset->addRdata(generic::NS(name));
-                result.addRRset(rrset);
-                result.setStatus(SearchResult::success);
-            } else {
-                result.setStatus(SearchResult::name_not_found);
-            }
-        } else {
-            result.setStatus(SearchResult::name_not_found);
-        }
-    } else if (clas == RRClass::IN()) {
-        if (zones.contains(name)) {
-            RRsetPtr rrset = RRsetPtr(new RRset(name, clas, type, RRTTL(3600)));
-            result.setStatus(SearchResult::success);
-            if (type == RRType::A()) {
-                BOOST_FOREACH(RdataPtr a, a_records) {
-                    rrset->addRdata(a);
-                }
-            } else if (type == RRType::AAAA()) {
-                BOOST_FOREACH(RdataPtr aaaa, aaaa_records) {
-                    rrset->addRdata(aaaa);
-                }
-            } else if (type == RRType::NS()) {
-                BOOST_FOREACH(RdataPtr ns, ns_records) {
-                    rrset->addRdata(ns);
-                }
-            } else if (type == RRType::SOA()) {
-                rrset->addRdata(soa);
-            }
-            result.addRRset(rrset);
-        } else {
-            // we don't have the name itself. Do we have the zone?
-            if (zones.contains(zone_name)) {
-                result.setStatus(SearchResult::name_not_found);
-            } else {
-                result.setStatus(SearchResult::zone_not_found);
-            }
-        }
-    } else {
-        result.setStatus(SearchResult::zone_not_found);
-    }
-    return result;
-}
-
-/// Do direct 'search' in database, no extra processing,
-/// and add the resulting rrsets to the specified section
-/// in the given message
-/// returns the status code of the searchresult
-/// Once the dns logic is moved from parkinglot to this class,
-/// we should probably make this private
-SearchResult::status_type
-DataSourceParkingLot::addToMessage(Message& msg,
-             const Section& section,
-             const Name& zone_name,
-             const Name& name,
-             const RRClass& clas,
-             const RRType& type) const
-{
-    SearchResult result = findRRsets(zone_name, name, clas, type);
-    BOOST_FOREACH(RRsetPtr rrset, result) {
-        msg.addRRset(section, rrset);
-    }
-    return result.getStatus();
-}
-
-
-}
-}

+ 0 - 96
src/bin/parkinglot/data_source_plot.h

@@ -1,96 +0,0 @@
-
-// Copyright (C) 2009  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$
-
-#ifndef __DATA_SOURCE_SIMPLE_H
-#define __DATA_SOURCE_SIMPLE_H
-
-#include <dns/buffer.h>
-#include <dns/name.h>
-#include <dns/rdata.h>
-#include <dns/rrclass.h>
-#include <dns/rrtype.h>
-#include <dns/rrset.h>
-#include <dns/message.h>
-
-#include <cc/data.h>
-
-#include "common.h"
-
-#include "data_source.h"
-
-#include "zoneset.h"
-
-namespace isc {
-namespace dns {
-
-class DataSourceParkingLot : public DataSource {
-public:
-    DataSourceParkingLot();
-    
-    void init() {};
-    void close() {};
-    bool hasZoneFor(const Name& name, Name &zone_name);
-    SearchResult findRRsets(const isc::dns::Name& zone_name,
-                            const isc::dns::Name& name,
-                            const isc::dns::RRClass& clas,
-                            const isc::dns::RRType& type) const;
-
-    /* move these to private (or to zoneset) and the calling functions
-     * from parkinglot to here? */
-    void serve(std::string zone_name);
-    void clear_zones() { zones.clear_zones(); };
-
-    void clearARecords() { a_records.clear(); };
-    void clearAAAARecords() { aaaa_records.clear(); };
-    void clearNSRecords() { ns_records.clear(); };
-
-    void addARecord(std::string data);
-    void addAAAARecord(std::string data);
-    void addNSRecord(std::string data);
-
-    void setSOARecord(isc::dns::rdata::RdataPtr soa_record);
-
-    /// Do direct 'search' in database, no extra processing,
-    /// and add the resulting rrsets to the specified section
-    /// in the given message
-    /// Once the dns logic is moved from parkinglot to this class,
-    /// we should probably make this private
-    SearchResult::status_type addToMessage(Message& msg,
-                                           const isc::dns::Section& section,
-                                           const isc::dns::Name& zone_name,
-                                           const isc::dns::Name& name,
-                                           const isc::dns::RRClass& clas,
-                                           const isc::dns::RRType& type) const;
-
-private:
-    //
-    void setDefaultZoneData();
-
-    std::vector<isc::dns::rdata::RdataPtr> a_records, aaaa_records, ns_records;
-    isc::dns::rdata::RdataPtr soa;
-    ZoneSet zones;
-
-};
-
-}
-}
-
-#endif
-
-// Local Variables: 
-// mode: c++
-// End: 

+ 0 - 148
src/bin/parkinglot/main.cc

@@ -1,148 +0,0 @@
-// Copyright (C) 2009  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 <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <netdb.h>
-#include <stdlib.h>
-
-#include <set>
-#include <iostream>
-
-#include <boost/foreach.hpp>
-
-#include <dns/buffer.h>
-#include <dns/name.h>
-#include <dns/rrset.h>
-#include <dns/message.h>
-
-#include <cc/session.h>
-#include <cc/data.h>
-#include <config/ccsession.h>
-
-#include "zoneset.h"
-#include "b10-parkinglot.h"
-
-#include "common.h"
-
-#include <boost/foreach.hpp>
-
-#include "config.h"
-
-using namespace std;
-
-//const string PROGRAM = "ParkingLot";
-const int DNSPORT = 5300;
-
-/* need global var for config/command handlers.
- * todo: turn this around, and put handlers in the parkinglot
- * class itself? */
-ParkingLot plot = ParkingLot(DNSPORT);
-
-static void
-usage() {
-    cerr << "Usage: parkinglot [-p port]" << endl;
-    exit(1);
-}
-
-isc::data::ElementPtr
-my_config_handler(isc::data::ElementPtr config)
-{
-    return plot.updateConfig(config);
-}
-
-isc::data::ElementPtr
-my_command_handler(isc::data::ElementPtr command)
-{
-    isc::data::ElementPtr answer = isc::data::Element::createFromString("{ \"result\": [0] }");
-
-    if (command->get(0)->stringValue() == "print_message") 
-    {
-        cout << command->get(1)->get("message") << endl;
-        /* let's add that message to our answer as well */
-        answer->get("result")->add(command->get(1));
-    }
-
-    return answer;
-}
-
-int
-main(int argc, char* argv[]) {
-    int ch;
-    int port = DNSPORT;
-
-    while ((ch = getopt(argc, argv, "p:")) != -1) {
-        switch (ch) {
-        case 'p':
-            port = atoi(optarg);
-            break;
-        case '?':
-        default:
-            usage();
-        }
-    }
-
-    if (argc - optind > 0)
-        usage();
-
-    // initialize parking lot
-    //plot = ParkingLot(port);
-
-    // initialize command channel
-    try {
-        std::string specfile;
-        if (getenv("B10_FROM_SOURCE")) {
-            specfile = std::string(getenv("B10_FROM_SOURCE")) + "/src/bin/parkinglot/parkinglot.spec";
-        } else {
-            specfile = std::string(PARKINGLOT_SPECFILE_LOCATION);
-        }
-        CommandSession cs = CommandSession(specfile, my_config_handler, my_command_handler);
-    
-        // main server loop
-        fd_set fds;
-        int ps = plot.getSocket();
-        int ss = cs.getSocket();
-        int nfds = max(ps, ss) + 1;
-        int counter = 0;
-    
-        cout << "[parkinglot] Server started." << endl;
-        while (true) {
-            FD_ZERO(&fds);
-            FD_SET(ps, &fds);
-            FD_SET(ss, &fds);
-    
-            int n = select(nfds, &fds, NULL, NULL, NULL);
-            if (n < 0)
-                throw FatalError("[parkinglot] select error");
-    
-            if (FD_ISSET(ps, &fds)) {
-                ++counter;
-                plot.processMessage();
-            }
-    
-            /* isset not really necessary, but keep it for now */
-            if (FD_ISSET(ss, &fds)) {
-                cs.check_command();
-            }
-        }
-    } catch (isc::cc::SessionError se) {
-        cout << se.what() << endl;
-        exit(1);
-    }
-    
-    return (0);
-}

+ 0 - 74
src/bin/parkinglot/parkinglot.spec

@@ -1,74 +0,0 @@
-{
-  "data_specification": {
-    "module_name": "ParkingLot",
-    "config_data": [
-      {
-        "item_name": "port",
-        "item_type": "integer",
-        "item_optional": false,
-        "item_default": 5300
-      },
-      {
-        "item_name": "zones",
-        "item_type": "list",
-        "item_optional": false,
-        "item_default": [ ],
-        "list_item_spec": {
-          "item_name": "zone_name",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        }
-      },
-      {
-        "item_name": "a_records",
-        "item_type": "list",
-        "item_optional": false,
-        "item_default": [ "127.0.0.1" ],
-        "list_item_spec": {
-          "item_name": "address",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        }
-      },
-      {
-        "item_name": "aaaa_records",
-        "item_type": "list",
-        "item_optional": false,
-        "item_default": [ "::1" ],
-        "list_item_spec": {
-          "item_name": "address",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        }
-      },
-      {
-        "item_name": "ns_records",
-        "item_type": "list",
-        "item_optional": false,
-        "item_default": [ "ns1.parking.example", "ns2.parking.example" ],
-        "list_item_spec": {
-          "item_name": "address",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        }
-      }
-    ],
-    "commands": [
-      {
-        "command_name": "print_message",
-        "command_description": "Print the given message to stdout",
-        "command_args": [ {
-          "item_name": "message",
-          "item_type": "string",
-          "item_optional": False,
-          "item_default": ""
-        } ]
-      }
-    ]
-  }
-}
-

+ 0 - 37
src/bin/parkinglot/zoneset.cc

@@ -1,37 +0,0 @@
-#include "zoneset.h"
-
-// see findClosest()
-static bool
-stripLabel(isc::dns::Name& n) {
-    std::string str = n.toText(false);
-    size_t pos = str.find('.');
-    if (pos + 1 < str.size()) {
-        n = isc::dns::Name(str.substr(pos+1));
-        return true;
-    } else {
-        return false;
-    }
-}
-
-bool
-ZoneSet::findClosest(const isc::dns::Name& n, isc::dns::Name& closest) {
-
-    // name compare doesnt work in this branch, so we convert and
-    // strip labels
-    isc::dns::Name cur = n;
-    if (contains(n)) {
-        closest = n;
-        return true;
-    }
-
-    bool labels_left = stripLabel(cur);
-    while(labels_left) {
-        if (contains(cur)) {
-            closest = cur;
-            return true;
-        } else {
-            labels_left = stripLabel(cur);
-        }
-    }
-    return false;
-}

+ 0 - 64
src/bin/parkinglot/zoneset.h

@@ -1,64 +0,0 @@
-// Copyright (C) 2009  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$
-
-#ifndef __ZONESET_H
-#define __ZONESET_H 1
-
-#include <set>
-#include <dns/buffer.h>
-#include <dns/name.h>
-
-class ZoneSet {
-public:
-    void serve(const std::string& s) {
-        serve(isc::dns::Name(s));
-    }
-
-    void serve(const isc::dns::Name& n) {
-        elements.insert(n);
-    }
-    
-    void forget(const std::string& s) {
-        forget(isc::dns::Name(s));
-    }
-
-    void forget(const isc::dns::Name& n) {
-        elements.erase(n);
-    }
-
-    void clear_zones() {
-        elements.clear();
-    }
-
-    bool contains(const std::string& s) const {
-        return contains(isc::dns::Name(s));
-    }
-
-    bool contains(const isc::dns::Name& n) const {
-        return (elements.find(n) != elements.end());
-    }
-
-    bool findClosest(const isc::dns::Name& n, isc::dns::Name& closest);
-
-private:
-    std::set<isc::dns::Name> elements;
-};
-
-#endif // __ZONESET_H
-
-// Local Variables:
-// mode: c++
-// End:

+ 0 - 12
src/lib/cc/cpp/parkinglot.data

@@ -1,12 +0,0 @@
-{
-  "port": 5300,
-  "zones": [
-    {
-      "zone_name": "tjeb.nl"
-    },
-    {
-      "zone_name": "jinmei.org"
-    }
-  ]
-}
-

+ 0 - 46
src/lib/cc/cpp/parkinglot.spec

@@ -1,46 +0,0 @@
-{
-  "data_specification": {
-    "module_name": "ParkingLot",
-    "config_data": [
-      {
-        "item_name": "port",
-        "item_type": "integer",
-        "item_optional": false,
-        "item_default": 5300
-      },
-      {
-        "item_name": "zones",
-        "item_type": "list",
-        "item_optional": false,
-        "item_default": [ ],
-        "list_item_spec": {
-          "item_name": "zone_name",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        }
-      }
-    ],
-    "commands": [
-      {
-        "command_name": "zone_add",
-        "command_args": [ {
-          "item_name": "zone_name",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        } ]
-      },
-      {
-        "command_name": "zone_delete",
-        "command_args": [ {
-          "item_name": "zone_name",
-          "item_type": "string",
-          "item_optional": false,
-          "item_default": ""
-        } ]
-      }
-    ]
-  }
-}
-