diff options
author | Razvan Becheriu <razvan@isc.org> | 2024-04-17 09:56:07 +0200 |
---|---|---|
committer | Razvan Becheriu <razvan@isc.org> | 2024-04-17 19:40:17 +0200 |
commit | 41d0286cea0947a13909d9680f55745ae2b6c40f (patch) | |
tree | cb4ee702c83ba39fdd41ef7443567d33b6c6e5b5 /src | |
parent | [#3320] minor changes (diff) | |
download | kea-41d0286cea0947a13909d9680f55745ae2b6c40f.tar.xz kea-41d0286cea0947a13909d9680f55745ae2b6c40f.zip |
[#3320] minor changes
Diffstat (limited to 'src')
51 files changed, 313 insertions, 313 deletions
diff --git a/src/lib/asiodns/Makefile.am b/src/lib/asiodns/Makefile.am index 53d8e0536c..5ac221b393 100644 --- a/src/lib/asiodns/Makefile.am +++ b/src/lib/asiodns/Makefile.am @@ -1,10 +1,10 @@ -SUBDIRS = . tests // @todo - please update - // @todo - please update +SUBDIRS = . tests + AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib -AM_CPPFLAGS += $(BOOST_INCLUDES) // @todo - please update - // @todo - please update +AM_CPPFLAGS += $(BOOST_INCLUDES) + AM_CXXFLAGS = $(KEA_CXXFLAGS) - // @todo - please update + CLEANFILES = *.gcno *.gcda EXTRA_DIST = asiodns_messages.mes diff --git a/src/lib/asiodns/asiodns_messages.mes b/src/lib/asiodns/asiodns_messages.mes index 07518add41..1f7f35eced 100644 --- a/src/lib/asiodns/asiodns_messages.mes +++ b/src/lib/asiodns/asiodns_messages.mes @@ -4,7 +4,7 @@ # 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/. -$NAMESPACE isc::asiodns // @todo - please update +$NAMESPACE isc::asiodns % ASIODNS_FD_ADD_TCP adding a new TCP server by opened fd %1 A debug message informing about installing a file descriptor as a server. diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc index 7370490ec6..742abc66e9 100644 --- a/src/lib/asiodns/io_fetch.cc +++ b/src/lib/asiodns/io_fetch.cc @@ -21,7 +21,7 @@ #include <cryptolink/crypto_rng.h> #include <dns/rcode.h> #include <util/io.h> - // @todo - please update + #include <boost/scoped_ptr.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> @@ -31,7 +31,7 @@ #include <stdint.h> #include <sys/socket.h> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; using namespace isc::dns; using namespace isc::log; using namespace isc::util; @@ -39,8 +39,8 @@ using namespace isc::util; using namespace boost::asio; using namespace std; -namespace isc { // @todo - please update -namespace asiodns { // @todo - please update +namespace isc { +namespace asiodns { // Log debug verbosity. @@ -167,9 +167,9 @@ IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, initIOFetch(question, protocol, service, **(query_message->beginQuestion()), address, port, buff, cb, wait); -} // @todo - please update - // @todo - please update -void // @todo - please update +} + +void 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) { @@ -190,8 +190,8 @@ IOFetch::initIOFetch(MessagePtr& query, Protocol protocol, const IOServicePtr& s r.setBuffer(data_->msgbuf.get()); query->toWire(r); r.setBuffer(NULL); -} // @todo - please update - // @todo - please update +} + IOFetch::Protocol IOFetch::getProtocol() const { return (data_->protocol); diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h index 40dbc76f4a..22ace29c4f 100644 --- a/src/lib/asiodns/io_fetch.h +++ b/src/lib/asiodns/io_fetch.h @@ -18,9 +18,9 @@ #include <ext/coroutine/coroutine.hpp> #endif -#include <asiolink/io_address.h> // @todo - please update +#include <asiolink/io_address.h> #include <asiolink/io_service.h> -#include <dns/message.h> // @todo - please update +#include <dns/message.h> #include <dns/question.h> #include <util/buffer.h> @@ -29,8 +29,8 @@ #include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/system/error_code.hpp> -namespace isc { // @todo - please update -namespace asiodns { // @todo - please update +namespace isc { +namespace asiodns { // Forward declarations struct IOFetchData; @@ -136,7 +136,7 @@ public: bool edns = true); /// @brief Constructor - /// // @todo - please update + /// /// 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. @@ -163,7 +163,7 @@ public: isc::util::OutputBufferPtr& buff, Callback* cb, int wait = -1); - // @todo - please update + /// @brief Constructor. /// /// Creates the object that will handle the upstream fetch. @@ -237,7 +237,7 @@ private: isc::util::OutputBufferPtr& buff, Callback* cb, int wait, bool edns = true); - // @todo - please update + /// @brief Log I/O Failure. /// /// Records an I/O failure to the log file. diff --git a/src/lib/asiodns/tests/Makefile.am b/src/lib/asiodns/tests/Makefile.am index 57b04581d3..323e453660 100644 --- a/src/lib/asiodns/tests/Makefile.am +++ b/src/lib/asiodns/tests/Makefile.am @@ -1,24 +1,24 @@ -AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib // @todo - please update -AM_CPPFLAGS += $(BOOST_INCLUDES) // @todo - please update - // @todo - please update +AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) + AM_CXXFLAGS = $(KEA_CXXFLAGS) - // @todo - please update -if USE_STATIC_LINK // @todo - please update -AM_LDFLAGS = -static // @todo - please update -endif // @todo - please update - // @todo - please update -CLEANFILES = *.gcno *.gcda // @todo - please update - // @todo - please update + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +CLEANFILES = *.gcno *.gcda + TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) -TESTS = // @todo - please update -if HAVE_GTEST // @todo - please update -TESTS += run_unittests // @todo - please update -run_unittests_SOURCES = run_unittests.cc // @todo - please update -run_unittests_SOURCES += io_fetch_unittest.cc // @todo - please update - // @todo - please update -run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) // @todo - please update - // @todo - please update +TESTS = +if HAVE_GTEST +TESTS += run_unittests +run_unittests_SOURCES = run_unittests.cc +run_unittests_SOURCES += io_fetch_unittest.cc + +run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) + run_unittests_LDADD = $(top_builddir)/src/lib/asiodns/libkea-asiodns.la run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la run_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la @@ -29,14 +29,14 @@ 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) $(CRYPTO_LIBS) run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) - // @todo - please update + run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) - // @todo - please update + # Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) -run_unittests_CXXFLAGS = $(AM_CXXFLAGS) // @todo - please update -if USE_GXX // @todo - please update -run_unittests_CXXFLAGS += -Wno-unused-parameter // @todo - please update -endif // @todo - please update -endif // @todo - please update - // @todo - please update +run_unittests_CXXFLAGS = $(AM_CXXFLAGS) +if USE_GXX +run_unittests_CXXFLAGS += -Wno-unused-parameter +endif +endif + noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc index 7e9f7a52f5..66dc67ab5a 100644 --- a/src/lib/asiodns/tests/io_fetch_unittest.cc +++ b/src/lib/asiodns/tests/io_fetch_unittest.cc @@ -33,7 +33,7 @@ using namespace isc::asiolink; using namespace isc::dns; -using namespace isc::util; // @todo - please update +using namespace isc::util; using namespace boost::asio; using namespace boost::asio::ip; @@ -41,8 +41,8 @@ using namespace std; namespace ph = std::placeholders; -namespace isc { // @todo - please update -namespace asiodns { // @todo - please update +namespace isc { +namespace asiodns { const boost::asio::ip::address TEST_HOST(boost::asio::ip::address::from_string("127.0.0.1")); const uint16_t TEST_PORT(5301); diff --git a/src/lib/asiodns/tests/run_unittests.cc b/src/lib/asiodns/tests/run_unittests.cc index 47e343294b..cf3f2040f2 100644 --- a/src/lib/asiodns/tests/run_unittests.cc +++ b/src/lib/asiodns/tests/run_unittests.cc @@ -1,19 +1,19 @@ // Copyright (C) 2009-2015 Internet Systems Consortium, Inc. ("ISC") -// // @todo - please update +// // 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/. - // @todo - please update + #include <config.h> -#include <gtest/gtest.h> // @todo - please update - // @todo - please update +#include <gtest/gtest.h> + #include <util/unittests/run_all.h> #include <log/logger_support.h> - // @todo - please update -int // @todo - please update + +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); return (isc::util::unittests::run_all()); -} // @todo - please update +} diff --git a/src/lib/asiolink/dummy_io_cb.h b/src/lib/asiolink/dummy_io_cb.h index d8a39cae9f..8bf33449aa 100644 --- a/src/lib/asiolink/dummy_io_cb.h +++ b/src/lib/asiolink/dummy_io_cb.h @@ -13,7 +13,7 @@ #include <boost/asio/error.hpp> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief Asynchronous I/O Completion Callback diff --git a/src/lib/asiolink/interval_timer.cc b/src/lib/asiolink/interval_timer.cc index 58dea7f972..fa0d9e1b67 100644 --- a/src/lib/asiolink/interval_timer.cc +++ b/src/lib/asiolink/interval_timer.cc @@ -22,7 +22,7 @@ using namespace std; namespace ph = std::placeholders; -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// This class holds a call back function of asynchronous operations. diff --git a/src/lib/asiolink/interval_timer.h b/src/lib/asiolink/interval_timer.h index 7e733b5520..0b1c10c788 100644 --- a/src/lib/asiolink/interval_timer.h +++ b/src/lib/asiolink/interval_timer.h @@ -12,7 +12,7 @@ #include <asiolink/io_service.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { class IntervalTimerImpl; diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc index 749e4dcf45..43459bfe5a 100644 --- a/src/lib/asiolink/io_address.cc +++ b/src/lib/asiolink/io_address.cc @@ -25,7 +25,7 @@ using boost::asio::ip::tcp; using namespace std; -namespace isc { // @todo - please update +namespace isc { namespace asiolink { size_t diff --git a/src/lib/asiolink/io_address.h b/src/lib/asiolink/io_address.h index 3d3f0e30e7..3544ebe125 100644 --- a/src/lib/asiolink/io_address.h +++ b/src/lib/asiolink/io_address.h @@ -20,7 +20,7 @@ #include <exceptions/exceptions.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// Defines length of IPv6 address (in binary format). diff --git a/src/lib/asiolink/io_asio_socket.h b/src/lib/asiolink/io_asio_socket.h index dbcf004ed4..f44f2c9135 100644 --- a/src/lib/asiolink/io_asio_socket.h +++ b/src/lib/asiolink/io_asio_socket.h @@ -32,7 +32,7 @@ #include <boost/asio/coroutine.hpp> #endif -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief Socket not open diff --git a/src/lib/asiolink/io_endpoint.cc b/src/lib/asiolink/io_endpoint.cc index 2ba5861ff9..975372fe27 100644 --- a/src/lib/asiolink/io_endpoint.cc +++ b/src/lib/asiolink/io_endpoint.cc @@ -21,7 +21,7 @@ using namespace std; -namespace isc { // @todo - please update +namespace isc { namespace asiolink { const IOEndpoint* diff --git a/src/lib/asiolink/io_endpoint.h b/src/lib/asiolink/io_endpoint.h index 824b482205..0f5ddf701d 100644 --- a/src/lib/asiolink/io_endpoint.h +++ b/src/lib/asiolink/io_endpoint.h @@ -23,7 +23,7 @@ #include <sys/socket.h> // for sockaddr -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief The \c IOEndpoint class is an abstract base class to represent diff --git a/src/lib/asiolink/io_error.h b/src/lib/asiolink/io_error.h index 15210e61e2..125cdd6b80 100644 --- a/src/lib/asiolink/io_error.h +++ b/src/lib/asiolink/io_error.h @@ -10,7 +10,7 @@ #include <exceptions/exceptions.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief An exception that is thrown if an error occurs within the IO diff --git a/src/lib/asiolink/io_service.cc b/src/lib/asiolink/io_service.cc index 18d2f2261a..3cc6012fe2 100644 --- a/src/lib/asiolink/io_service.cc +++ b/src/lib/asiolink/io_service.cc @@ -14,7 +14,7 @@ #include <boost/shared_ptr.hpp> #include <sys/socket.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { class IOServiceImpl { diff --git a/src/lib/asiolink/io_service.h b/src/lib/asiolink/io_service.h index c238c34e3b..7da1f9e108 100644 --- a/src/lib/asiolink/io_service.h +++ b/src/lib/asiolink/io_service.h @@ -22,7 +22,7 @@ namespace asio { } } -namespace isc { // @todo - please update +namespace isc { namespace asiolink { class IOServiceImpl; diff --git a/src/lib/asiolink/io_socket.cc b/src/lib/asiolink/io_socket.cc index 7a322303c1..8d399fbc23 100644 --- a/src/lib/asiolink/io_socket.cc +++ b/src/lib/asiolink/io_socket.cc @@ -8,7 +8,7 @@ #include <asiolink/asio_wrapper.h> #include <asiolink/io_socket.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief The \c DummySocket class is a concrete derived class of diff --git a/src/lib/asiolink/io_socket.h b/src/lib/asiolink/io_socket.h index ea52254d45..cb07c886ea 100644 --- a/src/lib/asiolink/io_socket.h +++ b/src/lib/asiolink/io_socket.h @@ -17,7 +17,7 @@ #include <exceptions/exceptions.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief The \c IOSocket class is an abstract base class to represent diff --git a/src/lib/asiolink/tcp_endpoint.h b/src/lib/asiolink/tcp_endpoint.h index 02df01aa03..453e629673 100644 --- a/src/lib/asiolink/tcp_endpoint.h +++ b/src/lib/asiolink/tcp_endpoint.h @@ -13,7 +13,7 @@ #include <asiolink/io_endpoint.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief The \c TCPEndpoint class is a concrete derived class of diff --git a/src/lib/asiolink/tcp_socket.h b/src/lib/asiolink/tcp_socket.h index 932a32e0d0..e56abe412d 100644 --- a/src/lib/asiolink/tcp_socket.h +++ b/src/lib/asiolink/tcp_socket.h @@ -28,7 +28,7 @@ #include <sys/socket.h> #include <unistd.h> // for some IPC/network system calls -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief Buffer Too Large diff --git a/src/lib/asiolink/tests/io_address_unittest.cc b/src/lib/asiolink/tests/io_address_unittest.cc index bdf1d7d15f..4caf30f232 100644 --- a/src/lib/asiolink/tests/io_address_unittest.cc +++ b/src/lib/asiolink/tests/io_address_unittest.cc @@ -17,7 +17,7 @@ #include <sstream> #include <unordered_set> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; TEST(IOAddressHashTest, hashIPv4) { IOAddress::Hash hash; diff --git a/src/lib/asiolink/tests/io_endpoint_unittest.cc b/src/lib/asiolink/tests/io_endpoint_unittest.cc index 3aebccbcfc..314a6a0c38 100644 --- a/src/lib/asiolink/tests/io_endpoint_unittest.cc +++ b/src/lib/asiolink/tests/io_endpoint_unittest.cc @@ -21,7 +21,7 @@ #include <netdb.h> #include <string.h> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; namespace { typedef boost::shared_ptr<const IOEndpoint> ConstIOEndpointPtr; diff --git a/src/lib/asiolink/tests/io_socket_unittest.cc b/src/lib/asiolink/tests/io_socket_unittest.cc index 7e9b3ab805..659a6a6019 100644 --- a/src/lib/asiolink/tests/io_socket_unittest.cc +++ b/src/lib/asiolink/tests/io_socket_unittest.cc @@ -11,7 +11,7 @@ #include <gtest/gtest.h> #include <netinet/in.h> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; TEST(IOSocketTest, dummySockets) { EXPECT_EQ(static_cast<short>(IPPROTO_UDP), diff --git a/src/lib/asiolink/tests/tcp_endpoint_unittest.cc b/src/lib/asiolink/tests/tcp_endpoint_unittest.cc index 599f84b5eb..0d838d4ebd 100644 --- a/src/lib/asiolink/tests/tcp_endpoint_unittest.cc +++ b/src/lib/asiolink/tests/tcp_endpoint_unittest.cc @@ -13,7 +13,7 @@ #include <string> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; using namespace std; // This test checks that the endpoint can manage its own internal diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc index c29397ed21..f97a8f6665 100644 --- a/src/lib/asiolink/tests/tcp_socket_unittest.cc +++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc @@ -32,7 +32,7 @@ #include <string> #include <vector> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; using namespace isc::util; using namespace std; diff --git a/src/lib/asiolink/tests/udp_endpoint_unittest.cc b/src/lib/asiolink/tests/udp_endpoint_unittest.cc index 7164e3da56..cf932f1a64 100644 --- a/src/lib/asiolink/tests/udp_endpoint_unittest.cc +++ b/src/lib/asiolink/tests/udp_endpoint_unittest.cc @@ -13,7 +13,7 @@ #include <string> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; using namespace std; // This test checks that the endpoint can manage its own internal diff --git a/src/lib/asiolink/tests/udp_socket_unittest.cc b/src/lib/asiolink/tests/udp_socket_unittest.cc index 10622268ed..c607fce92a 100644 --- a/src/lib/asiolink/tests/udp_socket_unittest.cc +++ b/src/lib/asiolink/tests/udp_socket_unittest.cc @@ -32,7 +32,7 @@ #include <vector> -using namespace isc::asiolink; // @todo - please update +using namespace isc::asiolink; using namespace isc::util; using namespace boost::asio; diff --git a/src/lib/asiolink/udp_endpoint.h b/src/lib/asiolink/udp_endpoint.h index 69b843344f..f2e040ee03 100644 --- a/src/lib/asiolink/udp_endpoint.h +++ b/src/lib/asiolink/udp_endpoint.h @@ -13,7 +13,7 @@ #include <asiolink/io_endpoint.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief The \c UDPEndpoint class is a concrete derived class of diff --git a/src/lib/asiolink/udp_socket.h b/src/lib/asiolink/udp_socket.h index 6ceb54e7b7..380d344e36 100644 --- a/src/lib/asiolink/udp_socket.h +++ b/src/lib/asiolink/udp_socket.h @@ -24,7 +24,7 @@ #include <exceptions/isc_assert.h> -namespace isc { // @todo - please update +namespace isc { namespace asiolink { /// \brief The \c UDPSocket class is a concrete derived class of \c IOAsioSocket diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am index 78b8c45a4a..eefa489c66 100644 --- a/src/lib/dns/Makefile.am +++ b/src/lib/dns/Makefile.am @@ -54,7 +54,7 @@ libkea_dns___la_LIBADD = $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.l libkea_dns___la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la libkea_dns___la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libkea_dns___la_LIBADD += $(CRYPTO_LIBS) - // @todo - please update + # The following files used to be generated, but they are now part of the git tree: # rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc libkea_dns___la_SOURCES += rdataclass.h rrclass.h rrtype.h diff --git a/src/lib/dns/message.cc b/src/lib/dns/message.cc index 7cc4e6075b..913240c583 100644 --- a/src/lib/dns/message.cc +++ b/src/lib/dns/message.cc @@ -33,7 +33,7 @@ #include <boost/shared_ptr.hpp> using namespace isc::dns::rdata; -using namespace isc::util; // @todo - please update +using namespace isc::util; using namespace std; using boost::lexical_cast; diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h index 44482bc3da..d5c57950d0 100644 --- a/src/lib/dns/message.h +++ b/src/lib/dns/message.h @@ -603,7 +603,7 @@ public: /// NOTE: If the header has already been parsed by a previous call /// to this method, this method simply returns (i.e., it does not /// read from the \c buffer). - void parseHeader(isc::util::InputBuffer& buffer); // @todo - please update + void parseHeader(isc::util::InputBuffer& buffer); /// \brief (Re)build a \c Message object from wire-format data. /// @@ -668,7 +668,7 @@ private: /// that ongoing state information will not be lost if the object /// that originated the asynchronous call falls out of scope. typedef boost::shared_ptr<Message> MessagePtr; -typedef boost::shared_ptr<const Message> ConstMessagePtr; // @todo - please update +typedef boost::shared_ptr<const Message> ConstMessagePtr; /// Insert the \c Message as a string into stream. /// diff --git a/src/lib/dns/messagerenderer.cc b/src/lib/dns/messagerenderer.cc index 772709548b..4e1dfeaa8b 100644 --- a/src/lib/dns/messagerenderer.cc +++ b/src/lib/dns/messagerenderer.cc @@ -20,9 +20,9 @@ #include <cassert> #include <vector> -using namespace isc::util; // @todo - please update +using namespace isc::util; using isc::dns::name::internal::maptolower; - // @todo - please update + using namespace std; namespace isc { diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc index 813c64d287..ac48205955 100644 --- a/src/lib/dns/name.cc +++ b/src/lib/dns/name.cc @@ -19,7 +19,7 @@ #include <iostream> #include <algorithm> -using namespace isc::util; // @todo - please update +using namespace isc::util; using namespace isc::dns::name::internal; using namespace std; diff --git a/src/lib/dns/name.h b/src/lib/dns/name.h index d94db5d8d8..37723e88f7 100644 --- a/src/lib/dns/name.h +++ b/src/lib/dns/name.h @@ -18,7 +18,7 @@ #include <dns/exceptions.h> namespace isc { -namespace dns { // @todo - please update +namespace dns { /// /// \brief A standard DNS module exception that is thrown if the name parser /// encounters an empty label in the middle of a name. diff --git a/src/lib/dns/question.cc b/src/lib/dns/question.cc index 65447ede32..af52842ffa 100644 --- a/src/lib/dns/question.cc +++ b/src/lib/dns/question.cc @@ -16,7 +16,7 @@ #include <iostream> #include <string> -using namespace isc::util; // @todo - please update +using namespace isc::util; using namespace std; diff --git a/src/lib/dns/rdata.h b/src/lib/dns/rdata.h index 54493532f0..47d7c77923 100644 --- a/src/lib/dns/rdata.h +++ b/src/lib/dns/rdata.h @@ -19,7 +19,7 @@ #include <stdint.h> namespace isc { -namespace dns { // @todo - please update +namespace dns { class AbstractMessageRenderer; class RRType; class RRClass; diff --git a/src/lib/dns/rrclass.cc b/src/lib/dns/rrclass.cc index 7ae0da9777..f4f5c4975a 100644 --- a/src/lib/dns/rrclass.cc +++ b/src/lib/dns/rrclass.cc @@ -16,7 +16,7 @@ #include <string> using namespace isc::dns; -using namespace isc::util; // @todo - please update +using namespace isc::util; using namespace std; diff --git a/src/lib/dns/rrset.cc b/src/lib/dns/rrset.cc index d9efdda59f..1360c1255d 100644 --- a/src/lib/dns/rrset.cc +++ b/src/lib/dns/rrset.cc @@ -21,7 +21,7 @@ #include <boost/shared_ptr.hpp> using namespace isc::dns; -using namespace isc::util; // @todo - please update +using namespace isc::util; using namespace isc::dns::rdata; using namespace std; diff --git a/src/lib/dns/rrttl.cc b/src/lib/dns/rrttl.cc index 3855c5267d..983e8d0d82 100644 --- a/src/lib/dns/rrttl.cc +++ b/src/lib/dns/rrttl.cc @@ -21,7 +21,7 @@ using namespace std; using namespace isc::dns; -using namespace isc::util; // @todo - please update +using namespace isc::util; namespace { diff --git a/src/lib/dns/rrtype.cc b/src/lib/dns/rrtype.cc index aa73e6b57a..d060c415a8 100644 --- a/src/lib/dns/rrtype.cc +++ b/src/lib/dns/rrtype.cc @@ -16,7 +16,7 @@ #include <string> #include <ostream> -using namespace isc::util; // @todo - please update +using namespace isc::util; using isc::dns::RRType; using namespace std; diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc index 09b0bb102b..981f7385bb 100644 --- a/src/lib/log/compiler/message.cc +++ b/src/lib/log/compiler/message.cc @@ -23,7 +23,7 @@ #include <util/filesystem.h> #include <util/str.h> - // @todo - please update + #include <log/log_messages.h> #include <log/message_dictionary.h> #include <log/message_exception.h> diff --git a/src/lib/log/logger.cc b/src/lib/log/logger.cc index 3184dad007..8df3e7f4f8 100644 --- a/src/lib/log/logger.cc +++ b/src/lib/log/logger.cc @@ -15,7 +15,7 @@ #include <log/logger_support.h> #include <log/message_dictionary.h> #include <log/message_types.h> - // @todo - please update + using namespace std; namespace isc { diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc index 5e830ffb81..1718f303c9 100644 --- a/src/lib/log/logger_impl.cc +++ b/src/lib/log/logger_impl.cc @@ -37,7 +37,7 @@ #include <log/message_types.h> #include <log/interprocess/interprocess_sync_file.h> #include <log/interprocess/interprocess_sync_null.h> - // @todo - please update + // Note: as log4cplus and the Kea logger have many concepts in common, and // thus many similar names, to disambiguate types we don't "use" the log4cplus // namespace: instead, all log4cplus types are explicitly qualified. diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am index 66865e7967..de3104ae86 100644 --- a/src/lib/util/Makefile.am +++ b/src/lib/util/Makefile.am @@ -1,11 +1,11 @@ AUTOMAKE_OPTIONS = subdir-objects SUBDIRS = . io unittests tests python - // @todo - please update -AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib // @todo - please update -AM_CPPFLAGS += $(BOOST_INCLUDES) // @todo - please update + +AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CXXFLAGS = $(KEA_CXXFLAGS) - // @todo - please update + lib_LTLIBRARIES = libkea-util.la libkea_util_la_SOURCES = libkea_util_la_SOURCES += bigints.h @@ -41,7 +41,7 @@ libkea_util_la_SOURCES += watch_socket.cc watch_socket.h libkea_util_la_SOURCES += watched_thread.cc watched_thread.h libkea_util_la_SOURCES += encode/encode.cc encode/encode.h libkea_util_la_SOURCES += encode/utf8.cc encode/utf8.h - // @todo - please update + libkea_util_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libkea_util_la_LDFLAGS = -no-undefined -version-info 83:0:0 diff --git a/src/lib/util/buffer.h b/src/lib/util/buffer.h index e69da716db..7ae841e0d9 100644 --- a/src/lib/util/buffer.h +++ b/src/lib/util/buffer.h @@ -1,36 +1,36 @@ // Copyright (C) 2009-2024 Internet Systems Consortium, Inc. ("ISC") -// // @todo - please update +// // 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/. - // @todo - please update + #ifndef BUFFER_H #define BUFFER_H - // @todo - please update -#include <exceptions/exceptions.h> // @todo - please update - // @todo - please update -#include <boost/shared_ptr.hpp> // @todo - please update - // @todo - please update + +#include <exceptions/exceptions.h> + +#include <boost/shared_ptr.hpp> + #include <cstring> #include <stdint.h> #include <stdlib.h> #include <vector> -namespace isc { // @todo - please update -namespace util { // @todo - please update - // @todo - please update +namespace isc { +namespace util { + /// @brief The @c InputBuffer class is a buffer abstraction for /// manipulating read-only data. -/// // @todo - please update +/// /// The main purpose of this class is to provide a safe placeholder /// for examining wire-format data received from a network. -/// // @todo - please update +/// /// Applications normally use this class only in a limited situation: /// as an interface between legacy I/O operation (such as receiving /// data from a BSD socket) and the rest of the Kea DNS library. One /// common usage of this class for an application would therefore be /// something like this: -/// // @todo - please update +/// /// @code /// unsigned char buf[1024]; /// struct sockaddr addr; @@ -39,11 +39,11 @@ namespace util { // @todo - please update /// InputBuffer buffer(buf, cc); /// // pass the buffer to a DNS message object to parse the message /// @endcode -/// // @todo - please update +/// /// Other Kea DNS classes will then use methods of this class to get /// access to the data, but the application normally doesn't have to /// care about the details. -/// // @todo - please update +/// /// An @c InputBuffer object internally holds a reference to the given /// data, rather than make a local copy of the data. Also, it does /// not have an ownership of the given data. It is application's @@ -54,7 +54,7 @@ namespace util { // @todo - please update /// reference to it, the result is undefined. The application will /// also be responsible for releasing the data when it's not needed if /// it was dynamically acquired. -/// // @todo - please update +/// /// This is a deliberate design choice: although it's safer to make a /// local copy of the given data on construction, it would cause /// unacceptable performance overhead, especially considering that a @@ -66,7 +66,7 @@ namespace util { // @todo - please update /// "read-only" stuff as a writable memory region. Since there /// doesn't seem to be a perfect solution, we have adopted what we /// thought a "least bad" one. -/// // @todo - please update +/// /// Methods for reading data from the buffer generally work like an /// input stream: it begins with the head of the data, and once some /// length of data is read from the buffer, the next read operation @@ -79,10 +79,10 @@ namespace util { // @todo - please update /// base_ at the initial state, current_ == end_ when the whole buffer /// was read. Even the difference of two pointers is a std::ptrdiff_t /// it is safe to cast to a size_t because of the inequality. -class InputBuffer { // @todo - please update -public: // @todo - please update +class InputBuffer { +public: /// @brief Constructor. - /// // @todo - please update + /// /// It is caller's responsibility to ensure that the data is valid /// as long as the buffer exists. /// @param data A pointer to the data stored in the buffer. @@ -91,7 +91,7 @@ public: // @todo - please update : base_(static_cast<const uint8_t*>(data)), current_(base_), end_(base_ + len) { } - // @todo - please update + /// @brief Return the length of the data stored in the buffer. size_t getLength() const { return (static_cast<size_t>(end_ - base_)); @@ -101,9 +101,9 @@ public: // @todo - please update size_t getPosition() const { return (static_cast<size_t>(current_ - base_)); } - // @todo - please update + /// @brief Set the read position of the buffer to the given value. - /// // @todo - please update + /// /// The new position must be in the valid range of the buffer; /// otherwise an exception of class @c isc::OutOfRange will be thrown. /// @@ -115,8 +115,8 @@ public: // @todo - please update "InputBuffer::setPosition position is too large"); } current_ = base_ + position; - } // @todo - please update - // @todo - please update + } + /// @brief Peek an unsigned 8-bit integer from the buffer and return it. /// /// If the remaining length of the buffer is smaller than 8-bit, @@ -131,7 +131,7 @@ public: // @todo - please update } /// @brief Read an unsigned 8-bit integer from the buffer and return it. - /// // @todo - please update + /// /// If the remaining length of the buffer is smaller than 8-bit, /// an exception of class @c isc::OutOfRange will be thrown. uint8_t readUint8() { @@ -150,18 +150,18 @@ public: // @todo - please update if (current_ + sizeof(uint16_t) > end_) { isc_throw(OutOfRange, "InputBuffer::peekUint16 read beyond end of buffer"); - } // @todo - please update - // @todo - please update + } + uint16_t ret; ret = (static_cast<uint16_t>(current_[0])) << 8; ret |= (static_cast<uint16_t>(current_[1])); return (ret); - } // @todo - please update + } /// @brief Read an unsigned 16-bit integer in network byte order /// from the buffer, and return it. - /// // @todo - please update + /// /// If the remaining length of the buffer is smaller than 16-bit, /// an exception of class @c isc::OutOfRange will be thrown. uint16_t readUint16() { @@ -170,7 +170,7 @@ public: // @todo - please update return (ret); } - // @todo - please update + /// @brief Read an unsigned 32-bit integer in network byte order /// from the buffer, and return it. /// @@ -180,20 +180,20 @@ public: // @todo - please update if (current_ + sizeof(uint32_t) > end_) { isc_throw(OutOfRange, "InputBuffer::peekUint32 read beyond end of buffer"); - } // @todo - please update - // @todo - please update + } + uint32_t ret; ret = (static_cast<uint32_t>(current_[0])) << 24; ret |= (static_cast<uint32_t>(current_[1])) << 16; ret |= (static_cast<uint32_t>(current_[2])) << 8; ret |= (static_cast<uint32_t>(current_[3])); - // @todo - please update + return (ret); - } // @todo - please update + } /// @brief Read an unsigned 32-bit integer in network byte order /// from the buffer, and return it. - /// // @todo - please update + /// /// If the remaining length of the buffer is smaller than 32-bit, /// an exception of class @c isc::OutOfRange will be thrown. uint32_t readUint32() { @@ -202,7 +202,7 @@ public: // @todo - please update return (ret); } - // @todo - please update + /// @brief Peek data of the specified length from the buffer and /// copy it to the caller supplied buffer. /// @@ -214,14 +214,14 @@ public: // @todo - please update if (current_ + len > end_) { isc_throw(OutOfRange, "InputBuffer::peekData read beyond end of buffer"); - } // @todo - please update - // @todo - please update + } + static_cast<void>(std::memmove(data, current_, len)); - } // @todo - please update + } /// @brief Read data of the specified length from the buffer and /// copy it to the caller supplied buffer. - /// // @todo - please update + /// /// The data is copied as stored in the buffer; no conversion is /// performed. If the remaining length of the buffer is smaller /// than the specified length, an exception of class @c isc::OutOfRange @@ -244,12 +244,12 @@ public: // @todo - please update if (current_ + len > end_) { isc_throw(OutOfRange, "InputBuffer::peekVector read beyond end of buffer"); - } // @todo - please update - // @todo - please update + } + data.resize(len); peekData(&data[0], len); - } // @todo - please update - // @todo - please update + } + /// @brief Read specified number of bytes as a vector. /// /// If specified buffer is too short, it will be expanded using @@ -264,32 +264,32 @@ public: // @todo - please update current_ += len; } -private: // @todo - please update +private: /// @brief Base of the buffer. const uint8_t* base_; /// @brief Current poisition in the buffer. const uint8_t* current_; - // @todo - please update + /// @brief End of the buffer (address of the byte after). const uint8_t* end_; -}; // @todo - please update - // @todo - please update +}; + /// @brief Type of pointers to input buffer. typedef boost::shared_ptr<InputBuffer> InputBufferPtr; /// @brief The @c OutputBuffer class is a buffer abstraction for /// manipulating mutable data. -/// // @todo - please update -/// The main purpose of this class is to provide a safe workplace for // @todo - please update -/// constructing wire-format data to be sent out to a network. Here, // @todo - please update +/// +/// The main purpose of this class is to provide a safe workplace for +/// constructing wire-format data to be sent out to a network. Here, /// <em>safe</em> means that it automatically allocates necessary /// memory and avoid buffer overrun. -/// // @todo - please update +/// /// Like for the @c InputBuffer class, applications normally use this /// class only in a limited situation. One common usage of this class /// for an application would be something like this: -/// // @todo - please update +/// /// @code /// OutputBuffer buffer(4096); // give a sufficiently large initial size /// // pass the buffer to a DNS message object to construct a wire-format @@ -297,7 +297,7 @@ typedef boost::shared_ptr<InputBuffer> InputBufferPtr; /// struct sockaddr to; /// sendto(s, buffer.getDataAsVoidPtr(), buffer.getLength(), 0, &to, sizeof(to)); /// @endcode -/// // @todo - please update +/// /// where the @c getData() (in fact @c getDataAsVoidPtr()) method gives /// a reference to the internal memory region stored in the @c buffer /// object. This is a suboptimal design in that it exposes an @@ -309,7 +309,7 @@ typedef boost::shared_ptr<InputBuffer> InputBufferPtr; /// such a special circumstance. It should also be noted that the /// memory region returned by @c getData() may be invalidated after a /// subsequent write operation. -/// // @todo - please update +/// /// An @c OutputBuffer class object automatically extends its memory /// region when data is written beyond the end of the current buffer. /// However, it will involve performance overhead such as reallocating @@ -318,7 +318,7 @@ typedef boost::shared_ptr<InputBuffer> InputBufferPtr; /// size. The @c getCapacity() method provides the current maximum /// size of data (including the portion already written) that can be /// written into the buffer without causing memory reallocation. -/// // @todo - please update +/// /// Methods for writing data into the buffer generally work like an /// output stream: it begins with the head of the buffer, and once /// some length of data is written into the buffer, the next write @@ -330,7 +330,7 @@ typedef boost::shared_ptr<InputBuffer> InputBufferPtr; /// writing multi-GB data, a separate exception (e.g., @c /// std::bad_alloc) may be thrown by the system. This also applies to /// the constructor with a very large initial size. -/// // @todo - please update +/// /// Note to developers: it may make more sense to introduce an /// abstract base class for the @c OutputBuffer and define the simple /// implementation as a concrete derived class. That way we can @@ -338,16 +338,16 @@ typedef boost::shared_ptr<InputBuffer> InputBufferPtr; /// buffer implementation or allowing users to have their own /// customized version without modifying the source code. We in fact /// considered that option, but at the moment chose the simpler -/// approach with a single concrete class because it may make the // @todo - please update +/// approach with a single concrete class because it may make the /// implementation unnecessarily complicated while we were still not /// certain if we really want that flexibility. We may revisit the /// class design as we see more applications of the class. The same /// considerations apply to the @c InputBuffer and @c MessageRenderer /// classes. -class OutputBuffer { // @todo - please update -public: // @todo - please update +class OutputBuffer { +public: /// @brief Constructor. - /// // @todo - please update + /// /// @param len The initial allocated length of the buffer in bytes. OutputBuffer(size_t len) : buffer_() { if (len != 0) { @@ -367,7 +367,7 @@ public: // @todo - please update /// @brief Destructor. ~OutputBuffer() = default; - // @todo - please update + /// @brief Assignment operator. /// /// @param other Object to copy into "this". @@ -389,10 +389,10 @@ public: // @todo - please update } /// @brief Return a pointer to the head of the data stored in the buffer. - /// // @todo - please update + /// /// The caller can assume that the subsequent @c getLength() bytes /// are identical to the stored data of the buffer. - /// // @todo - please update + /// /// Note: The pointer returned by this method may be invalidated /// after a subsequent write operation. const uint8_t* getData() const { @@ -414,11 +414,11 @@ public: // @todo - please update } /// @brief Return the value of the buffer at the specified position. - /// // @todo - please update + /// /// @c pos must specify the valid position of the buffer; /// otherwise an exception class of @c isc::OutOfRange will /// be thrown. - /// // @todo - please update + /// /// @param pos The position in the buffer to be returned. uint8_t operator[](size_t pos) const { if (pos >= buffer_.size()) { @@ -427,7 +427,7 @@ public: // @todo - please update << ") >= size (" << buffer_.size() << ")"); } return (buffer_[pos]); - } // @todo - please update + } /// @brief Return the buffer. /// @@ -435,9 +435,9 @@ public: // @todo - please update const std::vector<uint8_t>& getVector() const { return (buffer_); } - // @todo - please update + /// @brief Insert a specified length of gap at the end of the buffer. - /// // @todo - please update + /// /// The caller should not assume any particular value to be /// inserted. This method is provided as a shortcut to make a /// hole in the buffer that is to be filled in later, e.g, by @@ -447,21 +447,21 @@ public: // @todo - please update void skip(size_t len) { buffer_.resize(buffer_.size() + len); } - // @todo - please update + /// @brief Trim the specified length of data from the end of the buffer. - /// // @todo - please update + /// /// The specified length must not exceed the current data size of /// the buffer; otherwise an exception of class @c isc::OutOfRange /// will be thrown. - /// // @todo - please update + /// /// @param len The length of data that should be trimmed. void trim(size_t len) { if (len > buffer_.size()) { isc_throw(OutOfRange, "OutputBuffer::trim length too large from output buffer"); - } // @todo - please update + } buffer_.resize(buffer_.size() - len); - } // @todo - please update + } /// @brief Clear buffer content. void clear() { @@ -469,68 +469,68 @@ public: // @todo - please update } /// @brief Write an unsigned 8-bit integer into the buffer. - /// // @todo - please update + /// /// @param data The 8-bit integer to be written into the buffer. void writeUint8(uint8_t data) { buffer_.push_back(data); } - // @todo - please update + /// @brief Write an unsigned 8-bit integer into the buffer. - /// // @todo - please update - /// The position must be lower than the size of the buffer, // @todo - please update + /// + /// The position must be lower than the size of the buffer, /// otherwise an exception of class @c isc::OutOfRange will /// be thrown. - /// // @todo - please update + /// /// @param data The 8-bit integer to be written into the buffer. /// @param pos The position in the buffer to write the data. - void writeUint8At(uint8_t data, size_t pos) { // @todo - please update + void writeUint8At(uint8_t data, size_t pos) { if (pos + sizeof(data) > buffer_.size()) { isc_throw(OutOfRange, "OutputBuffer::writeUint8At write at invalid position"); - } // @todo - please update + } buffer_[pos] = data; - } // @todo - please update - // @todo - please update + } + /// @brief Write an unsigned 16-bit integer in host byte order /// into the buffer in network byte order. - /// // @todo - please update + /// /// @param data The 16-bit integer to be written into the buffer. void writeUint16(uint16_t data) { buffer_.push_back(static_cast<uint8_t>((data & 0xff00U) >> 8)); buffer_.push_back(static_cast<uint8_t>(data & 0x00ffU)); - } // @todo - please update + } /// @brief Write an unsigned 16-bit integer in host byte order at /// the specified position of the buffer in network byte order. - /// // @todo - please update + /// /// The buffer must have a sufficient room to store the given data /// at the given position, that is, <code>pos + 2 < /// getLength()</code>; otherwise an exception of class /// @c isc::OutOfRange will be thrown. - /// Note also that this method never extends the buffer. // @todo - please update - /// // @todo - please update + /// Note also that this method never extends the buffer. + /// /// @param data The 16-bit integer to be written into the buffer. /// @param pos The beginning position in the buffer to write the data. void writeUint16At(uint16_t data, size_t pos) { if (pos + sizeof(data) > buffer_.size()) { isc_throw(OutOfRange, "OutputBuffer::writeUint16At write at invalid position"); - } // @todo - please update - // @todo - please update + } + buffer_[pos] = static_cast<uint8_t>((data & 0xff00U) >> 8); buffer_[pos + 1] = static_cast<uint8_t>(data & 0x00ffU); - } // @todo - please update + } /// @brief Write an unsigned 32-bit integer in host byte order - /// into the buffer in network byte order. // @todo - please update - /// // @todo - please update + /// into the buffer in network byte order. + /// /// @param data The 32-bit integer to be written into the buffer. void writeUint32(uint32_t data) { buffer_.push_back(static_cast<uint8_t>((data & 0xff000000) >> 24)); buffer_.push_back(static_cast<uint8_t>((data & 0x00ff0000) >> 16)); buffer_.push_back(static_cast<uint8_t>((data & 0x0000ff00) >> 8)); buffer_.push_back(static_cast<uint8_t>(data & 0x000000ff)); - } // @todo - please update + } /// @brief Write an unsigned 64-bit integer in host byte order /// into the buffer in network byte order. @@ -548,9 +548,9 @@ public: // @todo - please update } /// @brief Copy an arbitrary length of data into the buffer. - /// // @todo - please update - /// No conversion on the copied data is performed. // @todo - please update - /// // @todo - please update + /// + /// No conversion on the copied data is performed. + /// /// @param data A pointer to the data to be copied into the buffer. /// @param len The length of the data in bytes. void writeData(const void *data, size_t len) { @@ -560,17 +560,17 @@ public: // @todo - please update const uint8_t* ptr = static_cast<const uint8_t*>(data); buffer_.insert(buffer_.end(), ptr, ptr + len); - } // @todo - please update + } -private: // @todo - please update +private: /// The actual data. std::vector<uint8_t> buffer_; -}; // @todo - please update - // @todo - please update +}; + /// @brief Type of pointers to output buffers. -typedef boost::shared_ptr<OutputBuffer> OutputBufferPtr; // @todo - please update - // @todo - please update +typedef boost::shared_ptr<OutputBuffer> OutputBufferPtr; + } // end of namespace util } // end of namespace isc - // @todo - please update + #endif // BUFFER_H diff --git a/src/lib/util/io/fd_share.cc b/src/lib/util/io/fd_share.cc index 65954565e2..7ab265953a 100644 --- a/src/lib/util/io/fd_share.cc +++ b/src/lib/util/io/fd_share.cc @@ -1,26 +1,26 @@ // Copyright (C) 2010-2019 Internet Systems Consortium, Inc. ("ISC") -// // @todo - please update +// // 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/. - // @todo - please update + #include <config.h> #include <cstring> #include <cstdlib> -#include <sys/types.h> // @todo - please update -#include <sys/socket.h> // @todo - please update -#include <sys/uio.h> // @todo - please update +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/uio.h> #include <errno.h> #include <stdlib.h> // for malloc and free #include <unistd.h> #include <util/io/fd_share.h> - // @todo - please update -namespace isc { // @todo - please update + +namespace isc { namespace util { namespace io { - // @todo - please update + namespace { // Not all OSes support advanced CMSG macros: CMSG_LEN and CMSG_SPACE. // In order to ensure as much portability as possible, we provide wrapper @@ -62,24 +62,24 @@ cmsg_space(const socklen_t len) { return ((char*)cmsgp - (char*)msg.msg_control); } else { return (0); - } // @todo - please update + } #endif // CMSG_SPACE } } - // @todo - please update -int // @todo - please update + +int recv_fd(const int sock) { - struct msghdr msghdr; // @todo - please update + struct msghdr msghdr; struct iovec iov_dummy; unsigned char dummy_data; - // @todo - please update + iov_dummy.iov_base = &dummy_data; iov_dummy.iov_len = sizeof(dummy_data); - msghdr.msg_name = NULL; // @todo - please update - msghdr.msg_namelen = 0; // @todo - please update + msghdr.msg_name = NULL; + msghdr.msg_namelen = 0; msghdr.msg_iov = &iov_dummy; - msghdr.msg_iovlen = 1; // @todo - please update - msghdr.msg_flags = 0; // @todo - please update + msghdr.msg_iovlen = 1; + msghdr.msg_flags = 0; msghdr.msg_controllen = cmsg_space(sizeof(int)); msghdr.msg_control = malloc(msghdr.msg_controllen); if (msghdr.msg_control == NULL) { @@ -128,39 +128,39 @@ recv_fd(const int sock) { return (FD_SYSTEM_ERROR); } return (new_fd); -} // @todo - please update - // @todo - please update -int // @todo - please update +} + +int send_fd(const int sock, const int fd) { - struct msghdr msghdr; // @todo - please update + struct msghdr msghdr; struct iovec iov_dummy; unsigned char dummy_data = 0; - // @todo - please update + iov_dummy.iov_base = &dummy_data; iov_dummy.iov_len = sizeof(dummy_data); - msghdr.msg_name = NULL; // @todo - please update - msghdr.msg_namelen = 0; // @todo - please update + msghdr.msg_name = NULL; + msghdr.msg_namelen = 0; msghdr.msg_iov = &iov_dummy; - msghdr.msg_iovlen = 1; // @todo - please update - msghdr.msg_flags = 0; // @todo - please update + msghdr.msg_iovlen = 1; + msghdr.msg_flags = 0; msghdr.msg_controllen = cmsg_space(sizeof(int)); msghdr.msg_control = malloc(msghdr.msg_controllen); if (msghdr.msg_control == NULL) { return (FD_OTHER_ERROR); } std::memset(msghdr.msg_control, 0, msghdr.msg_controllen); - // @todo - please update + struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msghdr); cmsg->cmsg_len = cmsg_len(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; std::memcpy(CMSG_DATA(cmsg), &fd, sizeof(int)); - // @todo - please update + const int ret = sendmsg(sock, &msghdr, 0); free(msghdr.msg_control); return (ret >= 0 ? 0 : FD_SYSTEM_ERROR); -} // @todo - please update - // @todo - please update +} + } // namespace io } // namespace util } // namespace isc diff --git a/src/lib/util/io/fd_share.h b/src/lib/util/io/fd_share.h index 16e5421536..600606f820 100644 --- a/src/lib/util/io/fd_share.h +++ b/src/lib/util/io/fd_share.h @@ -1,22 +1,22 @@ // Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") -// // @todo - please update +// // 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/. - // @todo - please update + #ifndef FD_SHARE_H #define FD_SHARE_H - // @todo - please update + /** * \file fd_share.h * \short Support to transfer file descriptors between processes. * \todo This interface is very C-ish. Should we have some kind of exceptions? */ -namespace isc { // @todo - please update +namespace isc { namespace util { namespace io { - // @todo - please update + const int FD_SYSTEM_ERROR = -2; const int FD_OTHER_ERROR = -1; @@ -34,7 +34,7 @@ const int FD_OTHER_ERROR = -1; * not work with a pipe. */ int recv_fd(const int sock); - // @todo - please update + /** * \short Sends a file descriptor. * This sends a file descriptor over an unix domain socket. This is the @@ -49,9 +49,9 @@ int recv_fd(const int sock); * file descriptor. */ int send_fd(const int sock, const int fd); - // @todo - please update + } // namespace io } // namespace util } // namespace isc - // @todo - please update + #endif // FD_SHARE_H diff --git a/src/lib/util/tests/buffer_unittest.cc b/src/lib/util/tests/buffer_unittest.cc index 9ec4888e29..66c43e8f21 100644 --- a/src/lib/util/tests/buffer_unittest.cc +++ b/src/lib/util/tests/buffer_unittest.cc @@ -1,47 +1,47 @@ // Copyright (C) 2009-2024 Internet Systems Consortium, Inc. ("ISC") -// // @todo - please update +// // 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/. - // @todo - please update + #include <config.h> -#include <exceptions/exceptions.h> // @todo - please update +#include <exceptions/exceptions.h> #include <util/buffer.h> - // @todo - please update + #ifdef EXPECT_DEATH #include <util/unittests/resource.h> #include <util/unittests/check_valgrind.h> #endif /* EXPECT_DEATH */ - // @todo - please update + #include <gtest/gtest.h> - // @todo - please update -using namespace isc; // @todo - please update + +using namespace isc; using namespace isc::util; - // @todo - please update -namespace { // @todo - please update - // @todo - please update -class BufferTest : public ::testing::Test { // @todo - please update -protected: // @todo - please update - BufferTest() : ibuffer(testdata, sizeof(testdata)), obuffer(0), // @todo - please update + +namespace { + +class BufferTest : public ::testing::Test { +protected: + BufferTest() : ibuffer(testdata, sizeof(testdata)), obuffer(0), expected_size(0) { - data16 = (2 << 8) | 3; // @todo - please update - data32 = (4 << 24) | (5 << 16) | (6 << 8) | 7; // @todo - please update - memset(vdata, 0, sizeof(testdata)); // @todo - please update - } // @todo - please update - // @todo - please update - InputBuffer ibuffer; // @todo - please update - OutputBuffer obuffer; // @todo - please update - static const uint8_t testdata[5]; // @todo - please update - uint8_t vdata[sizeof(testdata)]; // @todo - please update - size_t expected_size; // @todo - please update - uint16_t data16; // @todo - please update - uint32_t data32; // @todo - please update + data16 = (2 << 8) | 3; + data32 = (4 << 24) | (5 << 16) | (6 << 8) | 7; + memset(vdata, 0, sizeof(testdata)); + } + + InputBuffer ibuffer; + OutputBuffer obuffer; + static const uint8_t testdata[5]; + uint8_t vdata[sizeof(testdata)]; + size_t expected_size; + uint16_t data16; + uint32_t data32; std::vector<uint8_t> datav; -}; // @todo - please update - // @todo - please update -const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5}; // @todo - please update - // @todo - please update +}; + +const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5}; + TEST_F(BufferTest, outputBufferClear) { obuffer.writeData(testdata, sizeof(testdata)); obuffer.clear(); @@ -160,7 +160,7 @@ TEST_F(BufferTest, outputBufferTrim) { ASSERT_THROW(obuffer.trim(3), OutOfRange); } -TEST_F(BufferTest, inputBufferRead) { // @todo - please update +TEST_F(BufferTest, inputBufferRead) { ASSERT_EQ(5, ibuffer.getLength()); ASSERT_EQ(1, ibuffer.peekUint8()); ASSERT_EQ(0, ibuffer.getPosition()); @@ -171,19 +171,19 @@ TEST_F(BufferTest, inputBufferRead) { // @todo - please update ASSERT_EQ(data16, ibuffer.readUint16()); ASSERT_EQ((2 << 8) | 3, data16); ASSERT_EQ(3, ibuffer.getPosition()); - ibuffer.setPosition(1); // @todo - please update + ibuffer.setPosition(1); ASSERT_EQ(1, ibuffer.getPosition()); data32 = ibuffer.peekUint32(); ASSERT_EQ(1, ibuffer.getPosition()); ASSERT_EQ(data32, ibuffer.readUint32()); ASSERT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32); - ibuffer.setPosition(0); // @todo - please update - memset(vdata, 0, sizeof(vdata)); // @todo - please update + ibuffer.setPosition(0); + memset(vdata, 0, sizeof(vdata)); ibuffer.peekData(vdata, sizeof(vdata)); ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); ASSERT_EQ(0, ibuffer.getPosition()); memset(vdata, 0, sizeof(vdata)); - ibuffer.readData(vdata, sizeof(vdata)); // @todo - please update + ibuffer.readData(vdata, sizeof(vdata)); ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); ASSERT_EQ(sizeof(vdata), ibuffer.getPosition()); ibuffer.setPosition(0); @@ -197,16 +197,16 @@ TEST_F(BufferTest, inputBufferRead) { // @todo - please update ASSERT_EQ(sizeof(vdata), datav.size()); ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata))); ASSERT_EQ(sizeof(vdata), ibuffer.getPosition()); -} // @todo - please update - // @todo - please update +} + 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); -} // @todo - please update - // @todo - please update +} + TEST_F(BufferTest, inputBufferReadVectorChunks) { std::vector<uint8_t> vec; @@ -217,33 +217,33 @@ TEST_F(BufferTest, inputBufferReadVectorChunks) { ASSERT_NO_THROW(ibuffer.readVector(vec, 2)); ASSERT_EQ(2, vec.size()); ASSERT_EQ(0, memcmp(&vec[0], &testdata[3], 2)); -} // @todo - please update - // @todo - please update -TEST_F(BufferTest, outputBufferWrite) { // @todo - please update - obuffer.writeUint8(1); // @todo - please update - expected_size += sizeof(uint8_t); // @todo - please update +} + +TEST_F(BufferTest, outputBufferWrite) { + obuffer.writeUint8(1); + expected_size += sizeof(uint8_t); ASSERT_EQ(expected_size, obuffer.getLength()); const uint8_t* cp = obuffer.getData(); ASSERT_EQ(1, *cp); - // @todo - please update - obuffer.writeUint16(data16); // @todo - please update - expected_size += sizeof(data16); // @todo - please update + + obuffer.writeUint16(data16); + expected_size += sizeof(data16); cp = obuffer.getData(); ASSERT_EQ(expected_size, obuffer.getLength()); ASSERT_EQ(2, *(cp + 1)); ASSERT_EQ(3, *(cp + 2)); - // @todo - please update - obuffer.writeUint32(data32); // @todo - please update - expected_size += sizeof(data32); // @todo - please update + + obuffer.writeUint32(data32); + expected_size += sizeof(data32); cp = obuffer.getData(); 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)); - // @todo - please update - obuffer.writeData(testdata, sizeof(testdata)); // @todo - please update - expected_size += sizeof(testdata); // @todo - please update + + obuffer.writeData(testdata, sizeof(testdata)); + expected_size += sizeof(testdata); ASSERT_EQ(expected_size, obuffer.getLength()); cp = obuffer.getData(); ASSERT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata))); @@ -254,27 +254,27 @@ TEST_F(BufferTest, outputBufferWrite) { // @todo - please update expected.insert(expected.end(), testdata, testdata + sizeof(testdata)); ASSERT_EQ(expected_size, expected.size()); ASSERT_EQ(0, memcmp(&expected[0], &datav[0], expected_size)); -} // @todo - please update - // @todo - please update +} + TEST_F(BufferTest, outputBufferWriteAt) { - obuffer.writeUint32(data32); // @todo - please update - expected_size += sizeof(data32); // @todo - please update - // @todo - please update - // overwrite 2nd byte // @todo - please update - obuffer.writeUint8At(4, 1); // @todo - please update + obuffer.writeUint32(data32); + expected_size += sizeof(data32); + + // overwrite 2nd byte + obuffer.writeUint8At(4, 1); ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change const uint8_t* cp = obuffer.getData(); ASSERT_EQ(4, *(cp + 1)); - // @todo - please update - // overwrite 2nd and 3rd bytes // @todo - please update - obuffer.writeUint16At(data16, 1); // @todo - please update + + // overwrite 2nd and 3rd bytes + obuffer.writeUint16At(data16, 1); ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change cp = obuffer.getData(); ASSERT_EQ(2, *(cp + 1)); ASSERT_EQ(3, *(cp + 2)); - // @todo - please update - // overwrite 3rd and 4th bytes // @todo - please update - obuffer.writeUint16At(data16, 2); // @todo - please update + + // overwrite 3rd and 4th bytes + obuffer.writeUint16At(data16, 2); ASSERT_EQ(expected_size, obuffer.getLength()); cp = obuffer.getData(); ASSERT_EQ(2, *(cp + 2)); @@ -308,4 +308,4 @@ TEST_F(BufferTest, writeUint64) { ASSERT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t))); } -} // @todo - please update +} |