Commit b6e72599 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3391] Fix distcheck issues.

parent 250f56b4
......@@ -1469,7 +1469,6 @@ AC_CONFIG_FILES([compatcheck/Makefile
src/lib/dhcpsrv/tests/Makefile
src/lib/dhcpsrv/tests/test_libraries.h
src/lib/dhcp/tests/Makefile
src/lib/dns/benchmarks/Makefile
src/lib/dns/gen-rdatacode.py
src/lib/dns/Makefile
src/lib/dns/python/Makefile
......@@ -1668,11 +1667,6 @@ fi
cat >> config.report << END
Components:
DHCP: $want_dhcp
DNS: $want_dns
Experimental resolver: $want_experimental_resolver
Features:
$enable_features
......
......@@ -15,7 +15,9 @@
#ifndef ASIOLINK_DNS_SERVICE_H
#define ASIOLINK_DNS_SERVICE_H 1
#include <resolve/resolver_interface.h>
// The commented header occurs to be unused so we remove it to get
// rid of dependency on resolver.
// #include <resolve/resolver_interface.h>
#include <asiolink/io_service.h>
#include <asiolink/simple_callback.h>
......
/resolve_messages.cc
/resolve_messages.h
/s-messages
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
# Define rule to build logging source files from message file
resolve_messages.h resolve_messages.cc: s-messages
s-messages: resolve_messages.mes
$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/resolve/resolve_messages.mes
touch $@
# Tell Automake that the nsasdef.{cc,h} source files are created in the build
# process, so it must create these before doing anything else. Although they
# are a dependency of the library (so will be created from the message file
# anyway), there is no guarantee as to exactly _when_ in the build they will be
# created. As the .h file is included in other sources file (so must be
# present when they are compiled), the safest option is to create it first.
BUILT_SOURCES = resolve_messages.h resolve_messages.cc
CLEANFILES = *.gcno *.gcda resolve_messages.cc resolve_messages.h s-messages
lib_LTLIBRARIES = libb10-resolve.la
libb10_resolve_la_SOURCES = resolve.h resolve.cc
libb10_resolve_la_SOURCES += resolve_log.h resolve_log.cc
libb10_resolve_la_SOURCES += resolver_interface.h
libb10_resolve_la_SOURCES += resolver_callback.h resolver_callback.cc
libb10_resolve_la_SOURCES += response_classifier.cc response_classifier.h
libb10_resolve_la_SOURCES += recursive_query.cc recursive_query.h
nodist_libb10_resolve_la_SOURCES = resolve_messages.h resolve_messages.cc
libb10_resolve_la_LIBADD = $(top_builddir)/src/lib/dns/libb10-dns++.la
libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/log/libb10-log.la
libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/asiodns/libb10-asiodns.la
libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/nsas/libb10-nsas.la
# The message file should be in the distribution.
EXTRA_DIST = resolve_messages.mes
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS)
libb10_resolve_la_CXXFLAGS = $(AM_CXXFLAGS)
libb10_resolve_la_CPPFLAGS = $(AM_CPPFLAGS)
This diff is collapsed.
// Copyright (C) 2011 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.
#ifndef RECURSIVE_QUERY_H
#define RECURSIVE_QUERY_H 1
#include <util/buffer.h>
#include <asiodns/dns_service.h>
#include <asiodns/dns_server.h>
#include <nsas/nameserver_address_store.h>
#include <cache/resolver_cache.h>
namespace isc {
namespace asiodns {
/// \brief RTT Recorder
///
/// Used for testing, this class will hold the set of round-trip times to
/// nameservers for the current recursive query.
///
/// A pointer to an object of this class is passed to RecursiveQuery which in
/// turn passes it to the created RunningQuery class. When a running query
/// completes, its RTT is passed to the RTT Recorder object.
class RttRecorder {
public:
/// \brief Record Time
///
/// Adds a round-trip time to the internal vector of times.
///
/// \param rtt RTT to record.
void addRtt(uint32_t rtt) {
rtt_.push_back(rtt);
}
/// \brief Return RTT Vector
std::vector<uint32_t> getRtt() const {
return rtt_;
}
private:
std::vector<uint32_t> rtt_; ///< Stored round-trip times
};
typedef std::vector<std::pair<std::string, uint16_t> > AddressVector;
/// \brief A Running query
///
/// This base class represents an active running query object;
/// i.e. an outstanding query to an authoritative name server or
/// upstream server (when running in forwarder mode).
///
/// It can not be instantiated directly, but is created by
/// RecursiveQuery::resolve() and RecursiveQuery::forward().
///
/// Its only public method is its destructor, and that should in theory
/// not be called either except in some unit tests. Instances should
/// delete themselves when the query is finished.
class AbstractRunningQuery {
protected:
AbstractRunningQuery() {};
public:
virtual ~AbstractRunningQuery() {};
};
/// \brief Recursive Query
///
/// The \c RecursiveQuery class provides a layer of abstraction around
/// the ASIO code that carries out an upstream query.
class RecursiveQuery {
///
/// \name Constructors
///
//@{
public:
/// \brief Constructor
///
/// This is currently the only way to construct \c RecursiveQuery
/// object. If the addresses of the forward nameservers is specified,
/// and every upstream query will be sent to one random address, and
/// the result sent back directly. If not, it will do full resolving.
///
/// \param dns_service The DNS Service to perform the recursive
/// query on.
/// \param nsas Nameserver address store, used to hold information about zone
/// nameservers.
/// \param cache Resolver cache object, used to hold information about retrieved
/// records.
/// \param upstream Addresses and ports of the upstream servers
/// to forward queries to.
/// \param upstream_root Addresses and ports of the root servers
/// to use when resolving.
/// \param query_timeout Timeout value for queries we sent, in ms
/// \param client_timeout Timeout value for when we send back an
/// error, in ms
/// \param lookup_timeout Timeout value for when we give up, in ms
/// \param retries how many times we try again (0 means just send and
/// and return if it returs).
RecursiveQuery(DNSServiceBase& dns_service,
isc::nsas::NameserverAddressStore& nsas,
isc::cache::ResolverCache& cache,
const std::vector<std::pair<std::string, uint16_t> >&
upstream,
const std::vector<std::pair<std::string, uint16_t> >&
upstream_root,
int query_timeout = 2000,
int client_timeout = 4000,
int lookup_timeout = 30000,
unsigned retries = 3);
//@}
/// \brief Set Round-Trip Time Recorder
///
/// Sets the RTT recorder object. This is not accessed directly, instead
/// it is passed to created RunningQuery objects.
///
/// \param recorder Pointer to the RTT recorder object used to hold RTTs.
void setRttRecorder(boost::shared_ptr<RttRecorder>& recorder);
/// \brief Initiate resolving
///
/// When sendQuery() is called, a (set of) message(s) is sent
/// asynchronously. If upstream servers are set, one is chosen
/// and the response (if any) from that server will be returned.
///
/// If not upstream is set, a root server is chosen from the
/// root_servers, and the RunningQuery shall do a full resolve
/// (i.e. if the answer is a delegation, it will be followed, etc.)
/// until there is an answer or an error.
///
/// When there is a response or an error and we give up, the given
/// CallbackPtr object shall be called (with either success() or
/// failure(). See ResolverInterface::Callback for more information.
///
/// \param question The question being answered <qname/qclass/qtype>
/// \param callback Callback object. See
/// \c ResolverInterface::Callback for more information
AbstractRunningQuery* resolve(const isc::dns::QuestionPtr& question,
const isc::resolve::ResolverInterface::CallbackPtr callback);
/// \brief Initiates resolving for the given question.
///
/// This actually calls the previous sendQuery() with a default
/// callback object, which calls resume() on the given DNSServer
/// object.
///
/// \param question The question being answered <qname/qclass/qtype>
/// \param answer_message An output Message into which the final response will
/// be copied.
/// \param buffer An output buffer into which the intermediate responses will
/// be copied.
/// \param server A pointer to the \c DNSServer object handling the client
/// \return A pointer to the active AbstractRunningQuery object
/// created by this call (if any); this object should delete
/// itself in normal circumstances, and can normally be ignored
/// by the caller, but a pointer is returned for use-cases
/// such as unit tests.
/// Returns NULL if the data was found internally and no actual
/// query was sent.
AbstractRunningQuery* resolve(const isc::dns::Question& question,
isc::dns::MessagePtr answer_message,
isc::util::OutputBufferPtr buffer,
DNSServer* server);
/// \brief Initiates forwarding for the given query.
///
/// Others parameters are same with the parameters of
/// function resolve().
///
/// \param query_message the full query got from client.
/// \param answer_message the full answer received from other server.
/// \param buffer Output buffer into which the responses will be copied.
/// \param server Server object that handles receipt and processing of the
/// received messages.
/// \param callback callback object
/// \return A pointer to the active ForwardQuery created by this call;
/// this object should delete itself in normal circumstances,
/// and can normally be ignored by the caller, but a pointer
/// is returned for use-cases such as unit tests.
AbstractRunningQuery* forward(isc::dns::ConstMessagePtr query_message,
isc::dns::MessagePtr answer_message,
isc::util::OutputBufferPtr buffer,
DNSServer* server,
isc::resolve::ResolverInterface::CallbackPtr callback =
isc::resolve::ResolverInterface::CallbackPtr());
/// \brief Set Test Server
///
/// This method is *only* for unit testing the class. If set, it enables
/// recursive behaviour but, regardless of responses received, sends every
/// query to the test server.
///
/// The test server is enabled by setting a non-zero port number.
///
/// \param address IP address of the test server.
/// \param port Port number of the test server
void setTestServer(const std::string& address, uint16_t port);
private:
DNSServiceBase& dns_service_;
isc::nsas::NameserverAddressStore& nsas_;
isc::cache::ResolverCache& cache_;
boost::shared_ptr<std::vector<std::pair<std::string, uint16_t> > >
upstream_;
boost::shared_ptr<std::vector<std::pair<std::string, uint16_t> > >
upstream_root_;
std::pair<std::string, uint16_t> test_server_;
int query_timeout_;
int client_timeout_;
int lookup_timeout_;
unsigned retries_;
boost::shared_ptr<RttRecorder> rtt_recorder_; ///< Round-trip time recorder
};
} // namespace asiodns
} // namespace isc
#endif // RECURSIVE_QUERY_H
// Copyright (C) 2011 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.
#include <resolve/resolve.h>
#include <dns/message.h>
#include <dns/opcode.h>
using namespace isc::dns;
namespace {
class SectionInserter {
public:
SectionInserter(MessagePtr message, const Message::Section sect) :
message_(message), section_(sect)
{}
void operator()(const RRsetPtr rrset) {
message_->addRRset(section_, rrset);
}
MessagePtr message_;
const Message::Section section_;
};
}
namespace isc {
namespace resolve {
void
makeErrorMessage(MessagePtr answer_message,
const Rcode& error_code)
{
answer_message->clearSection(Message::SECTION_ANSWER);
answer_message->clearSection(Message::SECTION_AUTHORITY);
answer_message->clearSection(Message::SECTION_ADDITIONAL);
answer_message->setRcode(error_code);
}
void initResponseMessage(const isc::dns::Message& query_message,
isc::dns::Message& response_message)
{
response_message.setOpcode(query_message.getOpcode());
response_message.setQid(query_message.getQid());
assert(response_message.getRRCount(Message::SECTION_QUESTION) == 0);
response_message.appendSection(Message::SECTION_QUESTION,
query_message);
}
void initResponseMessage(const isc::dns::Question& question,
isc::dns::Message& response_message)
{
response_message.setOpcode(isc::dns::Opcode::QUERY());
response_message.addQuestion(question);
}
void copyResponseMessage(const Message& source, MessagePtr target) {
target->setRcode(source.getRcode());
target->appendSection(Message::SECTION_ANSWER, source);
target->appendSection(Message::SECTION_AUTHORITY, source);
target->appendSection(Message::SECTION_ADDITIONAL, source);
}
} // namespace resolve
} // namespace isc
// Copyright (C) 2011 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.
#ifndef ISC_RESOLVE_H
#define ISC_RESOLVE_H 1
/// This file includes all other libresolve headers, and provides
/// several helper functions used in resolving.
#include <resolve/resolver_interface.h>
#include <resolve/resolver_callback.h>
#include <resolve/response_classifier.h>
#include <dns/rcode.h>
namespace isc {
namespace resolve {
/// \brief Create an error response
///
/// Clears the answer, authority, and additional section of the
/// given MessagePtr and sets the given error code
///
/// Notes: Assuming you have already done initial preparations
/// on the given answer message (copy the opcode, qid and question
/// section), you can simply use this to create an error response.
///
/// \param answer_message The message to clear and place the error in
/// \param error_code The error Rcode
void makeErrorMessage(isc::dns::MessagePtr answer_message,
const isc::dns::Rcode& error_code);
/// \brief Initialize a response message
///
/// Based on the given query message, this fills in the very
/// first details of the response (i.e. the Question section and
/// the Opcode). This allows for direct usage of makeErrorMessage(),
/// as well as ResolveCache.lookup().
///
/// Raises an isc::dns::InvalidMessageOperation if reponse_message is
/// not in RENDER mode.
///
/// \param query_message The query message to take the Question, Qid,
/// and Opcode from.
/// \param response_message The fresh response message to initialize
/// (must be in RENDER mode)
void initResponseMessage(const isc::dns::Message& query_message,
isc::dns::Message& response_message);
/// \brief Initialize a response message
///
/// Based on the given question, this fills in the very
/// first details of the response (i.e. the Question section and the
/// Opcode Query). This allows for direct usage of makeErrorMessage(),
/// as well as ResolveCache.lookup().
///
/// Raises an isc::dns::InvalidMessageOperation if reponse_message is
/// not in RENDER mode.
///
/// \param question The question to place in the Question section
/// \param response_message The fresh response message to initialize
/// (must be in RENDER mode)
void initResponseMessage(const isc::dns::Question& question,
isc::dns::Message& response_message);
/// \brief Copies the parts relevant for a DNS response to the
/// target message
///
/// This adds all the RRsets in the answer, authority and
/// additional sections to the target, as well as the response
/// code
/// \param source The Message to copy the data from
/// \param target The Message to copy the data to
void copyResponseMessage(const isc::dns::Message& source,
isc::dns::MessagePtr target);
} // namespace resolve
} // namespace isc
#endif // ISC_RESOLVE_H_
// Copyright (C) 2011 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.
/// Defines the logger used by the NSAS
#include <resolve/resolve_log.h>
namespace isc {
namespace resolve {
isc::log::Logger logger("reslib"); // Distinct from "resolver"
} // namespace resolve
} // namespace isc
// Copyright (C) 2011 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.
#ifndef RESOLVE_LOG_H
#define RESOLVE_LOG_H
#include <log/macros.h>
#include "resolve_messages.h"
namespace isc {
namespace resolve {
/// \brief Resolver Library Logging
///
/// Defines the levels used to output debug messages in the resolver library.
/// Note that higher numbers equate to more verbose (and detailed) output.
// The first level traces normal operations
const int RESLIB_DBG_TRACE = DBGLVL_TRACE_BASIC;
// The next level extends the normal operations and records the results of the
// lookups.
const int RESLIB_DBG_RESULTS = DBGLVL_TRACE_BASIC_DATA;
// Report cache lookups and results
const int RESLIB_DBG_CACHE = DBGLVL_TRACE_DETAIL_DATA;
// Indicate when callbacks are called
const int RESLIB_DBG_CB = DBGLVL_TRACE_DETAIL_DATA + 10;
/// \brief Resolver Library Logger
///
/// Define the logger used to log messages. We could define it in multiple
/// modules, but defining in a single module and linking to it saves time and
/// space.
extern isc::log::Logger logger;
} // namespace resolve
} // namespace isc
#endif // RESOLVE_LOG_H
# Copyright (C) 2011 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.
$NAMESPACE isc::resolve
% RESLIB_ANSWER answer received in response to query for <%1>
A debug message reporting that an answer has been received to an upstream
query for the specified question. Previous debug messages will have
indicated the server to which the question was sent.
% RESLIB_CNAME CNAME received in response to query for <%1>
A debug message recording that CNAME response has been received to an
upstream query for the specified question. Previous debug messages will
have indicated the server to which the question was sent.
% RESLIB_DEEPEST did not find <%1> in cache, deepest delegation found is %2
A debug message, a cache lookup did not find the specified <name,
class, type> tuple in the cache; instead, the deepest delegation found
is indicated.
% RESLIB_EMPTY_RESPONSE empty response received to query for <%1>
A debug message, the response to the specified query from an upstream
nameserver did not contain anything in the answer or authority sections,
although in all other respects it was a valid response. A SERVFAIL will
be returned to the system making the original query.
% RESLIB_ERROR_RESPONSE unspecified error received in response to query for <%1>
A debug message, the response to the specified query to an upstream
nameserver indicated that the response was classified as an erroneous
response, but that the nature of the error cannot be identified.
A SERVFAIL will be returned to the system making the original query.
% RESLIB_EXTRADATA_RESPONSE extra data in response to query for <%1>
A debug message indicating that the response to the specified query
from an upstream nameserver contained too much data. This can happen if
an ANY query was sent and the answer section in the response contained
multiple RRs with different names. A SERVFAIL will be returned to the
system making the original query.