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])
#include <config.h>
#include <log/logger_support.h>
-#include <dhcp4/dhcp4_log.h>
+
#include <gtest/gtest.h>
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);
}
// 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);
// 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);
// 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);
#include <config.h>
#include <log/logger_support.h>
-
#include <gtest/gtest.h>
int
// 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);
// 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);
#include <config.h>
#include <log/logger_support.h>
-
#include <gtest/gtest.h>
int
// 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);
#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);
SUBDIRS = . tests
-AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
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
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
+++ /dev/null
-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.
--- /dev/null
+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.
#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>
#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
/// 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_))
- ),
+ 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_))),
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);
}
}
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,
- query_message->getHeaderFlag(Message::HEADERFLAG_RD));
- msg->setHeaderFlag(Message::HEADERFLAG_CD,
- query_message->getHeaderFlag(Message::HEADERFLAG_CD));
-
- initIOFetch(msg, protocol, service,
- **(query_message->beginQuestion()),
- address, port, buff, cb, wait);
+ 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));
+ question->setHeaderFlag(Message::HEADERFLAG_CD,
+ query_message->getHeaderFlag(Message::HEADERFLAG_CD));
+
+ 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) {
}
}
-// 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) {
}
}
-// 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) &&
arg(data_->remote_snd->getPort());
}
-} // namespace asiodns
-} // namespace isc {
+} // namespace asiodns
+} // namespace isc
// 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.
#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 {
// 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.
+ ///
+ /// 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
+ /// @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
-} // namespace isc
+} // namespace asiodns
+} // namespace isc
#endif // IO_FETCH_H
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
#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 {
}
-} // namespace asiodns
-} // namespace isc
+} // namespace asiodns
+} // namespace isc
#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());
}
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
}
};
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // DUMMY_IO_CB_H
return (impl_->getInterval());
}
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
typedef boost::shared_ptr<isc::asiolink::IntervalTimer> IntervalTimerPtr;
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
+
#endif // ASIOLINK_INTERVAL_TIMER_H
}
}
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
/// \return The hash of the IOAddress.
size_t hash_value(const IOAddress& address);
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
+
#endif // IO_ADDRESS_H
// See the description of the namespace below.
#include <config.h>
-#include <unistd.h> // for some network system calls
-
-#include <functional>
-#include <string>
#include <exceptions/exceptions.h>
-
-#include <util/buffer.h>
-
#include <asiolink/io_error.h>
#include <asiolink/io_socket.h>
+#include <util/buffer.h>
+
+#include <functional>
+#include <string>
+
+#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
IOAsioSocket() {}
public:
/// The destructor.
- virtual ~IOAsioSocket() {}
+ virtual ~IOAsioSocket() = default;
//@}
/// \brief Return the "native" representation of the socket.
/// 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
- /// needed. This is always true for UDP, but for TCP involves
- /// checking the amount of data received so far against the amount
- /// expected (as indicated by the two-byte count field). If this
- /// method returns false, another read should be queued and data
- /// should be read into the staging buffer at offset given by the
- /// "offset" parameter.
+ /// needed. This is always true for UDP, but for TCP involves
+ /// checking the amount of data received so far against the amount
+ /// expected (as indicated by the two-byte count field). If this
+ /// method returns false, another read should be queued and data
+ /// 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;
const int protocol_;
};
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // IO_ASIO_SOCKET_H
os << ":" << boost::lexical_cast<string>(endpoint.getPort());
return (os);
}
-} // namespace asiolink
-} // namespace isc
+
+} // namespace asiolink
+} // namespace isc
/// \return A reference to the same \c std::ostream object referenced by
/// parameter \c os after the insertion operation.
std::ostream& operator<<(std::ostream& os, const IOEndpoint& endpoint);
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // IO_ENDPOINT_H
-// Local Variables:
-// mode: c++
-// End:
isc::Exception(file, line, what) {}
};
-
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // IO_ERROR_H
return (io_impl_->post(callback));
}
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
/// @brief Defines a smart pointer to an IOService instance.
typedef boost::shared_ptr<IOService> IOServicePtr;
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
+
#endif // ASIOLINK_IO_SERVICE_H
return (socket);
}
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
static IOSocket& getDummyTCPSocket();
};
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // IO_SOCKET_H
boost::asio::ip::tcp::endpoint& asio_endpoint_;
};
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // TCP_ENDPOINT_H
-
-// Local Variables:
-// mode: c++
-// End:
// 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 {
/// 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();
}
}
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // TCP_SOCKET_H
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
#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.
#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());
}
#include <string>
#include <vector>
-using namespace boost::asio;
-using namespace boost::asio::ip;
-using namespace isc::util;
using namespace isc::asiolink;
+using namespace isc::util;
+
using namespace std;
+using namespace boost::asio;
+using namespace boost::asio::ip;
namespace {
#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 {
boost::asio::ip::udp::endpoint& asio_endpoint_;
};
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // UDP_ENDPOINT_H
-
-// Local Variables:
-// mode: c++
-// End:
/// 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();
}
}
-} // namespace asiolink
-} // namespace isc
+} // namespace asiolink
+} // namespace isc
#endif // UDP_SOCKET_H
} // namespace isc
#endif // ISC_DATA_H
-
-// Local Variables:
-// mode: c++
-// End:
#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>
#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());
}
-/data_def_unittests_config.h
/run_unittests
-SUBDIRS = testdata .
+SUBDIRS = .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES)
endif
CLEANFILES = *.gcno *.gcda
-DISTCLEANFILES = data_def_unittests_config.h
TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+++ /dev/null
-// 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"
#include <config.h>
#include <gtest/gtest.h>
+
#include <util/unittests/run_all.h>
#include <log/logger_support.h>
+++ /dev/null
-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
+++ /dev/null
-{
- "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 } }
-}
+++ /dev/null
-{
- "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 } }
-}
+++ /dev/null
-{
- "value1": "asdf",
- "value2": 2.3,
- "value3": true,
- "value4": "foo",
- "value5": [ 1, 2, 3 ],
- "value6": { "v61": "bar", "v62": true }
-}
+++ /dev/null
-{
- "value1": 1,
- "value2": false,
- "value3": true,
- "value4": "foo",
- "value5": [ 1, 2, 3 ],
- "value6": { "v61": "bar", "v62": true }
-}
+++ /dev/null
-{
- "value1": 1,
- "value2": 2.3,
- "value3": true,
- "value4": "foo",
- "value5": [ 1, 2, "a" ],
- "value6": { "v61": "bar", "v62": true }
-}
+++ /dev/null
-{
- "value1": 1,
- "value2": 2.3,
- "value3": true,
- "value4": "foo",
- "value5": [ 1, 2, 3 ],
- "value6": { "v61": "bar", "v62": "Break" }
-}
+++ /dev/null
-{
- "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 } }
-}
+++ /dev/null
-{
- "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 } }
-}
+++ /dev/null
-{
- "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 } }
-}
+++ /dev/null
-{
- "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
-}
+++ /dev/null
-{
- "named_set_item": { "foo": 1, "bar": 2 }
-}
+++ /dev/null
-{
- "named_set_item": { "foo": "wrongtype", "bar": 2 }
-}
+++ /dev/null
-{
- "named_set_item": []
-}
+++ /dev/null
-{
- "dummy_str": "Dummy String",
- "dummy_int": 118,
- "dummy_datetime": "2011-05-27T19:42:57Z",
- "dummy_date": "2011-05-27",
- "dummy_time": "19:42:57"
-}
+++ /dev/null
-{
- "dummy_str": "Dummy String",
- "dummy_int": 118,
- "dummy_datetime": "xxxx",
- "dummy_date": "xxxx",
- "dummy_time": "xxxx"
-}
+++ /dev/null
-{
- "zones": {
- "example.org": {
- "queries.tcp": 100,
- "queries.udp": 200
- },
- "example.net": {
- "queries.tcp": 300,
- "queries.udp": 400
- }
- }
-}
+++ /dev/null
-{
- "zones": [
- {
- "example.org": {
- "queries.tcp": 100,
- "queries.udp": 200
- }
- },
- {
- "example.net": {
- "queries.tcp": 300,
- "queries.udp": 400
- }
- }
- ]
-}
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec1"
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "real",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "boolean",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "string",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "list",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "map",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "badname",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": 1
- }
-}
-
+++ /dev/null
-{
- "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": ""
- } ]
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "commands": [
- {
- "command_name": "print_message",
- "command_description": "Print the given message to stdout"
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "commands": [
- {
- "command_name": "print_message",
- "command_description": "Print the given message to stdout",
- "command_args": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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"
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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": ""
- } ]
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "commands": 1
- }
-}
-
+++ /dev/null
-{
- "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
- }
- ]
- }
- ]
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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": ""
- } ]
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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": ""
- }
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec25",
- "module_description": "Just an empty module"
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec26",
- "module_description": 1
- }
-}
+++ /dev/null
-{
- "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
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec28",
- 'commands': [ ]
- }
-}
-
+++ /dev/null
-{
- "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
- } ]
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec3",
- "config_data": [
- {
- "item_type": "integer",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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"
- }
- ]
- }
- }
- ]
- }
- }
- ]
- }
-}
+++ /dev/null
-{
- "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
- }
- }
- }]
- }
- ]
- }
- }
- ]
- }
- }
- ]
- }
-}
+++ /dev/null
-{
- "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
- }
- }
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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"
- }
- ]
- }
-}
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec34",
- "statistics": [
- {
- "item_name": "dummy_str",
- "item_type": "string",
- "item_optional": false,
- "item_default": "Dummy",
- "item_description": "A dummy string"
- }
- ]
- }
-}
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec35",
- "statistics": [
- {
- "item_name": "dummy_str",
- "item_type": "string",
- "item_optional": false,
- "item_default": "Dummy",
- "item_title": "Dummy String"
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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"
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec37",
- "statistics": 8
- }
-}
-
+++ /dev/null
-{
- "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"
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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": []
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_optional": false,
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "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
- }
- ]
- }
-}
+++ /dev/null
-{
- "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
- }
- ]
- }
- }
- ]
- }
-}
+++ /dev/null
-{
- "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": ""
- }
- }
- ]
- }
-}
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "integer",
- "item_default": 1
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "integer",
- "item_optional": false
- }
- ]
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- }
-}
-
+++ /dev/null
-{
- "module_spec": {
- "module_name": "Spec2",
- "config_data": [
- { "item_name": "item1",
- "item_type": "integer",
- "item_optional": false,
- "item_default": "asdf"
- }
- ]
- }
-}
-
libcb_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libcb_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libcb_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libcb_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libcb_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libcb_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libcb_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
#include <config.h>
-#include <log/logger_support.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);
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ isc::log::initLogger();
+ return (isc::util::unittests::run_all());
}
namespace isc {
namespace cryptolink {
-/// \brief Hash algorithm identifiers
+/// @brief Hash algorithm identifiers.
enum HashAlgorithm {
- UNKNOWN_HASH = 0, ///< This value can be used in conversion
- /// functions, to be returned when the
- /// input is unknown (but a value MUST be
- /// returned), for instance when the input
- /// is a Name or a string, and the return
- /// value is a HashAlgorithm.
- MD5 = 1, ///< MD5
- SHA1 = 2, ///< SHA-1
- SHA256 = 3, ///< SHA-256
- SHA224 = 4, ///< SHA-224
- SHA384 = 5, ///< SHA-384
- SHA512 = 6 ///< SHA-512
-
+ UNKNOWN_HASH = 0, // This value can be used in conversion
+ // functions, to be returned when the
+ // input is unknown (but a value MUST be
+ // returned), for instance when the input
+ // is a Name or a string, and the return
+ // value is a HashAlgorithm.
+ MD5 = 1, // MD5
+ SHA1 = 2, // SHA-1
+ SHA256 = 3, // SHA-256
+ SHA224 = 4, // SHA-224
+ SHA384 = 5, // SHA-384
+ SHA512 = 6 // SHA-512
};
-/// \brief Forward declaration for createHash()
+/// @brief Forward declaration for createHash().
class Hash;
-/// \brief Forward declaration for createHMAC()
+/// @brief Forward declaration for createHMAC().
class HMAC;
-/// \brief Forward declaration for getRNG()
+/// @brief Forward declaration for getRNG().
class RNG;
-/// \brief Type representing the pointer to the RNG.
+/// @brief Type representing the pointer to the RNG.
typedef boost::shared_ptr<RNG> RNGPtr;
-/// General exception class that is the base for all crypto-related
+/// @brief General exception class that is the base for all crypto-related
/// exceptions
class CryptoLinkError : public Exception {
public:
isc::Exception(file, line, what) {}
};
-/// This exception is thrown if there was a problem initializing the
+/// @brief This exception is thrown if there was a problem initializing the
/// crypto library
class InitializationError : public CryptoLinkError {
public:
CryptoLinkError(file, line, what) {}
};
-/// This exception is thrown when a cryptographic action is requested
+/// @brief This exception is thrown when a cryptographic action is requested
/// for an algorithm that is not supported by the underlying library.
class UnsupportedAlgorithm : public CryptoLinkError {
public:
CryptoLinkError(file, line, what) {}
};
-/// This exception is thrown when the underlying library could not
+/// @brief This exception is thrown when the underlying library could not
/// handle the key data.
class BadKey : public CryptoLinkError {
public:
CryptoLinkError(file, line, what) {}
};
-/// This exception is raised when a general error that was not
+/// @brief This exception is raised when a general error that was not
/// specifically caught is thrown by the underlying library. It
/// is replaced by this one so as not have 'external' exceptions
/// bubbling up
CryptoLinkError(file, line, what) {}
};
-/// \brief Forward declarations for CryptoLink pimpl.
+/// @brief Forward declarations for CryptoLink pimpl.
class CryptoLinkImpl;
-/// \brief Type representing the pointer to the CryptoLinkImpl.
+/// @brief Type representing the pointer to the CryptoLinkImpl.
typedef boost::shared_ptr<CryptoLinkImpl> CryptoLinkImplPtr;
-/// \brief Forward declarations for RNG pimpl.
+/// @brief Forward declarations for RNG pimpl.
class RNGImpl;
-/// \brief Singleton entry point and factory class
+/// @brief Singleton entry point and factory class
///
/// This is a singleton class that serves as the entry point to
/// the underlying cryptography library, and as a factory for objects
/// sure you do not forget this, is to place the result of the create
/// functions in a shared_ptr with the corresponding deleter function.
///
-/// \note All other classes within cryptolink should have private
+/// @note All other classes within cryptolink should have private
/// constructors as well, and should have a factory function from
/// CryptoLink, and a deleter function.
///
-// Internal note: we can use this class later to initialize and manage
-// dynamic (PKCS#11) libs
+/// Internal note: we can use this class later to initialize and manage
+/// dynamic (PKCS#11) libs.
class CryptoLink : private boost::noncopyable {
public:
- /// \brief Returns a reference to the singleton instance
+ /// @brief Returns a reference to the singleton instance.
///
/// If the library has not been initialized yet, it will be
/// initialized with some default values.
/// Since this class is noncopyable, you must use the return
/// value directly, or store it in a reference variable.
///
- /// \exception InitializationError if initialization fails
+ /// @throw InitializationError if initialization fails.
///
- /// \return Reference to the singleton instance
+ /// @return Reference to the singleton instance.
static CryptoLink& getCryptoLink();
- /// \brief Get version string
+ /// @brief Get version string.
+ ///
+ /// @return The version as string.
static std::string getVersion();
- /// \brief Factory function for Hash objects
+ /// @brief Factory function for Hash objects.
///
/// CryptoLink objects cannot be constructed directly. This
/// function creates a new Hash object usable for signing or
///
/// If you want to safely delete objects created with this method,
/// you can use the function deleteHash() as defined in
- /// crypto_hash.h
+ /// crypto_hash.h.
+ ///
+ /// @throw UnsupportedAlgorithmException if the given algorithm
+ /// is unknown or not supported by the underlying library.
+ /// @throw LibraryError if there was any unexpected exception
+ /// in the underlying library.
///
- /// \exception UnsupportedAlgorithmException if the given algorithm
- /// is unknown or not supported by the underlying library
- /// \exception LibraryError if there was any unexpected exception
- /// in the underlying library
+ /// @param hash_algorithm The hash algorithm.
///
- /// \param hash_algorithm The hash algorithm
+ /// @return The new hash.
Hash* createHash(const HashAlgorithm hash_algorithm);
- /// \brief Factory function for HMAC objects
+ /// @brief Factory function for HMAC objects
///
/// CryptoLink objects cannot be constructed directly. This
/// function creates a new HMAC object usable for signing or
/// Notes: if the secret is longer than the block size of its
/// algorithm, the constructor will run it through the hash
/// algorithm, and use the digest as the secret for this HMAC
- /// operation
+ /// operation.
///
/// If you want to safely delete objects created with this method,
/// you can use the function deleteHMAC() as defined in
- /// crypto_hmac.h
+ /// crypto_hmac.h.
///
- /// \exception UnsupportedAlgorithmException if the given algorithm
- /// is unknown or not supported by the underlying library
- /// \exception InvalidKeyLength if the given key secret_len is bad
- /// \exception LibraryError if there was any unexpected exception
- /// in the underlying library
+ /// @throw UnsupportedAlgorithmException if the given algorithm
+ /// is unknown or not supported by the underlying library.
+ /// @throw InvalidKeyLength if the given key secret_len is bad.
+ /// @throw LibraryError if there was any unexpected exception
+ /// in the underlying library.
///
- /// \param secret The secret to sign with
- /// \param secret_len The length of the secret
- /// \param hash_algorithm The hash algorithm
+ /// @param secret The secret to sign with
+ /// @param secret_len The length of the secret
+ /// @param hash_algorithm The hash algorithm
+ ///
+ /// @return The new hash.
HMAC* createHMAC(const void* secret, size_t secret_len,
const HashAlgorithm hash_algorithm);
- /// \brief Get the global RNG
+ /// @brief Get the global RNG.
+ ///
+ /// @throw NotImplemented if the method was not implemented
+ /// in a derived class.
+ /// @throw LibraryError if there was any unexpected exception
+ /// in the underlying library.
///
- /// \exception NotImplemented if the method was not implemented
- /// in a derived class
- /// \exception LibraryError if there was any unexpected exception
- /// in the underlying library
+ /// @return The gobal RNG.
virtual RNGPtr const& getRNG() const;
private:
- /// \brief Initialize the library
+ /// @brief Initialize the library.
///
/// If the library has already been initialized (either by a call
/// to initialize() or automatically in getCryptoLink()), this
/// function does nothing.
///
- /// \note A call to initialize() is not strictly necessary with
+ /// @note A call to initialize() is not strictly necessary with
/// the current implementation.
///
- /// \exception InitializationError if initialization fails
+ /// @throw InitializationError if initialization fails.
///
- /// \param c the CryptoLink singleton instance which is being initialized.
+ /// @param c the CryptoLink singleton instance which is being initialized.
void initialize(CryptoLink& c);
- // To prevent people constructing their own, we make the constructor
- // private too.
+ /// @note To prevent people constructing their own, we make the constructor
+ /// private too.
CryptoLink() {
initialize(*this);
}
~CryptoLink();
- /// \brief Smart pointer holding the implementation.
+ /// @brief Smart pointer holding the implementation.
CryptoLinkImplPtr impl_;
- /// \brief Smart pointer holding the RNG.
+ /// @brief Smart pointer holding the RNG.
RNGPtr rng_;
};
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
+
#include <gtest/gtest.h>
-#include <log/logger_support.h>
#include <util/unittests/run_all.h>
+#include <log/logger_support.h>
int
main(int argc, char* argv[]) {
libd2srv_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libd2srv_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libd2srv_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libd2srv_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libd2srv_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libd2srv_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libd2srv_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libdatabase_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libdatabase_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libdhcp___unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libdhcp___unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
ASSERT_EQ(expected_vec.size(), buf.getLength());
// Check that the generated wire format is correct.
- const uint8_t* data = buf.getData();
const std::vector<uint8_t>& vec = buf.getVector();
ASSERT_TRUE(std::equal(vec.cbegin(), vec.cend(), expected_vec.cbegin()));
}
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libdhcp_ddns_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libdhcpsrv_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
public:
/// Constants to specify the operation mode of the \c Message.
enum Mode {
- PARSE = 0, ///< Parse mode (handling an incoming message)
- RENDER = 1 ///< Render mode (building an outgoing message)
+ PARSE = 0, // Parse mode (handling an incoming message)
+ RENDER = 1 // Render mode (building an outgoing message)
};
/// \brief Constants for flag bit fields of a DNS message header.
/// between the complexity and advantage, but hopefully the cast notation
/// is sufficiently ugly to prevent proliferation of the usage.
enum HeaderFlag {
- HEADERFLAG_QR = 0x8000, ///< Query (if cleared) or response (if set)
- HEADERFLAG_AA = 0x0400, ///< Authoritative answer
- HEADERFLAG_TC = 0x0200, ///< Truncation
- HEADERFLAG_RD = 0x0100, ///< Recursion desired
- HEADERFLAG_RA = 0x0080, ///< Recursion available
- HEADERFLAG_AD = 0x0020, ///< Authentic %data (RFC4035)
- HEADERFLAG_CD = 0x0010 ///< DNSSEC checking disabled (RFC4035)
+ HEADERFLAG_QR = 0x8000, // Query (if cleared) or response (if set)
+ HEADERFLAG_AA = 0x0400, // Authoritative answer
+ HEADERFLAG_TC = 0x0200, // Truncation
+ HEADERFLAG_RD = 0x0100, // Recursion desired
+ HEADERFLAG_RA = 0x0080, // Recursion available
+ HEADERFLAG_AD = 0x0020, // Authentic %data (RFC4035)
+ HEADERFLAG_CD = 0x0010 // DNSSEC checking disabled (RFC4035)
};
/// \brief Constants to specify sections of a DNS message.
/// <b>Future Extension:</b> We'll probably also define constants for
/// the section names used in dynamic updates in future versions.
enum Section {
- SECTION_QUESTION = 0, ///< %Question section
- SECTION_ANSWER = 1, ///< Answer section
- SECTION_AUTHORITY = 2, ///< Authority section
- SECTION_ADDITIONAL = 3 ///< Additional section
+ SECTION_QUESTION = 0, // Question section
+ SECTION_ANSWER = 1, // Answer section
+ SECTION_AUTHORITY = 2, // Authority section
+ SECTION_ADDITIONAL = 3 // Additional section
};
///
/// These are values of a bitmask type. Bitwise operations can be
/// performed on these values to express compound options.
enum ParseOptions {
- PARSE_DEFAULT = 0, ///< The default options
- PRESERVE_ORDER = 1 ///< Preserve RR order and don't combine them
+ PARSE_DEFAULT = 0, // The default options
+ PRESERVE_ORDER = 1 // Preserve RR order and don't combine them
};
/// \brief Parse the header section of the \c Message.
/// In addition, if resource allocation for the new name fails, a
/// corresponding standard exception will be thrown.
///
- /// \param buffer A buffer storing the wire format %data.
+ /// \param buff A buffer storing the wire format %data.
/// \param downcase Whether to convert upper case alphabets to lower case.
- explicit Name(isc::util::InputBuffer& buffer, bool downcase = false);
+ explicit Name(isc::util::InputBuffer& buff, bool downcase = false);
///
/// We use the default copy constructor intentionally.
//@}
/// <code>buffer.getCapacity() - buffer.getLength() >= Name::MAX_WIRE</code>
/// then this method should not throw an exception.
///
- /// \param buffer An output buffer to store the wire %data.
- void toWire(isc::util::OutputBuffer& buffer) const;
+ /// \param buff An output buffer to store the wire %data.
+ void toWire(isc::util::OutputBuffer& buff) const;
//@}
///
/// It may throw an exception if the construction of these component
/// classes fails.
///
- /// \param buffer A buffer storing the wire format data.
- Question(isc::util::InputBuffer& buffer);
+ /// \param buff A buffer storing the wire format data.
+ Question(isc::util::InputBuffer& buff);
/// \brief Constructor from fixed parameters of the \c Question.
///
/// conversion is specific to each derived concrete class and
/// should be explicitly defined in the derived class.
///
- /// \param buffer An output buffer to store the wire data.
- virtual void toWire(isc::util::OutputBuffer& buffer) const = 0;
+ /// \param buff An output buffer to store the wire data.
+ virtual void toWire(isc::util::OutputBuffer& buff) const = 0;
/// \brief Render the \c Rdata in the wire format into a
/// \c MessageRenderer object.
/// contain \c rdata_len bytes of unread data, an exception of
/// class \c isc::OutOfRange will be thrown.
///
- /// \param buffer A reference to an \c InputBuffer object storing the
+ /// \param buff A reference to an \c InputBuffer object storing the
/// \c Rdata to parse.
/// \param rdata_len The length in buffer of the \c Rdata. In bytes.
- Generic(isc::util::InputBuffer& buffer, size_t rdata_len);
+ Generic(isc::util::InputBuffer& buff, size_t rdata_len);
/// \brief Constructor from master lexer.
///
/// necessary memory space fails, a corresponding standard exception will
/// be thrown.
///
- /// \param buffer An output buffer to store the wire data.
- virtual void toWire(isc::util::OutputBuffer& buffer) const;
+ /// \param buff An output buffer to store the wire data.
+ virtual void toWire(isc::util::OutputBuffer& buff) const;
/// \brief Render the \c generic::Generic in the wire format into a
/// \c MessageRenderer object.
///
/// \param rrtype An \c RRType object specifying the type/class pair.
/// \param rrclass An \c RRClass object specifying the type/class pair.
-/// \param buffer A reference to an \c InputBuffer object storing the
+/// \param buff A reference to an \c InputBuffer object storing the
/// \c Rdata to parse.
/// \param len The length in buffer of the \c Rdata. In bytes.
/// \return An \c RdataPtr object pointing to the created \c Rdata
/// object.
RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
- isc::util::InputBuffer& buffer, size_t len);
+ isc::util::InputBuffer& buff, size_t len);
/// \brief Create RDATA of a given pair of RR type and class, copying
/// of another RDATA of same kind.
/// of specific class corresponding to the specific derived class of
/// \c AbstractRdataFactory.
///
- /// \param buffer A reference to an \c InputBuffer object storing the
+ /// \param buff A reference to an \c InputBuffer object storing the
/// \c Rdata to parse.
/// \param rdata_len The length in buffer of the \c Rdata. In bytes.
/// \return An \c RdataPtr object pointing to the created \c Rdata object.
- virtual RdataPtr create(isc::util::InputBuffer& buffer,
+ virtual RdataPtr create(isc::util::InputBuffer& buff,
size_t rdata_len) const = 0;
/// \brief Create RDATA from another \c Rdata object of the same type.
///
/// \param rrtype An \c RRType object specifying the type/class pair.
/// \param rrclass An \c RRClass object specifying the type/class pair.
- /// \param buffer A reference to an \c InputBuffer object storing the
+ /// \param buff A reference to an \c InputBuffer object storing the
/// \c Rdata to parse.
/// \param len The length in buffer of the \c Rdata. In bytes.
/// \return An \c rdata::RdataPtr object pointing to the created \c Rdata
/// object.
rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass,
- isc::util::InputBuffer& buffer, size_t len);
+ isc::util::InputBuffer& buff, size_t len);
/// \brief Create RDATA of a given pair of RR type and class, copying
/// of another RDATA of same kind.
///
/// If the given data does not large enough to contain a 16-bit integer,
/// an exception of class \c IncompleteRRTTL will be thrown.
///
- /// \param buffer A buffer storing the wire format data.
- explicit RRTTL(isc::util::InputBuffer& buffer);
+ /// \param buff A buffer storing the wire format data.
+ explicit RRTTL(isc::util::InputBuffer& buff);
/// A separate factory of RRTTL from text.
///
/// If resource allocation in rendering process fails, a corresponding
/// standard exception will be thrown.
///
- /// \param buffer An output buffer to store the wire data.
- void toWire(isc::util::OutputBuffer& buffer) const;
+ /// \param buff An output buffer to store the wire data.
+ void toWire(isc::util::OutputBuffer& buff) const;
//@}
///
namespace isc {
namespace dns {
-namespace {
- HashAlgorithm
- convertAlgorithmName(const isc::dns::Name& name) {
- if (name == TSIGKey::HMACMD5_NAME()) {
- return (isc::cryptolink::MD5);
- }
- if (name == TSIGKey::HMACMD5_SHORT_NAME()) {
- return (isc::cryptolink::MD5);
- }
- if (name == TSIGKey::HMACSHA1_NAME()) {
- return (isc::cryptolink::SHA1);
- }
- if (name == TSIGKey::HMACSHA256_NAME()) {
- return (isc::cryptolink::SHA256);
- }
- if (name == TSIGKey::HMACSHA224_NAME()) {
- return (isc::cryptolink::SHA224);
- }
- if (name == TSIGKey::HMACSHA384_NAME()) {
- return (isc::cryptolink::SHA384);
- }
- if (name == TSIGKey::HMACSHA512_NAME()) {
- return (isc::cryptolink::SHA512);
- }
-
- return (isc::cryptolink::UNKNOWN_HASH);
- }
-}
-
struct
TSIGKey::TSIGKeyImpl {
TSIGKeyImpl(const Name& key_name, const Name& algorithm_name,
const vector<uint8_t> secret_;
};
+namespace {
+ HashAlgorithm
+ convertAlgorithmName(const isc::dns::Name& name) {
+ if (name == TSIGKey::HMACMD5_NAME()) {
+ return (isc::cryptolink::MD5);
+ }
+ if (name == TSIGKey::HMACMD5_SHORT_NAME()) {
+ return (isc::cryptolink::MD5);
+ }
+ if (name == TSIGKey::HMACSHA1_NAME()) {
+ return (isc::cryptolink::SHA1);
+ }
+ if (name == TSIGKey::HMACSHA224_NAME()) {
+ return (isc::cryptolink::SHA224);
+ }
+ if (name == TSIGKey::HMACSHA256_NAME()) {
+ return (isc::cryptolink::SHA256);
+ }
+ if (name == TSIGKey::HMACSHA384_NAME()) {
+ return (isc::cryptolink::SHA384);
+ }
+ if (name == TSIGKey::HMACSHA512_NAME()) {
+ return (isc::cryptolink::SHA512);
+ }
+
+ return (isc::cryptolink::UNKNOWN_HASH);
+ }
+}
+
TSIGKey::TSIGKey(const Name& key_name, const Name& algorithm_name,
const void* secret, size_t secret_len,
size_t digestbits /*= 0*/) : impl_(0) {
}
}
-const
-Name& TSIGKey::HMACMD5_NAME() {
- static Name alg_name("hmac-md5.sig-alg.reg.int");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::HMACMD5_SHORT_NAME() {
- static Name alg_name("hmac-md5");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::HMACSHA1_NAME() {
- static Name alg_name("hmac-sha1");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::HMACSHA256_NAME() {
- static Name alg_name("hmac-sha256");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::HMACSHA224_NAME() {
- static Name alg_name("hmac-sha224");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::HMACSHA384_NAME() {
- static Name alg_name("hmac-sha384");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::HMACSHA512_NAME() {
- static Name alg_name("hmac-sha512");
- return (alg_name);
-}
-
-const
-Name& TSIGKey::GSSTSIG_NAME() {
- static Name alg_name("gss-tsig");
- return (alg_name);
-}
-
struct TSIGKeyRing::TSIGKeyRingImpl {
typedef map<Name, TSIGKey> TSIGKeyMap;
typedef pair<Name, TSIGKey> NameAndKey;
TSIGKeyRing::Result
TSIGKeyRing::add(const TSIGKey& key) {
- if (impl_->keys.insert(
- TSIGKeyRingImpl::NameAndKey(key.getKeyName(), key)).second
- == true) {
+ if (impl_->keys.insert(TSIGKeyRingImpl::NameAndKey(key.getKeyName(), key)).second) {
return (SUCCESS);
} else {
return (EXIST);
return (FindResult(SUCCESS, &((*found).second)));
}
+const
+Name& TSIGKey::HMACMD5_NAME() {
+ static Name alg_name("hmac-md5.sig-alg.reg.int");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::HMACMD5_SHORT_NAME() {
+ static Name alg_name("hmac-md5");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::HMACSHA1_NAME() {
+ static Name alg_name("hmac-sha1");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::HMACSHA224_NAME() {
+ static Name alg_name("hmac-sha224");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::HMACSHA256_NAME() {
+ static Name alg_name("hmac-sha256");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::HMACSHA384_NAME() {
+ static Name alg_name("hmac-sha384");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::HMACSHA512_NAME() {
+ static Name alg_name("hmac-sha512");
+ return (alg_name);
+}
+
+const
+Name& TSIGKey::GSSTSIG_NAME() {
+ static Name alg_name("gss-tsig");
+ return (alg_name);
+}
+
} // namespace dns
} // namespace isc
class Name;
-/// \brief TSIG key.
+/// @brief TSIG key.
///
/// This class holds a TSIG key along with some related attributes as
/// defined in RFC2845.
/// In the TSIG protocol, hash algorithms are represented in the form of
/// domain name.
/// Our interfaces provide direct translation of this concept; for example,
-/// the constructor from parameters take a \c Name object to specify the
+/// the constructor from parameters take a @class Name object to specify the
/// algorithm.
/// On one hand, this may be counter intuitive.
/// An API user would rather specify "hmac-md5" instead of
class TSIGKey {
public:
///
- /// \name Constructors, Assignment Operator and Destructor.
+ /// @brief Constructors, Assignment Operator and Destructor.
///
//@{
- /// \brief Constructor from key parameters
+ /// @brief Constructor from key parameters.
///
- /// \c algorithm_name should generally be a known algorithm to this
+ /// The algorithm_name should generally be a known algorithm to this
/// implementation, which are defined via the
/// <code>static const</code> member functions.
///
/// Other names are still accepted as long as the secret is empty
- /// (\c secret is null and \c secret_len is 0), however; in some cases
+ /// (secret is null and secret_len is 0), however; in some cases
/// we might want to treat just the pair of key name and algorithm name
/// opaquely, e.g., when generating a response TSIG with a BADKEY error
/// because the algorithm is unknown as specified in Section 3.2 of
/// RFC2845 (in which case the algorithm name would be copied from the
/// request to the response, and for that purpose it would be convenient
- /// if a \c TSIGKey object can hold a name for an "unknown" algorithm).
+ /// if a TSIGKey object can hold a name for an "unknown" algorithm).
///
- /// \note RFC2845 does not specify which algorithm name should be used
+ /// @note RFC2845 does not specify which algorithm name should be used
/// in such a BADKEY response. The behavior of using the same algorithm
/// is derived from the BIND 9 implementation.
///
/// accidental creation of such a dangerous key, e.g., due to misspelling
/// in a configuration file).
/// If the given algorithm name is unknown and non empty secret is
- /// specified, an exception of type \c InvalidParameter will be thrown.
+ /// specified, an exception of type InvalidParameter will be thrown.
///
- /// \c secret and \c secret_len must be consistent in that the latter
+ /// secret and secret_len must be consistent in that the latter
/// is 0 if and only if the former is null;
- /// otherwise an exception of type \c InvalidParameter will be thrown.
+ /// otherwise an exception of type InvalidParameter will be thrown.
///
- /// \c digestbits is the truncated length in bits or 0 which means no
+ /// digestbits is the truncated length in bits or 0 which means no
/// truncation and is the default. Constraints for non-zero value
/// are in RFC 4635 section 3.1: minimum 80 or the half of the
/// full (i.e., not truncated) length, integral number of octets
/// This constructor internally involves resource allocation, and if
/// it fails, a corresponding standard exception will be thrown.
///
- /// \param key_name The name of the key as a domain name.
- /// \param algorithm_name The hash algorithm used for this key in the
+ /// @param key_name The name of the key as a domain name.
+ /// @param algorithm_name The hash algorithm used for this key in the
/// form of domain name. For example, it can be
- /// \c TSIGKey::HMACSHA256_NAME() for HMAC-SHA256.
- /// \param secret Point to a binary sequence of the shared secret to be
+ /// TSIGKey::HMACSHA256_NAME() for HMAC-SHA256.
+ /// @param secret Point to a binary sequence of the shared secret to be
/// used for this key, or null if the secret is empty.
- /// \param secret_len The size of the binary %data (\c secret) in bytes.
- /// \param digestbits The number of bits to include in the digest
- /// (0 means to include all)
+ /// @param secret_len The size of the binary %data (secret) in bytes.
+ /// @param digestbits The number of bits to include in the digest
+ /// (0 means to include all).
TSIGKey(const Name& key_name, const Name& algorithm_name,
const void* secret, size_t secret_len, size_t digestbits = 0);
- /// \brief Constructor from an input string
+ /// @brief Constructor from an input string
///
/// The string must be of the form:
/// name:secret[:algorithm][:digestbits]
/// use this constructor to create keys with a ':' character in
/// their name.
///
- /// \exception InvalidParameter exception if the input string is
+ /// @throw InvalidParameter exception if the input string is
/// invalid.
///
- /// \param str The string to make a TSIGKey from
+ /// @param str The string to make a TSIGKey from
explicit TSIGKey(const std::string& str);
- /// \brief The copy constructor.
+ /// @brief The copy constructor.
///
/// It internally allocates a resource, and if it fails a corresponding
/// standard exception will be thrown.
/// This constructor never throws an exception otherwise.
TSIGKey(const TSIGKey& source);
- /// \brief Assignment operator.
+ /// @brief Assignment operator.
///
/// It internally allocates a resource, and if it fails a corresponding
/// standard exception will be thrown.
/// intact.
TSIGKey& operator=(const TSIGKey& source);
- /// The destructor.
+ /// @brief The destructor.
virtual ~TSIGKey();
//@}
///
- /// \name Getter Methods
+ /// @brief Getter Methods
///
/// These methods never throw an exception.
//@{
- /// Return the key name.
+ /// @brief Return the key name.
const Name& getKeyName() const;
- /// Return the algorithm name.
+ /// @brief Return the algorithm name.
const Name& getAlgorithmName() const;
- /// Return the hash algorithm name in the form of cryptolink::HashAlgorithm
+ /// @brief Return the hash algorithm name in the form of cryptolink::HashAlgorithm
isc::cryptolink::HashAlgorithm getAlgorithm() const;
- /// Return the minimum truncated length.
+ /// @brief Return the minimum truncated length.
size_t getDigestbits() const;
- /// Return the length of the TSIG secret in bytes.
+ /// @brief Return the length of the TSIG secret in bytes.
size_t getSecretLength() const;
- /// Return the value of the TSIG secret.
+ /// @brief Return the value of the TSIG secret.
///
/// If it returns a non null pointer, the memory region beginning at the
/// address returned by this method is valid up to the bytes specified
- /// by the return value of \c getSecretLength().
+ /// by the return value of getSecretLength().
///
- /// The memory region is only valid while the corresponding \c TSIGKey
- /// object is valid. The caller must hold the \c TSIGKey object while
+ /// The memory region is only valid while the corresponding TSIGKey
+ /// object is valid. The caller must hold the TSIGKey object while
/// it needs to refer to the region or it must make a local copy of the
/// region.
const void* getSecret() const;
//@}
- /// \brief Converts the TSIGKey to a string value
+ /// @brief Converts the TSIGKey to a string value
///
/// The resulting string will be of the form
- /// name:secret:algorithm[:digestbits]
+ /// name:secret:algorithm[:digestbits].
/// Where "name" is a domain name for the key, "secret" is a
/// base64 representation of the key secret, and "algorithm" is
/// an algorithm identifier as specified in RFC 4635.
/// When not zero, digestbits is appended.
///
- /// \return The string representation of the given TSIGKey.
+ /// @return The string representation of the given TSIGKey.
std::string toText() const;
- ///
- /// \name Well known algorithm names as defined in RFC2845 and RFC4635.
+ /// @brief Well known algorithm names as defined in RFC2845 and RFC4635.
///
/// Note: we begin with the "mandatory" algorithms defined in RFC4635
/// as a minimal initial set.
/// We'll add others as we see the need for them.
//@{
- static const Name& HMACMD5_NAME(); ///< HMAC-MD5 (RFC2845)
+ static const Name& HMACMD5_NAME(); // HMAC-MD5 (RFC2845)
static const Name& HMACMD5_SHORT_NAME();
- static const Name& HMACSHA1_NAME(); ///< HMAC-SHA1 (RFC4635)
- static const Name& HMACSHA256_NAME(); ///< HMAC-SHA256 (RFC4635)
- static const Name& HMACSHA224_NAME(); ///< HMAC-SHA256 (RFC4635)
- static const Name& HMACSHA384_NAME(); ///< HMAC-SHA256 (RFC4635)
- static const Name& HMACSHA512_NAME(); ///< HMAC-SHA256 (RFC4635)
- static const Name& GSSTSIG_NAME(); ///< GSS-TSIG (RFC3645)
+ static const Name& HMACSHA1_NAME(); // HMAC-SHA1 (RFC4635)
+ static const Name& HMACSHA256_NAME(); // HMAC-SHA256 (RFC4635)
+ static const Name& HMACSHA224_NAME(); // HMAC-SHA256 (RFC4635)
+ static const Name& HMACSHA384_NAME(); // HMAC-SHA256 (RFC4635)
+ static const Name& HMACSHA512_NAME(); // HMAC-SHA256 (RFC4635)
+ static const Name& GSSTSIG_NAME(); // GSS-TSIG (RFC3645)
//@}
private:
boost::shared_ptr<TSIGKeyImpl> impl_;
};
-/// \brief A simple repository of a set of \c TSIGKey objects.
+/// @brief A simple repository of a set of TSIGKey objects.
///
-/// This is a "key ring" to maintain TSIG keys (\c TSIGKey objects) and
+/// This is a "key ring" to maintain TSIG keys (TSIGKey objects) and
/// provides trivial operations such as add, remove, and find.
///
/// The keys are identified by their key names.
/// we may have to revisit the design.
class TSIGKeyRing {
public:
- /// Result codes of various public methods of \c TSIGKeyRing
+ /// Result codes of various public methods of TSIGKeyRing
enum Result {
- SUCCESS = 0, ///< The operation is successful.
- EXIST = 1, ///< A key is already stored in \c TSIGKeyRing.
- NOTFOUND = 2 ///< The specified key is not found in \c TSIGKeyRing.
+ SUCCESS = 0, // The operation is successful.
+ EXIST = 1, // A key is already stored in TSIGKeyRing.
+ NOTFOUND = 2 // The specified key is not found in TSIGKeyRing.
};
- /// \brief A helper structure to represent the search result of
+ /// @brief A helper structure to represent the search result of
/// <code>TSIGKeyRing::find()</code>.
///
/// This is a straightforward pair of the result code and a pointer
- /// to the found key to represent the result of \c find().
+ /// to the found key to represent the result of find().
/// We use this in order to avoid overloading the return value for both
/// the result code ("success" or "not found") and the found object,
/// i.e., avoid using null to mean "not found", etc.
/// convenience we allow the applications to refer to the members
/// directly.
///
- /// See the description of \c find() for the semantics of the member
+ /// See the description of find() for the semantics of the member
/// variables.
struct FindResult {
FindResult(Result param_code, const TSIGKey* param_key) :
};
///
- /// \name Constructors and Destructor.
+ /// @brief Constructors and Destructor.
///
- /// \b Note:
- /// The copy constructor and the assignment operator are
+ /// @note The copy constructor and the assignment operator are
/// intentionally defined as private, making this class non copyable.
/// There is no technical reason why this class cannot be copied,
/// but since the key ring can potentially have a large number of keys,
TSIGKeyRing(const TSIGKeyRing& source);
TSIGKeyRing& operator=(const TSIGKeyRing& source);
public:
- /// \brief The default constructor.
+ /// @brief The default constructor.
///
/// This constructor never throws an exception.
TSIGKeyRing();
- /// The destructor.
+ /// @brief The destructor.
~TSIGKeyRing();
//@}
- /// Return the number of keys stored in the \c TSIGKeyRing.
+ /// @brief Return the number of keys stored in the TSIGKeyRing.
///
/// This method never throws an exception.
unsigned int size() const;
- /// Add a \c TSIGKey to the \c TSIGKeyRing.
+ /// @brief Add a TSIGKey to the TSIGKeyRing.
///
/// This method will create a local copy of the given key, so the caller
/// does not have to keep owning it.
/// exception will be thrown.
/// This method never throws an exception otherwise.
///
- /// \param key A \c TSIGKey to be added.
- /// \return \c SUCCESS If the key is successfully added to the key ring.
- /// \return \c EXIST The key ring already stores a key whose name is
- /// identical to that of \c key.
+ /// @param key A TSIGKey to be added.
+ /// @return SUCCESS if the key is successfully added to the key ring or
+ /// EXIST if the key ring already stores a key whose name is identical to
+ /// that of key.
Result add(const TSIGKey& key);
- /// Remove a \c TSIGKey for the given name from the \c TSIGKeyRing.
+ /// Remove a TSIGKey for the given name from the TSIGKeyRing.
///
/// This method never throws an exception.
///
- /// \param key_name The name of the key to be removed.
- /// \return \c SUCCESS If the key is successfully removed from the key
- /// ring.
- /// \return \c NOTFOUND The key ring does not store the key that matches
- /// \c key_name.
+ /// @param key_name The name of the key to be removed.
+ /// @return SUCCESS if the key is successfully removed from the key
+ /// ring or NOTFOUND if the key ring does not store the key that matches
+ /// key_name.
Result remove(const Name& key_name);
- /// Find a \c TSIGKey for the given name in the \c TSIGKeyRing.
+ /// Find a TSIGKey for the given name in the TSIGKeyRing.
///
- /// It searches the internal storage for a \c TSIGKey whose name is
- /// \c key_name.
- /// It returns the result in the form of a \c FindResult
+ /// It searches the internal storage for a TSIGKey whose name is
+ /// key_name.
+ /// It returns the result in the form of a FindResult
/// object as follows:
- /// - \c code: \c SUCCESS if a key is found; otherwise \c NOTFOUND.
- /// - \c key: A pointer to the found \c TSIGKey object if one is found;
+ /// - code: SUCCESS if a key is found; otherwise NOTFOUND.
+ /// - key: A pointer to the found TSIGKey object if one is found;
/// otherwise null.
///
- /// The pointer returned in the \c FindResult object is only valid until
+ /// The pointer returned in the FindResult object is only valid until
/// the corresponding key is removed from the key ring.
/// The caller must ensure that the key is held in the key ring while
/// it needs to refer to it, or it must make a local copy of the key.
///
/// This method never throws an exception.
///
- /// \param key_name The name of the key to be found.
- /// \return A \c FindResult object enclosing the search result (see above).
+ /// @param key_name The name of the key to be found.
+ /// @return A FindResult object enclosing the search result (see above).
FindResult find(const Name& key_name) const;
- /// Find a \c TSIGKey for the given name in the \c TSIGKeyRing.
+ /// Find a TSIGKey for the given name in the TSIGKeyRing.
///
- /// It searches the internal storage for a \c TSIGKey whose name is
- /// \c key_name and that uses the hash algorithm identified by
- /// \c algorithm_name.
- /// It returns the result in the form of a \c FindResult
+ /// It searches the internal storage for a TSIGKey whose name is
+ /// key_name and that uses the hash algorithm identified by
+ /// algorithm_name.
+ /// It returns the result in the form of a FindResult
/// object as follows:
- /// - \c code: \c SUCCESS if a key is found; otherwise \c NOTFOUND.
- /// - \c key: A pointer to the found \c TSIGKey object if one is found;
+ /// - code: SUCCESS if a key is found; otherwise NOTFOUND.
+ /// - key: A pointer to the found TSIGKey object if one is found;
/// otherwise null.
///
- /// The pointer returned in the \c FindResult object is only valid until
+ /// The pointer returned in the FindResult object is only valid until
/// the corresponding key is removed from the key ring.
/// The caller must ensure that the key is held in the key ring while
/// it needs to refer to it, or it must make a local copy of the key.
///
/// This method never throws an exception.
///
- /// \param key_name The name of the key to be found.
- /// \param algorithm_name The name of the algorithm of the found key.
- /// \return A \c FindResult object enclosing the search result (see above).
+ /// @param key_name The name of the key to be found.
+ /// @param algorithm_name The name of the algorithm of the found key.
+ /// @return A FindResult object enclosing the search result (see above).
FindResult find(const Name& key_name, const Name& algorithm_name) const;
private:
libeval_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libeval_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libeval_unittests_LDADD += $(CRYPTO_LIBS) $(LOG4CPLUS_LIBS)
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
}
#endif // EXCEPTIONS_H
-
-// Local Variables:
-// mode: c++
-// End:
#include <config.h>
-#include <log/logger_support.h>
-#include <util/unittests/run_all.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);
libhttp_unittests_LDADD += $(top_builddir)/src/lib/asiolink/testutils/libasiolinktest.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libhttp_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libhttp_unittests_LDADD += $(LOG4CPLUS_LIBS)
#include <config.h>
-#include <log/logger_support.h>
-#include <http/http_log.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
EXTRA_DIST += logimpl_messages.mes
EXTRA_DIST += log_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_log_la_CXXFLAGS = $(AM_CXXFLAGS)
if USE_GXX
libkea_log_la_CXXFLAGS += -Wno-unused-parameter -Wno-deprecated-declarations
using namespace std;
using namespace isc::log;
+using namespace isc::util;
using namespace isc::util::file;
/// \file log/compiler/message.cc
string name = file.stem();
string ext = file.extension();
string sentinel_text = name + "_" + ext.substr(1);
- isc::util::str::uppercase(sentinel_text);
+ str::uppercase(sentinel_text);
return (sentinel_text);
}
// ... and return the vector of namespace components split on the single
// colon.
- return (isc::util::str::tokens(ns, ":"));
+ return (str::tokens(ns, ":"));
}
/// \brief Write Opening Namespace(s)
#include <log/message_reader.h>
#include <util/str.h>
+using namespace isc::util;
using namespace std;
namespace {
MessageReader::processLine(const string& line, MessageReader::Mode mode) {
// Get rid of leading and trailing spaces
- string text = isc::util::str::trim(line);
+ string text(str::trim(line));
if (text.empty()) {
; // Ignore blank lines
// Break into tokens
- vector<string> tokens = isc::util::str::tokens(text);
+ vector<string> tokens(str::tokens(text));
// Uppercase directive and branch on valid ones
- isc::util::str::uppercase(tokens[0]);
- if (tokens[0] == string("$PREFIX")) {
+ str::uppercase(tokens[0]);
+ if (tokens[0] == "$PREFIX") {
parsePrefix(tokens);
- } else if (tokens[0] == string("$NAMESPACE")) {
+ } else if (tokens[0] == "$NAMESPACE") {
parseNamespace(tokens);
} else {
}
// Strip off the introducer and any leading space after that.
- string message_line = isc::util::str::trim(text.substr(1));
+ string message_line = str::trim(text.substr(1));
// Look for the first delimiter.
size_t first_delim = message_line.find_first_of(delimiters);
LOG_INVALID_MESSAGE_ID, ident, lineno_);
}
}
- isc::util::str::uppercase(ident);
+ str::uppercase(ident);
// Locate the start of the message text
size_t first_text = message_line.find_first_not_of(delimiters, first_delim);
libmysql_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libmysql_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libmysql_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libmysql_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libmysql_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libmysql_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
libpgsql_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libpgsql_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libpgsql_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libpgsql_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libpgsql_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libpgsql_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
run_unittests_LDADD = $(top_builddir)/src/lib/process/cfgrpt/libcfgrpt.la
-run_unittests_LDADD += $(GTEST_LDADD)
+run_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
+run_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+run_unittests_LDADD += $(LOG4CPLUS_LIBS)
+run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
endif
#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);
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ isc::log::initLogger();
+ return (isc::util::unittests::run_all());
}
#include <config.h>
#include <log/logger_support.h>
-#include <process/d_log.h>
+
#include <gtest/gtest.h>
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();
- // Override --localstatedir value for PID files
setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1);
-
int result = RUN_ALL_TESTS();
return (result);
libstats_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libstats_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libstats_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libstats_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
libstats_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libstats_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libstats_unittests_LDADD += $(LOG4CPLUS_LIBS) $(GTEST_LDADD) $(BOOST_LIBS)
#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);
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ isc::log::initLogger();
+ return (isc::util::unittests::run_all());
}
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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
-#include <log/logger_support.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();
-
- int result = RUN_ALL_TESTS();
-
- return (result);
+ return (isc::util::unittests::run_all());
}
return (ret >= 0 ? 0 : FD_SYSTEM_ERROR);
}
-} // End for namespace io
-} // End for namespace util
-} // End for namespace isc
+} // namespace io
+} // namespace util
+} // namespace isc
// 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/.
-#ifndef FD_SHARE_H_
-#define FD_SHARE_H_
+#ifndef FD_SHARE_H
+#define FD_SHARE_H
/**
* \file fd_share.h
*/
int send_fd(const int sock, const int fd);
-} // End for namespace io
-} // End for namespace util
-} // End for namespace isc
+} // namespace io
+} // namespace util
+} // namespace isc
-#endif
-
-// Local Variables:
-// mode: c++
-// End:
+#endif // FD_SHARE_H
}
#endif // SOCKADDR_UTIL_H
-
-// Local Variables:
-// mode: c++
-// End:
}
#endif // SOCKETSESSION_H
-
-// Local Variables:
-// mode: c++
-// End:
} // namespace isc
#endif // MEMORY_SEGMENT_H
-
-// Local Variables:
-// mode: c++
-// End:
} // namespace isc
#endif // MEMORY_SEGMENT_LOCAL_H
-
-// Local Variables:
-// mode: c++
-// End:
self.fingerprint))
f.write('%02x %02x %s\n' % (self.algorithm, self.fingerprint_type, self.fingerprint))
-class MINFO(RR):
- '''Implements rendering MINFO RDATA in the test data format.
-
- Configurable parameters are as follows (see the description of the
- same name of attribute for the default value):
- - rmailbox (string): The rmailbox field.
- - emailbox (string): The emailbox field.
- These strings must be interpreted as a valid domain name.
- '''
- rmailbox = 'rmailbox.example.com'
- emailbox = 'emailbox.example.com'
- def dump(self, f):
- rmailbox_wire = encode_name(self.rmailbox)
- emailbox_wire = encode_name(self.emailbox)
- if self.rdlen is None:
- self.rdlen = (len(rmailbox_wire) + len(emailbox_wire)) / 2
- else:
- self.rdlen = int(self.rdlen)
- self.dump_header(f, self.rdlen)
- f.write('# RMAILBOX=%s EMAILBOX=%s\n' % (self.rmailbox, self.emailbox))
- f.write('%s %s\n' % (rmailbox_wire, emailbox_wire))
-
-class AFSDB(RR):
- '''Implements rendering AFSDB RDATA in the test data format.
-
- Configurable parameters are as follows (see the description of the
- same name of attribute for the default value):
- - subtype (16 bit int): The subtype field.
- - server (string): The server field.
- The string must be interpreted as a valid domain name.
- '''
- subtype = 1
- server = 'afsdb.example.com'
- def dump(self, f):
- server_wire = encode_name(self.server)
- if self.rdlen is None:
- self.rdlen = 2 + len(server_wire) / 2
- else:
- self.rdlen = int(self.rdlen)
- self.dump_header(f, self.rdlen)
- f.write('# SUBTYPE=%d SERVER=%s\n' % (self.subtype, self.server))
- f.write('%04x %s\n' % (self.subtype, server_wire))
-
class CAA(RR):
'''Implements rendering CAA RDATA in the test data format.
f.write('%04x%s\n' % (other_len,
' ' + other_data if len(other_data) > 0 else ''))
+class MINFO(RR):
+ '''Implements rendering MINFO RDATA in the test data format.
+
+ Configurable parameters are as follows (see the description of the
+ same name of attribute for the default value):
+ - rmailbox (string): The rmailbox field.
+ - emailbox (string): The emailbox field.
+ These strings must be interpreted as a valid domain name.
+ '''
+ rmailbox = 'rmailbox.example.com'
+ emailbox = 'emailbox.example.com'
+ def dump(self, f):
+ rmailbox_wire = encode_name(self.rmailbox)
+ emailbox_wire = encode_name(self.emailbox)
+ if self.rdlen is None:
+ self.rdlen = (len(rmailbox_wire) + len(emailbox_wire)) / 2
+ else:
+ self.rdlen = int(self.rdlen)
+ self.dump_header(f, self.rdlen)
+ f.write('# RMAILBOX=%s EMAILBOX=%s\n' % (self.rmailbox, self.emailbox))
+ f.write('%s %s\n' % (rmailbox_wire, emailbox_wire))
+
+class AFSDB(RR):
+ '''Implements rendering AFSDB RDATA in the test data format.
+
+ Configurable parameters are as follows (see the description of the
+ same name of attribute for the default value):
+ - subtype (16 bit int): The subtype field.
+ - server (string): The server field.
+ The string must be interpreted as a valid domain name.
+ '''
+ subtype = 1
+ server = 'afsdb.example.com'
+ def dump(self, f):
+ server_wire = encode_name(self.server)
+ if self.rdlen is None:
+ self.rdlen = 2 + len(server_wire) / 2
+ else:
+ self.rdlen = int(self.rdlen)
+ self.dump_header(f, self.rdlen)
+ f.write('# SUBTYPE=%d SERVER=%s\n' % (self.subtype, self.server))
+ f.write('%04x %s\n' % (self.subtype, server_wire))
+
# Build section-class mapping
config_param = { 'name' : (Name, {}),
'header' : (DNSHeader, header_xtables),
const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5};
+TEST_F(BufferTest, outputBufferClear) {
+ obuffer.writeData(testdata, sizeof(testdata));
+ obuffer.clear();
+ ASSERT_EQ(0, obuffer.getLength());
+ ASSERT_FALSE(obuffer.getData());
+}
+
+TEST_F(BufferTest, outputBufferCopy) {
+ ASSERT_NO_THROW({
+ obuffer.writeData(testdata, sizeof(testdata));
+
+ OutputBuffer copy(obuffer);
+ ASSERT_EQ(sizeof(testdata), copy.getLength());
+ ASSERT_NE(obuffer.getData(), copy.getData());
+ for (size_t i = 0; i < sizeof(testdata); ++i) {
+ ASSERT_EQ(testdata[i], copy[i]);
+ if (i + 1 < sizeof(testdata)) {
+ obuffer.writeUint16At(0, i);
+ }
+ ASSERT_EQ(testdata[i], copy[i]);
+ }
+ obuffer.clear();
+ ASSERT_EQ(sizeof(testdata), copy.getLength());
+ });
+}
+
+TEST_F(BufferTest, outputEmptyBufferCopy) {
+ ASSERT_NO_THROW({
+ OutputBuffer copy(obuffer);
+ ASSERT_EQ(0, copy.getLength());
+ ASSERT_FALSE(copy.getData());
+ });
+}
+
+TEST_F(BufferTest, outputBufferAssign) {
+ ASSERT_NO_THROW({
+ OutputBuffer another(0);
+ another.clear();
+ obuffer.writeData(testdata, sizeof(testdata));
+
+ another = obuffer;
+ ASSERT_EQ(sizeof(testdata), another.getLength());
+ ASSERT_NE(obuffer.getData(), another.getData());
+ for (size_t i = 0; i < sizeof(testdata); ++i) {
+ ASSERT_EQ(testdata[i], another[i]);
+ if (i + 1 < sizeof(testdata)) {
+ obuffer.writeUint16At(0, i);
+ }
+ ASSERT_EQ(testdata[i], another[i]);
+ }
+ obuffer.clear();
+ ASSERT_EQ(sizeof(testdata), another.getLength());
+ });
+}
+
+TEST_F(BufferTest, outputEmptyBufferAssign) {
+ OutputBuffer copy(0);
+ ASSERT_NO_THROW(copy = obuffer;);
+ ASSERT_EQ(0, copy.getLength());
+ ASSERT_EQ(0, copy.getData());
+}
+
+// Check assign to self doesn't break stuff
+TEST_F(BufferTest, outputBufferAssignSelf) {
+ ASSERT_NO_THROW(obuffer = obuffer);
+}
+
+TEST_F(BufferTest, inputBufferException) {
+ ASSERT_THROW(ibuffer.setPosition(6), isc::OutOfRange);
+
+ ibuffer.setPosition(sizeof(testdata));
+ ASSERT_THROW(ibuffer.peekUint8(), isc::OutOfRange);
+ ASSERT_THROW(ibuffer.readUint8(), isc::OutOfRange);
+
+ ibuffer.setPosition(sizeof(testdata) - 1);
+ ASSERT_THROW(ibuffer.peekUint16(), isc::OutOfRange);
+ ASSERT_THROW(ibuffer.readUint16(), isc::OutOfRange);
+
+ ibuffer.setPosition(sizeof(testdata) - 3);
+ ASSERT_THROW(ibuffer.peekUint32(), isc::OutOfRange);
+ ASSERT_THROW(ibuffer.readUint32(), isc::OutOfRange);
+
+ ibuffer.setPosition(sizeof(testdata) - 4);
+ ASSERT_THROW(ibuffer.peekData(vdata, sizeof(vdata)), isc::OutOfRange);
+ ASSERT_THROW(ibuffer.readData(vdata, sizeof(vdata)), isc::OutOfRange);
+ ASSERT_THROW(ibuffer.peekVector(datav, sizeof(vdata)), isc::OutOfRange);
+ ASSERT_THROW(ibuffer.readVector(datav, sizeof(vdata)), isc::OutOfRange);
+}
+
+TEST_F(BufferTest, outputBufferExtend) {
+ ASSERT_EQ(0, obuffer.getCapacity());
+ ASSERT_EQ(0, obuffer.getLength());
+ obuffer.writeUint8(10);
+ ASSERT_LT(0, obuffer.getCapacity());
+ ASSERT_EQ(1, obuffer.getLength());
+}
+
+TEST_F(BufferTest, outputBufferSkip) {
+ obuffer.skip(4);
+ ASSERT_EQ(4, obuffer.getLength());
+
+ obuffer.skip(2);
+ ASSERT_EQ(6, obuffer.getLength());
+}
+
+TEST_F(BufferTest, outputBufferTrim) {
+ obuffer.writeData(testdata, sizeof(testdata));
+ ASSERT_EQ(5, obuffer.getLength());
+
+ obuffer.trim(1);
+ ASSERT_EQ(4, obuffer.getLength());
+
+ obuffer.trim(2);
+ ASSERT_EQ(2, obuffer.getLength());
+
+ ASSERT_THROW(obuffer.trim(3), OutOfRange);
+}
+
TEST_F(BufferTest, inputBufferRead) {
- EXPECT_EQ(5, ibuffer.getLength());
- EXPECT_EQ(1, ibuffer.peekUint8());
- EXPECT_EQ(0, ibuffer.getPosition());
- EXPECT_EQ(1, ibuffer.readUint8());
- EXPECT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(5, ibuffer.getLength());
+ ASSERT_EQ(1, ibuffer.peekUint8());
+ ASSERT_EQ(0, ibuffer.getPosition());
+ ASSERT_EQ(1, ibuffer.readUint8());
+ ASSERT_EQ(1, ibuffer.getPosition());
data16 = ibuffer.peekUint16();
- EXPECT_EQ(1, ibuffer.getPosition());
- EXPECT_EQ(data16, ibuffer.readUint16());
- EXPECT_EQ((2 << 8) | 3, data16);
- EXPECT_EQ(3, ibuffer.getPosition());
+ ASSERT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(data16, ibuffer.readUint16());
+ ASSERT_EQ((2 << 8) | 3, data16);
+ ASSERT_EQ(3, ibuffer.getPosition());
ibuffer.setPosition(1);
- EXPECT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(1, ibuffer.getPosition());
data32 = ibuffer.peekUint32();
- EXPECT_EQ(1, ibuffer.getPosition());
- EXPECT_EQ(data32, ibuffer.readUint32());
- EXPECT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32);
+ ASSERT_EQ(1, ibuffer.getPosition());
+ ASSERT_EQ(data32, ibuffer.readUint32());
+ ASSERT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32);
ibuffer.setPosition(0);
memset(vdata, 0, sizeof(vdata));
ibuffer.peekData(vdata, sizeof(vdata));
- EXPECT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
- EXPECT_EQ(0, ibuffer.getPosition());
+ ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
+ ASSERT_EQ(0, ibuffer.getPosition());
memset(vdata, 0, sizeof(vdata));
ibuffer.readData(vdata, sizeof(vdata));
- EXPECT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
- EXPECT_EQ(sizeof(vdata), ibuffer.getPosition());
+ ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
+ ASSERT_EQ(sizeof(vdata), ibuffer.getPosition());
ibuffer.setPosition(0);
datav.clear();
ibuffer.peekVector(datav, sizeof(vdata));
ASSERT_EQ(sizeof(vdata), datav.size());
- EXPECT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata)));
- EXPECT_EQ(0, ibuffer.getPosition());
+ ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata)));
+ ASSERT_EQ(0, ibuffer.getPosition());
datav.clear();
ibuffer.readVector(datav, sizeof(vdata));
ASSERT_EQ(sizeof(vdata), datav.size());
- EXPECT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata)));
- EXPECT_EQ(sizeof(vdata), ibuffer.getPosition());
+ ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata)));
+ ASSERT_EQ(sizeof(vdata), ibuffer.getPosition());
}
-TEST_F(BufferTest, inputBufferException) {
- EXPECT_THROW(ibuffer.setPosition(6), isc::OutOfRange);
-
- ibuffer.setPosition(sizeof(testdata));
- EXPECT_THROW(ibuffer.peekUint8(), isc::OutOfRange);
- EXPECT_THROW(ibuffer.readUint8(), isc::OutOfRange);
-
- ibuffer.setPosition(sizeof(testdata) - 1);
- EXPECT_THROW(ibuffer.peekUint16(), isc::OutOfRange);
- EXPECT_THROW(ibuffer.readUint16(), isc::OutOfRange);
-
- ibuffer.setPosition(sizeof(testdata) - 3);
- EXPECT_THROW(ibuffer.peekUint32(), isc::OutOfRange);
- EXPECT_THROW(ibuffer.readUint32(), isc::OutOfRange);
-
- ibuffer.setPosition(sizeof(testdata) - 4);
- EXPECT_THROW(ibuffer.peekData(vdata, sizeof(vdata)), isc::OutOfRange);
- EXPECT_THROW(ibuffer.readData(vdata, sizeof(vdata)), isc::OutOfRange);
- EXPECT_THROW(ibuffer.peekVector(datav, sizeof(vdata)), isc::OutOfRange);
- EXPECT_THROW(ibuffer.readVector(datav, sizeof(vdata)), isc::OutOfRange);
+TEST_F(BufferTest, outputBufferReadAt) {
+ obuffer.writeData(testdata, sizeof(testdata));
+ for (size_t i = 0; i < sizeof(testdata); ++i) {
+ ASSERT_EQ(testdata[i], obuffer[i]);
+ }
+ ASSERT_THROW(obuffer[sizeof(testdata)], isc::OutOfRange);
}
-TEST_F(BufferTest, outputBufferExtend) {
- EXPECT_EQ(0, obuffer.getCapacity());
- EXPECT_EQ(0, obuffer.getLength());
- obuffer.writeUint8(10);
- EXPECT_LT(0, obuffer.getCapacity());
- EXPECT_EQ(1, obuffer.getLength());
+TEST_F(BufferTest, inputBufferReadVectorChunks) {
+ std::vector<uint8_t> vec;
+
+ // check that vector can read the whole buffer
+ ibuffer.readVector(vec, 3);
+ ASSERT_EQ(3, vec.size());
+ ASSERT_EQ(0, memcmp(&vec[0], testdata, 3));
+ ASSERT_NO_THROW(ibuffer.readVector(vec, 2));
+ ASSERT_EQ(2, vec.size());
+ ASSERT_EQ(0, memcmp(&vec[0], &testdata[3], 2));
}
TEST_F(BufferTest, outputBufferWrite) {
obuffer.writeUint8(1);
expected_size += sizeof(uint8_t);
- EXPECT_EQ(expected_size, obuffer.getLength());
+ ASSERT_EQ(expected_size, obuffer.getLength());
const uint8_t* cp = obuffer.getData();
- EXPECT_EQ(1, *cp);
+ ASSERT_EQ(1, *cp);
obuffer.writeUint16(data16);
expected_size += sizeof(data16);
cp = obuffer.getData();
- EXPECT_EQ(expected_size, obuffer.getLength());
- EXPECT_EQ(2, *(cp + 1));
- EXPECT_EQ(3, *(cp + 2));
+ ASSERT_EQ(expected_size, obuffer.getLength());
+ ASSERT_EQ(2, *(cp + 1));
+ ASSERT_EQ(3, *(cp + 2));
obuffer.writeUint32(data32);
expected_size += sizeof(data32);
cp = obuffer.getData();
- EXPECT_EQ(expected_size, obuffer.getLength());
- EXPECT_EQ(4, *(cp + 3));
- EXPECT_EQ(5, *(cp + 4));
- EXPECT_EQ(6, *(cp + 5));
- EXPECT_EQ(7, *(cp + 6));
+ ASSERT_EQ(expected_size, obuffer.getLength());
+ ASSERT_EQ(4, *(cp + 3));
+ ASSERT_EQ(5, *(cp + 4));
+ ASSERT_EQ(6, *(cp + 5));
+ ASSERT_EQ(7, *(cp + 6));
obuffer.writeData(testdata, sizeof(testdata));
expected_size += sizeof(testdata);
- EXPECT_EQ(expected_size, obuffer.getLength());
+ ASSERT_EQ(expected_size, obuffer.getLength());
cp = obuffer.getData();
- EXPECT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata)));
+ ASSERT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata)));
datav = obuffer.getVector();
ASSERT_EQ(expected_size, datav.size());
std::vector<uint8_t> expected = { 1, 2, 3, 4, 5, 6, 7 };
expected.insert(expected.end(), testdata, testdata + sizeof(testdata));
ASSERT_EQ(expected_size, expected.size());
- EXPECT_EQ(0, memcmp(&expected[0], &datav[0], expected_size));
+ ASSERT_EQ(0, memcmp(&expected[0], &datav[0], expected_size));
}
TEST_F(BufferTest, outputBufferWriteAt) {
// overwrite 2nd byte
obuffer.writeUint8At(4, 1);
- EXPECT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
+ ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
const uint8_t* cp = obuffer.getData();
- EXPECT_EQ(4, *(cp + 1));
+ ASSERT_EQ(4, *(cp + 1));
// overwrite 2nd and 3rd bytes
obuffer.writeUint16At(data16, 1);
- EXPECT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
+ ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
cp = obuffer.getData();
- EXPECT_EQ(2, *(cp + 1));
- EXPECT_EQ(3, *(cp + 2));
+ ASSERT_EQ(2, *(cp + 1));
+ ASSERT_EQ(3, *(cp + 2));
// overwrite 3rd and 4th bytes
obuffer.writeUint16At(data16, 2);
- EXPECT_EQ(expected_size, obuffer.getLength());
+ ASSERT_EQ(expected_size, obuffer.getLength());
cp = obuffer.getData();
- EXPECT_EQ(2, *(cp + 2));
- EXPECT_EQ(3, *(cp + 3));
-
- EXPECT_THROW(obuffer.writeUint8At(data16, 5), isc::OutOfRange);
- EXPECT_THROW(obuffer.writeUint8At(data16, 4), isc::OutOfRange);
- EXPECT_THROW(obuffer.writeUint16At(data16, 3), isc::OutOfRange);
- EXPECT_THROW(obuffer.writeUint16At(data16, 4), isc::OutOfRange);
- EXPECT_THROW(obuffer.writeUint16At(data16, 5), isc::OutOfRange);
-}
-
-TEST_F(BufferTest, outputBufferSkip) {
- obuffer.skip(4);
- EXPECT_EQ(4, obuffer.getLength());
-
- obuffer.skip(2);
- EXPECT_EQ(6, obuffer.getLength());
-}
-
-TEST_F(BufferTest, outputBufferTrim) {
- obuffer.writeData(testdata, sizeof(testdata));
- EXPECT_EQ(5, obuffer.getLength());
-
- obuffer.trim(1);
- EXPECT_EQ(4, obuffer.getLength());
-
- obuffer.trim(2);
- EXPECT_EQ(2, obuffer.getLength());
-
- EXPECT_THROW(obuffer.trim(3), OutOfRange);
-}
-
-TEST_F(BufferTest, outputBufferReadAt) {
- obuffer.writeData(testdata, sizeof(testdata));
- for (size_t i = 0; i < sizeof(testdata); ++i) {
- EXPECT_EQ(testdata[i], obuffer[i]);
- }
- EXPECT_THROW(obuffer[sizeof(testdata)], isc::OutOfRange);
-}
-
-TEST_F(BufferTest, outputBufferClear) {
- obuffer.writeData(testdata, sizeof(testdata));
- const uint8_t* cp = obuffer.getData();
- obuffer.clear();
- EXPECT_EQ(0, obuffer.getLength());
- EXPECT_FALSE(obuffer.getData());
-}
-
-TEST_F(BufferTest, outputBufferCopy) {
- EXPECT_NO_THROW({
- obuffer.writeData(testdata, sizeof(testdata));
-
- OutputBuffer copy(obuffer);
- ASSERT_EQ(sizeof(testdata), copy.getLength());
- ASSERT_NE(obuffer.getData(), copy.getData());
- for (size_t i = 0; i < sizeof(testdata); ++i) {
- EXPECT_EQ(testdata[i], copy[i]);
- if (i + 1 < sizeof(testdata)) {
- obuffer.writeUint16At(0, i);
- }
- EXPECT_EQ(testdata[i], copy[i]);
- }
- obuffer.clear();
- ASSERT_EQ(sizeof(testdata), copy.getLength());
- });
-}
-
-TEST_F(BufferTest, outputEmptyBufferCopy) {
- EXPECT_NO_THROW({
- OutputBuffer copy(obuffer);
- ASSERT_EQ(0, copy.getLength());
- EXPECT_FALSE(copy.getData());
- });
-}
-
-TEST_F(BufferTest, outputBufferAssign) {
- EXPECT_NO_THROW({
- OutputBuffer another(0);
- another.clear();
- obuffer.writeData(testdata, sizeof(testdata));
-
- another = obuffer;
- ASSERT_EQ(sizeof(testdata), another.getLength());
- ASSERT_NE(obuffer.getData(), another.getData());
- for (size_t i = 0; i < sizeof(testdata); ++i) {
- EXPECT_EQ(testdata[i], another[i]);
- if (i + 1 < sizeof(testdata)) {
- obuffer.writeUint16At(0, i);
- }
- EXPECT_EQ(testdata[i], another[i]);
- }
- obuffer.clear();
- ASSERT_EQ(sizeof(testdata), another.getLength());
- });
-}
-
-TEST_F(BufferTest, outputEmptyBufferAssign) {
- OutputBuffer copy(0);
- EXPECT_NO_THROW(copy = obuffer;);
- EXPECT_EQ(0, copy.getLength());
- EXPECT_EQ(0, copy.getData());
-}
-
-// Check assign to self doesn't break stuff
-TEST_F(BufferTest, outputBufferAssignSelf) {
- EXPECT_NO_THROW(obuffer = obuffer);
-}
-
-TEST_F(BufferTest, inputBufferReadVectorChunks) {
- std::vector<uint8_t> vec;
-
- // check that vector can read the whole buffer
- ibuffer.readVector(vec, 3);
- EXPECT_EQ(3, vec.size());
- EXPECT_EQ(0, memcmp(&vec[0], testdata, 3));
- EXPECT_NO_THROW(ibuffer.readVector(vec, 2));
- ASSERT_EQ(2, vec.size());
- EXPECT_EQ(0, memcmp(&vec[0], &testdata[3], 2));
+ ASSERT_EQ(2, *(cp + 2));
+ ASSERT_EQ(3, *(cp + 3));
+
+ ASSERT_THROW(obuffer.writeUint8At(data16, 5), isc::OutOfRange);
+ ASSERT_THROW(obuffer.writeUint8At(data16, 4), isc::OutOfRange);
+ ASSERT_THROW(obuffer.writeUint16At(data16, 3), isc::OutOfRange);
+ ASSERT_THROW(obuffer.writeUint16At(data16, 4), isc::OutOfRange);
+ ASSERT_THROW(obuffer.writeUint16At(data16, 5), isc::OutOfRange);
}
// Tests whether uint64 can be written properly.
obuffer.writeUint64(val1);
ASSERT_EQ(sizeof(uint64_t), obuffer.getLength());
const uint8_t* cp = obuffer.getData();
- EXPECT_TRUE(cp);
- EXPECT_FALSE(memcmp(exp_val1, obuffer.getData(), sizeof(uint64_t)));
+ ASSERT_TRUE(cp);
+ ASSERT_FALSE(memcmp(exp_val1, obuffer.getData(), sizeof(uint64_t)));
- EXPECT_NO_THROW(obuffer.clear());
+ ASSERT_NO_THROW(obuffer.clear());
obuffer.writeUint64(val2);
ASSERT_EQ(sizeof(uint64_t), obuffer.getLength());
cp = obuffer.getData();
- EXPECT_TRUE(cp);
- EXPECT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t)));
+ ASSERT_TRUE(cp);
+ ASSERT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t)));
}
}
}
}
}
-
-// Local Variables:
-// mode: c++
-// End:
}
}
-// Local Variables:
-// mode: c++
-// End:
} // end of isc
#endif // UTIL_UNITTESTS_MOCKSOCKETSESSION_H
-// Local Variables:
-// mode: c++
-// End:
}
#endif // UTIL_UNITTESTS_NEWHOOK_H
-
-// Local Variables:
-// mode: c++
-// End:
} // end of namespace isc
#endif // UTIL_UNITTESTS_RESOURCE_H
-
-// Local Variables:
-// mode: c++
-// End:
}
#endif // UTIL_UNITTESTS_TESTDATA_H
-
-// Local Variables:
-// mode: c++
-// End:
}
#endif // UTIL_UNITTESTS_TEXTDATA_H
-
-// Local Variables:
-// mode: c++
-// End:
}
#endif // UTIL_UNITTESTS_WIREDATA_H
-
-// Local Variables:
-// mode: c++
-// End:
#include <gtest/gtest.h>
-#include <log/logger_support.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());
}