2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#3320] minor changes

This commit is contained in:
Razvan Becheriu
2024-04-17 10:54:46 +03:00
parent 0f71c39365
commit da95be459b
51 changed files with 313 additions and 313 deletions

View File

@@ -1,10 +1,10 @@
SUBDIRS = . tests SUBDIRS = . tests // @todo - please update
// @todo - please update
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_CPPFLAGS += $(BOOST_INCLUDES) // @todo - please update
// @todo - please update
AM_CXXFLAGS = $(KEA_CXXFLAGS) AM_CXXFLAGS = $(KEA_CXXFLAGS)
// @todo - please update
CLEANFILES = *.gcno *.gcda CLEANFILES = *.gcno *.gcda
EXTRA_DIST = asiodns_messages.mes EXTRA_DIST = asiodns_messages.mes

View File

@@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
$NAMESPACE isc::asiodns $NAMESPACE isc::asiodns // @todo - please update
% ASIODNS_FD_ADD_TCP adding a new TCP server by opened fd %1 % 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. A debug message informing about installing a file descriptor as a server.

View File

@@ -21,7 +21,7 @@
#include <cryptolink/crypto_rng.h> #include <cryptolink/crypto_rng.h>
#include <dns/rcode.h> #include <dns/rcode.h>
#include <util/io.h> #include <util/io.h>
// @todo - please update
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp>
@@ -31,7 +31,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/socket.h> #include <sys/socket.h>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
using namespace isc::dns; using namespace isc::dns;
using namespace isc::log; using namespace isc::log;
using namespace isc::util; using namespace isc::util;
@@ -39,8 +39,8 @@ using namespace isc::util;
using namespace boost::asio; using namespace boost::asio;
using namespace std; using namespace std;
namespace isc { namespace isc { // @todo - please update
namespace asiodns { namespace asiodns { // @todo - please update
// Log debug verbosity. // Log debug verbosity.
@@ -167,9 +167,9 @@ IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service,
initIOFetch(question, protocol, service, **(query_message->beginQuestion()), address, initIOFetch(question, protocol, service, **(query_message->beginQuestion()), address,
port, buff, cb, wait); port, buff, cb, wait);
} } // @todo - please update
// @todo - please update
void void // @todo - please update
IOFetch::initIOFetch(MessagePtr& query, Protocol protocol, const IOServicePtr& service, IOFetch::initIOFetch(MessagePtr& query, Protocol protocol, const IOServicePtr& service,
const isc::dns::Question& question, const IOAddress& address, uint16_t port, const isc::dns::Question& question, const IOAddress& address, uint16_t port,
OutputBufferPtr& buff, Callback* cb, int wait, bool edns) { 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()); r.setBuffer(data_->msgbuf.get());
query->toWire(r); query->toWire(r);
r.setBuffer(NULL); r.setBuffer(NULL);
} } // @todo - please update
// @todo - please update
IOFetch::Protocol IOFetch::Protocol
IOFetch::getProtocol() const { IOFetch::getProtocol() const {
return (data_->protocol); return (data_->protocol);

View File

@@ -18,9 +18,9 @@
#include <ext/coroutine/coroutine.hpp> #include <ext/coroutine/coroutine.hpp>
#endif #endif
#include <asiolink/io_address.h> #include <asiolink/io_address.h> // @todo - please update
#include <asiolink/io_service.h> #include <asiolink/io_service.h>
#include <dns/message.h> #include <dns/message.h> // @todo - please update
#include <dns/question.h> #include <dns/question.h>
#include <util/buffer.h> #include <util/buffer.h>
@@ -29,8 +29,8 @@
#include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/system/error_code.hpp> #include <boost/system/error_code.hpp>
namespace isc { namespace isc { // @todo - please update
namespace asiodns { namespace asiodns { // @todo - please update
// Forward declarations // Forward declarations
struct IOFetchData; struct IOFetchData;
@@ -136,7 +136,7 @@ public:
bool edns = true); bool edns = true);
/// @brief Constructor /// @brief Constructor
/// /// // @todo - please update
/// This constructor has one parameter "query_message", which is the shared_ptr /// 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 /// to a full query message. It's different with above constructor which has only
/// question section. All other parameters are the same. /// question section. All other parameters are the same.
@@ -163,7 +163,7 @@ public:
isc::util::OutputBufferPtr& buff, isc::util::OutputBufferPtr& buff,
Callback* cb, Callback* cb,
int wait = -1); int wait = -1);
// @todo - please update
/// @brief Constructor. /// @brief Constructor.
/// ///
/// Creates the object that will handle the upstream fetch. /// Creates the object that will handle the upstream fetch.
@@ -237,7 +237,7 @@ private:
isc::util::OutputBufferPtr& buff, isc::util::OutputBufferPtr& buff,
Callback* cb, int wait, Callback* cb, int wait,
bool edns = true); bool edns = true);
// @todo - please update
/// @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.

View File

@@ -1,24 +1,24 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib // @todo - please update
AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CPPFLAGS += $(BOOST_INCLUDES) // @todo - please update
// @todo - please update
AM_CXXFLAGS = $(KEA_CXXFLAGS) AM_CXXFLAGS = $(KEA_CXXFLAGS)
// @todo - please update
if USE_STATIC_LINK if USE_STATIC_LINK // @todo - please update
AM_LDFLAGS = -static AM_LDFLAGS = -static // @todo - please update
endif endif // @todo - please update
// @todo - please update
CLEANFILES = *.gcno *.gcda CLEANFILES = *.gcno *.gcda // @todo - please update
// @todo - please update
TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
TESTS = TESTS = // @todo - please update
if HAVE_GTEST if HAVE_GTEST // @todo - please update
TESTS += run_unittests TESTS += run_unittests // @todo - please update
run_unittests_SOURCES = run_unittests.cc run_unittests_SOURCES = run_unittests.cc // @todo - please update
run_unittests_SOURCES += io_fetch_unittest.cc run_unittests_SOURCES += io_fetch_unittest.cc // @todo - please update
// @todo - please update
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) // @todo - please update
// @todo - please update
run_unittests_LDADD = $(top_builddir)/src/lib/asiodns/libkea-asiodns.la 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/asiolink/libkea-asiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.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 += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
run_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) run_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
// @todo - please update
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
// @todo - please update
# 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) run_unittests_CXXFLAGS = $(AM_CXXFLAGS) // @todo - please update
if USE_GXX if USE_GXX // @todo - please update
run_unittests_CXXFLAGS += -Wno-unused-parameter run_unittests_CXXFLAGS += -Wno-unused-parameter // @todo - please update
endif endif // @todo - please update
endif endif // @todo - please update
// @todo - please update
noinst_PROGRAMS = $(TESTS) noinst_PROGRAMS = $(TESTS)

View File

