Commit 2363b50b authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[trac494] move ResolverInterface to lib/resolve

parent 9f172776
......@@ -127,7 +127,7 @@ public:
}
void resolve(const isc::dns::QuestionPtr& question,
const isc::nsas::ResolverInterface::CallbackPtr& callback);
const isc::resolve::ResolverInterface::CallbackPtr& callback);
void processNormalQuery(const Question& question,
MessagePtr answer_message,
......@@ -345,7 +345,7 @@ Resolver::getConfigSession() const {
}
/* tmp for in-dev testing */
class MyCallback : public nsas::ResolverInterface::Callback {
class MyCallback : public resolve::ResolverInterface::Callback {
public:
virtual void success(
const boost::shared_ptr<isc::dns::AbstractRRset>&
......@@ -366,7 +366,7 @@ public:
void
Resolver::resolve(const isc::dns::QuestionPtr& question,
const isc::nsas::ResolverInterface::CallbackPtr& callback)
const isc::resolve::ResolverInterface::CallbackPtr& callback)
{
std::cout << "[XX] asked to resolve: " << *question << std::endl;
impl_->resolve(question, callback);
......@@ -391,7 +391,6 @@ Resolver::processMessage(const IOMessage& io_message,
//resolve(q, callback);
std::cout << "[XX] up to here" << std::endl;
dlog("Got a DNS message");
InputBuffer request_buffer(io_message.getData(), io_message.getDataSize());
// First, check the header part. If we fail even for the base header,
......@@ -470,7 +469,7 @@ Resolver::processMessage(const IOMessage& io_message,
void
ResolverImpl::resolve(const QuestionPtr& question,
const isc::nsas::ResolverInterface::CallbackPtr& callback)
const isc::resolve::ResolverInterface::CallbackPtr& callback)
{
rec_query_->sendQuery(question, callback);
}
......
......@@ -24,7 +24,7 @@
#include <asiolink/asiolink.h>
#include <nsas/resolver_interface.h>
#include <resolve/resolver_interface.h>
class ResolverImpl;
......@@ -37,7 +37,7 @@ class ResolverImpl;
* answer. It doesn't really know about chasing referrals and similar, it
* simply plugs the parts that know into the network handling code.
*/
class Resolver : public isc::nsas::ResolverInterface {
class Resolver : public isc::resolve::ResolverInterface {
///
/// \name Constructors, Assignment Operator and Destructor.
///
......@@ -53,8 +53,9 @@ public:
~Resolver();
//@}
virtual void resolve(const isc::dns::QuestionPtr& question,
const isc::nsas::ResolverInterface::CallbackPtr& callback);
virtual void resolve(
const isc::dns::QuestionPtr& question,
const isc::resolve::ResolverInterface::CallbackPtr& callback);
/// \brief Process an incoming DNS message, then signal 'server' to resume
///
......
......@@ -561,7 +561,7 @@ public:
void
RecursiveQuery::sendQuery(const isc::dns::QuestionPtr& question,
const isc::nsas::ResolverInterface::CallbackPtr callback)
const isc::resolve::ResolverInterface::CallbackPtr callback)
{
asio::io_service& io = dns_service_.get_io_service();
......
......@@ -40,7 +40,7 @@
#include <asiolink/iomessage.h>
#include <asiolink/iosocket.h>
#include <nsas/resolver_interface.h>
#include <resolve/resolver_interface.h>
namespace asio {
// forward declaration for IOService::get_io_service() below
......@@ -558,7 +558,7 @@ public:
//@}
void sendQuery(const isc::dns::QuestionPtr& question,
const isc::nsas::ResolverInterface::CallbackPtr callback);
const isc::resolve::ResolverInterface::CallbackPtr callback);
/// \brief Initiates an upstream query in the \c RecursiveQuery object.
......
......@@ -35,7 +35,6 @@ libnsas_la_SOURCES += nsas_entry.h nsas_types.h
libnsas_la_SOURCES += zone_entry.cc zone_entry.h
libnsas_la_SOURCES += fetchable.h
libnsas_la_SOURCES += address_request_callback.h
libnsas_la_SOURCES += resolver_interface.h
libnsas_la_SOURCES += random_number_generator.h
CLEANFILES = *.gcno *.gcda
......@@ -56,8 +56,8 @@ namespace nsas {
// hash table, on the assumption that three elements is the longest linear
// search we want to do when looking up names in the hash table.
NameserverAddressStore::NameserverAddressStore(
boost::shared_ptr<ResolverInterface> resolver, uint32_t zonehashsize,
uint32_t nshashsize) :
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
uint32_t zonehashsize, uint32_t nshashsize) :
zone_hash_(new HashTable<ZoneEntry>(new NsasEntryCompare<ZoneEntry>,
zonehashsize)),
nameserver_hash_(new HashTable<NameserverEntry>(
......@@ -78,8 +78,9 @@ namespace {
* called at all to create the object, just call the function.
*/
boost::shared_ptr<ZoneEntry>
newZone(const boost::shared_ptr<ResolverInterface>* resolver, const string* zone,
const RRClass* class_code,
newZone(
const boost::shared_ptr<isc::resolve::ResolverInterface>* resolver,
const string* zone, const RRClass* class_code,
const boost::shared_ptr<HashTable<NameserverEntry> >* ns_hash,
const boost::shared_ptr<LruList<NameserverEntry> >* ns_lru)
{
......
......@@ -20,6 +20,8 @@
#include <boost/shared_ptr.hpp>
#include <resolve/resolver_interface.h>
#include "nsas_types.h"
namespace isc {
......@@ -62,7 +64,8 @@ public:
/// value of 3001 is the first prime number over 3000, and by implication,
/// there is an assumption that there will be more nameservers than zones
/// in the store.
NameserverAddressStore(boost::shared_ptr<ResolverInterface> resolver,
NameserverAddressStore(
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
uint32_t zonehashsize = 1009, uint32_t nshashsize = 3001);
/// \brief Destructor
......@@ -105,7 +108,7 @@ protected:
boost::shared_ptr<LruList<NameserverEntry> > nameserver_lru_;
// The resolver we use
private:
boost::shared_ptr<ResolverInterface> resolver_;
boost::shared_ptr<isc::resolve::ResolverInterface> resolver_;
//}@
};
......
......@@ -31,11 +31,11 @@
#include <dns/rrclass.h>
#include <dns/rrttl.h>
#include <dns/question.h>
#include <resolve/resolver_interface.h>
#include "address_entry.h"
#include "nameserver_address.h"
#include "nameserver_entry.h"
#include "resolver_interface.h"
using namespace asiolink;
using namespace isc::nsas;
......@@ -199,7 +199,8 @@ NameserverEntry::setAddressUnreachable(const IOAddress& address) {
* fed back trough this. It holds a shared pointer to the entry so it is not
* destroyed too soon.
*/
class NameserverEntry::ResolverCallback : public ResolverInterface::Callback {
class NameserverEntry::ResolverCallback :
public isc::resolve::ResolverInterface::Callback {
public:
ResolverCallback(boost::shared_ptr<NameserverEntry> entry,
AddressFamily family, const RRType& type) :
......@@ -363,7 +364,8 @@ class NameserverEntry::ResolverCallback : public ResolverInterface::Callback {
};
void
NameserverEntry::askIP(boost::shared_ptr<ResolverInterface> resolver,
NameserverEntry::askIP(
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
const RRType& type, AddressFamily family)
{
QuestionPtr question(new Question(Name(getName()), RRClass(getClass()),
......@@ -374,7 +376,8 @@ NameserverEntry::askIP(boost::shared_ptr<ResolverInterface> resolver,
}
void
NameserverEntry::askIP(boost::shared_ptr<ResolverInterface> resolver,
NameserverEntry::askIP(
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
boost::shared_ptr<Callback> callback, AddressFamily family)
{
Lock lock(mutex_);
......
......@@ -36,13 +36,14 @@
#include <dns/rrset.h>
#include <dns/rrtype.h>
#include <resolve/resolver_interface.h>
#include "address_entry.h"
#include "asiolink.h"
#include "nsas_types.h"
#include "hash_key.h"
#include "lru_list.h"
#include "fetchable.h"
#include "resolver_interface.h"
#include "nsas_entry.h"
#include "nameserver_address.h"
......@@ -84,7 +85,7 @@ public:
};
class ZoneEntry;
class ResolverInterface;
//class ResolverInterface;
/// \brief Nameserver Entry
///
......@@ -247,7 +248,7 @@ public:
* even when there are addresses, if there are no addresses for this
* family.
*/
void askIP(boost::shared_ptr<ResolverInterface> resolver,
void askIP(boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
boost::shared_ptr<Callback> callback, AddressFamily family);
//@}
......@@ -279,7 +280,7 @@ private:
/// \short Private version that does the actual asking of one address type
///
/// Call unlocked.
void askIP(boost::shared_ptr<ResolverInterface> resolver,
void askIP(boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
const isc::dns::RRType&, AddressFamily);
};
......
......@@ -31,8 +31,8 @@
#include <dns/rrttl.h>
#include <dns/messagerenderer.h>
#include <dns/rdataclass.h>
#include <resolve/resolver_interface.h>
#include "../nsas_entry.h"
#include "../resolver_interface.h"
using namespace isc::dns::rdata;
using namespace isc::dns;
......@@ -217,7 +217,7 @@ using namespace std;
* This pretends to be a resolver. It stores the queries and
* they can be answered.
*/
class TestResolver : public isc::nsas::ResolverInterface {
class TestResolver : public isc::resolve::ResolverInterface {
private:
bool checkIndex(size_t index) {
return (requests.size() > index);
......
......@@ -42,7 +42,8 @@ namespace {
/// \brief Inherited version with access into its internals for tests
class InheritedZoneEntry : public ZoneEntry {
public:
InheritedZoneEntry(boost::shared_ptr<ResolverInterface> resolver,
InheritedZoneEntry(
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
const std::string& name, const RRClass& class_code,
boost::shared_ptr<HashTable<NameserverEntry> > nameserver_table,
boost::shared_ptr<LruList<NameserverEntry> > nameserver_lru) :
......
......@@ -32,7 +32,8 @@ using namespace dns;
namespace nsas {
ZoneEntry::ZoneEntry(boost::shared_ptr<ResolverInterface> resolver,
ZoneEntry::ZoneEntry(
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
const std::string& name, const isc::dns::RRClass& class_code,
boost::shared_ptr<HashTable<NameserverEntry> > nameserver_table,
boost::shared_ptr<LruList<NameserverEntry> > nameserver_lru) :
......@@ -73,7 +74,8 @@ newNs(const std::string* name, const RRClass* class_code) {
* code. It manipulates directly ZoneEntry's data members, locks it and like
* that. Mostly eliminates C++ bad design of missing lambda functions.
*/
class ZoneEntry::ResolverCallback : public ResolverInterface::Callback {
class ZoneEntry::ResolverCallback :
public isc::resolve::ResolverInterface::Callback {
public:
/// \short Constructor. Pass "this" zone entry
ResolverCallback(boost::shared_ptr<ZoneEntry> entry) :
......
......@@ -36,11 +36,12 @@
#include <dns/rrset.h>
#include <resolve/resolver_interface.h>
#include "hash_key.h"
#include "nsas_entry.h"
#include "asiolink.h"
#include "fetchable.h"
#include "resolver_interface.h"
#include "nsas_types.h"
#include "random_number_generator.h"
......@@ -76,7 +77,8 @@ public:
* \todo Move to cc file, include the lookup (if NSAS uses resolver for
* everything)
*/
ZoneEntry(boost::shared_ptr<ResolverInterface> resolver,
ZoneEntry(
boost::shared_ptr<isc::resolve::ResolverInterface> resolver,
const std::string& name, const isc::dns::RRClass& class_code,
boost::shared_ptr<HashTable<NameserverEntry> > nameserver_table,
boost::shared_ptr<LruList<NameserverEntry> > nameserver_lru);
......@@ -151,7 +153,7 @@ private:
void process(AddressFamily family,
const boost::shared_ptr<NameserverEntry>& nameserver);
// Resolver we use
boost::shared_ptr<ResolverInterface> resolver_;
boost::shared_ptr<isc::resolve::ResolverInterface> resolver_;
// We store the nameserver table and lru, so we can look up when there's
// update
boost::shared_ptr<HashTable<NameserverEntry> > nameserver_table_;
......
......@@ -11,5 +11,6 @@ CLEANFILES = *.gcno *.gcda
lib_LTLIBRARIES = libresolve.la
libresolve_la_SOURCES = resolve.h resolve.cc
libresolve_la_SOURCES += resolver_interface.h
libresolve_la_LIBADD = $(top_builddir)/src/lib/dns/libdns++.la
libresolve_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
......@@ -45,14 +45,14 @@ private:
class ResolverCallbackDirect : public AbstractResolverCallback {
public:
ResolverCallbackDirect(
const isc::nsas::ResolverInterface::CallbackPtr callback,
const isc::resolve::ResolverInterface::CallbackPtr callback,
isc::dns::MessagePtr answer_message) :
callback_(callback),
answer_message_(answer_message) {}
void callback(bool result);
private:
const isc::nsas::ResolverInterface::CallbackPtr callback_;
const isc::resolve::ResolverInterface::CallbackPtr callback_;
isc::dns::MessagePtr answer_message_;
};
......
......@@ -25,10 +25,12 @@
* This file contains a dummy interface for the resolver, which does not yet
* exist. When the resolver appears, this file should either wrap its
* interface or, better, be removed completely.
*
* Currently left in while moving interfaces and classes around
*/
namespace isc {
namespace nsas {
namespace resolve {
/**
* \short Abstract interface to the resolver.
......
......@@ -33,6 +33,7 @@ const char* const DEFAULT_REMOTE_ADDRESS = "192.0.2.1";
SrvTestBase::SrvTestBase() : request_message(Message::RENDER),
parse_message(new Message(Message::PARSE)),
response_message(new Message(Message::RENDER)),
default_qid(0x1035),
opcode(Opcode(Opcode::QUERY())),
qname("www.example.com"),
......
......@@ -89,8 +89,8 @@ protected:
MockSession notify_session;
MockServer dnsserv;
isc::dns::Message request_message;
isc::dns::MessagePtr response_message;
isc::dns::MessagePtr parse_message;
isc::dns::MessagePtr response_message;
const isc::dns::qid_t default_qid;
const isc::dns::Opcode opcode;
const isc::dns::Name qname;
......
Markdown is supported
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