mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-03 07:25:18 +00:00
[#3316] fixed doxygen
This commit is contained in:
@@ -1596,8 +1596,6 @@ AC_CONFIG_FILES([src/lib/cc/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/cc/tests/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/config/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/config/tests/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/config/tests/data_def_unittests_config.h])
|
||||
AC_CONFIG_FILES([src/lib/config/tests/testdata/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/config_backend/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/config_backend/tests/Makefile])
|
||||
AC_CONFIG_FILES([src/lib/cryptolink/Makefile])
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
#include <dhcp4/dhcp4_log.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
|
@@ -14,10 +14,13 @@ int
|
||||
main(int argc, char* argv[]) {
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
// See the documentation of the KEA_* environment variables in
|
||||
// src/lib/log/README for info on how to tweak logging
|
||||
isc::log::initLogger();
|
||||
|
||||
setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1);
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return result;
|
||||
return (result);
|
||||
}
|
||||
|
@@ -1,19 +1,18 @@
|
||||
// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the End User License
|
||||
// Agreement. See COPYING file in the premium/ directory.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -1,19 +1,18 @@
|
||||
// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the End User License
|
||||
// Agreement. See COPYING file in the premium/ directory.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -1,19 +1,18 @@
|
||||
// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the End User License
|
||||
// Agreement. See COPYING file in the premium/ directory.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
|
@@ -1,19 +1,18 @@
|
||||
// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the End User License
|
||||
// Agreement. See COPYING file in the premium/ directory.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -1,19 +1,18 @@
|
||||
// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the End User License
|
||||
// Agreement. See COPYING file in the premium/ directory.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
|
@@ -1,19 +1,18 @@
|
||||
// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the End User License
|
||||
// Agreement. See COPYING file in the premium/ directory.
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -7,14 +7,12 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <log/logger_support.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
|
||||
int result = RUN_ALL_TESTS();
|
||||
|
||||
return (result);
|
||||
|
@@ -7,6 +7,8 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS)
|
||||
|
||||
CLEANFILES = *.gcno *.gcda
|
||||
|
||||
EXTRA_DIST = asiodns_messages.mes
|
||||
|
||||
lib_LTLIBRARIES = libkea-asiodns.la
|
||||
|
||||
libkea_asiodns_la_LDFLAGS = -no-undefined -version-info 47:0:0
|
||||
@@ -15,10 +17,7 @@ libkea_asiodns_la_SOURCES = io_fetch.cc io_fetch.h
|
||||
libkea_asiodns_la_SOURCES += logger.h logger.cc
|
||||
libkea_asiodns_la_SOURCES += asiodns_messages.cc asiodns_messages.h
|
||||
|
||||
EXTRA_DIST = asiodns_messages.mes
|
||||
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
|
||||
# KEA_CXXFLAGS)
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS)
|
||||
libkea_asiodns_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libkea_asiodns_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
libkea_asiodns_la_LIBADD = $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
|
||||
|
@@ -1,154 +0,0 @@
|
||||
The asiodns library is intended to provide an abstraction layer between
|
||||
BIND10 modules and asiolink library.
|
||||
|
||||
These DNS server and client routines are written using the "stackless
|
||||
coroutine" pattern invented by Chris Kohlhoff and described at
|
||||
http://blog.think-async.com/2010/03/potted-guide-to-stackless-coroutines.html.
|
||||
This is intended to simplify development a bit, since it allows the
|
||||
routines to be written in a straightforward step-step-step fashion rather
|
||||
than as a complex chain of separate handler functions.
|
||||
|
||||
Coroutine objects (i.e., UDPServer, TCPServer and IOFetch) are objects
|
||||
with reentrant operator() members. When an instance of one of these
|
||||
classes is called as a function, it resumes at the position where it left
|
||||
off. Thus, a UDPServer can issue an asynchronous I/O call and specify
|
||||
itself as the handler object; when the call completes, the UDPServer
|
||||
carries on at the same position. As a result, the code can look as
|
||||
if it were using synchronous, not asynchronous, I/O, providing some of
|
||||
the benefit of threading but with minimal switching overhead.
|
||||
|
||||
So, in simplified form, the behavior of a DNS Server is:
|
||||
|
||||
REENTER:
|
||||
while true:
|
||||
YIELD packet = read_packet
|
||||
FORK
|
||||
if not parent:
|
||||
break
|
||||
|
||||
YIELD answer = DNSLookup(packet, this)
|
||||
response = DNSAnswer(answer)
|
||||
YIELD send(response)
|
||||
|
||||
At each "YIELD" point, the coroutine initiates an asynchronous operation,
|
||||
then pauses and turns over control to some other task on the ASIO service
|
||||
queue. When the operation completes, the coroutine resumes.
|
||||
|
||||
DNSLookup and DNSAnswer define callback methods
|
||||
used by a DNS Server to communicate with the module that called it.
|
||||
They are abstract-only classes whose concrete implementations
|
||||
are supplied by the calling module.
|
||||
|
||||
The DNSLookup callback always runs asynchronously. Concrete
|
||||
implementations must be sure to call the server's "resume" method when
|
||||
it is finished.
|
||||
|
||||
In an authoritative server, the DNSLookup implementation would examine
|
||||
the query, look up the answer, then call "resume". (See the diagram
|
||||
in doc/auth_process.jpg.)
|
||||
|
||||
In a recursive server, the DNSLookup implementation would initiate a
|
||||
DNSQuery, which in turn would be responsible for calling the server's
|
||||
"resume" method. (See the diagram in doc/recursive_process.jpg.)
|
||||
|
||||
A DNSQuery object is intended to handle resolution of a query over
|
||||
the network when the local authoritative data sources or cache are not
|
||||
sufficient. The plan is that it will make use of subsidiary DNSFetch
|
||||
calls to get data from particular authoritative servers, and when it has
|
||||
gotten a complete answer, it calls "resume".
|
||||
|
||||
In current form, however, DNSQuery is much simpler; it forwards queries
|
||||
to a single upstream resolver and passes the answers back to the client.
|
||||
It is constructed with the address of the forward server. Queries are
|
||||
initiated with the question to ask the forward server, a buffer into
|
||||
which to write the answer, and a pointer to the coroutine to be resumed
|
||||
when the answer has arrived. In simplified form, the DNSQuery routine is:
|
||||
|
||||
REENTER:
|
||||
render the question into a wire-format query packet
|
||||
YIELD send(query)
|
||||
YIELD response = read_packet
|
||||
server->resume
|
||||
|
||||
Currently, DNSQuery is only implemented for UDP queries. In future work
|
||||
it will be necessary to write code to fall back to TCP when circumstances
|
||||
require it.
|
||||
|
||||
|
||||
Upstream Fetches
|
||||
================
|
||||
Upstream fetches (queries by the resolver on behalf of a client) are made
|
||||
using a slightly-modified version of the pattern described above.
|
||||
|
||||
Sockets
|
||||
-------
|
||||
First, it will be useful to understand the class hierarchy used in the
|
||||
fetch logic:
|
||||
|
||||
IOSocket
|
||||
|
|
||||
IOAsioSocket
|
||||
|
|
||||
+-----+-----+
|
||||
| |
|
||||
UDPSocket TCPSocket
|
||||
|
||||
IOSocket is a wrapper class for a socket and is used by the authoritative
|
||||
server code. It is an abstract base class, providing little more that the ability to hold the socket and to return the protocol in use.
|
||||
|
||||
Built on this is IOAsioSocket, which adds the open, close, asyncSend and
|
||||
asyncReceive methods. This is a template class, which takes as template
|
||||
argument the class of the object that will be used as the callback when the
|
||||
asynchronous operation completes. This object can be of any type, but must
|
||||
include an operator() method with the signature:
|
||||
|
||||
operator()(boost::system::error_code ec, size_t length)
|
||||
|
||||
... the two arguments being the status of the completed I/O operation and
|
||||
the number of bytes transferred. (In the case of the open method, the second
|
||||
argument will be zero.)
|
||||
|
||||
Finally, the TCPSocket and UDPSocket classes provide the body of the
|
||||
asynchronous operations.
|
||||
|
||||
Fetch Sequence
|
||||
--------------
|
||||
The fetch is implemented by the IOFetch class, which takes as argument the
|
||||
protocol to use. The sequence is:
|
||||
|
||||
REENTER:
|
||||
render the question into a wire-format query packet
|
||||
open() // Open socket and optionally connect
|
||||
if (! synchronous) {
|
||||
YIELD;
|
||||
}
|
||||
YIELD asyncSend(query) // Send query
|
||||
do {
|
||||
YIELD asyncReceive(response) // Read response
|
||||
} while (! complete(response))
|
||||
close() // Drop connection and close socket
|
||||
server->resume
|
||||
|
||||
The open() method opens a socket for use. On TCP, it also makes a
|
||||
connection to the remote end. So under UDP the operation will complete
|
||||
immediately, but under TCP it could take a long time. One solution would be
|
||||
for the open operation to post an event to the I/O queue; then both cases
|
||||
could be regarded as being equivalent, with the completion being signalled
|
||||
by the posting of the completion event. However UDP is the most common case
|
||||
and that would involve extra overhead. So the open() returns a status
|
||||
indicating whether the operation completed asynchronously. If it did, the
|
||||
code yields back to the coroutine; if not the yield is bypassed.
|
||||
|
||||
The asynchronous send is straightforward, invoking the underlying ASIO
|
||||
function. (Note that the address/port is supplied to both the open() and
|
||||
asyncSend() methods - it is used by the TCPSocket in open() and by the
|
||||
UDPSocket in asyncSend().)
|
||||
|
||||
The asyncReceive() method issues an asynchronous read and waits for completion.
|
||||
The fetch object keeps track of the amount of data received so far and when
|
||||
the receive completes it calls a method on the socket to determine if the
|
||||
entire message has been received. (This will always be the case for UDP. On
|
||||
TCP though, the message is preceded by a count field as several reads may be
|
||||
required to read all the data.) The fetch loops until all the data is read.
|
||||
|
||||
Finally, the socket is closed and the server called to resume operation.
|
150
src/lib/asiodns/asiodns.dox
Normal file
150
src/lib/asiodns/asiodns.dox
Normal file
@@ -0,0 +1,150 @@
|
||||
The asiodns library is intended to provide an abstraction layer between Kea
|
||||
modules and asiolink library.
|
||||
|
||||
These DNS server and client routines are written using the "stackless coroutine"
|
||||
pattern invented by Chris Kohlhoff and described at:
|
||||
http://blog.think-async.com/2010/03/potted-guide-to-stackless-coroutines.html.
|
||||
This is intended to simplify development a bit, since it allows the routines to
|
||||
be written in a straightforward step-step-step fashion rather than as a complex
|
||||
chain of separate handler functions.
|
||||
|
||||
Coroutine objects (i.e., UDPServer, TCPServer and IOFetch) are objects with
|
||||
reentrant operator() members. When an instance of one of these classes is
|
||||
called as a function, it resumes at the position where it left off. Thus, an
|
||||
UDPServer can issue an asynchronous I/O call and specify itself as the handler
|
||||
object; when the call completes, the UDPServer carries on at the same position.
|
||||
As a result, the code can look as if it were using synchronous, not asynchronous
|
||||
I/O, providing some of the benefit of threading but with minimal switching
|
||||
overhead.
|
||||
|
||||
So, in simplified form, the behavior of a DNS Server is:
|
||||
|
||||
REENTER:
|
||||
while true:
|
||||
YIELD packet = read_packet
|
||||
FORK
|
||||
if not parent:
|
||||
break
|
||||
|
||||
YIELD answer = DNSLookup(packet, this)
|
||||
response = DNSAnswer(answer)
|
||||
YIELD send(response)
|
||||
|
||||
At each "YIELD" point, the coroutine initiates an asynchronous operation, then
|
||||
pauses and turns over control to some other task on the ASIO service queue. When
|
||||
the operation completes, the coroutine resumes.
|
||||
|
||||
The DNSLookup and DNSAnswer define callback methods used by a DNS Server to
|
||||
communicate with the module that called it. They are abstract-only classes whose
|
||||
concrete implementations are supplied by the calling module.
|
||||
|
||||
The DNSLookup callback always runs asynchronously. Concrete implementations must
|
||||
be sure to call the server's "resume" method when it is finished.
|
||||
|
||||
In an authoritative server, the DNSLookup implementation would examine the query,
|
||||
look up the answer, then call "resume" (See the diagram in doc/auth_process.jpg).
|
||||
|
||||
In a recursive server, the DNSLookup implementation would initiate a DNSQuery,
|
||||
which in turn would be responsible for calling the server's "resume" method
|
||||
(See the diagram in doc/recursive_process.jpg).
|
||||
|
||||
A DNSQuery object is intended to handle resolution of a query over the network
|
||||
when the local authoritative data sources or cache are not sufficient. The plan
|
||||
is that it will make use of subsidiary DNSFetch calls to get data from\
|
||||
particular authoritative servers, and when it has gotten a complete answer, it
|
||||
calls "resume".
|
||||
|
||||
In current form, however, DNSQuery is much simpler; it forwards queries to a
|
||||
single upstream resolver and passes the answers back to the client. It is
|
||||
constructed with the address of the forward server. Queries are initiated with
|
||||
the question to ask the forward server, a buffer into which to write the answer,
|
||||
and a pointer to the coroutine to be resumed when the answer has arrived. In
|
||||
simplified form, the DNSQuery routine is:
|
||||
|
||||
REENTER:
|
||||
render the question into a wire-format query packet
|
||||
YIELD send(query)
|
||||
YIELD response = read_packet
|
||||
server->resume
|
||||
|
||||
Currently, DNSQuery is only implemented for UDP queries. In future work it will
|
||||
be necessary to write code to fall back to TCP when circumstances require it.
|
||||
|
||||
Upstream Fetches
|
||||
================
|
||||
Upstream fetches (queries by the resolver on behalf of a client) are made using
|
||||
a slightly-modified version of the pattern described above.
|
||||
|
||||
Sockets
|
||||
-------
|
||||
First, it will be useful to understand the class hierarchy used in the fetch
|
||||
logic:
|
||||
|
||||
IOSocket
|
||||
|
|
||||
IOAsioSocket
|
||||
|
|
||||
+-----+-----+
|
||||
| |
|
||||
UDPSocket TCPSocket
|
||||
|
||||
IOSocket is a wrapper class for a socket and is used by the authoritative server
|
||||
code. It is an abstract base class, providing little more that the ability to
|
||||
hold the socket and to return the protocol in use.
|
||||
|
||||
Built on this is the IOAsioSocket, which adds the open, close, asyncSend and
|
||||
asyncReceive methods. This is a template class, which takes as template argument
|
||||
the class of the object that will be used as the callback when the asynchronous
|
||||
operation completes. This object can be of any type, but must include an
|
||||
operator() method with the signature:
|
||||
|
||||
operator()(boost::system::error_code ec, size_t length)
|
||||
|
||||
... the two arguments being the status of the completed I/O operation and the
|
||||
number of bytes transferred (in the case of the open method, the second argument
|
||||
will be zero).
|
||||
|
||||
Finally, the TCPSocket and UDPSocket classes provide the body of the
|
||||
asynchronous operations.
|
||||
|
||||
Fetch Sequence
|
||||
--------------
|
||||
The fetch is implemented by the IOFetch class which takes as argument the
|
||||
protocol to use. The sequence is:
|
||||
|
||||
REENTER:
|
||||
render the question into a wire-format query packet
|
||||
open() // Open socket and optionally connect
|
||||
if (! synchronous) {
|
||||
YIELD;
|
||||
}
|
||||
YIELD asyncSend(query) // Send query
|
||||
do {
|
||||
YIELD asyncReceive(response) // Read response
|
||||
} while (! complete(response))
|
||||
close() // Drop connection and close socket
|
||||
server->resume
|
||||
|
||||
The open() method opens a socket for use. On TCP, it also makes a connection to
|
||||
the remote end. So under UDP the operation will complete immediately, but under
|
||||
TCP it could take a long time. One solution would befor the open operation to
|
||||
post an event to the I/O queue; then both cases could be regarded as being
|
||||
equivalent, with the completion being signalled by the posting of the completion
|
||||
event. However UDP is the most common case and that would involve extra overhead.
|
||||
So the open() returns a status indicating whether the operation completed
|
||||
asynchronously. If it did, the code yields back to the coroutine; if not the
|
||||
yield is bypassed.
|
||||
|
||||
The asynchronous send is straightforward, invoking the underlying ASIO function.
|
||||
Note that the address/port is supplied to both the open() and asyncSend()
|
||||
methods - it is used by the TCPSocket in open() and by the UDPSocket in
|
||||
asyncSend().
|
||||
|
||||
The asyncReceive() method issues an asynchronous read and waits for completion.
|
||||
The fetch object keeps track of the amount of data received so far and when the
|
||||
receive completes it calls a method on the socket to determine if the entire
|
||||
message has been received. This will always be the case for UDP. On TCP though,
|
||||
the message is preceded by a count field as several reads may be required to
|
||||
read all the data. The fetch loops until all the data is read.
|
||||
|
||||
Finally, the socket is closed and the server called to resume operation.
|
@@ -20,7 +20,6 @@
|
||||
#include <dns/opcode.h>
|
||||
#include <cryptolink/crypto_rng.h>
|
||||
#include <dns/rcode.h>
|
||||
#include <util/buffer.h>
|
||||
#include <util/io.h>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
@@ -32,23 +31,24 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
using namespace boost::asio;
|
||||
using namespace isc::asiolink;
|
||||
using namespace isc::dns;
|
||||
using namespace isc::util;
|
||||
using namespace isc::log;
|
||||
using namespace isc::util;
|
||||
|
||||
using namespace boost::asio;
|
||||
using namespace std;
|
||||
|
||||
namespace isc {
|
||||
namespace asiodns {
|
||||
|
||||
// Log debug verbosity
|
||||
// Log debug verbosity.
|
||||
|
||||
const int DBG_IMPORTANT = DBGLVL_TRACE_BASIC;
|
||||
const int DBG_COMMON = DBGLVL_TRACE_DETAIL;
|
||||
const int DBG_ALL = DBGLVL_TRACE_DETAIL + 20;
|
||||
|
||||
/// \brief IOFetch Data
|
||||
/// @brief IOFetch Data
|
||||
///
|
||||
/// The data for IOFetch is held in a separate struct pointed to by a shared_ptr
|
||||
/// object. This is because the IOFetch object will be copied often (it is used
|
||||
@@ -56,111 +56,94 @@ const int DBG_ALL = DBGLVL_TRACE_DETAIL + 20;
|
||||
/// want keep the same data). Organising the data in this way keeps copying to
|
||||
/// a minimum.
|
||||
struct IOFetchData : boost::noncopyable {
|
||||
IOServicePtr io_service_; ///< The IO service
|
||||
IOServicePtr io_service_; // The IO service
|
||||
// The first two members are shared pointers to a base class because what is
|
||||
// actually instantiated depends on whether the fetch is over UDP or TCP,
|
||||
// which is not known until construction of the IOFetch. Use of a shared
|
||||
// pointer here is merely to ensure deletion when the data object is deleted.
|
||||
boost::scoped_ptr<IOAsioSocket<IOFetch>> socket; ///< Socket to use for I/O
|
||||
boost::scoped_ptr<IOEndpoint> remote_snd; ///< Where the fetch is sent
|
||||
boost::scoped_ptr<IOEndpoint> remote_rcv; ///< Where the response came from
|
||||
OutputBufferPtr msgbuf; ///< Wire buffer for question
|
||||
OutputBufferPtr received; ///< Received data put here
|
||||
IOFetch::Callback* callback; ///< Called on I/O Completion
|
||||
boost::asio::deadline_timer timer; ///< Timer to measure timeouts
|
||||
IOFetch::Protocol protocol; ///< Protocol being used
|
||||
size_t cumulative; ///< Cumulative received amount
|
||||
size_t expected; ///< Expected amount of data
|
||||
size_t offset; ///< Offset to receive data
|
||||
bool stopped; ///< Have we stopped running?
|
||||
int timeout; ///< Timeout in ms
|
||||
bool packet; ///< true if packet was supplied
|
||||
boost::scoped_ptr<IOAsioSocket<IOFetch>> socket; // Socket to use for I/O
|
||||
boost::scoped_ptr<IOEndpoint> remote_snd; // Where the fetch is sent
|
||||
boost::scoped_ptr<IOEndpoint> remote_rcv; // Where the response came from
|
||||
OutputBufferPtr msgbuf; // Wire buffer for question
|
||||
OutputBufferPtr received; // Received data put here
|
||||
IOFetch::Callback* callback; // Called on I/O Completion
|
||||
boost::asio::deadline_timer timer; // Timer to measure timeouts
|
||||
IOFetch::Protocol protocol; // Protocol being used
|
||||
size_t cumulative; // Cumulative received amount
|
||||
size_t expected; // Expected amount of data
|
||||
size_t offset; // Offset to receive data
|
||||
bool stopped; // Have we stopped running?
|
||||
int timeout; // Timeout in ms
|
||||
bool packet; // true if packet was supplied
|
||||
|
||||
// In case we need to log an error, the origin of the last asynchronous
|
||||
// I/O is recorded. To save time and simplify the code, this is recorded
|
||||
// as the ID of the error message that would be generated if the I/O failed.
|
||||
// This means that we must make sure that all possible "origins" take the
|
||||
// same arguments in their message in the same order.
|
||||
isc::log::MessageID origin; ///< Origin of last asynchronous I/O
|
||||
isc::log::MessageID origin; // Origin of last asynchronous I/O
|
||||
uint8_t staging[IOFetch::STAGING_LENGTH];
|
||||
///< Temporary array for received data
|
||||
isc::dns::qid_t qid; ///< The QID set in the query
|
||||
// Temporary array for received data
|
||||
isc::dns::qid_t qid; // The QID set in the query
|
||||
|
||||
/// \brief Constructor
|
||||
/// @brief Constructor.
|
||||
///
|
||||
/// Just fills in the data members of the IOFetchData structure
|
||||
/// Just fills in the data members of the IOFetchData structure.
|
||||
///
|
||||
/// \param proto Either IOFetch::TCP or IOFetch::UDP.
|
||||
/// \param service I/O Service object to handle the asynchronous
|
||||
/// @param proto Either IOFetch::TCP or IOFetch::UDP.
|
||||
/// @param service I/O Service object to handle the asynchronous
|
||||
/// operations.
|
||||
/// \param address IP address of upstream server
|
||||
/// \param port Port to use for the query
|
||||
/// \param buff Output buffer into which the response (in wire format)
|
||||
/// @param address IP address of upstream server.
|
||||
/// @param port Port to use for the query.
|
||||
/// @param buff Output buffer into which the response (in wire format)
|
||||
/// is written (if a response is received).
|
||||
/// \param cb Callback object containing the callback to be called
|
||||
/// @param cb Callback object containing the callback to be called
|
||||
/// when we terminate. The caller is responsible for managing this
|
||||
/// object and deleting it if necessary.
|
||||
/// \param wait Timeout for the fetch (in ms).
|
||||
/// @param wait Timeout for the fetch (in ms).
|
||||
///
|
||||
/// TODO: May need to alter constructor (see comment 4 in Trac ticket #554)
|
||||
/// TODO: May need to alter constructor (see comment 4 in Trac ticket #554).
|
||||
IOFetchData(IOFetch::Protocol proto, const IOServicePtr& service,
|
||||
const IOAddress& address, uint16_t port, OutputBufferPtr& buff,
|
||||
IOFetch::Callback* cb, int wait) : io_service_(service),
|
||||
socket((proto == IOFetch::UDP) ?
|
||||
static_cast<IOAsioSocket<IOFetch>*>(
|
||||
new UDPSocket<IOFetch>(io_service_)) :
|
||||
static_cast<IOAsioSocket<IOFetch>*>(
|
||||
new TCPSocket<IOFetch>(io_service_))
|
||||
),
|
||||
IOFetch::Callback* cb, int wait) :
|
||||
io_service_(service), socket((proto == IOFetch::UDP) ?
|
||||
static_cast<IOAsioSocket<IOFetch>*>(new UDPSocket<IOFetch>(io_service_)) :
|
||||
static_cast<IOAsioSocket<IOFetch>*>(new TCPSocket<IOFetch>(io_service_))),
|
||||
remote_snd((proto == IOFetch::UDP) ?
|
||||
static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) :
|
||||
static_cast<IOEndpoint*>(new TCPEndpoint(address, port))
|
||||
),
|
||||
static_cast<IOEndpoint*>(new TCPEndpoint(address, port))),
|
||||
remote_rcv((proto == IOFetch::UDP) ?
|
||||
static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) :
|
||||
static_cast<IOEndpoint*>(new TCPEndpoint(address, port))
|
||||
),
|
||||
msgbuf(new OutputBuffer(512)),
|
||||
received(buff),
|
||||
callback(cb),
|
||||
timer(io_service_->getInternalIOService()),
|
||||
protocol(proto),
|
||||
cumulative(0),
|
||||
expected(0),
|
||||
offset(0),
|
||||
stopped(false),
|
||||
timeout(wait),
|
||||
packet(false),
|
||||
origin(ASIODNS_UNKNOWN_ORIGIN),
|
||||
staging(),
|
||||
qid(cryptolink::generateQid()) {
|
||||
static_cast<IOEndpoint*>(new TCPEndpoint(address, port))),
|
||||
msgbuf(new OutputBuffer(512)), received(buff), callback(cb),
|
||||
timer(io_service_->getInternalIOService()), protocol(proto), cumulative(0),
|
||||
expected(0), offset(0), stopped(false), timeout(wait), packet(false),
|
||||
origin(ASIODNS_UNKNOWN_ORIGIN), staging(), qid(cryptolink::generateQid()) {
|
||||
}
|
||||
|
||||
/// \brief Destructor
|
||||
/// @brief Destructor
|
||||
~IOFetchData() {
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
// Checks if the response we received was ok;
|
||||
// - data contains the buffer we read, as well as the address
|
||||
// we sent to and the address we received from.
|
||||
// length is provided by the operator() in IOFetch.
|
||||
// Addresses must match, number of octets read must be at least
|
||||
// 2, and the first two octets must match the qid of the message
|
||||
// we sent.
|
||||
/// @brief Checks if the response we received was ok.
|
||||
///
|
||||
/// The data member contains the buffer we read, as well as the address we
|
||||
/// sent to and the address we received from, length is provided by the
|
||||
/// operator() in IOFetch.
|
||||
/// The addresses must match, number of octets read must be at least two,
|
||||
/// and they must match the qid of the message we sent.
|
||||
bool responseOK() {
|
||||
return (*remote_snd == *remote_rcv && cumulative >= 2 &&
|
||||
readUint16(received->getData(), received->getLength()) == qid);
|
||||
}
|
||||
};
|
||||
|
||||
/// IOFetch Constructor - just initialize the private data
|
||||
|
||||
IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service,
|
||||
const isc::dns::Question& question, const IOAddress& address,
|
||||
uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait, bool edns) {
|
||||
MessagePtr query_msg(new Message(Message::RENDER));
|
||||
initIOFetch(query_msg, protocol, service, question, address, port, buff,
|
||||
MessagePtr query(new Message(Message::RENDER));
|
||||
initIOFetch(query, protocol, service, question, address, port, buff,
|
||||
cb, wait, edns);
|
||||
}
|
||||
|
||||
@@ -174,57 +157,46 @@ IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service,
|
||||
}
|
||||
|
||||
IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service,
|
||||
ConstMessagePtr query_message, const IOAddress& address, uint16_t port,
|
||||
OutputBufferPtr& buff, Callback* cb, int wait) {
|
||||
MessagePtr msg(new Message(Message::RENDER));
|
||||
|
||||
msg->setHeaderFlag(Message::HEADERFLAG_RD,
|
||||
ConstMessagePtr query_message, const IOAddress& address,
|
||||
uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait) {
|
||||
MessagePtr question(new Message(Message::RENDER));
|
||||
question->setHeaderFlag(Message::HEADERFLAG_RD,
|
||||
query_message->getHeaderFlag(Message::HEADERFLAG_RD));
|
||||
msg->setHeaderFlag(Message::HEADERFLAG_CD,
|
||||
question->setHeaderFlag(Message::HEADERFLAG_CD,
|
||||
query_message->getHeaderFlag(Message::HEADERFLAG_CD));
|
||||
|
||||
initIOFetch(msg, protocol, service,
|
||||
**(query_message->beginQuestion()),
|
||||
address, port, buff, cb, wait);
|
||||
initIOFetch(question, protocol, service, **(query_message->beginQuestion()), address,
|
||||
port, buff, cb, wait);
|
||||
}
|
||||
|
||||
void
|
||||
IOFetch::initIOFetch(MessagePtr& query_msg, Protocol protocol,
|
||||
const IOServicePtr& service,
|
||||
const isc::dns::Question& question,
|
||||
const IOAddress& address, uint16_t port,
|
||||
IOFetch::initIOFetch(MessagePtr& query, Protocol protocol, const IOServicePtr& service,
|
||||
const isc::dns::Question& question, const IOAddress& address, uint16_t port,
|
||||
OutputBufferPtr& buff, Callback* cb, int wait, bool edns) {
|
||||
data_ = boost::shared_ptr<IOFetchData>(new IOFetchData(
|
||||
protocol, service, address, port, buff, cb, wait));
|
||||
|
||||
query_msg->setQid(data_->qid);
|
||||
query_msg->setOpcode(Opcode::QUERY());
|
||||
query_msg->setRcode(Rcode::NOERROR());
|
||||
query_msg->setHeaderFlag(Message::HEADERFLAG_RD);
|
||||
query_msg->addQuestion(question);
|
||||
data_ = boost::shared_ptr<IOFetchData>(new IOFetchData(protocol, service, address, port, buff, cb, wait));
|
||||
query->setQid(data_->qid);
|
||||
query->setOpcode(Opcode::QUERY());
|
||||
query->setRcode(Rcode::NOERROR());
|
||||
query->setHeaderFlag(Message::HEADERFLAG_RD);
|
||||
query->addQuestion(question);
|
||||
|
||||
if (edns) {
|
||||
EDNSPtr edns_query(new EDNS());
|
||||
edns_query->setUDPSize(Message::DEFAULT_MAX_EDNS0_UDPSIZE);
|
||||
query_msg->setEDNS(edns_query);
|
||||
query->setEDNS(edns_query);
|
||||
}
|
||||
|
||||
MessageRenderer renderer;
|
||||
renderer.setBuffer(data_->msgbuf.get());
|
||||
query_msg->toWire(renderer);
|
||||
renderer.setBuffer(NULL);
|
||||
MessageRenderer r;
|
||||
r.setBuffer(data_->msgbuf.get());
|
||||
query->toWire(r);
|
||||
r.setBuffer(NULL);
|
||||
}
|
||||
|
||||
// Return protocol in use.
|
||||
|
||||
IOFetch::Protocol
|
||||
IOFetch::getProtocol() const {
|
||||
return (data_->protocol);
|
||||
}
|
||||
|
||||
/// The function operator is implemented with the "stackless coroutine"
|
||||
/// pattern; see boost/asio/coroutine.hpp for details.
|
||||
|
||||
void
|
||||
IOFetch::operator()(boost::system::error_code ec, size_t length) {
|
||||
if (data_->stopped) {
|
||||
@@ -320,13 +292,6 @@ IOFetch::operator()(boost::system::error_code ec, size_t length) {
|
||||
}
|
||||
}
|
||||
|
||||
// Function that stops the coroutine sequence. It is called either when the
|
||||
// query finishes or when the timer times out. Either way, it sets the
|
||||
// "stopped_" flag and cancels anything that is in progress.
|
||||
//
|
||||
// As the function may be entered multiple times as things wind down, it checks
|
||||
// if the stopped_ flag is already set. If it is, the call is a no-op.
|
||||
|
||||
void
|
||||
IOFetch::stop(Result result) {
|
||||
if (!data_->stopped) {
|
||||
@@ -385,8 +350,6 @@ IOFetch::stop(Result result) {
|
||||
}
|
||||
}
|
||||
|
||||
// Log an error - called on I/O failure
|
||||
|
||||
void IOFetch::logIOFailure(boost::system::error_code ec) {
|
||||
// Should only get here with a known error code.
|
||||
if ((data_->origin != ASIODNS_OPEN_SOCKET) &&
|
||||
@@ -404,4 +367,4 @@ void IOFetch::logIOFailure(boost::system::error_code ec) {
|
||||
}
|
||||
|
||||
} // namespace asiodns
|
||||
} // namespace isc {
|
||||
} // namespace isc
|
||||
|
@@ -5,14 +5,10 @@
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef IO_FETCH_H
|
||||
#define IO_FETCH_H 1
|
||||
#define IO_FETCH_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <boost/shared_array.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
|
||||
// We want to use coroutine.hpp from the system's boost headers if possible.
|
||||
// However, very old Boost versions (provided by RHEL 7 or CentOS 7) didn't have
|
||||
// this header. So we can resort to our bundled version, but only if necessary.
|
||||
@@ -22,13 +18,16 @@
|
||||
#include <ext/coroutine/coroutine.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <asiolink/io_address.h>
|
||||
#include <asiolink/io_service.h>
|
||||
|
||||
#include <util/buffer.h>
|
||||
#include <dns/question.h>
|
||||
#include <dns/message.h>
|
||||
#include <dns/question.h>
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <boost/shared_array.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
namespace isc {
|
||||
namespace asiodns {
|
||||
@@ -36,208 +35,223 @@ namespace asiodns {
|
||||
// Forward declarations
|
||||
struct IOFetchData;
|
||||
|
||||
/// \brief Upstream Fetch Processing
|
||||
/// @brief Upstream Fetch Processing.
|
||||
///
|
||||
/// IOFetch is the class used to send upstream fetches and to handle responses.
|
||||
///
|
||||
/// \param E Endpoint type to use.
|
||||
|
||||
class IOFetch : public boost::asio::coroutine {
|
||||
public:
|
||||
/// \brief Protocol to use on the fetch
|
||||
/// @brief Protocol to use on the fetch
|
||||
enum Protocol {
|
||||
UDP = 0,
|
||||
TCP = 1
|
||||
};
|
||||
|
||||
/// \brief Origin of Asynchronous I/O Call
|
||||
/// @brief Origin of Asynchronous I/O Call.
|
||||
///
|
||||
/// Indicates what initiated an asynchronous I/O call and used in deciding
|
||||
/// what error message to output if the I/O fails.
|
||||
/// Indicates what initiated an asynchronous I/O call and used in deciding what
|
||||
/// error message to output if the I/O fails.
|
||||
enum Origin {
|
||||
NONE = 0, ///< No asynchronous call outstanding
|
||||
NONE = 0, // No asynchronous call outstanding
|
||||
OPEN = 1,
|
||||
SEND = 2,
|
||||
RECEIVE = 3,
|
||||
CLOSE = 4
|
||||
};
|
||||
|
||||
/// \brief Result of Upstream Fetch
|
||||
/// @brief Result of Upstream Fetch.
|
||||
///
|
||||
/// Note that this applies to the status of I/Os in the fetch - a fetch
|
||||
/// that resulted in a packet being received from the server is a SUCCESS,
|
||||
/// even if the contents of the packet indicate that some error occurred.
|
||||
/// @note that this applies to the status of I/Os in the fetch - a fetch that
|
||||
/// resulted in a packet being received from the server is a SUCCESS, even if
|
||||
/// the contents of the packet indicate that some error occurred.
|
||||
enum Result {
|
||||
SUCCESS = 0, ///< Success, fetch completed
|
||||
TIME_OUT = 1, ///< Failure, fetch timed out
|
||||
STOPPED = 2, ///< Control code, fetch has been stopped
|
||||
NOTSET = 3 ///< For testing, indicates value not set
|
||||
SUCCESS = 0, // Success, fetch completed
|
||||
TIME_OUT = 1, // Failure, fetch timed out
|
||||
STOPPED = 2, // Control code, fetch has been stopped
|
||||
NOTSET = 3 // For testing, indicates value not set
|
||||
};
|
||||
|
||||
// The next enum is a "trick" to allow constants to be defined in a class
|
||||
// declaration.
|
||||
/// @note The next enum is a "trick" to allow constants to be defined in a class
|
||||
/// declaration.
|
||||
|
||||
/// \brief Integer Constants
|
||||
/// @brief Integer Constants.
|
||||
enum {
|
||||
STAGING_LENGTH = 8192 ///< Size of staging buffer
|
||||
STAGING_LENGTH = 8192 // Size of staging buffer
|
||||
};
|
||||
|
||||
/// \brief I/O Fetch Callback
|
||||
/// @brief I/O Fetch Callback.
|
||||
///
|
||||
/// Class of callback object for when the fetch itself has completed - an
|
||||
/// object of this class is passed to the IOFetch constructor and its
|
||||
/// operator() method called when the fetch completes.
|
||||
/// Class of callback object for when the fetch itself has completed - an object
|
||||
/// of this class is passed to the IOFetch constructor and its operator() method
|
||||
/// called when the fetch completes.
|
||||
///
|
||||
/// Note the difference between the two operator() methods:
|
||||
/// - IOFetch::operator() callback is called when an asynchronous I/O has
|
||||
/// completed.
|
||||
/// - IOFetch::Callback::operator() is called when an upstream fetch - which
|
||||
/// may have involved several asynchronous I/O operations - has completed.
|
||||
/// @note The difference between the two operator() methods:
|
||||
/// - IOFetch::operator() callback is called when an asynchronous I/O has completed.
|
||||
/// - IOFetch::Callback::operator() is called when an upstream fetch - which may
|
||||
/// have involved several asynchronous I/O operations - has completed.
|
||||
///
|
||||
/// This is an abstract class.
|
||||
class Callback {
|
||||
public:
|
||||
/// \brief Default Constructor
|
||||
Callback()
|
||||
{}
|
||||
/// @brief Constructor.
|
||||
Callback() = default;
|
||||
|
||||
/// \brief Virtual Destructor
|
||||
virtual ~Callback()
|
||||
{}
|
||||
/// @brief Destructor.
|
||||
virtual ~Callback() = default;
|
||||
|
||||
/// \brief Callback method
|
||||
/// @brief Callback method.
|
||||
///
|
||||
/// This is the method called when the fetch completes.
|
||||
/// This method is called when the fetch completes.
|
||||
///
|
||||
/// \param result Result of the fetch
|
||||
/// @param result Result of the fetch.
|
||||
virtual void operator()(Result result) = 0;
|
||||
};
|
||||
|
||||
/// \brief Constructor.
|
||||
/// @brief Constructor.
|
||||
///
|
||||
/// Creates the object that will handle the upstream fetch.
|
||||
///
|
||||
/// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP
|
||||
/// \param service I/O Service object to handle the asynchronous
|
||||
/// @param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP.
|
||||
/// @param service I/O Service object to handle the asynchronous
|
||||
/// operations.
|
||||
/// \param question DNS question to send to the upstream server.
|
||||
/// \param address IP address of upstream server
|
||||
/// \param port Port to which to connect on the upstream server
|
||||
/// \param buff Output buffer into which the response (in wire format)
|
||||
/// @param question DNS question to send to the upstream server.
|
||||
/// @param address IP address of upstream server.
|
||||
/// @param port Port to which to connect on the upstream server.
|
||||
/// @param buff Output buffer into which the response (in wire format)
|
||||
/// is written (if a response is received).
|
||||
/// \param cb Callback object containing the callback to be called when we
|
||||
/// @param cb Callback object containing the callback to be called when we
|
||||
/// terminate. The caller is responsible for managing this object
|
||||
/// and deleting it if necessary.
|
||||
/// \param wait Timeout for the fetch (in ms). The default value of
|
||||
/// @param wait Timeout for the fetch (in ms). The default value of
|
||||
/// -1 indicates no timeout.
|
||||
/// \param edns true if the request should be EDNS. The default value is
|
||||
/// @param edns true if the request should be EDNS. The default value is
|
||||
/// true.
|
||||
IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service,
|
||||
IOFetch(Protocol protocol,
|
||||
const isc::asiolink::IOServicePtr& service,
|
||||
const isc::dns::Question& question,
|
||||
const isc::asiolink::IOAddress& address,
|
||||
uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb,
|
||||
uint16_t port,
|
||||
isc::util::OutputBufferPtr& buff,
|
||||
Callback* cb,
|
||||
int wait = -1,
|
||||
bool edns = true);
|
||||
|
||||
/// \brief Constructor
|
||||
/// This constructor has one parameter "query_message", which
|
||||
/// is the shared_ptr to a full query message. It's different
|
||||
/// with above constructor which has only question section. All
|
||||
/// other parameters are same.
|
||||
/// @brief Constructor
|
||||
///
|
||||
/// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP
|
||||
/// \param service I/O Service object to handle the asynchronous
|
||||
/// This constructor has one parameter "query_message", which is the shared_ptr
|
||||
/// to a full query message. It's different with above constructor which has only
|
||||
/// question section. All other parameters are the same.
|
||||
///
|
||||
/// @param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP.
|
||||
/// @param service I/O Service object to handle the asynchronous
|
||||
/// operations.
|
||||
/// \param query_message the shared_ptr to a full query message
|
||||
/// got from a query client.
|
||||
/// \param address IP address of upstream server
|
||||
/// \param port Port to which to connect on the upstream server
|
||||
/// \param buff Output buffer into which the response (in wire format)
|
||||
/// @param query_message the shared_ptr to a full query message got from a
|
||||
/// query client.
|
||||
/// @param address IP address of upstream server.
|
||||
/// @param port Port to which to connect on the upstream server.
|
||||
/// @param buff Output buffer into which the response (in wire format)
|
||||
/// is written (if a response is received).
|
||||
/// \param cb Callback object containing the callback to be called when we
|
||||
/// @param cb Callback object containing the callback to be called when we
|
||||
/// terminate. The caller is responsible for managing this object
|
||||
/// and deleting it if necessary.
|
||||
/// \param wait Timeout for the fetch (in ms). The default value of
|
||||
/// -1 indicates no timeout.
|
||||
IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service,
|
||||
/// @param wait Timeout for the fetch (in ms). The default value of -1
|
||||
/// indicates no timeout.
|
||||
IOFetch(Protocol protocol,
|
||||
const isc::asiolink::IOServicePtr& service,
|
||||
isc::dns::ConstMessagePtr query_message,
|
||||
const isc::asiolink::IOAddress& address,
|
||||
uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb,
|
||||
uint16_t port,
|
||||
isc::util::OutputBufferPtr& buff,
|
||||
Callback* cb,
|
||||
int wait = -1);
|
||||
|
||||
/// \brief Constructor.
|
||||
/// @brief Constructor.
|
||||
///
|
||||
/// Creates the object that will handle the upstream fetch.
|
||||
///
|
||||
/// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP
|
||||
/// \param service I/O Service object to handle the asynchronous
|
||||
/// @param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP
|
||||
/// @param service I/O Service object to handle the asynchronous
|
||||
/// operations.
|
||||
/// \param outpkt Packet to send to upstream server. Note that the
|
||||
/// @param outpkt Packet to send to upstream server. Note that the
|
||||
/// QID (first two bytes of the packet) may be altered in the sending.
|
||||
/// \param buff Output buffer into which the response (in wire format)
|
||||
/// @param buff Output buffer into which the response (in wire format)
|
||||
/// is written (if a response is received).
|
||||
/// \param cb Callback object containing the callback to be called
|
||||
/// @param cb Callback object containing the callback to be called
|
||||
/// when we terminate. The caller is responsible for managing this
|
||||
/// object and deleting it if necessary.
|
||||
/// \param address IP address of upstream server
|
||||
/// \param port Port to which to connect on the upstream server
|
||||
/// (default = 53)
|
||||
/// \param wait Timeout for the fetch (in ms). The default value of
|
||||
/// @param address IP address of upstream server.
|
||||
/// @param port Port to which to connect on the upstream server
|
||||
/// (default = 53).
|
||||
/// @param wait Timeout for the fetch (in ms). The default value of
|
||||
/// -1 indicates no timeout.
|
||||
IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service,
|
||||
IOFetch(Protocol protocol,
|
||||
const isc::asiolink::IOServicePtr& service,
|
||||
isc::util::OutputBufferPtr& outpkt,
|
||||
const isc::asiolink::IOAddress& address,
|
||||
uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb,
|
||||
uint16_t port,
|
||||
isc::util::OutputBufferPtr& buff,
|
||||
Callback* cb,
|
||||
int wait = -1);
|
||||
|
||||
/// \brief Return Current Protocol
|
||||
/// @brief Return Current Protocol.
|
||||
///
|
||||
/// \return Protocol associated with this IOFetch object.
|
||||
/// @return Protocol associated with this IOFetch object.
|
||||
Protocol getProtocol() const;
|
||||
|
||||
/// \brief Coroutine entry point
|
||||
/// @brief Coroutine entry point.
|
||||
///
|
||||
/// The operator() method is the method in which the coroutine code enters
|
||||
/// this object when an operation has been completed.
|
||||
///
|
||||
/// \param ec Error code, the result of the last asynchronous I/O operation.
|
||||
/// \param length Amount of data received on the last asynchronous read
|
||||
void operator()(boost::system::error_code ec = boost::system::error_code(), size_t length = 0);
|
||||
/// @param ec Error code, the result of the last asynchronous I/O operation.
|
||||
/// @param length Amount of data received on the last asynchronous read.
|
||||
void operator()(boost::system::error_code ec = boost::system::error_code(),
|
||||
size_t length = 0);
|
||||
|
||||
/// \brief Terminate query
|
||||
/// @brief Terminate query.
|
||||
///
|
||||
/// This method can be called at any point. It terminates the current
|
||||
/// query with the specified reason.
|
||||
/// This function stops the coroutine sequence. It is called either when the
|
||||
/// query finishes or when the timer times out. Either way, it sets the
|
||||
/// "stopped_" flag and cancels anything that is in progress.
|
||||
///
|
||||
/// \param reason Reason for terminating the query
|
||||
/// As the function may be entered multiple times as things wind down, it checks
|
||||
/// if the stopped_ flag is already set. If it is, the call is a no-op.
|
||||
///
|
||||
/// @param reason Reason for terminating the query.
|
||||
void stop(Result reason = STOPPED);
|
||||
|
||||
private:
|
||||
/// \brief IOFetch Initialization Function.
|
||||
/// All the parameters are same with the constructor, except
|
||||
/// parameter "query_message"
|
||||
/// \param query_message the message to be sent out.
|
||||
void initIOFetch(isc::dns::MessagePtr& query_message, Protocol protocol,
|
||||
/// @brief IOFetch Initialization Function.
|
||||
///
|
||||
/// All the parameters are same with the constructor, except parameter
|
||||
/// "query_message".
|
||||
///
|
||||
/// @param query_message the message to be sent out.
|
||||
void initIOFetch(isc::dns::MessagePtr& query_message,
|
||||
Protocol protocol,
|
||||
const isc::asiolink::IOServicePtr& service,
|
||||
const isc::dns::Question& question,
|
||||
const isc::asiolink::IOAddress& address, uint16_t port,
|
||||
isc::util::OutputBufferPtr& buff, Callback* cb, int wait,
|
||||
const isc::asiolink::IOAddress& address,
|
||||
uint16_t port,
|
||||
isc::util::OutputBufferPtr& buff,
|
||||
Callback* cb, int wait,
|
||||
bool edns = true);
|
||||
|
||||
/// \brief Log I/O Failure
|
||||
/// @brief Log I/O Failure.
|
||||
///
|
||||
/// Records an I/O failure to the log file
|
||||
/// Records an I/O failure to the log file.
|
||||
///
|
||||
/// \param ec ASIO error code
|
||||
/// @param ec ASIO error code.
|
||||
void logIOFailure(boost::system::error_code ec);
|
||||
|
||||
// Member variables. All data is in a structure pointed to by a shared
|
||||
// pointer. The IOFetch object is copied a number of times during its
|
||||
// life, and only requiring a pointer to be copied reduces overhead.
|
||||
/// @brief data which is a structure pointed to by a shared pointer. The IOFetch
|
||||
/// object is copied a number of times during its life, and only requiring a
|
||||
/// pointer to be copied reduces overhead.
|
||||
boost::shared_ptr<IOFetchData> data_; ///< Private data
|
||||
};
|
||||
|
||||
/// \brief Defines a pointer to an IOFetch.
|
||||
/// @brief Defines a pointer to an IOFetch.
|
||||
typedef boost::shared_ptr<IOFetch> IOFetchPtr;
|
||||
|
||||
} // namespace asiodns
|
||||
|
@@ -32,8 +32,7 @@ run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
|
||||
|
||||
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
|
||||
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
|
||||
# KEA_CXXFLAGS)
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS)
|
||||
run_unittests_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
if USE_GXX
|
||||
run_unittests_CXXFLAGS += -Wno-unused-parameter
|
||||
|
@@ -31,12 +31,14 @@
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
using namespace boost::asio::ip;
|
||||
using namespace boost::asio;
|
||||
using namespace isc::asiolink;
|
||||
using namespace isc::dns;
|
||||
using namespace isc::util;
|
||||
|
||||
using namespace boost::asio;
|
||||
using namespace boost::asio::ip;
|
||||
using namespace std;
|
||||
|
||||
namespace ph = std::placeholders;
|
||||
|
||||
namespace isc {
|
||||
|
@@ -7,15 +7,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <util/unittests/run_all.h>
|
||||
|
||||
#include <util/unittests/run_all.h>
|
||||
#include <log/logger_support.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv); // Initialize Google test
|
||||
isc::log::initLogger(); // Initialize logging
|
||||
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
return (isc::util::unittests::run_all());
|
||||
}
|
||||
|
@@ -56,8 +56,7 @@ if HAVE_OPENSSL
|
||||
libkea_asiolink_la_SOURCES += openssl_tls.cc
|
||||
endif
|
||||
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
|
||||
# KEA_CXXFLAGS)
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS)
|
||||
libkea_asiolink_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
libkea_asiolink_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
libkea_asiolink_la_LIBADD = $(top_builddir)/src/lib/util/libkea-util.la
|
||||
|
@@ -139,4 +139,5 @@ typedef boost::shared_ptr<isc::asiolink::IntervalTimer> IntervalTimerPtr;
|
||||
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
|
||||
#endif // ASIOLINK_INTERVAL_TIMER_H
|
||||
|
@@ -326,4 +326,5 @@ size_t hash_value(const IOAddress& address);
|
||||
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
|
||||
#endif // IO_ADDRESS_H
|
||||
|
@@ -12,17 +12,16 @@
|
||||
// See the description of the namespace below.
|
||||
#include <config.h>
|
||||
|
||||
#include <unistd.h> // for some network system calls
|
||||
|
||||
#include <exceptions/exceptions.h>
|
||||
#include <asiolink/io_error.h>
|
||||
#include <asiolink/io_socket.h>
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <exceptions/exceptions.h>
|
||||
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <asiolink/io_error.h>
|
||||
#include <asiolink/io_socket.h>
|
||||
#include <unistd.h> // for some network system calls
|
||||
|
||||
// We want to use coroutine.hpp from the system's boost headers if possible.
|
||||
// However, very old Boost versions (provided by RHEL 7 or CentOS 7) didn't have
|
||||
@@ -106,7 +105,7 @@ protected:
|
||||
IOAsioSocket() {}
|
||||
public:
|
||||
/// The destructor.
|
||||
virtual ~IOAsioSocket() {}
|
||||
virtual ~IOAsioSocket() = default;
|
||||
//@}
|
||||
|
||||
/// \brief Return the "native" representation of the socket.
|
||||
@@ -258,7 +257,7 @@ public:
|
||||
/// really the TCP count field and is set to that value when enough
|
||||
/// of a TCP message is received. It should be initialized to -1
|
||||
/// before the first read is executed.
|
||||
/// \param outbuff Output buffer. Data in the staging buffer may be copied
|
||||
/// \param buff Output buffer. Data in the staging buffer may be copied
|
||||
/// to this output buffer in the call.
|
||||
///
|
||||
/// \return true if the receive is complete, false if another receive is
|
||||
@@ -269,9 +268,9 @@ public:
|
||||
/// should be read into the staging buffer at offset given by the
|
||||
/// "offset" parameter.
|
||||
virtual bool processReceivedData(const void* staging, size_t length,
|
||||
size_t& cumulative, size_t& offset,
|
||||
size_t& expected,
|
||||
isc::util::OutputBufferPtr& outbuff) = 0;
|
||||
size_t& cumulative,
|
||||
size_t& offset, size_t& expected,
|
||||
isc::util::OutputBufferPtr& buff) = 0;
|
||||
|
||||
/// \brief Cancel I/O On AsioSocket
|
||||
virtual void cancel() = 0;
|
||||
|
@@ -64,5 +64,6 @@ operator<<(ostream& os, const IOEndpoint& endpoint) {
|
||||
os << ":" << boost::lexical_cast<string>(endpoint.getPort());
|
||||
return (os);
|
||||
}
|
||||
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
|
@@ -178,6 +178,3 @@ std::ostream& operator<<(std::ostream& os, const IOEndpoint& endpoint);
|
||||
} // namespace isc
|
||||
#endif // IO_ENDPOINT_H
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
||||
|
@@ -22,7 +22,6 @@ public:
|
||||
isc::Exception(file, line, what) {}
|
||||
};
|
||||
|
||||
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
|
||||
|
@@ -123,4 +123,5 @@ typedef boost::shared_ptr<IOService> IOServicePtr;
|
||||
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
|
||||
#endif // ASIOLINK_IO_SERVICE_H
|
||||
|
@@ -109,7 +109,3 @@ private:
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
#endif // TCP_ENDPOINT_H
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
||||
|
@@ -5,30 +5,28 @@
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef TCP_SOCKET_H
|
||||
#define TCP_SOCKET_H 1
|
||||
#define TCP_SOCKET_H
|
||||
|
||||
#ifndef BOOST_ASIO_HPP
|
||||
#error "asio.hpp must be included before including this, see asiolink.h as to why"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h> // for some IPC/network system calls
|
||||
#include <asiolink/io_asio_socket.h>
|
||||
#include <asiolink/io_endpoint.h>
|
||||
#include <asiolink/io_service.h>
|
||||
#include <asiolink/tcp_endpoint.h>
|
||||
#include <exceptions/isc_assert.h>
|
||||
#include <util/buffer.h>
|
||||
#include <util/io.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <util/buffer.h>
|
||||
#include <util/io.h>
|
||||
|
||||
#include <asiolink/io_asio_socket.h>
|
||||
#include <asiolink/io_endpoint.h>
|
||||
#include <asiolink/io_service.h>
|
||||
#include <asiolink/tcp_endpoint.h>
|
||||
|
||||
#include <exceptions/isc_assert.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h> // for some IPC/network system calls
|
||||
|
||||
namespace isc {
|
||||
namespace asiolink {
|
||||
@@ -199,14 +197,14 @@ public:
|
||||
/// processed.
|
||||
/// \param offset Unused.
|
||||
/// \param expected unused.
|
||||
/// \param outbuff Output buffer. Data in the staging buffer is be copied
|
||||
/// \param buff Output buffer. Data in the staging buffer is be copied
|
||||
/// to this output buffer in the call.
|
||||
///
|
||||
/// \return Always true
|
||||
virtual bool processReceivedData(const void* staging, size_t length,
|
||||
size_t& cumulative, size_t& offset,
|
||||
size_t& expected,
|
||||
isc::util::OutputBufferPtr& outbuff);
|
||||
isc::util::OutputBufferPtr& buff);
|
||||
|
||||
/// \brief Cancel I/O On Socket
|
||||
virtual void cancel();
|
||||
|
@@ -64,8 +64,7 @@ run_unittests_LDADD += $(GTEST_LDADD)
|
||||
|
||||
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
|
||||
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
|
||||
# KEA_CXXFLAGS)
|
||||
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS)
|
||||
run_unittests_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
if USE_GXX
|
||||
run_unittests_CXXFLAGS += -Wno-unused-parameter -Wno-unused-private-field
|
||||
|
@@ -11,14 +11,14 @@
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace isc::asiolink;
|
||||
|
||||
namespace {
|
||||
// TODO: Consider this margin
|
||||
const boost::posix_time::time_duration TIMER_MARGIN_MSEC =
|
||||
boost::posix_time::milliseconds(50);
|
||||
}
|
||||
|
||||
using namespace isc::asiolink;
|
||||
|
||||
// This fixture is for testing IntervalTimer. Some callback functors are
|
||||
// registered as callback function of the timer to test if they are called
|
||||
// or not.
|
||||
|
@@ -7,13 +7,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <util/unittests/run_all.h>
|
||||
#include <log/logger_manager.h>
|
||||
#include <log/logger_support.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv); // Initialize Google test
|
||||
isc::log::LoggerManager::init("unittest"); // Set a root logger name
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
return (isc::util::unittests::run_all());
|
||||
}
|
||||
|
@@ -32,11 +32,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace isc::asiolink;
|
||||
using namespace isc::util;
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::asio;
|
||||
using namespace boost::asio::ip;
|
||||
using namespace isc::util;
|
||||
using namespace isc::asiolink;
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -32,9 +32,10 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
using namespace boost::asio;
|
||||
using namespace isc::util;
|
||||
using namespace isc::asiolink;
|
||||
using namespace isc::util;
|
||||
|
||||
using namespace boost::asio;
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
@@ -109,7 +109,3 @@ private:
|
||||
} // namespace asiolink
|
||||
} // namespace isc
|
||||
#endif // UDP_ENDPOINT_H
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
||||
|
@@ -130,14 +130,14 @@ public:
|
||||
/// processed.
|
||||
/// \param offset Unused.
|
||||
/// \param expected unused.
|
||||
/// \param outbuff Output buffer. Data in the staging buffer is be copied
|
||||
/// \param buff Output buffer. Data in the staging buffer is be copied
|
||||
/// to this output buffer in the call.
|
||||
///
|
||||
/// \return Always true
|
||||
virtual bool processReceivedData(const void* staging, size_t length,
|
||||
size_t& cumulative, size_t& offset,
|
||||
size_t& expected,
|
||||
isc::util::OutputBufferPtr& outbuff);
|
||||
isc::util::OutputBufferPtr& buff);
|
||||
|
||||
/// \brief Cancel I/O On Socket
|
||||
virtual void cancel();
|
||||
|
@@ -1069,7 +1069,3 @@ bool operator<(const Element& a, const Element& b);
|
||||
} // namespace isc
|
||||
|
||||
#endif // ISC_DATA_H
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cc/command_interpreter.h>
|
||||
#include <config/tests/data_def_unittests_config.h>
|
||||
#include <log/logger_name.h>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
@@ -7,14 +7,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <util/unittests/run_all.h>
|
||||
#include <log/logger_support.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
isc::log::initLogger();
|
||||
|
||||
return (isc::util::unittests::run_all());
|
||||
}
|
||||
|
1
src/lib/config/tests/.gitignore
vendored
1
src/lib/config/tests/.gitignore
vendored
@@ -1,2 +1 @@
|
||||
/data_def_unittests_config.h
|
||||
/run_unittests
|
||||
|
@@ -1,4 +1,4 @@
|
||||
SUBDIRS = testdata .
|
||||
SUBDIRS = .
|
||||
|
||||
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
|
||||
AM_CPPFLAGS += $(BOOST_INCLUDES) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
|
||||
@@ -12,7 +12,6 @@ AM_LDFLAGS = -static
|
||||
endif
|
||||
|
||||
CLEANFILES = *.gcno *.gcda
|
||||
DISTCLEANFILES = data_def_unittests_config.h
|
||||
|
||||
TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
|
||||
|
||||
|
@@ -1,7 +0,0 @@
|
||||
// Copyright (C) 2009-2015 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#define TEST_DATA_PATH "@abs_srcdir@/testdata"
|
@@ -7,6 +7,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <util/unittests/run_all.h>
|
||||
#include <log/logger_support.h>
|
||||
|
||||
|
59
src/lib/config/tests/testdata/Makefile.am
vendored
59
src/lib/config/tests/testdata/Makefile.am
vendored
@@ -1,59 +0,0 @@
|
||||
EXTRA_DIST = data22_1.data
|
||||
EXTRA_DIST += data22_2.data
|
||||
EXTRA_DIST += data22_3.data
|
||||
EXTRA_DIST += data22_4.data
|
||||
EXTRA_DIST += data22_5.data
|
||||
EXTRA_DIST += data22_6.data
|
||||
EXTRA_DIST += data22_7.data
|
||||
EXTRA_DIST += data22_8.data
|
||||
EXTRA_DIST += data22_9.data
|
||||
EXTRA_DIST += data22_10.data
|
||||
EXTRA_DIST += data32_1.data
|
||||
EXTRA_DIST += data32_2.data
|
||||
EXTRA_DIST += data32_3.data
|
||||
EXTRA_DIST += data33_1.data
|
||||
EXTRA_DIST += data33_2.data
|
||||
EXTRA_DIST += data41_1.data
|
||||
EXTRA_DIST += data41_2.data
|
||||
EXTRA_DIST += spec1.spec
|
||||
EXTRA_DIST += spec2.spec
|
||||
EXTRA_DIST += spec3.spec
|
||||
EXTRA_DIST += spec4.spec
|
||||
EXTRA_DIST += spec5.spec
|
||||
EXTRA_DIST += spec6.spec
|
||||
EXTRA_DIST += spec7.spec
|
||||
EXTRA_DIST += spec8.spec
|
||||
EXTRA_DIST += spec9.spec
|
||||
EXTRA_DIST += spec10.spec
|
||||
EXTRA_DIST += spec11.spec
|
||||
EXTRA_DIST += spec12.spec
|
||||
EXTRA_DIST += spec13.spec
|
||||
EXTRA_DIST += spec14.spec
|
||||
EXTRA_DIST += spec15.spec
|
||||
EXTRA_DIST += spec16.spec
|
||||
EXTRA_DIST += spec17.spec
|
||||
EXTRA_DIST += spec18.spec
|
||||
EXTRA_DIST += spec19.spec
|
||||
EXTRA_DIST += spec20.spec
|
||||
EXTRA_DIST += spec21.spec
|
||||
EXTRA_DIST += spec22.spec
|
||||
EXTRA_DIST += spec23.spec
|
||||
EXTRA_DIST += spec24.spec
|
||||
EXTRA_DIST += spec25.spec
|
||||
EXTRA_DIST += spec26.spec
|
||||
EXTRA_DIST += spec27.spec
|
||||
EXTRA_DIST += spec28.spec
|
||||
EXTRA_DIST += spec29.spec
|
||||
EXTRA_DIST += spec30.spec
|
||||
EXTRA_DIST += spec31.spec
|
||||
EXTRA_DIST += spec32.spec
|
||||
EXTRA_DIST += spec33.spec
|
||||
EXTRA_DIST += spec34.spec
|
||||
EXTRA_DIST += spec35.spec
|
||||
EXTRA_DIST += spec36.spec
|
||||
EXTRA_DIST += spec37.spec
|
||||
EXTRA_DIST += spec38.spec
|
||||
EXTRA_DIST += spec39.spec
|
||||
EXTRA_DIST += spec40.spec
|
||||
EXTRA_DIST += spec41.spec
|
||||
EXTRA_DIST += spec42.spec
|
9
src/lib/config/tests/testdata/data22_1.data
vendored
9
src/lib/config/tests/testdata/data22_1.data
vendored
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true },
|
||||
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
|
||||
}
|
11
src/lib/config/tests/testdata/data22_10.data
vendored
11
src/lib/config/tests/testdata/data22_10.data
vendored
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"version": 123,
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true },
|
||||
"value8": [ { "a": "d" }, { "a": "e" } ],
|
||||
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
|
||||
}
|
8
src/lib/config/tests/testdata/data22_2.data
vendored
8
src/lib/config/tests/testdata/data22_2.data
vendored
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"value1": "asdf",
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true }
|
||||
}
|
8
src/lib/config/tests/testdata/data22_3.data
vendored
8
src/lib/config/tests/testdata/data22_3.data
vendored
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": false,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true }
|
||||
}
|
8
src/lib/config/tests/testdata/data22_4.data
vendored
8
src/lib/config/tests/testdata/data22_4.data
vendored
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, "a" ],
|
||||
"value6": { "v61": "bar", "v62": true }
|
||||
}
|
8
src/lib/config/tests/testdata/data22_5.data
vendored
8
src/lib/config/tests/testdata/data22_5.data
vendored
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": "Break" }
|
||||
}
|
10
src/lib/config/tests/testdata/data22_6.data
vendored
10
src/lib/config/tests/testdata/data22_6.data
vendored
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true },
|
||||
"value7": [ 1, 2.2, "str", true ],
|
||||
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
|
||||
}
|
10
src/lib/config/tests/testdata/data22_7.data
vendored
10
src/lib/config/tests/testdata/data22_7.data
vendored
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true },
|
||||
"value8": [ { "a": "d" }, { "a": "e" } ],
|
||||
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
|
||||
}
|
10
src/lib/config/tests/testdata/data22_8.data
vendored
10
src/lib/config/tests/testdata/data22_8.data
vendored
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true },
|
||||
"value8": [ { "a": "d" }, { "a": 1 } ],
|
||||
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }
|
||||
}
|
11
src/lib/config/tests/testdata/data22_9.data
vendored
11
src/lib/config/tests/testdata/data22_9.data
vendored
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"value1": 1,
|
||||
"value2": 2.3,
|
||||
"value3": true,
|
||||
"value4": "foo",
|
||||
"value5": [ 1, 2, 3 ],
|
||||
"value6": { "v61": "bar", "v62": true },
|
||||
"value8": [ { "a": "d" }, { "a": "e" } ],
|
||||
"value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } },
|
||||
"value_does_not_exist": 1
|
||||
}
|
3
src/lib/config/tests/testdata/data32_1.data
vendored
3
src/lib/config/tests/testdata/data32_1.data
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"named_set_item": { "foo": 1, "bar": 2 }
|
||||
}
|
3
src/lib/config/tests/testdata/data32_2.data
vendored
3
src/lib/config/tests/testdata/data32_2.data
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"named_set_item": { "foo": "wrongtype", "bar": 2 }
|
||||
}
|
3
src/lib/config/tests/testdata/data32_3.data
vendored
3
src/lib/config/tests/testdata/data32_3.data
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"named_set_item": []
|
||||
}
|
7
src/lib/config/tests/testdata/data33_1.data
vendored
7
src/lib/config/tests/testdata/data33_1.data
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"dummy_str": "Dummy String",
|
||||
"dummy_int": 118,
|
||||
"dummy_datetime": "2011-05-27T19:42:57Z",
|
||||
"dummy_date": "2011-05-27",
|
||||
"dummy_time": "19:42:57"
|
||||
}
|
7
src/lib/config/tests/testdata/data33_2.data
vendored
7
src/lib/config/tests/testdata/data33_2.data
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"dummy_str": "Dummy String",
|
||||
"dummy_int": 118,
|
||||
"dummy_datetime": "xxxx",
|
||||
"dummy_date": "xxxx",
|
||||
"dummy_time": "xxxx"
|
||||
}
|
12
src/lib/config/tests/testdata/data41_1.data
vendored
12
src/lib/config/tests/testdata/data41_1.data
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"zones": {
|
||||
"example.org": {
|
||||
"queries.tcp": 100,
|
||||
"queries.udp": 200
|
||||
},
|
||||
"example.net": {
|
||||
"queries.tcp": 300,
|
||||
"queries.udp": 400
|
||||
}
|
||||
}
|
||||
}
|
16
src/lib/config/tests/testdata/data41_2.data
vendored
16
src/lib/config/tests/testdata/data41_2.data
vendored
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"zones": [
|
||||
{
|
||||
"example.org": {
|
||||
"queries.tcp": 100,
|
||||
"queries.udp": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"example.net": {
|
||||
"queries.tcp": 300,
|
||||
"queries.udp": 400
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
6
src/lib/config/tests/testdata/spec1.spec
vendored
6
src/lib/config/tests/testdata/spec1.spec
vendored
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec1"
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec10.spec
vendored
13
src/lib/config/tests/testdata/spec10.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "real",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec11.spec
vendored
13
src/lib/config/tests/testdata/spec11.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec12.spec
vendored
13
src/lib/config/tests/testdata/spec12.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec13.spec
vendored
13
src/lib/config/tests/testdata/spec13.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec14.spec
vendored
13
src/lib/config/tests/testdata/spec14.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec15.spec
vendored
13
src/lib/config/tests/testdata/spec15.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "badname",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
7
src/lib/config/tests/testdata/spec16.spec
vendored
7
src/lib/config/tests/testdata/spec16.spec
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": 1
|
||||
}
|
||||
}
|
||||
|
17
src/lib/config/tests/testdata/spec17.spec
vendored
17
src/lib/config/tests/testdata/spec17.spec
vendored
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"commands": [
|
||||
{
|
||||
"command_description": "Print the given message to stdout",
|
||||
"command_args": [ {
|
||||
"item_name": "message",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": ""
|
||||
} ]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
12
src/lib/config/tests/testdata/spec18.spec
vendored
12
src/lib/config/tests/testdata/spec18.spec
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"commands": [
|
||||
{
|
||||
"command_name": "print_message",
|
||||
"command_description": "Print the given message to stdout"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec19.spec
vendored
13
src/lib/config/tests/testdata/spec19.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"commands": [
|
||||
{
|
||||
"command_name": "print_message",
|
||||
"command_description": "Print the given message to stdout",
|
||||
"command_args": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
83
src/lib/config/tests/testdata/spec2.spec
vendored
83
src/lib/config/tests/testdata/spec2.spec
vendored
@@ -1,83 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
},
|
||||
{ "item_name": "item2",
|
||||
"item_type": "real",
|
||||
"item_optional": false,
|
||||
"item_default": 1.1
|
||||
},
|
||||
{ "item_name": "item3",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": true
|
||||
},
|
||||
{ "item_name": "item4",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "test"
|
||||
},
|
||||
{ "item_name": "item5",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [ "a", "b" ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": ""
|
||||
}
|
||||
},
|
||||
{ "item_name": "item6",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "value1",
|
||||
"item_type": "string",
|
||||
"item_optional": true,
|
||||
"item_default": "default"
|
||||
},
|
||||
{ "item_name": "value2",
|
||||
"item_type": "integer",
|
||||
"item_optional": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"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": ""
|
||||
} ]
|
||||
},
|
||||
{
|
||||
"command_name": "shutdown",
|
||||
"command_description": "Shut down Kea",
|
||||
"command_args": []
|
||||
}
|
||||
],
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "dummy_time",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "1970-01-01T00:00:00Z",
|
||||
"item_title": "Dummy Time",
|
||||
"item_description": "A dummy date time",
|
||||
"item_format": "date-time"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
18
src/lib/config/tests/testdata/spec20.spec
vendored
18
src/lib/config/tests/testdata/spec20.spec
vendored
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"commands": [
|
||||
{
|
||||
"command_name": "print_message",
|
||||
"command_description": "Print the given message to stdout",
|
||||
"command_args": [ {
|
||||
"item_name": "message",
|
||||
"item_type": "somethingbad",
|
||||
"item_optional": false,
|
||||
"item_default": ""
|
||||
} ]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
7
src/lib/config/tests/testdata/spec21.spec
vendored
7
src/lib/config/tests/testdata/spec21.spec
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"commands": 1
|
||||
}
|
||||
}
|
||||
|
114
src/lib/config/tests/testdata/spec22.spec
vendored
114
src/lib/config/tests/testdata/spec22.spec
vendored
@@ -1,114 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec22",
|
||||
"config_data": [
|
||||
{ "item_name": "value1",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 9
|
||||
},
|
||||
{ "item_name": "value2",
|
||||
"item_type": "real",
|
||||
"item_optional": false,
|
||||
"item_default": 9.9
|
||||
},
|
||||
{ "item_name": "value3",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": false
|
||||
},
|
||||
{ "item_name": "value4",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "default_string"
|
||||
},
|
||||
{ "item_name": "value5",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [ "a", "b" ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 8
|
||||
}
|
||||
},
|
||||
{ "item_name": "value6",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "v61",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "def"
|
||||
},
|
||||
{ "item_name": "v62",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "item_name": "value7",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"item_default": [ ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "any",
|
||||
"item_optional": true
|
||||
}
|
||||
},
|
||||
{ "item_name": "value8",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"item_default": [ ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "map",
|
||||
"item_optional": true,
|
||||
"item_default": { "a": "b" },
|
||||
"map_item_spec": [
|
||||
{ "item_name": "a",
|
||||
"item_type": "string",
|
||||
"item_optional": true,
|
||||
"item_default": "empty"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{ "item_name": "value9",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": { "v91": "def", "v92": {} },
|
||||
"map_item_spec": [
|
||||
{ "item_name": "v91",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "def"
|
||||
},
|
||||
{ "item_name": "v92",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "v92a",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "Hello"
|
||||
} ,
|
||||
{
|
||||
"item_name": "v92b",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 56176
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
18
src/lib/config/tests/testdata/spec23.spec
vendored
18
src/lib/config/tests/testdata/spec23.spec
vendored
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"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": ""
|
||||
} ]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
18
src/lib/config/tests/testdata/spec24.spec
vendored
18
src/lib/config/tests/testdata/spec24.spec
vendored
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec24",
|
||||
"config_data": [
|
||||
{ "item_name": "item",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
7
src/lib/config/tests/testdata/spec25.spec
vendored
7
src/lib/config/tests/testdata/spec25.spec
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec25",
|
||||
"module_description": "Just an empty module"
|
||||
}
|
||||
}
|
||||
|
6
src/lib/config/tests/testdata/spec26.spec
vendored
6
src/lib/config/tests/testdata/spec26.spec
vendored
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec26",
|
||||
"module_description": 1
|
||||
}
|
||||
}
|
121
src/lib/config/tests/testdata/spec27.spec
vendored
121
src/lib/config/tests/testdata/spec27.spec
vendored
@@ -1,121 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec27",
|
||||
"commands": [
|
||||
{
|
||||
"command_name": "cmd1",
|
||||
"command_description": "command_for_unittest",
|
||||
"command_args": [
|
||||
{
|
||||
"item_name": "value1",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 9
|
||||
},
|
||||
{ "item_name": "value2",
|
||||
"item_type": "real",
|
||||
"item_optional": false,
|
||||
"item_default": 9.9
|
||||
},
|
||||
{ "item_name": "value3",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": false
|
||||
},
|
||||
{ "item_name": "value4",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "default_string"
|
||||
},
|
||||
{ "item_name": "value5",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [ "a", "b" ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 8
|
||||
}
|
||||
},
|
||||
{ "item_name": "value6",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "v61",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "def"
|
||||
},
|
||||
{ "item_name": "v62",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "item_name": "value7",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"item_default": [ ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "any",
|
||||
"item_optional": true
|
||||
}
|
||||
},
|
||||
{ "item_name": "value8",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"item_default": [ ],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "map",
|
||||
"item_optional": true,
|
||||
"item_default": { "a": "b" },
|
||||
"map_item_spec": [
|
||||
{ "item_name": "a",
|
||||
"item_type": "string",
|
||||
"item_optional": true,
|
||||
"item_default": "empty"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{ "item_name": "value9",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "v91",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "def"
|
||||
},
|
||||
{ "item_name": "v92",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "v92a",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "Hello"
|
||||
} ,
|
||||
{
|
||||
"item_name": "v92b",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 56176
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
7
src/lib/config/tests/testdata/spec28.spec
vendored
7
src/lib/config/tests/testdata/spec28.spec
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec28",
|
||||
'commands': [ ]
|
||||
}
|
||||
}
|
||||
|
35
src/lib/config/tests/testdata/spec29.spec
vendored
35
src/lib/config/tests/testdata/spec29.spec
vendored
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec29",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"command_name": "good_command",
|
||||
"command_description": "A good command",
|
||||
"command_args": []
|
||||
},
|
||||
{
|
||||
"command_name": "bad_command",
|
||||
"command_description": "A bad command",
|
||||
"command_args": []
|
||||
},
|
||||
{
|
||||
"command_name": "command_with_arg",
|
||||
"command_description": "A command with an (integer) argument",
|
||||
"command_args": [ {
|
||||
"item_name": "number",
|
||||
"item_type": "integer",
|
||||
"item_optional": true,
|
||||
"item_default": 1
|
||||
} ]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
13
src/lib/config/tests/testdata/spec3.spec
vendored
13
src/lib/config/tests/testdata/spec3.spec
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec3",
|
||||
"config_data": [
|
||||
{
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
45
src/lib/config/tests/testdata/spec30.spec
vendored
45
src/lib/config/tests/testdata/spec30.spec
vendored
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "lists",
|
||||
"module_description": "Logging options",
|
||||
"config_data": [
|
||||
{
|
||||
"item_name": "first_list_items",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec": {
|
||||
"item_name": "first_list_item",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "foo",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "foo"
|
||||
},
|
||||
{ "item_name": "second_list_items",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec": {
|
||||
"item_name": "second_list_item",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "final_element",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "hello"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
63
src/lib/config/tests/testdata/spec31.spec
vendored
63
src/lib/config/tests/testdata/spec31.spec
vendored
@@ -1,63 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "lists",
|
||||
"module_description": "Logging options",
|
||||
"config_data": [
|
||||
{
|
||||
"item_name": "first_list_items",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec": {
|
||||
"item_name": "first_list_item",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "foo",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "foo"
|
||||
},
|
||||
{ "item_name": "second_list_items",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec": {
|
||||
"item_name": "second_list_item",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "map_element",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "list1",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec":
|
||||
{ "item_name": "list2",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec":
|
||||
{ "item_name": "number",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
72
src/lib/config/tests/testdata/spec32.spec
vendored
72
src/lib/config/tests/testdata/spec32.spec
vendored
@@ -1,72 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec32",
|
||||
"config_data": [
|
||||
{ "item_name": "named_set_item",
|
||||
"item_type": "named_set",
|
||||
"item_optional": false,
|
||||
"item_default": { "a": 1, "b": 2 },
|
||||
"named_set_item_spec": {
|
||||
"item_name": "named_set_element",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 3
|
||||
}
|
||||
},
|
||||
{ "item_name": "named_set_item2",
|
||||
"item_type": "named_set",
|
||||
"item_optional": true,
|
||||
"item_default": { },
|
||||
"named_set_item_spec": {
|
||||
"item_name": "named_set_element",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": {},
|
||||
"map_item_spec": [
|
||||
{ "item_name": "first",
|
||||
"item_type": "integer",
|
||||
"item_optional": true
|
||||
},
|
||||
{ "item_name": "second",
|
||||
"item_type": "string",
|
||||
"item_optional": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{ "item_name": "named_set_item3",
|
||||
"item_type": "named_set",
|
||||
"item_optional": true,
|
||||
"item_default": { "values": [ 1, 2, 3 ] },
|
||||
"named_set_item_spec": {
|
||||
"item_name": "named_set_element",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec":
|
||||
{ "item_name": "list_value",
|
||||
"item_type": "integer",
|
||||
"item_optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "item_name": "named_set_item4",
|
||||
"item_type": "named_set",
|
||||
"item_optional": true,
|
||||
"item_default": {},
|
||||
"named_set_item_spec": {
|
||||
"item_name": "named_set_element",
|
||||
"item_type": "named_set",
|
||||
"item_optional": false,
|
||||
"item_default": { "a": 1, "b": 2 },
|
||||
"named_set_item_spec":
|
||||
{ "item_name": "named_set_element",
|
||||
"item_type": "integer",
|
||||
"item_optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
50
src/lib/config/tests/testdata/spec33.spec
vendored
50
src/lib/config/tests/testdata/spec33.spec
vendored
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec33",
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "dummy_str",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "Dummy",
|
||||
"item_title": "Dummy String",
|
||||
"item_description": "A dummy string"
|
||||
},
|
||||
{
|
||||
"item_name": "dummy_int",
|
||||
"item_type": "integer",
|
||||
"item_optional": false,
|
||||
"item_default": 0,
|
||||
"item_title": "Dummy Integer",
|
||||
"item_description": "A dummy integer"
|
||||
},
|
||||
{
|
||||
"item_name": "dummy_datetime",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "1970-01-01T00:00:00Z",
|
||||
"item_title": "Dummy DateTime",
|
||||
"item_description": "A dummy datetime",
|
||||
"item_format": "date-time"
|
||||
},
|
||||
{
|
||||
"item_name": "dummy_date",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "1970-01-01",
|
||||
"item_title": "Dummy Date",
|
||||
"item_description": "A dummy date",
|
||||
"item_format": "date"
|
||||
},
|
||||
{
|
||||
"item_name": "dummy_time",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "00:00:00",
|
||||
"item_title": "Dummy Time",
|
||||
"item_description": "A dummy time",
|
||||
"item_format": "time"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
14
src/lib/config/tests/testdata/spec34.spec
vendored
14
src/lib/config/tests/testdata/spec34.spec
vendored
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec34",
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "dummy_str",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "Dummy",
|
||||
"item_description": "A dummy string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
15
src/lib/config/tests/testdata/spec35.spec
vendored
15
src/lib/config/tests/testdata/spec35.spec
vendored
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec35",
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "dummy_str",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "Dummy",
|
||||
"item_title": "Dummy String"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
17
src/lib/config/tests/testdata/spec36.spec
vendored
17
src/lib/config/tests/testdata/spec36.spec
vendored
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec36",
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "dummy_str",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "Dummy",
|
||||
"item_title": "Dummy String",
|
||||
"item_description": "A dummy string",
|
||||
"item_format": "dummy"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
7
src/lib/config/tests/testdata/spec37.spec
vendored
7
src/lib/config/tests/testdata/spec37.spec
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec37",
|
||||
"statistics": 8
|
||||
}
|
||||
}
|
||||
|
17
src/lib/config/tests/testdata/spec38.spec
vendored
17
src/lib/config/tests/testdata/spec38.spec
vendored
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec38",
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "dummy_datetime",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": "11",
|
||||
"item_title": "Dummy DateTime",
|
||||
"item_description": "A dummy datetime",
|
||||
"item_format": "date-time"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
21
src/lib/config/tests/testdata/spec39.spec
vendored
21
src/lib/config/tests/testdata/spec39.spec
vendored
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec39",
|
||||
"config_data": [
|
||||
{ "item_name": "list",
|
||||
"item_type": "list",
|
||||
"item_optional": false,
|
||||
"item_default": [],
|
||||
"list_item_spec": {
|
||||
"item_name": "list_item",
|
||||
"item_type": "boolean",
|
||||
"item_optional": false,
|
||||
"item_default": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"commands": [],
|
||||
"statistics": []
|
||||
}
|
||||
}
|
||||
|
12
src/lib/config/tests/testdata/spec4.spec
vendored
12
src/lib/config/tests/testdata/spec4.spec
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_optional": false,
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
21
src/lib/config/tests/testdata/spec40.spec
vendored
21
src/lib/config/tests/testdata/spec40.spec
vendored
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec40",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "any",
|
||||
"item_optional": false,
|
||||
"item_default": "asdf"
|
||||
},
|
||||
{ "item_name": "item2",
|
||||
"item_type": "any",
|
||||
"item_optional": true
|
||||
},
|
||||
{ "item_name": "item3",
|
||||
"item_type": "any",
|
||||
"item_optional": true,
|
||||
"item_default": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
35
src/lib/config/tests/testdata/spec41.spec
vendored
35
src/lib/config/tests/testdata/spec41.spec
vendored
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec40",
|
||||
"statistics": [
|
||||
{
|
||||
"item_name": "zones",
|
||||
"item_type": "named_set",
|
||||
"item_optional": false,
|
||||
"item_default": { },
|
||||
"item_title": "Dummy name set",
|
||||
"item_description": "A dummy name set",
|
||||
"named_set_item_spec": {
|
||||
"item_name": "zonename",
|
||||
"item_type": "map",
|
||||
"item_optional": false,
|
||||
"item_default": { },
|
||||
"map_item_spec": [
|
||||
{
|
||||
"item_name": "queries.tcp",
|
||||
"item_optional": false,
|
||||
"item_type": "integer",
|
||||
"item_default": 0
|
||||
},
|
||||
{
|
||||
"item_name": "queries.udp",
|
||||
"item_optional": false,
|
||||
"item_type": "integer",
|
||||
"item_default": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
17
src/lib/config/tests/testdata/spec42.spec
vendored
17
src/lib/config/tests/testdata/spec42.spec
vendored
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec42",
|
||||
"config_data": [
|
||||
{ "item_name": "list_item",
|
||||
"item_type": "list",
|
||||
"item_optional": true,
|
||||
"list_item_spec": {
|
||||
"item_name": "list_element",
|
||||
"item_type": "string",
|
||||
"item_optional": false,
|
||||
"item_default": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
12
src/lib/config/tests/testdata/spec5.spec
vendored
12
src/lib/config/tests/testdata/spec5.spec
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"module_spec": {
|
||||
"module_name": "Spec2",
|
||||
"config_data": [
|
||||
{ "item_name": "item1",
|
||||
"item_type": "integer",
|
||||
"item_default": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user