@@ -33,7 +33,7 @@
using namespace isc::asiolink; using namespace isc::asiolink;
using namespace isc::dns; using namespace isc::dns;
using namespace isc::util; using namespace isc::util; // @todo - please update
using namespace boost::asio; using namespace boost::asio;
using namespace boost::asio::ip; using namespace boost::asio::ip;
@@ -41,8 +41,8 @@ using namespace std;
namespace ph = std::placeholders; namespace ph = std::placeholders;
namespace isc { namespace isc { // @todo - please update
namespace asiodns { namespace asiodns { // @todo - please update
const boost::asio::ip::address TEST_HOST(boost::asio::ip::address::from_string("127.0.0.1")); const boost::asio::ip::address TEST_HOST(boost::asio::ip::address::from_string("127.0.0.1"));
const uint16_t TEST_PORT(5301); const uint16_t TEST_PORT(5301);

View File

@@ -1,19 +1,19 @@
// Copyright (C) 2009-2015 Internet Systems Consortium, Inc. ("ISC") // 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 // 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 // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @todo - please update
#include <config.h> #include <config.h>
#include <gtest/gtest.h> #include <gtest/gtest.h> // @todo - please update
// @todo - please update
#include <util/unittests/run_all.h> #include <util/unittests/run_all.h>
#include <log/logger_support.h> #include <log/logger_support.h>
// @todo - please update
int int // @todo - please update
main(int argc, char* argv[]) { main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
isc::log::initLogger(); isc::log::initLogger();
return (isc::util::unittests::run_all()); return (isc::util::unittests::run_all());
} } // @todo - please update

View File

@@ -13,7 +13,7 @@
#include <boost/asio/error.hpp> #include <boost/asio/error.hpp>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief Asynchronous I/O Completion Callback /// \brief Asynchronous I/O Completion Callback

View File

@@ -22,7 +22,7 @@
using namespace std; using namespace std;
namespace ph = std::placeholders; namespace ph = std::placeholders;
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// This class holds a call back function of asynchronous operations. /// This class holds a call back function of asynchronous operations.

View File

@@ -12,7 +12,7 @@
#include <asiolink/io_service.h> #include <asiolink/io_service.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
class IntervalTimerImpl; class IntervalTimerImpl;

View File

@@ -25,7 +25,7 @@ using boost::asio::ip::tcp;
using namespace std; using namespace std;
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
size_t size_t

View File

@@ -20,7 +20,7 @@
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// Defines length of IPv6 address (in binary format). /// Defines length of IPv6 address (in binary format).

View File

@@ -32,7 +32,7 @@
#include <boost/asio/coroutine.hpp> #include <boost/asio/coroutine.hpp>
#endif #endif
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief Socket not open /// \brief Socket not open

View File

@@ -21,7 +21,7 @@
using namespace std; using namespace std;
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
const IOEndpoint* const IOEndpoint*

View File

@@ -23,7 +23,7 @@
#include <sys/socket.h> // for sockaddr #include <sys/socket.h> // for sockaddr
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief The \c IOEndpoint class is an abstract base class to represent /// \brief The \c IOEndpoint class is an abstract base class to represent

View File

@@ -10,7 +10,7 @@
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief An exception that is thrown if an error occurs within the IO /// \brief An exception that is thrown if an error occurs within the IO

View File

@@ -14,7 +14,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <sys/socket.h> #include <sys/socket.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
class IOServiceImpl { class IOServiceImpl {

View File

@@ -22,7 +22,7 @@ namespace asio {
} }
} }
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
class IOServiceImpl; class IOServiceImpl;

View File

@@ -8,7 +8,7 @@
#include <asiolink/asio_wrapper.h> #include <asiolink/asio_wrapper.h>
#include <asiolink/io_socket.h> #include <asiolink/io_socket.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief The \c DummySocket class is a concrete derived class of /// \brief The \c DummySocket class is a concrete derived class of

View File

@@ -17,7 +17,7 @@
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief The \c IOSocket class is an abstract base class to represent /// \brief The \c IOSocket class is an abstract base class to represent

View File

@@ -13,7 +13,7 @@
#include <asiolink/io_endpoint.h> #include <asiolink/io_endpoint.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief The \c TCPEndpoint class is a concrete derived class of /// \brief The \c TCPEndpoint class is a concrete derived class of

View File

@@ -28,7 +28,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> // for some IPC/network system calls #include <unistd.h> // for some IPC/network system calls
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief Buffer Too Large /// \brief Buffer Too Large

View File

@@ -17,7 +17,7 @@
#include <sstream> #include <sstream>
#include <unordered_set> #include <unordered_set>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
TEST(IOAddressHashTest, hashIPv4) { TEST(IOAddressHashTest, hashIPv4) {
IOAddress::Hash hash; IOAddress::Hash hash;

View File

@@ -21,7 +21,7 @@
#include <netdb.h> #include <netdb.h>
#include <string.h> #include <string.h>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
namespace { namespace {
typedef boost::shared_ptr<const IOEndpoint> ConstIOEndpointPtr; typedef boost::shared_ptr<const IOEndpoint> ConstIOEndpointPtr;

View File

@@ -11,7 +11,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <netinet/in.h> #include <netinet/in.h>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
TEST(IOSocketTest, dummySockets) { TEST(IOSocketTest, dummySockets) {
EXPECT_EQ(static_cast<short>(IPPROTO_UDP), EXPECT_EQ(static_cast<short>(IPPROTO_UDP),

View File

@@ -13,7 +13,7 @@
#include <string> #include <string>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
using namespace std; using namespace std;
// This test checks that the endpoint can manage its own internal // This test checks that the endpoint can manage its own internal

View File

@@ -32,7 +32,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
using namespace isc::util; using namespace isc::util;
using namespace std; using namespace std;

View File

@@ -13,7 +13,7 @@
#include <string> #include <string>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
using namespace std; using namespace std;
// This test checks that the endpoint can manage its own internal // This test checks that the endpoint can manage its own internal

View File

@@ -32,7 +32,7 @@
#include <vector> #include <vector>
using namespace isc::asiolink; using namespace isc::asiolink; // @todo - please update
using namespace isc::util; using namespace isc::util;
using namespace boost::asio; using namespace boost::asio;

View File

@@ -13,7 +13,7 @@
#include <asiolink/io_endpoint.h> #include <asiolink/io_endpoint.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief The \c UDPEndpoint class is a concrete derived class of /// \brief The \c UDPEndpoint class is a concrete derived class of

View File

@@ -24,7 +24,7 @@
#include <exceptions/isc_assert.h> #include <exceptions/isc_assert.h>
namespace isc { namespace isc { // @todo - please update
namespace asiolink { namespace asiolink {
/// \brief The \c UDPSocket class is a concrete derived class of \c IOAsioSocket /// \brief The \c UDPSocket class is a concrete derived class of \c IOAsioSocket

View File

@@ -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/util/libkea-util.la
libkea_dns___la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libkea_dns___la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libkea_dns___la_LIBADD += $(CRYPTO_LIBS) 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: # 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 # rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc
libkea_dns___la_SOURCES += rdataclass.h rrclass.h rrtype.h libkea_dns___la_SOURCES += rdataclass.h rrclass.h rrtype.h

View File

@@ -33,7 +33,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
using namespace isc::dns::rdata; using namespace isc::dns::rdata;
using namespace isc::util; using namespace isc::util; // @todo - please update
using namespace std; using namespace std;
using boost::lexical_cast; using boost::lexical_cast;

View File

@@ -603,7 +603,7 @@ public:
/// NOTE: If the header has already been parsed by a previous call /// NOTE: If the header has already been parsed by a previous call
/// to this method, this method simply returns (i.e., it does not /// to this method, this method simply returns (i.e., it does not
/// read from the \c buffer). /// read from the \c buffer).
void parseHeader(isc::util::InputBuffer& buffer); void parseHeader(isc::util::InputBuffer& buffer); // @todo - please update
/// \brief (Re)build a \c Message object from wire-format data. /// \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 ongoing state information will not be lost if the object
/// that originated the asynchronous call falls out of scope. /// that originated the asynchronous call falls out of scope.
typedef boost::shared_ptr<Message> MessagePtr; typedef boost::shared_ptr<Message> MessagePtr;
typedef boost::shared_ptr<const Message> ConstMessagePtr; typedef boost::shared_ptr<const Message> ConstMessagePtr; // @todo - please update
/// Insert the \c Message as a string into stream. /// Insert the \c Message as a string into stream.
/// ///

View File

@@ -20,9 +20,9 @@
#include <cassert> #include <cassert>
#include <vector> #include <vector>
using namespace isc::util; using namespace isc::util; // @todo - please update
using isc::dns::name::internal::maptolower; using isc::dns::name::internal::maptolower;
// @todo - please update
using namespace std; using namespace std;
namespace isc { namespace isc {

View File

@@ -19,7 +19,7 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
using namespace isc::util; using namespace isc::util; // @todo - please update
using namespace isc::dns::name::internal; using namespace isc::dns::name::internal;
using namespace std; using namespace std;

View File

@@ -18,7 +18,7 @@
#include <dns/exceptions.h> #include <dns/exceptions.h>
namespace isc { namespace isc {
namespace dns { namespace dns { // @todo - please update
/// ///
/// \brief A standard DNS module exception that is thrown if the name parser /// \brief A standard DNS module exception that is thrown if the name parser
/// encounters an empty label in the middle of a name. /// encounters an empty label in the middle of a name.

View File

@@ -16,7 +16,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
using namespace isc::util; using namespace isc::util; // @todo - please update
using namespace std; using namespace std;

View File

@@ -19,7 +19,7 @@
#include <stdint.h> #include <stdint.h>
namespace isc { namespace isc {
namespace dns { namespace dns { // @todo - please update
class AbstractMessageRenderer; class AbstractMessageRenderer;
class RRType; class RRType;
class RRClass; class RRClass;

View File

@@ -16,7 +16,7 @@
#include <string> #include <string>
using namespace isc::dns; using namespace isc::dns;
using namespace isc::util; using namespace isc::util; // @todo - please update
using namespace std; using namespace std;

View File

@@ -21,7 +21,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
using namespace isc::dns; using namespace isc::dns;
using namespace isc::util; using namespace isc::util; // @todo - please update
using namespace isc::dns::rdata; using namespace isc::dns::rdata;
using namespace std; using namespace std;

View File

@@ -21,7 +21,7 @@
using namespace std; using namespace std;
using namespace isc::dns; using namespace isc::dns;
using namespace isc::util; using namespace isc::util; // @todo - please update
namespace { namespace {

View File

@@ -16,7 +16,7 @@
#include <string> #include <string>
#include <ostream> #include <ostream>
using namespace isc::util; using namespace isc::util; // @todo - please update
using isc::dns::RRType; using isc::dns::RRType;
using namespace std; using namespace std;

View File

@@ -23,7 +23,7 @@
#include <util/filesystem.h> #include <util/filesystem.h>
#include <util/str.h> #include <util/str.h>
// @todo - please update
#include <log/log_messages.h> #include <log/log_messages.h>
#include <log/message_dictionary.h> #include <log/message_dictionary.h>
#include <log/message_exception.h> #include <log/message_exception.h>

View File

@@ -15,7 +15,7 @@
#include <log/logger_support.h> #include <log/logger_support.h>
#include <log/message_dictionary.h> #include <log/message_dictionary.h>
#include <log/message_types.h> #include <log/message_types.h>
// @todo - please update
using namespace std; using namespace std;
namespace isc { namespace isc {

View File

@@ -37,7 +37,7 @@
#include <log/message_types.h> #include <log/message_types.h>
#include <log/interprocess/interprocess_sync_file.h> #include <log/interprocess/interprocess_sync_file.h>
#include <log/interprocess/interprocess_sync_null.h> #include <log/interprocess/interprocess_sync_null.h>
// @todo - please update
// Note: as log4cplus and the Kea logger have many concepts in common, and // 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 // thus many similar names, to disambiguate types we don't "use" the log4cplus
// namespace: instead, all log4cplus types are explicitly qualified. // namespace: instead, all log4cplus types are explicitly qualified.

View File

@@ -1,11 +1,11 @@
AUTOMAKE_OPTIONS = subdir-objects AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = . io unittests tests python SUBDIRS = . io unittests tests python
// @todo - please update
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib // @todo - please update
AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CPPFLAGS += $(BOOST_INCLUDES) // @todo - please update
AM_CXXFLAGS = $(KEA_CXXFLAGS) AM_CXXFLAGS = $(KEA_CXXFLAGS)
// @todo - please update
lib_LTLIBRARIES = libkea-util.la lib_LTLIBRARIES = libkea-util.la
libkea_util_la_SOURCES = libkea_util_la_SOURCES =
libkea_util_la_SOURCES += bigints.h 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 += watched_thread.cc watched_thread.h
libkea_util_la_SOURCES += encode/encode.cc encode/encode.h libkea_util_la_SOURCES += encode/encode.cc encode/encode.h
libkea_util_la_SOURCES += encode/utf8.cc encode/utf8.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_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libkea_util_la_LDFLAGS = -no-undefined -version-info 83:0:0 libkea_util_la_LDFLAGS = -no-undefined -version-info 83:0:0

View File

@@ -1,36 +1,36 @@
// Copyright (C) 2009-2024 Internet Systems Consortium, Inc. ("ISC") // 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 // 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 // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @todo - please update
#ifndef BUFFER_H #ifndef BUFFER_H
#define BUFFER_H #define BUFFER_H
// @todo - please update
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h> // @todo - please update
// @todo - please update
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp> // @todo - please update
// @todo - please update
#include <cstring> #include <cstring>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <vector> #include <vector>
namespace isc { namespace isc { // @todo - please update
namespace util { namespace util { // @todo - please update
// @todo - please update
/// @brief The @c InputBuffer class is a buffer abstraction for /// @brief The @c InputBuffer class is a buffer abstraction for
/// manipulating read-only data. /// manipulating read-only data.
/// /// // @todo - please update
/// The main purpose of this class is to provide a safe placeholder /// The main purpose of this class is to provide a safe placeholder
/// for examining wire-format data received from a network. /// for examining wire-format data received from a network.
/// /// // @todo - please update
/// Applications normally use this class only in a limited situation: /// Applications normally use this class only in a limited situation:
/// as an interface between legacy I/O operation (such as receiving /// 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 /// 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 /// common usage of this class for an application would therefore be
/// something like this: /// something like this:
/// /// // @todo - please update
/// @code /// @code
/// unsigned char buf[1024]; /// unsigned char buf[1024];
/// struct sockaddr addr; /// struct sockaddr addr;
@@ -39,11 +39,11 @@ namespace util {
/// InputBuffer buffer(buf, cc); /// InputBuffer buffer(buf, cc);
/// // pass the buffer to a DNS message object to parse the message /// // pass the buffer to a DNS message object to parse the message
/// @endcode /// @endcode
/// /// // @todo - please update
/// Other Kea DNS classes will then use methods of this class to get /// 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 /// access to the data, but the application normally doesn't have to
/// care about the details. /// care about the details.
/// /// // @todo - please update
/// An @c InputBuffer object internally holds a reference to the given /// An @c InputBuffer object internally holds a reference to the given
/// data, rather than make a local copy of the data. Also, it does /// 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 /// not have an ownership of the given data. It is application's
@@ -54,7 +54,7 @@ namespace util {
/// reference to it, the result is undefined. The application will /// reference to it, the result is undefined. The application will
/// also be responsible for releasing the data when it's not needed if /// also be responsible for releasing the data when it's not needed if
/// it was dynamically acquired. /// it was dynamically acquired.
/// /// // @todo - please update
/// This is a deliberate design choice: although it's safer to make a /// This is a deliberate design choice: although it's safer to make a
/// local copy of the given data on construction, it would cause /// local copy of the given data on construction, it would cause
/// unacceptable performance overhead, especially considering that a /// unacceptable performance overhead, especially considering that a
@@ -66,7 +66,7 @@ namespace util {
/// "read-only" stuff as a writable memory region. Since there /// "read-only" stuff as a writable memory region. Since there
/// doesn't seem to be a perfect solution, we have adopted what we /// doesn't seem to be a perfect solution, we have adopted what we
/// thought a "least bad" one. /// thought a "least bad" one.
/// /// // @todo - please update
/// Methods for reading data from the buffer generally work like an /// Methods for reading data from the buffer generally work like an
/// input stream: it begins with the head of the data, and once some /// 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 /// length of data is read from the buffer, the next read operation
@@ -79,10 +79,10 @@ namespace util {
/// base_ at the initial state, current_ == end_ when the whole buffer /// base_ at the initial state, current_ == end_ when the whole buffer
/// was read. Even the difference of two pointers is a std::ptrdiff_t /// 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. /// it is safe to cast to a size_t because of the inequality.
class InputBuffer { class InputBuffer { // @todo - please update
public: public: // @todo - please update
/// @brief Constructor. /// @brief Constructor.
/// /// // @todo - please update
/// It is caller's responsibility to ensure that the data is valid /// It is caller's responsibility to ensure that the data is valid
/// as long as the buffer exists. /// as long as the buffer exists.
/// @param data A pointer to the data stored in the buffer. /// @param data A pointer to the data stored in the buffer.
@@ -91,7 +91,7 @@ public:
: base_(static_cast<const uint8_t*>(data)), current_(base_), : base_(static_cast<const uint8_t*>(data)), current_(base_),
end_(base_ + len) { end_(base_ + len) {
} }
// @todo - please update
/// @brief Return the length of the data stored in the buffer. /// @brief Return the length of the data stored in the buffer.
size_t getLength() const { size_t getLength() const {
return (static_cast<size_t>(end_ - base_)); return (static_cast<size_t>(end_ - base_));
@@ -101,9 +101,9 @@ public:
size_t getPosition() const { size_t getPosition() const {
return (static_cast<size_t>(current_ - base_)); return (static_cast<size_t>(current_ - base_));
} }
// @todo - please update
/// @brief Set the read position of the buffer to the given value. /// @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; /// The new position must be in the valid range of the buffer;
/// otherwise an exception of class @c isc::OutOfRange will be thrown. /// otherwise an exception of class @c isc::OutOfRange will be thrown.
/// ///
@@ -115,8 +115,8 @@ public:
"InputBuffer::setPosition position is too large"); "InputBuffer::setPosition position is too large");
} }
current_ = base_ + position; current_ = base_ + position;
} } // @todo - please update
// @todo - please update
/// @brief Peek an unsigned 8-bit integer from the buffer and return it. /// @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, /// If the remaining length of the buffer is smaller than 8-bit,
@@ -131,7 +131,7 @@ public:
} }
/// @brief Read an unsigned 8-bit integer from the buffer and return it. /// @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, /// If the remaining length of the buffer is smaller than 8-bit,
/// an exception of class @c isc::OutOfRange will be thrown. /// an exception of class @c isc::OutOfRange will be thrown.
uint8_t readUint8() { uint8_t readUint8() {
@@ -150,18 +150,18 @@ public:
if (current_ + sizeof(uint16_t) > end_) { if (current_ + sizeof(uint16_t) > end_) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"InputBuffer::peekUint16 read beyond end of buffer"); "InputBuffer::peekUint16 read beyond end of buffer");
} } // @todo - please update
// @todo - please update
uint16_t ret; uint16_t ret;
ret = (static_cast<uint16_t>(current_[0])) << 8; ret = (static_cast<uint16_t>(current_[0])) << 8;
ret |= (static_cast<uint16_t>(current_[1])); ret |= (static_cast<uint16_t>(current_[1]));
return (ret); return (ret);
} } // @todo - please update
/// @brief Read an unsigned 16-bit integer in network byte order /// @brief Read an unsigned 16-bit integer in network byte order
/// from the buffer, and return it. /// from the buffer, and return it.
/// /// // @todo - please update
/// If the remaining length of the buffer is smaller than 16-bit, /// If the remaining length of the buffer is smaller than 16-bit,
/// an exception of class @c isc::OutOfRange will be thrown. /// an exception of class @c isc::OutOfRange will be thrown.
uint16_t readUint16() { uint16_t readUint16() {
@@ -170,7 +170,7 @@ public:
return (ret); return (ret);
} }
// @todo - please update
/// @brief Read an unsigned 32-bit integer in network byte order /// @brief Read an unsigned 32-bit integer in network byte order
/// from the buffer, and return it. /// from the buffer, and return it.
/// ///
@@ -180,20 +180,20 @@ public:
if (current_ + sizeof(uint32_t) > end_) { if (current_ + sizeof(uint32_t) > end_) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"InputBuffer::peekUint32 read beyond end of buffer"); "InputBuffer::peekUint32 read beyond end of buffer");
} } // @todo - please update
// @todo - please update
uint32_t ret; uint32_t ret;
ret = (static_cast<uint32_t>(current_[0])) << 24; ret = (static_cast<uint32_t>(current_[0])) << 24;
ret |= (static_cast<uint32_t>(current_[1])) << 16; ret |= (static_cast<uint32_t>(current_[1])) << 16;
ret |= (static_cast<uint32_t>(current_[2])) << 8; ret |= (static_cast<uint32_t>(current_[2])) << 8;
ret |= (static_cast<uint32_t>(current_[3])); ret |= (static_cast<uint32_t>(current_[3]));
// @todo - please update
return (ret); return (ret);
} } // @todo - please update
/// @brief Read an unsigned 32-bit integer in network byte order /// @brief Read an unsigned 32-bit integer in network byte order
/// from the buffer, and return it. /// from the buffer, and return it.
/// /// // @todo - please update
/// If the remaining length of the buffer is smaller than 32-bit, /// If the remaining length of the buffer is smaller than 32-bit,
/// an exception of class @c isc::OutOfRange will be thrown. /// an exception of class @c isc::OutOfRange will be thrown.
uint32_t readUint32() { uint32_t readUint32() {
@@ -202,7 +202,7 @@ public:
return (ret); return (ret);
} }
// @todo - please update
/// @brief Peek data of the specified length from the buffer and /// @brief Peek data of the specified length from the buffer and
/// copy it to the caller supplied buffer. /// copy it to the caller supplied buffer.
/// ///
@@ -214,14 +214,14 @@ public:
if (current_ + len > end_) { if (current_ + len > end_) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"InputBuffer::peekData read beyond end of buffer"); "InputBuffer::peekData read beyond end of buffer");
} } // @todo - please update
// @todo - please update
static_cast<void>(std::memmove(data, current_, len)); static_cast<void>(std::memmove(data, current_, len));
} } // @todo - please update
/// @brief Read data of the specified length from the buffer and /// @brief Read data of the specified length from the buffer and
/// copy it to the caller supplied buffer. /// copy it to the caller supplied buffer.
/// /// // @todo - please update
/// The data is copied as stored in the buffer; no conversion is /// The data is copied as stored in the buffer; no conversion is
/// performed. If the remaining length of the buffer is smaller /// performed. If the remaining length of the buffer is smaller
/// than the specified length, an exception of class @c isc::OutOfRange /// than the specified length, an exception of class @c isc::OutOfRange
@@ -244,12 +244,12 @@ public:
if (current_ + len > end_) { if (current_ + len > end_) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"InputBuffer::peekVector read beyond end of buffer"); "InputBuffer::peekVector read beyond end of buffer");
} } // @todo - please update
// @todo - please update
data.resize(len); data.resize(len);
peekData(&data[0], len); peekData(&data[0], len);
} } // @todo - please update
// @todo - please update
/// @brief Read specified number of bytes as a vector. /// @brief Read specified number of bytes as a vector.
/// ///
/// If specified buffer is too short, it will be expanded using /// If specified buffer is too short, it will be expanded using
@@ -264,32 +264,32 @@ public:
current_ += len; current_ += len;
} }
private: private: // @todo - please update
/// @brief Base of the buffer. /// @brief Base of the buffer.
const uint8_t* base_; const uint8_t* base_;
/// @brief Current poisition in the buffer. /// @brief Current poisition in the buffer.
const uint8_t* current_; const uint8_t* current_;
// @todo - please update
/// @brief End of the buffer (address of the byte after). /// @brief End of the buffer (address of the byte after).
const uint8_t* end_; const uint8_t* end_;
}; }; // @todo - please update
// @todo - please update
/// @brief Type of pointers to input buffer. /// @brief Type of pointers to input buffer.
typedef boost::shared_ptr<InputBuffer> InputBufferPtr; typedef boost::shared_ptr<InputBuffer> InputBufferPtr;
/// @brief The @c OutputBuffer class is a buffer abstraction for /// @brief The @c OutputBuffer class is a buffer abstraction for
/// manipulating mutable data. /// manipulating mutable data.
/// /// // @todo - please update
/// The main purpose of this class is to provide a safe workplace for /// 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, /// constructing wire-format data to be sent out to a network. Here, // @todo - please update
/// <em>safe</em> means that it automatically allocates necessary /// <em>safe</em> means that it automatically allocates necessary
/// memory and avoid buffer overrun. /// memory and avoid buffer overrun.
/// /// // @todo - please update
/// Like for the @c InputBuffer class, applications normally use this /// Like for the @c InputBuffer class, applications normally use this
/// class only in a limited situation. One common usage of this class /// class only in a limited situation. One common usage of this class
/// for an application would be something like this: /// for an application would be something like this:
/// /// // @todo - please update
/// @code /// @code
/// OutputBuffer buffer(4096); // give a sufficiently large initial size /// OutputBuffer buffer(4096); // give a sufficiently large initial size
/// // pass the buffer to a DNS message object to construct a wire-format /// // 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; /// struct sockaddr to;
/// sendto(s, buffer.getDataAsVoidPtr(), buffer.getLength(), 0, &to, sizeof(to)); /// sendto(s, buffer.getDataAsVoidPtr(), buffer.getLength(), 0, &to, sizeof(to));
/// @endcode /// @endcode
/// /// // @todo - please update
/// where the @c getData() (in fact @c getDataAsVoidPtr()) method gives /// where the @c getData() (in fact @c getDataAsVoidPtr()) method gives
/// a reference to the internal memory region stored in the @c buffer /// a reference to the internal memory region stored in the @c buffer
/// object. This is a suboptimal design in that it exposes an /// 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 /// such a special circumstance. It should also be noted that the
/// memory region returned by @c getData() may be invalidated after a /// memory region returned by @c getData() may be invalidated after a
/// subsequent write operation. /// subsequent write operation.
/// /// // @todo - please update
/// An @c OutputBuffer class object automatically extends its memory /// An @c OutputBuffer class object automatically extends its memory
/// region when data is written beyond the end of the current buffer. /// region when data is written beyond the end of the current buffer.
/// However, it will involve performance overhead such as reallocating /// 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. The @c getCapacity() method provides the current maximum
/// size of data (including the portion already written) that can be /// size of data (including the portion already written) that can be
/// written into the buffer without causing memory reallocation. /// written into the buffer without causing memory reallocation.
/// /// // @todo - please update
/// Methods for writing data into the buffer generally work like an /// Methods for writing data into the buffer generally work like an
/// output stream: it begins with the head of the buffer, and once /// output stream: it begins with the head of the buffer, and once
/// some length of data is written into the buffer, the next write /// 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 /// writing multi-GB data, a separate exception (e.g., @c
/// std::bad_alloc) may be thrown by the system. This also applies to /// std::bad_alloc) may be thrown by the system. This also applies to
/// the constructor with a very large initial size. /// the constructor with a very large initial size.
/// /// // @todo - please update
/// Note to developers: it may make more sense to introduce an /// Note to developers: it may make more sense to introduce an
/// abstract base class for the @c OutputBuffer and define the simple /// abstract base class for the @c OutputBuffer and define the simple
/// implementation as a concrete derived class. That way we can /// 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 /// buffer implementation or allowing users to have their own
/// customized version without modifying the source code. We in fact /// customized version without modifying the source code. We in fact
/// considered that option, but at the moment chose the simpler /// considered that option, but at the moment chose the simpler
/// approach with a single concrete class because it may make the /// approach with a single concrete class because it may make the // @todo - please update
/// implementation unnecessarily complicated while we were still not /// implementation unnecessarily complicated while we were still not
/// certain if we really want that flexibility. We may revisit the /// certain if we really want that flexibility. We may revisit the
/// class design as we see more applications of the class. The same /// class design as we see more applications of the class. The same
/// considerations apply to the @c InputBuffer and @c MessageRenderer /// considerations apply to the @c InputBuffer and @c MessageRenderer
/// classes. /// classes.
class OutputBuffer { class OutputBuffer { // @todo - please update
public: public: // @todo - please update
/// @brief Constructor. /// @brief Constructor.
/// /// // @todo - please update
/// @param len The initial allocated length of the buffer in bytes. /// @param len The initial allocated length of the buffer in bytes.
OutputBuffer(size_t len) : buffer_() { OutputBuffer(size_t len) : buffer_() {
if (len != 0) { if (len != 0) {
@@ -367,7 +367,7 @@ public:
/// @brief Destructor. /// @brief Destructor.
~OutputBuffer() = default; ~OutputBuffer() = default;
// @todo - please update
/// @brief Assignment operator. /// @brief Assignment operator.
/// ///
/// @param other Object to copy into "this". /// @param other Object to copy into "this".
@@ -389,10 +389,10 @@ public:
} }
/// @brief Return a pointer to the head of the data stored in the buffer. /// @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 /// The caller can assume that the subsequent @c getLength() bytes
/// are identical to the stored data of the buffer. /// are identical to the stored data of the buffer.
/// /// // @todo - please update
/// Note: The pointer returned by this method may be invalidated /// Note: The pointer returned by this method may be invalidated
/// after a subsequent write operation. /// after a subsequent write operation.
const uint8_t* getData() const { const uint8_t* getData() const {
@@ -414,11 +414,11 @@ public:
} }
/// @brief Return the value of the buffer at the specified position. /// @brief Return the value of the buffer at the specified position.
/// /// // @todo - please update
/// @c pos must specify the valid position of the buffer; /// @c pos must specify the valid position of the buffer;
/// otherwise an exception class of @c isc::OutOfRange will /// otherwise an exception class of @c isc::OutOfRange will
/// be thrown. /// be thrown.
/// /// // @todo - please update
/// @param pos The position in the buffer to be returned. /// @param pos The position in the buffer to be returned.
uint8_t operator[](size_t pos) const { uint8_t operator[](size_t pos) const {
if (pos >= buffer_.size()) { if (pos >= buffer_.size()) {
@@ -427,7 +427,7 @@ public:
<< ") >= size (" << buffer_.size() << ")"); << ") >= size (" << buffer_.size() << ")");
} }
return (buffer_[pos]); return (buffer_[pos]);
} } // @todo - please update
/// @brief Return the buffer. /// @brief Return the buffer.
/// ///
@@ -435,9 +435,9 @@ public:
const std::vector<uint8_t>& getVector() const { const std::vector<uint8_t>& getVector() const {
return (buffer_); return (buffer_);
} }
// @todo - please update
/// @brief Insert a specified length of gap at the end of the buffer. /// @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 /// The caller should not assume any particular value to be
/// inserted. This method is provided as a shortcut to make a /// 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 /// hole in the buffer that is to be filled in later, e.g, by
@@ -447,21 +447,21 @@ public:
void skip(size_t len) { void skip(size_t len) {
buffer_.resize(buffer_.size() + len); buffer_.resize(buffer_.size() + len);
} }
// @todo - please update
/// @brief Trim the specified length of data from the end of the buffer. /// @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 specified length must not exceed the current data size of
/// the buffer; otherwise an exception of class @c isc::OutOfRange /// the buffer; otherwise an exception of class @c isc::OutOfRange
/// will be thrown. /// will be thrown.
/// /// // @todo - please update
/// @param len The length of data that should be trimmed. /// @param len The length of data that should be trimmed.
void trim(size_t len) { void trim(size_t len) {
if (len > buffer_.size()) { if (len > buffer_.size()) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"OutputBuffer::trim length too large from output buffer"); "OutputBuffer::trim length too large from output buffer");
} } // @todo - please update
buffer_.resize(buffer_.size() - len); buffer_.resize(buffer_.size() - len);
} } // @todo - please update
/// @brief Clear buffer content. /// @brief Clear buffer content.
void clear() { void clear() {
@@ -469,68 +469,68 @@ public:
} }
/// @brief Write an unsigned 8-bit integer into the buffer. /// @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. /// @param data The 8-bit integer to be written into the buffer.
void writeUint8(uint8_t data) { void writeUint8(uint8_t data) {
buffer_.push_back(data); buffer_.push_back(data);
} }
// @todo - please update
/// @brief Write an unsigned 8-bit integer into the buffer. /// @brief Write an unsigned 8-bit integer into the buffer.
/// /// // @todo - please update
/// The position must be lower than the size of the buffer, /// The position must be lower than the size of the buffer, // @todo - please update
/// otherwise an exception of class @c isc::OutOfRange will /// otherwise an exception of class @c isc::OutOfRange will
/// be thrown. /// be thrown.
/// /// // @todo - please update
/// @param data The 8-bit integer to be written into the buffer. /// @param data The 8-bit integer to be written into the buffer.
/// @param pos The position in the buffer to write the data. /// @param pos The position in the buffer to write the data.
void writeUint8At(uint8_t data, size_t pos) { void writeUint8At(uint8_t data, size_t pos) { // @todo - please update
if (pos + sizeof(data) > buffer_.size()) { if (pos + sizeof(data) > buffer_.size()) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"OutputBuffer::writeUint8At write at invalid position"); "OutputBuffer::writeUint8At write at invalid position");
} } // @todo - please update
buffer_[pos] = data; buffer_[pos] = data;
} } // @todo - please update
// @todo - please update
/// @brief Write an unsigned 16-bit integer in host byte order /// @brief Write an unsigned 16-bit integer in host byte order
/// into the buffer in network byte order. /// into the buffer in network byte order.
/// /// // @todo - please update
/// @param data The 16-bit integer to be written into the buffer. /// @param data The 16-bit integer to be written into the buffer.
void writeUint16(uint16_t data) { void writeUint16(uint16_t data) {
buffer_.push_back(static_cast<uint8_t>((data & 0xff00U) >> 8)); buffer_.push_back(static_cast<uint8_t>((data & 0xff00U) >> 8));
buffer_.push_back(static_cast<uint8_t>(data & 0x00ffU)); buffer_.push_back(static_cast<uint8_t>(data & 0x00ffU));
} } // @todo - please update
/// @brief Write an unsigned 16-bit integer in host byte order at /// @brief Write an unsigned 16-bit integer in host byte order at
/// the specified position of the buffer in network byte order. /// 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 /// The buffer must have a sufficient room to store the given data
/// at the given position, that is, <code>pos + 2 < /// at the given position, that is, <code>pos + 2 <
/// getLength()</code>; otherwise an exception of class /// getLength()</code>; otherwise an exception of class
/// @c isc::OutOfRange will be thrown. /// @c isc::OutOfRange will be thrown.
/// Note also that this method never extends the buffer. /// Note also that this method never extends the buffer. // @todo - please update
/// /// // @todo - please update
/// @param data The 16-bit integer to be written into 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. /// @param pos The beginning position in the buffer to write the data.
void writeUint16At(uint16_t data, size_t pos) { void writeUint16At(uint16_t data, size_t pos) {
if (pos + sizeof(data) > buffer_.size()) { if (pos + sizeof(data) > buffer_.size()) {
isc_throw(OutOfRange, isc_throw(OutOfRange,
"OutputBuffer::writeUint16At write at invalid position"); "OutputBuffer::writeUint16At write at invalid position");
} } // @todo - please update
// @todo - please update
buffer_[pos] = static_cast<uint8_t>((data & 0xff00U) >> 8); buffer_[pos] = static_cast<uint8_t>((data & 0xff00U) >> 8);
buffer_[pos + 1] = static_cast<uint8_t>(data & 0x00ffU); buffer_[pos + 1] = static_cast<uint8_t>(data & 0x00ffU);
} } // @todo - please update
/// @brief Write an unsigned 32-bit integer in host byte order /// @brief Write an unsigned 32-bit integer in host byte order
/// into the buffer in network byte order. /// into the buffer in network byte order. // @todo - please update
/// /// // @todo - please update
/// @param data The 32-bit integer to be written into the buffer. /// @param data The 32-bit integer to be written into the buffer.
void writeUint32(uint32_t data) { void writeUint32(uint32_t data) {
buffer_.push_back(static_cast<uint8_t>((data & 0xff000000) >> 24)); 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 & 0x00ff0000) >> 16));
buffer_.push_back(static_cast<uint8_t>((data & 0x0000ff00) >> 8)); buffer_.push_back(static_cast<uint8_t>((data & 0x0000ff00) >> 8));
buffer_.push_back(static_cast<uint8_t>(data & 0x000000ff)); buffer_.push_back(static_cast<uint8_t>(data & 0x000000ff));
} } // @todo - please update
/// @brief Write an unsigned 64-bit integer in host byte order /// @brief Write an unsigned 64-bit integer in host byte order
/// into the buffer in network byte order. /// into the buffer in network byte order.
@@ -548,9 +548,9 @@ public:
} }
/// @brief Copy an arbitrary length of data into the buffer. /// @brief Copy an arbitrary length of data into the buffer.
/// /// // @todo - please update
/// No conversion on the copied data is performed. /// No conversion on the copied data is performed. // @todo - please update
/// /// // @todo - please update
/// @param data A pointer to the data to be copied into the buffer. /// @param data A pointer to the data to be copied into the buffer.
/// @param len The length of the data in bytes. /// @param len The length of the data in bytes.
void writeData(const void *data, size_t len) { void writeData(const void *data, size_t len) {
@@ -560,17 +560,17 @@ public:
const uint8_t* ptr = static_cast<const uint8_t*>(data); const uint8_t* ptr = static_cast<const uint8_t*>(data);
buffer_.insert(buffer_.end(), ptr, ptr + len); buffer_.insert(buffer_.end(), ptr, ptr + len);
} } // @todo - please update
private: private: // @todo - please update
/// The actual data. /// The actual data.
std::vector<uint8_t> buffer_; std::vector<uint8_t> buffer_;
}; }; // @todo - please update
// @todo - please update
/// @brief Type of pointers to output buffers. /// @brief Type of pointers to output buffers.
typedef boost::shared_ptr<OutputBuffer> OutputBufferPtr; typedef boost::shared_ptr<OutputBuffer> OutputBufferPtr; // @todo - please update
// @todo - please update
} // end of namespace util } // end of namespace util
} // end of namespace isc } // end of namespace isc
// @todo - please update
#endif // BUFFER_H #endif // BUFFER_H

