Commit 76022a7e authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[master] Merge branch 'trac495'

Conflicts:
	src/lib/Makefile.am
	src/lib/asiolink/Makefile.am
	src/lib/asiolink/tcp_socket.h
	src/lib/asiolink/tests/Makefile.am
	src/lib/nsas/asiolink.h
	src/lib/resolve/recursive_query.cc
parents 11889ab3 454739d1
......@@ -207,7 +207,7 @@ public:
// Cancel all operations associated with the given descriptor. The
// handlers associated with the descriptor will be invoked with the
// operation_aborted error.
void cancel_ops(socket_type descriptor, per_descriptor_data& descriptor_data)
void cancel_ops(socket_type, per_descriptor_data& descriptor_data)
{
mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
......
......@@ -51,6 +51,7 @@ b10_resolver_LDADD += $(top_builddir)/src/lib/log/liblog.la
b10_resolver_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
b10_resolver_LDADD += $(top_builddir)/src/lib/cache/libcache.la
b10_resolver_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
b10_resolver_LDADD += $(top_builddir)/src/lib/resolve/libresolve.la
b10_resolver_LDADD += $(top_builddir)/src/bin/auth/change_user.o
b10_resolver_LDFLAGS = -pthread
......
......@@ -45,6 +45,9 @@
#include <resolver/spec_config.h>
#include <resolver/resolver.h>
#include <cache/resolver_cache.h>
#include <nsas/nameserver_address_store.h>
#include <log/dummylog.h>
using namespace std;
......@@ -59,7 +62,7 @@ namespace {
static const string PROGRAM = "Resolver";
IOService io_service;
static Resolver *resolver;
static boost::shared_ptr<Resolver> resolver;
ConstElementPtr
my_config_handler(ConstElementPtr new_config) {
......@@ -135,15 +138,58 @@ main(int argc, char* argv[]) {
specfile = string(RESOLVER_SPECFILE_LOCATION);
}
resolver = new Resolver();
resolver = boost::shared_ptr<Resolver>(new Resolver());
dlog("Server created.");
SimpleCallback* checkin = resolver->getCheckinProvider();
DNSLookup* lookup = resolver->getDNSLookupProvider();
DNSAnswer* answer = resolver->getDNSAnswerProvider();
isc::nsas::NameserverAddressStore nsas(resolver);
resolver->setNameserverAddressStore(nsas);
isc::cache::ResolverCache cache;
resolver->setCache(cache);
// TODO priming query, remove root from direct
// Fake a priming query result here (TODO2 how to flag non-expiry?)
// propagation to runningquery. And check for forwarder mode?
isc::dns::QuestionPtr root_question(new isc::dns::Question(
isc::dns::Name("."),
isc::dns::RRClass::IN(),
isc::dns::RRType::NS()));
isc::dns::RRsetPtr root_ns_rrset(new isc::dns::RRset(isc::dns::Name("."),
isc::dns::RRClass::IN(),
isc::dns::RRType::NS(),
isc::dns::RRTTL(8888)));
root_ns_rrset->addRdata(isc::dns::rdata::createRdata(isc::dns::RRType::NS(),
isc::dns::RRClass::IN(),
"l.root-servers.net."));
isc::dns::RRsetPtr root_a_rrset(new isc::dns::RRset(isc::dns::Name("l.root-servers.net"),
isc::dns::RRClass::IN(),
isc::dns::RRType::A(),
isc::dns::RRTTL(8888)));
root_a_rrset->addRdata(isc::dns::rdata::createRdata(isc::dns::RRType::A(),
isc::dns::RRClass::IN(),
"199.7.83.42"));
isc::dns::RRsetPtr root_aaaa_rrset(new isc::dns::RRset(isc::dns::Name("l.root-servers.net"),
isc::dns::RRClass::IN(),
isc::dns::RRType::AAAA(),
isc::dns::RRTTL(8888)));
root_aaaa_rrset->addRdata(isc::dns::rdata::createRdata(isc::dns::RRType::AAAA(),
isc::dns::RRClass::IN(),
"2001:500:3::42"));
isc::dns::MessagePtr priming_result(new isc::dns::Message(isc::dns::Message::RENDER));
priming_result->addQuestion(root_question);
priming_result->addRRset(isc::dns::Message::SECTION_ANSWER, root_ns_rrset);
priming_result->addRRset(isc::dns::Message::SECTION_ADDITIONAL, root_a_rrset);
priming_result->addRRset(isc::dns::Message::SECTION_ADDITIONAL, root_aaaa_rrset);
cache.update(*priming_result);
cache.update(root_ns_rrset);
cache.update(root_a_rrset);
cache.update(root_aaaa_rrset);
DNSService dns_service(io_service, checkin, lookup, answer);
resolver->setDNSService(dns_service);
dlog("IOService created.");
......@@ -172,7 +218,6 @@ main(int argc, char* argv[]) {
delete config_session;
delete cc_session;
delete resolver;
return (ret);
}
......@@ -41,6 +41,8 @@
#include <dns/messagerenderer.h>
#include <server_common/portconfig.h>
#include <resolve/recursive_query.h>
#include <log/dummylog.h>
#include <resolver/resolver.h>
......@@ -74,10 +76,15 @@ public:
queryShutdown();
}
void querySetup(DNSService& dnss) {
void querySetup(DNSService& dnss,
isc::nsas::NameserverAddressStore& nsas,
isc::cache::ResolverCache& cache)
{
assert(!rec_query_); // queryShutdown must be called first
dlog("Query setup");
rec_query_ = new RecursiveQuery(dnss, upstream_,
rec_query_ = new RecursiveQuery(dnss,
nsas, cache,
upstream_,
upstream_root_,
query_timeout_,
client_timeout_,
......@@ -129,7 +136,7 @@ public:
}
}
}
void resolve(const isc::dns::QuestionPtr& question,
const isc::resolve::ResolverInterface::CallbackPtr& callback);
......@@ -341,6 +348,19 @@ Resolver::setDNSService(asiolink::DNSService& dnss) {
dnss_ = &dnss;
}
void
Resolver::setNameserverAddressStore(isc::nsas::NameserverAddressStore& nsas)
{
nsas_ = &nsas;
}
void
Resolver::setCache(isc::cache::ResolverCache& cache)
{
cache_ = &cache;
}
void
Resolver::setConfigSession(ModuleCCSession* config_session) {
impl_->config_session_ = config_session;
......@@ -544,7 +564,7 @@ Resolver::updateConfig(ConstElementPtr config) {
if (need_query_restart) {
impl_->queryShutdown();
impl_->querySetup(*dnss_);
impl_->querySetup(*dnss_, *nsas_, *cache_);
}
return (isc::config::createAnswer());
} catch (const isc::Exception& error) {
......
......@@ -24,6 +24,9 @@
#include <asiolink/asiolink.h>
#include <nsas/nameserver_address_store.h>
#include <cache/resolver_cache.h>
#include <resolve/resolver_interface.h>
class ResolverImpl;
......@@ -86,10 +89,26 @@ public:
/// \brief Assign an ASIO IO Service queue to this Resolver object
void setDNSService(asiolink::DNSService& dnss);
/// \brief Assign a NameserverAddressStore to this Resolver object
void setNameserverAddressStore(isc::nsas::NameserverAddressStore &nsas);
/// \brief Assign a cache to this Resolver object
void setCache(isc::cache::ResolverCache& cache);
/// \brief Return this object's ASIO IO Service queue
asiolink::DNSService& getDNSService() const { return (*dnss_); }
/// \brief Returns this object's NSAS
isc::nsas::NameserverAddressStore& getNameserverAddressStore() const {
return *nsas_;
};
/// \brief Returns this object's ResolverCache
isc::cache::ResolverCache& getResolverCache() const {
return *cache_;
};
/// \brief Return pointer to the DNS Lookup callback function
asiolink::DNSLookup* getDNSLookupProvider() { return (dns_lookup_); }
......@@ -208,6 +227,8 @@ private:
asiolink::SimpleCallback* checkin_;
asiolink::DNSLookup* dns_lookup_;
asiolink::DNSAnswer* dns_answer_;
isc::nsas::NameserverAddressStore* nsas_;
isc::cache::ResolverCache* cache_;
};
#endif // __RESOLVER_H
......
......@@ -40,6 +40,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
run_unittests_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la
run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
run_unittests_LDADD += $(top_builddir)/src/lib/resolve/libresolve.la
# Note the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS
......
SUBDIRS = exceptions dns cc config datasrc python xfr bench log \
resolve nsas cache asiolink testutils server_common
asiolink nsas cache resolve testutils server_common
......@@ -27,10 +27,9 @@ libasiolink_la_SOURCES += io_endpoint.cc io_endpoint.h
libasiolink_la_SOURCES += io_error.h
libasiolink_la_SOURCES += io_fetch.cc io_fetch.h
libasiolink_la_SOURCES += io_message.h
libasiolink_la_SOURCES += io_service.cc io_service.h
libasiolink_la_SOURCES += io_socket.cc io_socket.h
libasiolink_la_SOURCES += qid_gen.cc qid_gen.h
libasiolink_la_SOURCES += recursive_query.cc recursive_query.h
libasiolink_la_SOURCES += io_service.h io_service.cc
libasiolink_la_SOURCES += io_socket.h io_socket.cc
libasiolink_la_SOURCES += simple_callback.h
libasiolink_la_SOURCES += tcp_endpoint.h
libasiolink_la_SOURCES += tcp_server.cc tcp_server.h
......@@ -44,9 +43,6 @@ EXTRA_DIST = asiodef.msg
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS)
libasiolink_la_CXXFLAGS = $(AM_CXXFLAGS)
if USE_GXX
libasiolink_la_CXXFLAGS += -Wno-unused-parameter
endif
if USE_CLANGPP
# Same for clang++, but we need to turn off -Werror completely.
libasiolink_la_CXXFLAGS += -Wno-error
......
......@@ -25,7 +25,6 @@
#include <asiolink/dns_lookup.h>
#include <asiolink/dns_answer.h>
#include <asiolink/simple_callback.h>
#include <asiolink/recursive_query.h>
#include <asiolink/interval_timer.h>
#include <asiolink/io_address.h>
......
......@@ -255,8 +255,8 @@ TCPSocket<C>::open(const IOEndpoint* endpoint, C& callback) {
// an exception if this is the case.
template <typename C> void
TCPSocket<C>::asyncSend(const void* data, size_t length, const IOEndpoint*,
C& callback)
TCPSocket<C>::asyncSend(const void* data, size_t length,
const IOEndpoint*, C& callback)
{
if (isopen_) {
......
......@@ -25,8 +25,6 @@ run_unittests_SOURCES += io_fetch_unittest.cc
run_unittests_SOURCES += io_socket_unittest.cc
run_unittests_SOURCES += io_service_unittest.cc
run_unittests_SOURCES += interval_timer_unittest.cc
run_unittests_SOURCES += recursive_query_unittest.cc
run_unittests_SOURCES += recursive_query_unittest_2.cc
run_unittests_SOURCES += tcp_endpoint_unittest.cc
run_unittests_SOURCES += tcp_socket_unittest.cc
run_unittests_SOURCES += udp_endpoint_unittest.cc
......
......@@ -53,6 +53,7 @@ endif
run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la
run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif
......
......@@ -21,7 +21,7 @@
/// convenience methods for accessing and updating the information.
#include <stdint.h>
#include "asiolink.h"
#include <asiolink/io_address.h>
namespace isc {
namespace nsas {
......@@ -39,7 +39,7 @@ public:
{}
/// \return Address object
asiolink::IOAddress getAddress() const {
const asiolink::IOAddress& getAddress() const {
return address_;
}
......
......@@ -18,41 +18,4 @@
#include <string>
#include <sys/socket.h>
namespace asiolink {
/// \brief IO Address Dummy Class
///
/// As part of ther resolver, Evan has written the asiolink.h file, which
/// encapsulates some of the boost::asio classes. Until these are checked
/// into trunk and merged with this branch, these dummy classes should fulfill
/// their function.
class IOAddress {
public:
/// \param address_str String representing the address
IOAddress(const std::string& address_str) : address_(address_str)
{}
/// \param Just a virtual destructor
virtual ~ IOAddress() { }
/// \return Textual representation of the address
std::string toText() const
{return address_;}
/// \return Address family of the address
virtual short getFamily() const {
return ((address_.find(".") != std::string::npos) ? AF_INET : AF_INET6);
}
/// \return true if two addresses are equal
bool equal(const IOAddress& address) const
{return (toText() == address.toText());}
private:
std::string address_; ///< Address represented
};
} // namespace asiolink
#endif // __ASIOLINK_H
......@@ -23,7 +23,9 @@ namespace nsas {
void
NameserverAddress::updateRTT(uint32_t rtt) const {
// We delegate it to the address entry inside the nameserver entry
ns_->updateAddressRTT(rtt, address_.getAddress(), family_);
if (ns_) {
ns_->updateAddressRTT(rtt, address_.getAddress(), family_);
}
}
} // namespace nsas
......
......@@ -93,5 +93,18 @@ NameserverAddressStore::lookup(const string& zone, const RRClass& class_code,
zone_obj.second->addCallback(callback, family);
}
void
NameserverAddressStore::cancel(const string& zone,
const RRClass& class_code,
const boost::shared_ptr<AddressRequestCallback>& callback,
AddressFamily family)
{
boost::shared_ptr<ZoneEntry> entry(zone_hash_->get(HashKey(zone,
class_code)));
if (entry) {
entry->removeCallback(callback, family);
}
}
} // namespace nsas
} // namespace isc
......@@ -87,6 +87,13 @@ public:
boost::shared_ptr<AddressRequestCallback> callback, AddressFamily
family = ANY_OK);
/// \brief cancel the given lookup action
///
/// \param callback Callback object that would be called
void cancel(const std::string& zone, const dns::RRClass& class_code,
const boost::shared_ptr<AddressRequestCallback>& callback,
AddressFamily family = ANY_OK);
/// \brief Protected Members
///
/// These members should be private. However, with so few public methods
......
......@@ -35,6 +35,8 @@
#include <dns/question.h>
#include <resolve/resolver_interface.h>
#include <asiolink/io_address.h>
#include "address_entry.h"
#include "nameserver_address.h"
#include "nameserver_entry.h"
......@@ -140,7 +142,7 @@ NameserverEntry::setAddressRTT(const IOAddress& address, uint32_t rtt) {
AddressFamily family(V4_ONLY);
for (;;) {
BOOST_FOREACH(AddressEntry& entry, addresses_[family]) {
if (entry.getAddress().equal(address)) {
if (entry.getAddress().equals(address)) {
entry.setRTT(rtt);
return;
}
......@@ -181,7 +183,7 @@ NameserverEntry::updateAddressRTT(uint32_t rtt,
{
Lock lock(mutex_);
for (size_t i(0); i < addresses_[family].size(); ++ i) {
if (addresses_[family][i].getAddress().equal(address)) {
if (addresses_[family][i].getAddress().equals(address)) {
updateAddressRTTAtIndex(rtt, i, family);
return;
}
......@@ -226,8 +228,9 @@ class NameserverEntry::ResolverCallback :
response_message->getRcode() != isc::dns::Rcode::NOERROR() ||
response_message->getRRCount(isc::dns::Message::SECTION_ANSWER) == 0) {
failureInternal(lock);
return;
}
isc::dns::RRsetIterator rrsi =
response_message->beginSection(isc::dns::Message::SECTION_ANSWER);
const isc::dns::RRsetPtr response = *rrsi;
......
......@@ -54,6 +54,7 @@ endif
run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif
......
......@@ -24,12 +24,12 @@
#include <stdint.h>
#include "../asiolink.h"
#include <asiolink/io_address.h>
#include "../address_entry.h"
static std::string V4A_TEXT("1.2.3.4");
static std::string V4B_TEXT("5.6.7.8");
static std::string V6A_TEXT("2001:dead:beef::0");
static std::string V6A_TEXT("2001:dead:beef::");
static std::string V6B_TEXT("1984:1985::1986:1987");
using namespace asiolink;
......
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