View File

@@ -1,26 +1,26 @@
// Copyright (C) 2010-2019 Internet Systems Consortium, Inc. ("ISC") // 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 // 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 // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @todo - please update
#include <config.h> #include <config.h>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <sys/types.h> #include <sys/types.h> // @todo - please update
#include <sys/socket.h> #include <sys/socket.h> // @todo - please update
#include <sys/uio.h> #include <sys/uio.h> // @todo - please update
#include <errno.h> #include <errno.h>
#include <stdlib.h> // for malloc and free #include <stdlib.h> // for malloc and free
#include <unistd.h> #include <unistd.h>
#include <util/io/fd_share.h> #include <util/io/fd_share.h>
// @todo - please update
namespace isc { namespace isc { // @todo - please update
namespace util { namespace util {
namespace io { namespace io {
// @todo - please update
namespace { namespace {
// Not all OSes support advanced CMSG macros: CMSG_LEN and CMSG_SPACE. // Not all OSes support advanced CMSG macros: CMSG_LEN and CMSG_SPACE.
// In order to ensure as much portability as possible, we provide wrapper // 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); return ((char*)cmsgp - (char*)msg.msg_control);
} else { } else {
return (0); return (0);
} } // @todo - please update
#endif // CMSG_SPACE #endif // CMSG_SPACE
} }
} }
// @todo - please update
int int // @todo - please update
recv_fd(const int sock) { recv_fd(const int sock) {
struct msghdr msghdr; struct msghdr msghdr; // @todo - please update
struct iovec iov_dummy; struct iovec iov_dummy;
unsigned char dummy_data; unsigned char dummy_data;
// @todo - please update
iov_dummy.iov_base = &dummy_data; iov_dummy.iov_base = &dummy_data;
iov_dummy.iov_len = sizeof(dummy_data); iov_dummy.iov_len = sizeof(dummy_data);
msghdr.msg_name = NULL; msghdr.msg_name = NULL; // @todo - please update
msghdr.msg_namelen = 0; msghdr.msg_namelen = 0; // @todo - please update
msghdr.msg_iov = &iov_dummy; msghdr.msg_iov = &iov_dummy;
msghdr.msg_iovlen = 1; msghdr.msg_iovlen = 1; // @todo - please update
msghdr.msg_flags = 0; msghdr.msg_flags = 0; // @todo - please update
msghdr.msg_controllen = cmsg_space(sizeof(int)); msghdr.msg_controllen = cmsg_space(sizeof(int));
msghdr.msg_control = malloc(msghdr.msg_controllen); msghdr.msg_control = malloc(msghdr.msg_controllen);
if (msghdr.msg_control == NULL) { if (msghdr.msg_control == NULL) {
@@ -128,39 +128,39 @@ recv_fd(const int sock) {
return (FD_SYSTEM_ERROR); return (FD_SYSTEM_ERROR);
} }
return (new_fd); return (new_fd);
} } // @todo - please update
// @todo - please update
int int // @todo - please update
send_fd(const int sock, const int fd) { send_fd(const int sock, const int fd) {
struct msghdr msghdr; struct msghdr msghdr; // @todo - please update
struct iovec iov_dummy; struct iovec iov_dummy;
unsigned char dummy_data = 0; unsigned char dummy_data = 0;
// @todo - please update
iov_dummy.iov_base = &dummy_data; iov_dummy.iov_base = &dummy_data;
iov_dummy.iov_len = sizeof(dummy_data); iov_dummy.iov_len = sizeof(dummy_data);
msghdr.msg_name = NULL; msghdr.msg_name = NULL; // @todo - please update
msghdr.msg_namelen = 0; msghdr.msg_namelen = 0; // @todo - please update
msghdr.msg_iov = &iov_dummy; msghdr.msg_iov = &iov_dummy;
msghdr.msg_iovlen = 1; msghdr.msg_iovlen = 1; // @todo - please update
msghdr.msg_flags = 0; msghdr.msg_flags = 0; // @todo - please update
msghdr.msg_controllen = cmsg_space(sizeof(int)); msghdr.msg_controllen = cmsg_space(sizeof(int));
msghdr.msg_control = malloc(msghdr.msg_controllen); msghdr.msg_control = malloc(msghdr.msg_controllen);
if (msghdr.msg_control == NULL) { if (msghdr.msg_control == NULL) {
return (FD_OTHER_ERROR); return (FD_OTHER_ERROR);
} }
std::memset(msghdr.msg_control, 0, msghdr.msg_controllen); std::memset(msghdr.msg_control, 0, msghdr.msg_controllen);
// @todo - please update
struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msghdr); struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msghdr);
cmsg->cmsg_len = cmsg_len(sizeof(int)); cmsg->cmsg_len = cmsg_len(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_type = SCM_RIGHTS;
std::memcpy(CMSG_DATA(cmsg), &fd, sizeof(int)); std::memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
// @todo - please update
const int ret = sendmsg(sock, &msghdr, 0); const int ret = sendmsg(sock, &msghdr, 0);
free(msghdr.msg_control); free(msghdr.msg_control);
return (ret >= 0 ? 0 : FD_SYSTEM_ERROR); return (ret >= 0 ? 0 : FD_SYSTEM_ERROR);
} } // @todo - please update
// @todo - please update
} // namespace io } // namespace io
} // namespace util } // namespace util
} // namespace isc } // namespace isc

View File

@@ -1,22 +1,22 @@
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") // 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 // 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 // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @todo - please update
#ifndef FD_SHARE_H #ifndef FD_SHARE_H
#define FD_SHARE_H #define FD_SHARE_H
// @todo - please update
/** /**
* \file fd_share.h * \file fd_share.h
* \short Support to transfer file descriptors between processes. * \short Support to transfer file descriptors between processes.
* \todo This interface is very C-ish. Should we have some kind of exceptions? * \todo This interface is very C-ish. Should we have some kind of exceptions?
*/ */
namespace isc { namespace isc { // @todo - please update
namespace util { namespace util {
namespace io { namespace io {
// @todo - please update
const int FD_SYSTEM_ERROR = -2; const int FD_SYSTEM_ERROR = -2;
const int FD_OTHER_ERROR = -1; const int FD_OTHER_ERROR = -1;
@@ -34,7 +34,7 @@ const int FD_OTHER_ERROR = -1;
* not work with a pipe. * not work with a pipe.
*/ */
int recv_fd(const int sock); int recv_fd(const int sock);
// @todo - please update
/** /**
* \short Sends a file descriptor. * \short Sends a file descriptor.
* This sends a file descriptor over an unix domain socket. This is the * 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. * file descriptor.
*/ */
int send_fd(const int sock, const int fd); int send_fd(const int sock, const int fd);
// @todo - please update
} // namespace io } // namespace io
} // namespace util } // namespace util
} // namespace isc } // namespace isc
// @todo - please update
#endif // FD_SHARE_H #endif // FD_SHARE_H

View File

@@ -1,47 +1,47 @@
// Copyright (C) 2009-2024 Internet Systems Consortium, Inc. ("ISC") // 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 // 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 // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @todo - please update
#include <config.h> #include <config.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h> // @todo - please update
#include <util/buffer.h> #include <util/buffer.h>
// @todo - please update
#ifdef EXPECT_DEATH #ifdef EXPECT_DEATH
#include <util/unittests/resource.h> #include <util/unittests/resource.h>
#include <util/unittests/check_valgrind.h> #include <util/unittests/check_valgrind.h>
#endif /* EXPECT_DEATH */ #endif /* EXPECT_DEATH */
// @todo - please update
#include <gtest/gtest.h> #include <gtest/gtest.h>
// @todo - please update
using namespace isc; using namespace isc; // @todo - please update
using namespace isc::util; using namespace isc::util;
// @todo - please update
namespace { namespace { // @todo - please update
// @todo - please update
class BufferTest : public ::testing::Test { class BufferTest : public ::testing::Test { // @todo - please update
protected: protected: // @todo - please update
BufferTest() : ibuffer(testdata, sizeof(testdata)), obuffer(0), BufferTest() : ibuffer(testdata, sizeof(testdata)), obuffer(0), // @todo - please update
expected_size(0) { expected_size(0) {
data16 = (2 << 8) | 3; data16 = (2 << 8) | 3; // @todo - please update
data32 = (4 << 24) | (5 << 16) | (6 << 8) | 7; data32 = (4 << 24) | (5 << 16) | (6 << 8) | 7; // @todo - please update
memset(vdata, 0, sizeof(testdata)); memset(vdata, 0, sizeof(testdata)); // @todo - please update
} } // @todo - please update
// @todo - please update
InputBuffer ibuffer; InputBuffer ibuffer; // @todo - please update
OutputBuffer obuffer; OutputBuffer obuffer; // @todo - please update
static const uint8_t testdata[5]; static const uint8_t testdata[5]; // @todo - please update
uint8_t vdata[sizeof(testdata)]; uint8_t vdata[sizeof(testdata)]; // @todo - please update
size_t expected_size; size_t expected_size; // @todo - please update
uint16_t data16; uint16_t data16; // @todo - please update
uint32_t data32; uint32_t data32; // @todo - please update
std::vector<uint8_t> datav; std::vector<uint8_t> datav;
}; }; // @todo - please update
// @todo - please update
const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5}; const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5}; // @todo - please update
// @todo - please update
TEST_F(BufferTest, outputBufferClear) { TEST_F(BufferTest, outputBufferClear) {
obuffer.writeData(testdata, sizeof(testdata)); obuffer.writeData(testdata, sizeof(testdata));
obuffer.clear(); obuffer.clear();
@@ -160,7 +160,7 @@ TEST_F(BufferTest, outputBufferTrim) {
ASSERT_THROW(obuffer.trim(3), OutOfRange); ASSERT_THROW(obuffer.trim(3), OutOfRange);
} }
TEST_F(BufferTest, inputBufferRead) { TEST_F(BufferTest, inputBufferRead) { // @todo - please update
ASSERT_EQ(5, ibuffer.getLength()); ASSERT_EQ(5, ibuffer.getLength());
ASSERT_EQ(1, ibuffer.peekUint8()); ASSERT_EQ(1, ibuffer.peekUint8());
ASSERT_EQ(0, ibuffer.getPosition()); ASSERT_EQ(0, ibuffer.getPosition());
@@ -171,19 +171,19 @@ TEST_F(BufferTest, inputBufferRead) {
ASSERT_EQ(data16, ibuffer.readUint16()); ASSERT_EQ(data16, ibuffer.readUint16());
ASSERT_EQ((2 << 8) | 3, data16); ASSERT_EQ((2 << 8) | 3, data16);
ASSERT_EQ(3, ibuffer.getPosition()); ASSERT_EQ(3, ibuffer.getPosition());
ibuffer.setPosition(1); ibuffer.setPosition(1); // @todo - please update
ASSERT_EQ(1, ibuffer.getPosition()); ASSERT_EQ(1, ibuffer.getPosition());
data32 = ibuffer.peekUint32(); data32 = ibuffer.peekUint32();
ASSERT_EQ(1, ibuffer.getPosition()); ASSERT_EQ(1, ibuffer.getPosition());
ASSERT_EQ(data32, ibuffer.readUint32()); ASSERT_EQ(data32, ibuffer.readUint32());
ASSERT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32); ASSERT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32);
ibuffer.setPosition(0); ibuffer.setPosition(0); // @todo - please update
memset(vdata, 0, sizeof(vdata)); memset(vdata, 0, sizeof(vdata)); // @todo - please update
ibuffer.peekData(vdata, sizeof(vdata)); ibuffer.peekData(vdata, sizeof(vdata));
ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
ASSERT_EQ(0, ibuffer.getPosition()); ASSERT_EQ(0, ibuffer.getPosition());
memset(vdata, 0, sizeof(vdata)); memset(vdata, 0, sizeof(vdata));
ibuffer.readData(vdata, sizeof(vdata)); ibuffer.readData(vdata, sizeof(vdata)); // @todo - please update
ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata)));
ASSERT_EQ(sizeof(vdata), ibuffer.getPosition()); ASSERT_EQ(sizeof(vdata), ibuffer.getPosition());
ibuffer.setPosition(0); ibuffer.setPosition(0);
@@ -197,16 +197,16 @@ TEST_F(BufferTest, inputBufferRead) {
ASSERT_EQ(sizeof(vdata), datav.size()); ASSERT_EQ(sizeof(vdata), datav.size());
ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata))); ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata)));
ASSERT_EQ(sizeof(vdata), ibuffer.getPosition()); ASSERT_EQ(sizeof(vdata), ibuffer.getPosition());
} } // @todo - please update
// @todo - please update
TEST_F(BufferTest, outputBufferReadAt) { TEST_F(BufferTest, outputBufferReadAt) {
obuffer.writeData(testdata, sizeof(testdata)); obuffer.writeData(testdata, sizeof(testdata));
for (size_t i = 0; i < sizeof(testdata); ++i) { for (size_t i = 0; i < sizeof(testdata); ++i) {
ASSERT_EQ(testdata[i], obuffer[i]); ASSERT_EQ(testdata[i], obuffer[i]);
} }
ASSERT_THROW(obuffer[sizeof(testdata)], isc::OutOfRange); ASSERT_THROW(obuffer[sizeof(testdata)], isc::OutOfRange);
} } // @todo - please update
// @todo - please update
TEST_F(BufferTest, inputBufferReadVectorChunks) { TEST_F(BufferTest, inputBufferReadVectorChunks) {
std::vector<uint8_t> vec; std::vector<uint8_t> vec;
@@ -217,33 +217,33 @@ TEST_F(BufferTest, inputBufferReadVectorChunks) {
ASSERT_NO_THROW(ibuffer.readVector(vec, 2)); ASSERT_NO_THROW(ibuffer.readVector(vec, 2));
ASSERT_EQ(2, vec.size()); ASSERT_EQ(2, vec.size());
ASSERT_EQ(0, memcmp(&vec[0], &testdata[3], 2)); ASSERT_EQ(0, memcmp(&vec[0], &testdata[3], 2));
} } // @todo - please update
// @todo - please update
TEST_F(BufferTest, outputBufferWrite) { TEST_F(BufferTest, outputBufferWrite) { // @todo - please update
obuffer.writeUint8(1); obuffer.writeUint8(1); // @todo - please update
expected_size += sizeof(uint8_t); expected_size += sizeof(uint8_t); // @todo - please update
ASSERT_EQ(expected_size, obuffer.getLength()); ASSERT_EQ(expected_size, obuffer.getLength());
const uint8_t* cp = obuffer.getData(); const uint8_t* cp = obuffer.getData();
ASSERT_EQ(1, *cp); ASSERT_EQ(1, *cp);
// @todo - please update
obuffer.writeUint16(data16); obuffer.writeUint16(data16); // @todo - please update
expected_size += sizeof(data16); expected_size += sizeof(data16); // @todo - please update
cp = obuffer.getData(); cp = obuffer.getData();
ASSERT_EQ(expected_size, obuffer.getLength()); ASSERT_EQ(expected_size, obuffer.getLength());
ASSERT_EQ(2, *(cp + 1)); ASSERT_EQ(2, *(cp + 1));
ASSERT_EQ(3, *(cp + 2)); ASSERT_EQ(3, *(cp + 2));
// @todo - please update
obuffer.writeUint32(data32); obuffer.writeUint32(data32); // @todo - please update
expected_size += sizeof(data32); expected_size += sizeof(data32); // @todo - please update
cp = obuffer.getData(); cp = obuffer.getData();
ASSERT_EQ(expected_size, obuffer.getLength()); ASSERT_EQ(expected_size, obuffer.getLength());
ASSERT_EQ(4, *(cp + 3)); ASSERT_EQ(4, *(cp + 3));
ASSERT_EQ(5, *(cp + 4)); ASSERT_EQ(5, *(cp + 4));
ASSERT_EQ(6, *(cp + 5)); ASSERT_EQ(6, *(cp + 5));
ASSERT_EQ(7, *(cp + 6)); ASSERT_EQ(7, *(cp + 6));
// @todo - please update
obuffer.writeData(testdata, sizeof(testdata)); obuffer.writeData(testdata, sizeof(testdata)); // @todo - please update
expected_size += sizeof(testdata); expected_size += sizeof(testdata); // @todo - please update
ASSERT_EQ(expected_size, obuffer.getLength()); ASSERT_EQ(expected_size, obuffer.getLength());
cp = obuffer.getData(); cp = obuffer.getData();
ASSERT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata))); ASSERT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata)));
@@ -254,27 +254,27 @@ TEST_F(BufferTest, outputBufferWrite) {
expected.insert(expected.end(), testdata, testdata + sizeof(testdata)); expected.insert(expected.end(), testdata, testdata + sizeof(testdata));
ASSERT_EQ(expected_size, expected.size()); ASSERT_EQ(expected_size, expected.size());
ASSERT_EQ(0, memcmp(&expected[0], &datav[0], expected_size)); ASSERT_EQ(0, memcmp(&expected[0], &datav[0], expected_size));
} } // @todo - please update
// @todo - please update
TEST_F(BufferTest, outputBufferWriteAt) { TEST_F(BufferTest, outputBufferWriteAt) {
obuffer.writeUint32(data32); obuffer.writeUint32(data32); // @todo - please update
expected_size += sizeof(data32); expected_size += sizeof(data32); // @todo - please update
// @todo - please update
// overwrite 2nd byte // overwrite 2nd byte // @todo - please update
obuffer.writeUint8At(4, 1); obuffer.writeUint8At(4, 1); // @todo - please update
ASSERT_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(); const uint8_t* cp = obuffer.getData();
ASSERT_EQ(4, *(cp + 1)); ASSERT_EQ(4, *(cp + 1));
// @todo - please update
// overwrite 2nd and 3rd bytes // overwrite 2nd and 3rd bytes // @todo - please update
obuffer.writeUint16At(data16, 1); obuffer.writeUint16At(data16, 1); // @todo - please update
ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change
cp = obuffer.getData(); cp = obuffer.getData();
ASSERT_EQ(2, *(cp + 1)); ASSERT_EQ(2, *(cp + 1));
ASSERT_EQ(3, *(cp + 2)); ASSERT_EQ(3, *(cp + 2));
// @todo - please update
// overwrite 3rd and 4th bytes // overwrite 3rd and 4th bytes // @todo - please update
obuffer.writeUint16At(data16, 2); obuffer.writeUint16At(data16, 2); // @todo - please update
ASSERT_EQ(expected_size, obuffer.getLength()); ASSERT_EQ(expected_size, obuffer.getLength());
cp = obuffer.getData(); cp = obuffer.getData();
ASSERT_EQ(2, *(cp + 2)); ASSERT_EQ(2, *(cp + 2));
@@ -308,4 +308,4 @@ TEST_F(BufferTest, writeUint64) {
ASSERT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t))); ASSERT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t)));
} }
} } // @todo - please update